- 积分
- 975
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-5-24
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2019-10-21 21:15:31
|
显示全部楼层
- import matplotlib.pyplot as plt
- import numpy as np
- from eofs.standard import Eof
- from eofs.examples import example_data_path
- from netCDF4 import Dataset
- filename = example_data_path('F:/School/NCEPNCAR/SST/sst.mnmean.nc')
- ncin = Dataset(filename, 'r')
- lon = ncin.variables['lon'][:]
- lat = ncin.variables['lat'][:]
- time = ncin.variables['time'][:]
- sst = ncin.variables['sst'][1201:1800,:,:]
- ncin.close()
- lat_bounds = [-30, 30]
- lon_bounds = [100, 270]
- lat_li = np.argmin(np.abs(lat - lat_bounds[0])) #
- lat_ui = np.argmin(np.abs(lat - lat_bounds[1]))
- # longitude lower and upper index
- lon_li = np.argmin(np.abs(lon - lon_bounds[0]))
- lon_ui = np.argmin(np.abs(lon - lon_bounds[1]))
- sstSubset = sst[:, lat_ui:lat_li, lon_li:lon_ui]
- sst[sst <=-9.96921e+36 ] = np.nan
- #计算sst年均
- sst_ann = np.zeros((49, lat_li-lat_ui, lon_ui-lon_li), dtype=np.float32)
- for i in range(0, 49):
- for j in range(0, 11):
- sst_ann[i,:, :] = sst_ann[i,:, : ] + sstSubset[12*i+j,:,:]
- sst_ann[i,:, :] = sst_ann[i,:, :]/12.
- lats = np.linspace(-30, 30, 60, endpoint=False)
- lons = np.linspace(100, 270, 85, endpoint=False)
- coslat = np.cos(np.deg2rad(lats[:]))
- wgts = np.sqrt(coslat)[..., np.newaxis]
- solver = Eof(sst_ann, weights=wgts)
|
|