Climate indices

The current production version of PAVICS provides ICCLIM indices through the FlyingPigeon server, which includes over fourty different indices. In the example below, we’re calling on one of these indices on a small test file available on a public URL, but it is also possible to send local files to the server.

Another implementation of climate indices is in the works. It relies on the xarray+dask backend to parallelize computations in the background. The library of climate indices is xclim and the WPS server hosting it is finch, but is not yet in production.

In [1]:
%matplotlib inline
from birdy import WPSClient
url = 'https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon/wps'
fp = WPSClient(url)
In [2]:
help(fp.icclim_tx)
Help on method icclim_tx in module birdy.client.base:

icclim_tx(resource=None, grouping='yr') method of birdy.client.base.WPSClient instance
    Calculates the TX indice: mean of daily maximum temperature.

    Parameters
    ----------
    resource : ComplexData:mimetype:`application/x-netcdf`, :mimetype:`application/x-tar`, :mimetype:`application/zip`
        NetCDF Files or archive (tar/zip) containing netCDF files.
    grouping : {'day', 'mon', 'sem', 'yr', 'ONDJFM', 'AMJJAS', 'DJF', 'MAM', 'JJA', 'SON', ...}string
        Temporal group over which the index is computed.

    Returns
    -------
    output_netcdf : ComplexData:mimetype:`application/x-netcdf`
        The indicator values computed on the original input grid.
    output_log : ComplexData:mimetype:`text/plain`
        Collected logs during process run.

In [3]:
thredds = 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/fileServer/birdhouse/testdata/flyingpigeon/'
resp = fp.icclim_tx(resource=thredds+'cmip3/tas.sresb1.giss_model_e_r.run1.atm.da.nc', grouping='yr')
tx, log = resp.get(asobj=True)
tx
Out[3]:
<class 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):
    source_data_global_attributes: {"title": "NASA/GISS  model output prepared for IPCC Fourth Assessment AMIP experiment", "cmor_version": 0.9599999785423279, "institution": "NASA/GISS (Goddard Institute for Space Studies)New York, NY", "source": "E3OCNf8aM20A", "contact": "Kenneth Lo (cdkkl@giss.nasa.gov)", "references": "www.giss.nasa.gov/research/modeling", "experiment_id": "sresb1", "realization": 1, "directory": "/ipcc/sresb1/atm/da/", "table_id": "Table A2 (20 September 2004)", "calendar": "noleap", "project_id": "IPCC Fourth Assessment", "Conventions": "CF-1.0", "id": "pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da", "history": "Tue Nov 22 09:25:17 2011: ncks -D 0 -4 -L 7 -d lat,42.0,64.0 -d lon,278.0,306.0 -d time,2040-01-01 00:00:00,2070-01-01 00:00:00 -v tas http://davidhuard:patate@esgcet.llnl.gov/dap/ipcc4/sresb1/giss_model_e_r/pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da.xml /home/david/projects/ingenieurs/data/CMIP3/tas.sresb1.giss_model_e_r.run1.atm.da.tas.nc\n  At 10:47:22 on 11/03/2004, CMOR rewrote data to comply with CF standards and IPCC Fourth Assessment requirements [2006-4-6 11:6:16] cdscan -x /var/www/html/ipcc4/sresb1/giss_model_e_r/pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da.xml -d pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da --exclude=plev --ignore-open-error --var-locate ps,ps_.* -f /tmp/scan/list.pcmdi.ipcc4.giss_model_e_r.sre ...", "NCO": "4.0.8"}
    history: Tue Nov 22 09:25:17 2011: ncks -D 0 -4 -L 7 -d lat,42.0,64.0 -d lon,278.0,306.0 -d time,2040-01-01 00:00:00,2070-01-01 00:00:00 -v tas http://davidhuard:patate@esgcet.llnl.gov/dap/ipcc4/sresb1/giss_model_e_r/pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da.xml /home/david/projects/ingenieurs/data/CMIP3/tas.sresb1.giss_model_e_r.run1.atm.da.tas.nc
  At 10:47:22 on 11/03/2004, CMOR rewrote data to comply with CF standards and IPCC Fourth Assessment requirements [2006-4-6 11:6:16] cdscan -x /var/www/html/ipcc4/sresb1/giss_model_e_r/pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da.xml -d pcmdi.ipcc4.giss_model_e_r.sresb1.run1.atm.da --exclude=plev --ignore-open-error --var-locate ps,ps_.* -f /tmp/scan/list.pcmdi.ipcc4.giss_model_e_r.sre ...
2019-01-18 17:30:14 Calculation of TX indice (annual) from 2046-1-1 to 2065-12-31.
2019-01-18 17:30:14.427279 UTC ocgis-2.2.0dev0: OcgOperations(calc_sample_size=False, optimizations=None, geom_select_sql_where=None, output_format="nc", spatial_wrapping="None", format_time=True, select_nearest=False, output_crs=None, time_range=None, calc_grouping=('year',), prefix="b6959f22-1b46-11e9-871f-0242ac12000b", abstraction="auto", regrid_destination=None, output_format_options=None, allow_empty=False, vector_wrap=False, aggregate=False, interpolate_spatial_bounds=False, dataset=<generator object __iter__ at 0x7f952019f320>, geom_uid=None, dir_output="/opt/birdhouse/var/lib/pywps/tmp/flyingpigeon/pywps_process_M9RLpn", backend="ocg", search_radius_mult=None, add_auxiliary_files=False, slice=None, regrid_options={'regrid_method': 'auto', 'value_mask': None, 'split': True}, callback=None, calc_raw=False, level_range=None, geom_select_uid=None, snippet=False, time_region=None, melted=False, geom=None, time_subset_func=None, conform_units_to=None, spatial_operation="intersects", calc=[{'meta_attrs': None, 'name': 'icclim_TX', 'func': 'icclim_TX', 'kwds': OrderedDict()}], optimized_bbox_subset=False, file_only=False, spatial_reorder=False, )
    title: ECA temperature indice TX
    references: ATBD of the ECA indices calculation (http://eca.knmi.nl/documents/atbd.pdf)
    institution: Climate impact portal (http://climate4impact.eu)
    comment:
    dimensions(sizes): lat(6), bnds(2), lon(5), time(20)
    variables(dimensions): float64 height(), float64 lat(lat), float64 lat_bnds(lat,bnds), float64 lon(lon), float64 lon_bnds(lon,bnds), |S1 latitude_longitude(), float64 time(time), float64 climatology_bounds(time,bnds), float32 icclim_TX(time,lat,lon)
    groups:

Let’s now check that we indeed computed an annual maximum temperature. Since the file object is already opened using netCDF, we need to tell xarray to create a dataset from a NetCDF4DataStore.

In [4]:
import xarray as xr
ds = xr.open_dataset(xr.backends.NetCDF4DataStore(tx))
ds.icclim_TX.isel(lat=0, lon=0).plot()
Out[4]:
[<matplotlib.lines.Line2D at 0x7f720f4fb588>]
../_images/notebooks_climate_indices_5_1.png