forked from manmeet3591/python_class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_dates.py
More file actions
21 lines (17 loc) · 1.18 KB
/
common_dates.py
File metadata and controls
21 lines (17 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ds_obs = ds_observed[i_var]
file_ = base_dir+'historical_v1/'+var+'_historical_'+df_corr_['model'].iloc[cnt]+'_ens_'+str(df_corr_['ensemble'].iloc[cnt])+'.nc'
print(file_)
ds_historical = xr.open_dataset(file_).sel(lat=location_[0], lon= 360-location_[1], method='nearest')
datetimeindex = ds_historical.indexes['time'].to_datetimeindex()
ds_historical['time'] = datetimeindex
common_dates = np.intersect1d(np.asarray(ds_historical.time.values.astype('datetime64[D]').tolist()), \
np.asarray(ds_obs.time.values.astype('datetime64[D]').tolist()))
ds_historical['time'] = ('time', ds_historical.time.values.astype('datetime64[D]'))
ds_historical_ = ds_historical.sel(time=common_dates)
ds_obs_ = ds_obs.sel(time=common_dates)
file_ = base_dir+'ssp126_v1/'+var+'_ssp126_'+df_corr_['model'].iloc[cnt]+'_ens_'+str(df_corr_['ensemble'].iloc[cnt])+'.nc'
print(file_)
ds_ssp126 = xr.open_dataset(file_).sel(lat=location_[0], lon= 360-location_[1], method='nearest')
file_ = base_dir+'ssp585_v1/'+var+'_ssp585_'+df_corr_['model'].iloc[cnt]+'_ens_'+str(df_corr_['ensemble'].iloc[cnt])+'.nc'
print(file_)
ds_ssp585 = xr.open_dataset(file_).sel(lat=location_[0], lon= 360-location_[1], method='nearest')