Skip to content

Instantly share code, notes, and snippets.

@Thomas-Moore-Creative
Last active May 13, 2021 01:52
Show Gist options
  • Save Thomas-Moore-Creative/73a3b464646ff09ae4cec23c05268273 to your computer and use it in GitHub Desktop.
Save Thomas-Moore-Creative/73a3b464646ff09ae4cec23c05268273 to your computer and use it in GitHub Desktop.
CMIP5 intake-esm loading example
import intake
import xarray as xr
NCI_catalog = intake.open_catalog('/g/data/hh5/public/apps/nci-intake-catalogue/catalogue.yaml')
CCiA_catalog = NCI_catalog.esgf.cmip5.search(variable=['psl','pr'],
realm=['atmos'],
time_frequency='mon',
experiment=['rcp85','historical'],
ensemble=['r1i1p1'],
model=['ACCESS1.0',
'CESM1(CAM5)',
'CNRM-CM5',
'GFDL-ESM2M',
'HadGEM2-CC',
'CanESM2',
'MIROC5',
'NorESM1-M']\
)
CCiA_dataset_dict = CCiA_catalog.to_dataset_dict()
#list out the keys
list(CCiA_dataset_dict.keys())
#Load data by choosing keys from the list above
NorESM1_M_rcp85_pr = CCiA_dataset_dict['cmip5.output1.NCC.NorESM1-M.rcp85.mon.atmos.Amon.r1i1p1.v20120412.pr']
NorESM1_M_historical_pr = CCiA_dataset_dict['cmip5.output1.NCC.NorESM1-M.historical.mon.atmos.Amon.r1i1p1.v20120412.pr']
#plot something silly
import cartopy.crs as ccrs
diff = NorESM1_M_historical_pr.pr.mean(dim='time') - NorESM1_M_rcp85_pr.pr.mean(dim='time')
p = diff.plot(
subplot_kws=dict(projection=ccrs.Orthographic(140, -20), facecolor="gray"),
transform=ccrs.PlateCarree(),
)
p.axes.set_global()
p.axes.set_title('NorESM1_M precip (historical - rcp85)',pad=20)
p.axes.coastlines()
p.axes.figure.set_size_inches(h=12,w=12)
#the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment