{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "western-player", "metadata": {}, "outputs": [], "source": [ "import os\n", "os.environ['ROOK_URL'] = 'http://rook.dkrz.de/wps'\n", "# os.environ['ROOK_URL'] = 'http://compute.mips.copernicus-climate.eu/wps'\n", "os.environ['ROOK_MODE'] = \"async\"\n", "\n", "from rooki import rooki" ] }, { "cell_type": "markdown", "id": "regulation-friday", "metadata": {}, "source": [ "## Check GetCapabilities" ] }, { "cell_type": "code", "execution_count": null, "id": "generic-princeton", "metadata": {}, "outputs": [], "source": [ "assert hasattr(rooki, 'subset')" ] }, { "cell_type": "code", "execution_count": null, "id": "acquired-creature", "metadata": {}, "outputs": [], "source": [ "assert hasattr(rooki, 'average')" ] }, { "cell_type": "code", "execution_count": null, "id": "chemical-school", "metadata": {}, "outputs": [], "source": [ "assert hasattr(rooki, 'orchestrate')" ] }, { "cell_type": "markdown", "id": "electronic-inspiration", "metadata": {}, "source": [ "## Check DescribeProcess" ] }, { "cell_type": "code", "execution_count": null, "id": "passive-engine", "metadata": {}, "outputs": [], "source": [ "import inspect\n", "signature = inspect.signature(rooki.subset)" ] }, { "cell_type": "code", "execution_count": null, "id": "united-acrylic", "metadata": {}, "outputs": [], "source": [ "assert \"collection\" in signature.parameters" ] }, { "cell_type": "code", "execution_count": null, "id": "instant-review", "metadata": {}, "outputs": [], "source": [ "assert \"time\" in signature.parameters" ] }, { "cell_type": "code", "execution_count": null, "id": "advisory-official", "metadata": {}, "outputs": [], "source": [ "assert \"area\" in signature.parameters" ] }, { "cell_type": "markdown", "id": "flush-constraint", "metadata": {}, "source": [ "## Check Execute" ] }, { "cell_type": "code", "execution_count": null, "id": "owned-relationship", "metadata": {}, "outputs": [], "source": [ "# use common cmip6 collection\n", "collection=\"c3s-cmip6.ScenarioMIP.INM.INM-CM5-0.ssp245.r1i1p1f1.Amon.rlds.gr1.v20190619\"" ] }, { "cell_type": "markdown", "id": "behavioral-saint", "metadata": {}, "source": [ "### Subset time" ] }, { "cell_type": "code", "execution_count": null, "id": "particular-interview", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time='2020-01-01/2020-12-30',\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "leading-validation", "metadata": {}, "outputs": [], "source": [ "ds = resp.datasets()[0]\n", "assert 'rlds' in ds.variables" ] }, { "cell_type": "markdown", "id": "enhanced-adjustment", "metadata": {}, "source": [ "### Subset time ... original files" ] }, { "cell_type": "code", "execution_count": null, "id": "irish-conflict", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time=\"2015-01-16T12:00:00/2100-12-16T12:00:00\",\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "adverse-salem", "metadata": {}, "outputs": [], "source": [ "\"data.mips.copernicus-climate.eu\" in resp.download_urls()[0]" ] }, { "cell_type": "markdown", "id": "popular-cleaner", "metadata": {}, "source": [ "### Subset time ... orignal files ... extended time range" ] }, { "cell_type": "code", "execution_count": null, "id": "honest-preservation", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time=\"1900-01-01/2500-12-30\",\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "upset-function", "metadata": {}, "outputs": [], "source": [ "\"data.mips.copernicus-climate.eu\" in resp.download_urls()[0]" ] }, { "cell_type": "markdown", "id": "distinct-surgery", "metadata": {}, "source": [ "### Subset time ... original files ... no time parameter" ] }, { "cell_type": "code", "execution_count": null, "id": "romantic-reform", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "alone-enterprise", "metadata": {}, "outputs": [], "source": [ "assert \"data.mips.copernicus-climate.eu\" in resp.download_urls()[0]" ] }, { "cell_type": "markdown", "id": "entitled-crazy", "metadata": {}, "source": [ "### Subset time and area ... positive lat/lon" ] }, { "cell_type": "code", "execution_count": null, "id": "facial-bleeding", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time=\"2020-01-01/2020-12-30\",\n", " area=\"10,10,40,40\"\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "double-denver", "metadata": {}, "outputs": [], "source": [ "ds = resp.datasets()[0]\n", "assert 'rlds' in ds.variables" ] }, { "cell_type": "markdown", "id": "mexican-governor", "metadata": {}, "source": [ "### Subset time and area ... negative lat/lon" ] }, { "cell_type": "code", "execution_count": null, "id": "eight-building", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time='2020-01-01/2020-12-30',\n", " area='-50,-50,-10,-10'\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "graduate-rehabilitation", "metadata": {}, "outputs": [], "source": [ "ds = resp.datasets()[0]\n", "assert 'rlds' in ds.variables" ] }, { "cell_type": "markdown", "id": "adjustable-niger", "metadata": {}, "source": [ "### Subset time and area ... cross meridian" ] }, { "cell_type": "code", "execution_count": null, "id": "infrared-swaziland", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time='2020-01-01/2020-12-30',\n", " area='-50,-50,50,50'\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "extended-celebration", "metadata": {}, "outputs": [], "source": [ "ds = resp.datasets()[0]\n", "assert 'rlds' in ds.variables" ] }, { "cell_type": "markdown", "id": "utility-session", "metadata": {}, "source": [ "### Subset time and area ... negative lat, positive lon" ] }, { "cell_type": "code", "execution_count": null, "id": "documented-retirement", "metadata": {}, "outputs": [], "source": [ "resp = rooki.subset(\n", " collection=collection,\n", " time='2020-01-01/2020-12-30',\n", " area='-200,40,-50,80'\n", ")\n", "assert resp.ok" ] }, { "cell_type": "code", "execution_count": null, "id": "confidential-writer", "metadata": {}, "outputs": [], "source": [ "ds = resp.datasets()[0]\n", "assert 'rlds' in ds.variables" ] } ], "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.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }