【发布时间】:2019-05-15 06:44:13
【问题描述】:
有没有办法在不创建巨大数组/循环的情况下对特定点进行多维插值?
import xarray as xr
import pandas as pd
xds = xr.tutorial.open_dataset('air_temperature')
xds['airx2'] = xds['air'] * 2
pdf = pd.DataFrame(dict(lat=[45, 60, 75], lon=[225, 320, 315],
time=pd.to_datetime(['2013-01-10', '2013-01-12', '2013-01-15'])))
# this seems to be very fast, but creates a large 3x3x3 array
# not ideal if I have 800 rows which will make a final array of 800x800x800
xds.interp(**pdf)
# this doesn't create a 800x800x800 array
# if there's 800 rows in the dataframe, but not vectorized
pd.concat([xds.interp(**row).to_array().to_dataframe('kelvin')
for i, row in pdf.iterrows()])
大数组
想要的结果(如果没有循环):
【问题讨论】:
标签: interpolation python-xarray