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')
Python按照时间、经纬度、变量裁剪nc数据
最新推荐文章于 2024-08-08 20:17:02 发布