下載安裝wrf_python
https://www.lfd.uci.edu/~gohlke/pythonlibs/#wrf_pythonpip 安裝
pip install ecmwflibs
pip install eccodes
pip install cfgrib
pip install xarray代碼編寫(xiě):
'''
nc_obj = xr.load_dataset("LAI_19981019.grib", engine="cfgrib")
lvdata=nc_obj["lai_lv"].data
lvdata1=lvdata[:,0:1800]
lvdata2=lvdata[:,1800:3600]
xy = np.hstack([lvdata2, lvdata1])
run=GRID()
'''
0:圖像左上角的X坐標(biāo);
1:圖像東西方向分辨率;
2:旋轉(zhuǎn)角度奋姿,如果圖像北方朝上,該值為0胀蛮;
3:圖像左上角的Y坐標(biāo)糯钙;
4:旋轉(zhuǎn)角度粪狼,如果圖像北方朝上任岸,該值為0再榄;
5:圖像南北方向分辨率享潜;
'''
outadfGeoTransform=[-180,0.1,0,90,0,-0.1]
def write_img(self, filename, im_proj, im_geotrans, im_data)
run.write_img("lv3.tif", "", outadfGeoTransform,xy)
print(nc_obj)
'''