座標の任意のコレクションで 240x240 構造化グリッドから hdf4/netcdf4/hdf5 ファイルの空気データをバイリニア補間する必要があります。これを行う方法がわかりません。pyresampleを使用してみましたが、構造化されていないターゲット データ (任意のポイント) の場合には不可能なターゲット グリッドの AreaDefinition が必要です。これが私のコードです:
import numpy as np
import pyresample
from netCDF4 import Dataset
air_file = Dataset('air.hdf', mode='r')
air_data = air_file.variables['air_2m' ][:].flatten()
air_lon = air_file.variables['air_lon'][:].flatten()
air_lat = air_file.variables['air_lat'][:].flatten()
air_data = air_data.reshape(240,240)
air_lon = air_lon. reshape(240,240) # grid size is 240x240
air_lat = air_lat. reshape(240,240)
tar_lon = 100 * np.random.random((100,1)) # random points
tar_lat = 100 * np.random.random((100,1)) # random points
source_def = pyresample.geometry.SwathDefinition(lons=air_lon, lats=air_lat)
target_def = pyresample.geometry.SwathDefinition(lons=tar_lon, lats=tar_lat)
result = pyresample.bilinear.resample_bilinear(gmt_1500, source_def, target_def, radius=50e3, neighbours=32, nprocs=1, fill_value=None, reduce_data=True, segments=None, epsilon=0)
次のエラーが表示されます (ターゲットに AreaDefinition が必要なため、これは理解されます):
AttributeError: 'SwathDefinition' object has no attribute 'proj_str'
これを行う他の方法はありますか?