Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
added notebook examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Oct 18, 2019
1 parent 0458a6b commit 2e5d5d9
Show file tree
Hide file tree
Showing 4 changed files with 395 additions and 0 deletions.
14 changes: 14 additions & 0 deletions notebooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# C4CDS WPS Examples

JupterLab notebooks with examples for C4CDS WPS usage.

## Installation

Update your conda environment:

$ conda env update -f environment.yml
$ source activate c4cds

## Start JupyterLab

$ jupyter lab
111 changes: 111 additions & 0 deletions notebooks/birdy-example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from birdy import WPSClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wps = WPSClient('http://compute.mips.copernicus-climate.eu/wps')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Execute cmip5 regridder"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = wps.cmip5_regridder(model='IPSL-CM5A-MR', experiment='historical', variable='tas')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.isSucceded()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.get()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Execute cordex subsetter"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = wps.cordex_subsetter(country='UK', variable='tas', year='1990')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.isSucceded()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.get()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
7 changes: 7 additions & 0 deletions notebooks/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# conda env update -f environment.yml
channels:
- conda-forge
dependencies:
- pip
- jupyterlab
- birdy
263 changes: 263 additions & 0 deletions notebooks/http-requests.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## HTTP WPS Request Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"See WPS documentation: http://geoprocessing.info/wpsdoc/\n",
"\n",
"Check server logs:\n",
"```\n",
"/var/log/supervisor/c4cds.log\n",
"/var/log/pywps/c4cds.log\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import requests"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"base_url = 'http://compute.mips.copernicus-climate.eu/wps'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Capabilites"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = base_url + '?service=WPS&request=GetCapabilities'\n",
"url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(url)\n",
"response.ok"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Process Descriptions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = base_url + '?service=WPS&version=1.0.0&request=DescribeProcess&identifier=all'\n",
"url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(url)\n",
"response.ok"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Execute cmip5 regridder"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = '{}?service=WPS&version=1.0.0&request=Execute&identifier=cmip5_regridder&DataInputs=model={};experiment={};variable={}'.format(\n",
" base_url,\n",
" 'IPSL-CM5A-MR',\n",
" 'historical',\n",
" 'tas')\n",
"url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(url)\n",
"response.ok"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Execute cmip5 regridder (async)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = '{}?service=WPS&version=1.0.0&request=Execute&identifier=cmip5_regridder&DataInputs=model={};experiment={};variable={}&storeExecuteResponse=true&status=true'.format(\n",
" base_url,\n",
" 'IPSL-CM5A-MR',\n",
" 'historical',\n",
" 'tas')\n",
"url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(url)\n",
"response.ok"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Poll the `statusLocation` URL, example:\n",
"http://cp4cds-cn1.dkrz.de:80/outputs/c4cds/bbfeb106-f1af-11e9-a8b9-f2e4655a10b7.xml"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Execute cordex subsetter"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = '{}?service=WPS&version=1.0.0&request=Execute&identifier=cordex_subsetter&DataInputs=country={};variable={};year={}'.format(\n",
" base_url,\n",
" 'UK',\n",
" 'tas',\n",
" '1990')\n",
"url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(url)\n",
"response.ok"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"response.text"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 2e5d5d9

Please sign in to comment.