Python按照时间、经纬度、变量裁剪nc数据
from scipy.io import savematimport netCDF4 as ncimport xarray as xrimport numpy as npnc = xr.open_dataset(r'H:/CMFD/prec.1979_2018.nc')v = nc['prec']# prec为变量内容(降雨)nc_30 = v.loc['2007-1-1':'2007-12-31
·
from scipy.io import savemat
import netCDF4 as nc
import xarray as xr
import numpy as np
nc = xr.open_dataset(r'H:/CMFD/prec.1979_2018.nc')
v = nc['prec'] # prec为变量内容(降雨)
nc_30 = v.loc['2007-1-1':'2007-12-31'] # 截取时间
nc_coordinate = nc_30.loc[:, 41.9:44.1, 117.4:123.6] # 截取经纬度
ds1 = xr.Dataset({'prec': nc_coordinate})
ds1.to_netcdf('H:\CMFD/prec.2007new.nc')
print('success')
更多推荐
已为社区贡献1条内容
所有评论(0)