In this notebook we demonstrate how to calculate the temperature and precipitation change in Australia using CMIP6 SenarioMIP prediction under two emission scenarios:
This example uses Coupled Model Intercomparison Project (CMIP6) collections. For more information, please visit data catalogue and terms of use.
import xarray as xr
%matplotlib inline
In CMIP6 data collection, there are four future scenarios in ScenarioMIP: ssp126, ssp245, ssp370 and ssp585. See more information about ScenarioMIP scenarios
Below, we have set up these attributes in order to get the future projection data under the ssp126 and ssp585 scenarios using member 'r1i1p1f2' of CNRM_CM6-1 model simulations as an example.
Cmip6Dir='/g/data/oi10/replicas/CMIP6'
Activity='ScenarioMIP'
Institute='CNRM-CERFACS'
Source='CNRM-CM6-1'
Experiment='' #leave it blank for later assignment
Member='r1i1p1f2'
Table='Amon'
Var='' #leave it blank for later assignment
Grid='gr'
Version='v20190219'
Period='201501-210012'
Use xarray to open the temperature data (tas) of the lowest emission scenario (ssp126)
Var='tas'
Experiment='ssp126'
ds=xr.open_dataset(''+Cmip6Dir+'/'+Activity+'/'+Institute+'/'+Source+'/'+Experiment+'/'+Member+'/'+Table+'/'+Var+'/'+Grid+'/'+Version+'/'+Var+'_'+Table+'_'+Source+'_'+Experiment+'_'+Member+'_'+Grid+'_'+Period+'.nc')
Extract temperature 'tas' data
tas_126=ds.tas
Calculate regional mean of Australia (lon: 115E-155E, lat: 45S-15S), and then calculate the yearly average of the monthly data.
tas_126_yr=tas_126.sel(lon=slice(115,155),lat=slice(-45,-15)).mean(dim=('lat','lon')).resample(time='Y').mean(dim='time')
/g/data/dk92/packages/xarray/core/common.py:1124: FutureWarning: 'base' in .resample() and in Grouper() is deprecated. The new arguments that you should use are 'offset' or 'origin'. >>> df.resample(freq="3s", base=2) becomes: >>> df.resample(freq="3s", offset="2s") freq=freq, closed=closed, label=label, base=base, loffset=loffset
Plot the yearly temperature change during the time period 2019-2060
tas_126_yr.sel(time=slice('2019','2060')).plot(size=6)
[<matplotlib.lines.Line2D at 0x7f66511e5610>]
Similarly as above, the yearly temperature change under the highest emission scenario (ssp585) during the time period 2019-2060 is below:
Experiment='ssp585'
ds=xr.open_dataset(''+Cmip6Dir+'/'+Activity+'/'+Institute+'/'+Source+'/'+Experiment+'/'+Member+'/'+Table+'/'+Var+'/'+Grid+'/'+Version+'/'+Var+'_'+Table+'_'+Source+'_'+Experiment+'_'+Member+'_'+Grid+'_201501-210012.nc')
tas_585=ds.tas
tas_585_yr=tas_585.sel(lon=slice(115,155),lat=slice(-45,-15)).mean(dim=('lat','lon')).resample(time='Y').mean(dim='time')
tas_585_yr.sel(time=slice('2019','2060')).plot(size=6)
/g/data/dk92/packages/xarray/core/common.py:1124: FutureWarning: 'base' in .resample() and in Grouper() is deprecated. The new arguments that you should use are 'offset' or 'origin'. >>> df.resample(freq="3s", base=2) becomes: >>> df.resample(freq="3s", offset="2s") freq=freq, closed=closed, label=label, base=base, loffset=loffset
[<matplotlib.lines.Line2D at 0x7f66510d2b90>]
The average temperature change difference between the lowest and highest emission scenario from 2019 to 2060:
TasDif=tas_585_yr.mean(dim='time')-tas_126_yr.mean(dim='time')
print(TasDif)
<xarray.DataArray 'tas' ()> array(1.4142151, dtype=float32) Coordinates: height float64 2.0
The above result shows that Australian temperature would have an additional 1.41 Celsius average warming in our lifetime span (2019-2060) under the highest emission scenario compared with the lowest emission scenario!
Var='pr'
Experiment='ssp126'
ds=xr.open_dataset(''+Cmip6Dir+'/'+Activity+'/'+Institute+'/'+Source+'/'+Experiment+'/'+Member+'/'+Table+'/'+Var+'/'+Grid+'/'+Version+'/'+Var+'_'+Table+'_'+Source+'_'+Experiment+'_'+Member+'_'+Grid+'_201501-210012.nc')
pr_126=ds.pr
pr_126_yr=pr_126.sel(lon=slice(115,155),lat=slice(-45,-15)).mean(dim=('lat','lon')).resample(time='Y').mean(dim='time')
pr_126_yr.sel(time=slice('2019','2060')).plot(size=6)
/g/data/dk92/packages/xarray/core/common.py:1124: FutureWarning: 'base' in .resample() and in Grouper() is deprecated. The new arguments that you should use are 'offset' or 'origin'. >>> df.resample(freq="3s", base=2) becomes: >>> df.resample(freq="3s", offset="2s") freq=freq, closed=closed, label=label, base=base, loffset=loffset
[<matplotlib.lines.Line2D at 0x7f6651068c10>]
Var='pr'
Experiment='ssp585'
ds=xr.open_dataset(''+Cmip6Dir+'/'+Activity+'/'+Institute+'/'+Source+'/'+Experiment+'/'+Member+'/'+Table+'/'+Var+'/'+Grid+'/'+Version+'/'+Var+'_'+Table+'_'+Source+'_'+Experiment+'_'+Member+'_'+Grid+'_201501-210012.nc')
pr_585=ds.pr
pr_585_yr=pr_585.sel(lon=slice(115,155),lat=slice(-45,-15)).mean(dim=('lat','lon')).resample(time='Y').mean(dim='time')
pr_585_yr.sel(time=slice('2019','2060')).plot(size=6)
/g/data/dk92/packages/xarray/core/common.py:1124: FutureWarning: 'base' in .resample() and in Grouper() is deprecated. The new arguments that you should use are 'offset' or 'origin'. >>> df.resample(freq="3s", base=2) becomes: >>> df.resample(freq="3s", offset="2s") freq=freq, closed=closed, label=label, base=base, loffset=loffset
[<matplotlib.lines.Line2D at 0x7f6650fee850>]
PrDif=(pr_585_yr.mean(dim='time')-pr_126_yr.mean(dim='time'))/pr_126_yr.mean(dim='time')
print(PrDif)
<xarray.DataArray 'pr' ()> array(-0.02813326, dtype=float32)
This shows that on average Australia is becoming drier under a higher emission scenario.