{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bias correction process\n", "\n", "This example shows how to call the bias-correction service based on the Kernel Density Distribution Mapping.\n", "We first connect to the WPS server and get some information on the service, identified by id `kddm_bc`. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Bias correction method using Kernel Density Distribution Mapping (KDDM).\n" ] } ], "source": [ "from owslib.wps import WebProcessingService\n", "\n", "url = \"https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon/wps\"\n", "wps = WebProcessingService(url=url)\n", "proc = wps.describeprocess(\"kddm_bc\")\n", "print(proc.abstract)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the next step, we'll create small synthetic files and run the process. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "\n", "obs_time_index = pd.date_range(start=\"2000-01-01\", end=\"2000-12-31\", freq=\"D\")\n", "obs = xr.DataArray(\n", " np.arange(len(obs_time_index)), coords={\"time\": obs_time_index}, dims=\"time\"\n", ")\n", "ref = obs + 1\n", "\n", "fut_time_index = pd.date_range(start=\"2050-01-01\", end=\"2050-12-31\", freq=\"D\")\n", "fut = xr.DataArray(\n", " np.arange(len(fut_time_index)) + 10, coords={\"time\": fut_time_index}, dims=\"time\"\n", ")\n", "\n", "fn = {\"obs\": \"/tmp/obs.nc\", \"ref\": \"/tmp/ref.nc\", \"fut\": \"/tmp/fut.nc\"}\n", "\n", "obs.to_netcdf(fn[\"obs\"])\n", "ref.to_netcdf(fn[\"ref\"])\n", "fut.to_netcdf(fn[\"fut\"])\n", "\n", "resp = wps.execute(\n", " \"kddm_bc\", inputs=[(\"obs\", fn[\"obs\"]), (\"ref\", fn[\"ref\"]), (\"fut\", fn[\"fut\"])]\n", ")" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ProcessAccepted\n" ] } ], "source": [ "print(resp.status)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 0 }