{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Computing indicators on DAP subsets\n", "\n", "\n", "In a typical programming environment, the standard way to compute an indicator for a given location would be to extract the time series at the given location, then run the computation on this subset. When interacting with a remote server, things are a bit more complicated. One option would be to first call a subsetting process to extract the data at the desired location, then run the climate indicator process on that subsetted file. The other option showcased here is to pass a DAP url that encodes the [subsetting operation](https://www.unidata.ucar.edu/software/tds/current/tutorial/Subset.html).\n", "\n", "This tutorial shows how to get the index for the desired location and pass them as a DAP link to a Finch indicator process." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "import xarray as xr\n", "from birdy import WPSClient\n", "\n", "# Link to file storing precipitation\n", "pr = \"https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/flyingpigeon/cmip3/pr.sresa2.miub_echo_g.run1.atm.da.nc\"\n", "\n", "# Open connection to Finch WPS server\n", "pavics_url = \"https://pavics.ouranos.ca/twitcher/ows/proxy/finch/wps\"\n", "url = os.environ.get(\"WPS_URL\", pavics_url)\n", "wps = WPSClient(url)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (lat: 6, bnds: 2, lon: 7, time: 7200)\n", "Coordinates:\n", " * lat (lat) float64 42.68 46.39 50.1 53.81 57.52 61.23\n", " * lon (lon) float64 281.2 285.0 288.8 292.5 296.2 300.0 303.8\n", " * time (time) object 2046-01-01 12:00:00 ... 2065-12-30 12:00:00\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " lat_bnds (lat, bnds) float64 ...\n", " lon_bnds (lon, bnds) float64 ...\n", " time_bnds (time, bnds) object ...\n", " pr (time, lat, lon) float32 ...\n", "Attributes: (12/17)\n", " comment: Spinup: restart files from end of experiment 20C3M (corre...\n", " title: MIUB model output prepared for IPCC Fourth Assessment SR...\n", " cmor_version: 0.96\n", " institution: MIUB (University of Bonn, Bonn, Germany)\n", " source: ECHO-G(1999): atmosphere: ECHAM4 (T30L19) with partial se...\n", " contact: Stephanie Legutke (legutke@dkrz.de), Seung-Ki Min(skmin@u...\n", " ... ...\n", " calendar: 360_day\n", " project_id: IPCC Fourth Assessment\n", " Conventions: CF-1.0\n", " id: pcmdi.ipcc4.miub_echo_g.sresa2.run1.atm.da\n", " history: Mon Aug 1 11:42:37 2011: ncks -4 -L 7 -d lat,42.0,64.0 -...\n", " NCO: 4.0.9
<xarray.Dataset>\n", "Dimensions: (time: 1, lat: 6, lon: 7)\n", "Dimensions without coordinates: time, lat, lon\n", "Data variables:\n", " pr (time, lat, lon) float32 ...\n", "Attributes: (12/17)\n", " comment: Spinup: restart files from end of experiment 20C3M (corre...\n", " title: MIUB model output prepared for IPCC Fourth Assessment SR...\n", " cmor_version: 0.96\n", " institution: MIUB (University of Bonn, Bonn, Germany)\n", " source: ECHO-G(1999): atmosphere: ECHAM4 (T30L19) with partial se...\n", " contact: Stephanie Legutke (legutke@dkrz.de), Seung-Ki Min(skmin@u...\n", " ... ...\n", " calendar: 360_day\n", " project_id: IPCC Fourth Assessment\n", " Conventions: CF-1.0\n", " id: pcmdi.ipcc4.miub_echo_g.sresa2.run1.atm.da\n", " history: Mon Aug 1 11:42:37 2011: ncks -4 -L 7 -d lat,42.0,64.0 -...\n", " NCO: 4.0.9
<xarray.Dataset>\n", "Dimensions: (lat: 6, lon: 7, time: 1)\n", "Coordinates:\n", " * lat (lat) float64 42.68 46.39 50.1 53.81 57.52 61.23\n", " * lon (lon) float64 281.2 285.0 288.8 292.5 296.2 300.0 303.8\n", " * time (time) object 2046-01-01 12:00:00\n", "Data variables:\n", " pr (time, lat, lon) float32 ...\n", "Attributes: (12/17)\n", " comment: Spinup: restart files from end of experiment 20C3M (corre...\n", " title: MIUB model output prepared for IPCC Fourth Assessment SR...\n", " cmor_version: 0.96\n", " institution: MIUB (University of Bonn, Bonn, Germany)\n", " source: ECHO-G(1999): atmosphere: ECHAM4 (T30L19) with partial se...\n", " contact: Stephanie Legutke (legutke@dkrz.de), Seung-Ki Min(skmin@u...\n", " ... ...\n", " calendar: 360_day\n", " project_id: IPCC Fourth Assessment\n", " Conventions: CF-1.0\n", " id: pcmdi.ipcc4.miub_echo_g.sresa2.run1.atm.da\n", " history: Mon Aug 1 11:42:37 2011: ncks -4 -L 7 -d lat,42.0,64.0 -...\n", " NCO: 4.0.9
<xarray.Dataset>\n", "Dimensions: (lat: 1, lon: 1, time: 1800, time_1: 1801)\n", "Coordinates:\n", " * lat (lat) float64 46.39\n", " * lon (lon) float64 288.8\n", " * time (time) object 2060-01-01 12:00:00 ... 2064-12-30 12:00:00\n", "Dimensions without coordinates: time_1\n", "Data variables:\n", " pr (time_1, lat, lon) float32 ...\n", "Attributes: (12/17)\n", " comment: Spinup: restart files from end of experiment 20C3M (corre...\n", " title: MIUB model output prepared for IPCC Fourth Assessment SR...\n", " cmor_version: 0.96\n", " institution: MIUB (University of Bonn, Bonn, Germany)\n", " source: ECHO-G(1999): atmosphere: ECHAM4 (T30L19) with partial se...\n", " contact: Stephanie Legutke (legutke@dkrz.de), Seung-Ki Min(skmin@u...\n", " ... ...\n", " calendar: 360_day\n", " project_id: IPCC Fourth Assessment\n", " Conventions: CF-1.0\n", " id: pcmdi.ipcc4.miub_echo_g.sresa2.run1.atm.da\n", " history: Mon Aug 1 11:42:37 2011: ncks -4 -L 7 -d lat,42.0,64.0 -...\n", " NCO: 4.0.9
<xarray.Dataset>\n", "Dimensions: (lat: 1, lon: 1, time: 1800)\n", "Coordinates:\n", " * lat (lat) float64 46.39\n", " * lon (lon) float64 288.8\n", " * time (time) object 2060-01-01 12:00:00 ... 2064-12-30 12:00:00\n", "Data variables:\n", " pr (time, lat, lon) float32 ...\n", "Attributes: (12/17)\n", " comment: Spinup: restart files from end of experiment 20C3M (corre...\n", " title: MIUB model output prepared for IPCC Fourth Assessment SR...\n", " cmor_version: 0.96\n", " institution: MIUB (University of Bonn, Bonn, Germany)\n", " source: ECHO-G(1999): atmosphere: ECHAM4 (T30L19) with partial se...\n", " contact: Stephanie Legutke (legutke@dkrz.de), Seung-Ki Min(skmin@u...\n", " ... ...\n", " calendar: 360_day\n", " project_id: IPCC Fourth Assessment\n", " Conventions: CF-1.0\n", " id: pcmdi.ipcc4.miub_echo_g.sresa2.run1.atm.da\n", " history: Mon Aug 1 11:42:37 2011: ncks -4 -L 7 -d lat,42.0,64.0 -...\n", " NCO: 4.0.9
<xarray.DataArray 'sdii' (time: 5, lat: 1, lon: 1)>\n", "[5 values with dtype=float64]\n", "Coordinates:\n", " * lat (lat) float64 46.39\n", " * lon (lon) float64 288.8\n", " * time (time) object 2060-01-01 00:00:00 ... 2064-01-01 00:00:00\n", "Attributes:\n", " units: mm d-1\n", " cell_methods: time: mean (interval: 30 minutes)\n", " history: pr=max(0,pr) applied to raw data;\\n[2024-03-19 13:28:16] ...\n", " standard_name: lwe_thickness_of_precipitation_amount\n", " long_name: Average precipitation during days with daily precipitatio...\n", " description: Annual simple daily intensity index (sdii) or annual aver...