{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ARC2 download example\n", "\n", "In this demo we show how to download ARC2 data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook\n", "import dh_py_access.lib.datahub as datahub\n", "import dh_py_access.package_api as package_api" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please put your datahub API key into a file called APIKEY and place it to the notebook folder or assign your API key directly to the variable API_key!" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "server = 'api.planetos.com'\n", "API_key = open('APIKEY').readlines()[0].strip() #''\n", "version = 'v1'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "At first, we need to define the dataset names and temporal ranges. Please note that the datasets have different time ranges. So we will download the data from 1981, when CHRIPS starts (ARC2 is from 1983)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dh=datahub.datahub(server,version,API_key)\n", "dataset1='noaa_arc2_africa_01'\n", "variable_name1 = 'pr'\n", "time_start = '1983-01-01T00:00:00'\n", "time_end = '2018-01-01T00:00:00'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we define spatial range. In this case we define all Africa. Keep in mind that it's a huge area and downloading all the data from Africa for 35 years is a lot and can take even several hours. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "area_name = 'Africa'\n", "latitude_north = 42.24; longitude_west = -24.64\n", "latitude_south = -45.76; longitude_east = 60.28" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download the data with package API\n", "\n", "1. Create package objects\n", "2. Send commands for the package creation\n", "3. Download the package files" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "package_arc2_africa_01 = package_api.package_api(dh,dataset1,variable_name1,longitude_west,longitude_east,latitude_south,latitude_north,time_start,time_end,area_name=area_name)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Package exists\n" ] } ], "source": [ "package_arc2_africa_01.make_package()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "File already downloaded\n" ] } ], "source": [ "package_arc2_africa_01.download_package()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 2 }