Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将数据数组插值到新坐标_Python_Python 3.x_Python Xarray - Fatal编程技术网

Python 将数据数组插值到新坐标

Python 将数据数组插值到新坐标,python,python-3.x,python-xarray,Python,Python 3.x,Python Xarray,我试图将一个更大的数据集插值到另一个数据集的坐标上,这样我就可以用它们进行计算。我以前使用过.interp,但它似乎失败了,因为维度似乎是由x,y索引的,而不是由lat,lon索引的。怎样才能修正它,这样我就可以插值数据了 lons, lats = precip_data.lon, precip_data.lat temperature_interp = temperature_data.interp(latitude=lats, longitude=lons) 抛出错误: ValueErro

我试图将一个更大的数据集插值到另一个数据集的坐标上,这样我就可以用它们进行计算。我以前使用过.interp,但它似乎失败了,因为维度似乎是由x,y索引的,而不是由lat,lon索引的。怎样才能修正它,这样我就可以插值数据了

lons, lats = precip_data.lon, precip_data.lat
temperature_interp = temperature_data.interp(latitude=lats, longitude=lons)
抛出错误:

ValueError: dimensions {'longitude', 'latitude'} do not exist
降水数据阵列


数组([[0,0,0.,…,0,0,0,0.]),
[0.      , 0.      , 0.      , ..., 0.      , 0.      , 0.      ],
[0.      , 0.      , 0.      , ..., 0.      , 0.      , 0.      ],
...,
[0.      , 0.      , 0.      , ..., 0.014764, 0.014764, 0.014764],
[0.      , 0.      , 0.      , ..., 0.014764, 0.014764, 0.014764],
[0.      , 0.      , 0.      , ..., 0.014764, 0.019685, 0.014764]],
dtype=32)
协调:
时间日期时间64[ns]2020-02-28
*y(y)浮动64-4.791e+06-4.786e+06-3.681e+06-3.677e+06
*x(x)浮动64 2.234e+062.238e+062.243e+06。。。3.081e+06 3.086e+06
横向(y,x)浮动64。。。
长(y,x)浮点数64。。。
属性:
姓名:PRECIP
单位:英寸
网格映射:crs
温度数据阵列


尺寸:(x:451,y:337)
协调:
时间日期时间64[ns]。。。
步骤时间Delta64[ns]。。。
纬度(y,x)浮动64。。。
经度(y,x)浮动64。。。
有效的\u时间日期时间64[ns]。。。
不带坐标的尺寸:x,y
数据变量:
t(y,x)浮动32294.39157 294.39157。。。259.6211 259.6211

您是否尝试过使用
温度\u interp=temperature\u data.interp(x=lats,y=lons)
?它可以工作,但只返回NaN值
<xarray.DataArray 'PRECIP' (y: 235, x: 180)>
array([[0.      , 0.      , 0.      , ..., 0.      , 0.      , 0.      ],
       [0.      , 0.      , 0.      , ..., 0.      , 0.      , 0.      ],
       [0.      , 0.      , 0.      , ..., 0.      , 0.      , 0.      ],
       ...,
       [0.      , 0.      , 0.      , ..., 0.014764, 0.014764, 0.014764],
       [0.      , 0.      , 0.      , ..., 0.014764, 0.014764, 0.014764],
       [0.      , 0.      , 0.      , ..., 0.014764, 0.019685, 0.014764]],
      dtype=float32)
Coordinates:
    time     datetime64[ns] 2020-02-28
  * y        (y) float64 -4.791e+06 -4.786e+06 ... -3.681e+06 -3.677e+06
  * x        (x) float64 2.234e+06 2.238e+06 2.243e+06 ... 3.081e+06 3.086e+06
    lat      (y, x) float64 ...
    lon      (y, x) float64 ...
Attributes:
    long_name:     PRECIP
    units:         IN
    grid_mapping:  crs
<xarray.Dataset>
Dimensions:     (x: 451, y: 337)
Coordinates:
    time        datetime64[ns] ...
    step        timedelta64[ns] ...
    latitude    (y, x) float64 ...
    longitude   (y, x) float64 ...
    valid_time  datetime64[ns] ...
Dimensions without coordinates: x, y
Data variables:
    t           (y, x) float32 294.39157 294.39157 ... 259.6211 259.6211