diff --git a/notebooks/HowTo-01_Import_and_Load_the_DR.ipynb b/notebooks/HowTo-01_Import_and_Load_the_DR.ipynb index 15ea8e88..9e43eac8 100644 --- a/notebooks/HowTo-01_Import_and_Load_the_DR.ipynb +++ b/notebooks/HowTo-01_Import_and_Load_the_DR.ipynb @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### List the version locally cashed (none for the moment)" + "#### List the versions locally cached (none for the moment)" ] }, { @@ -85,7 +85,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Download a specified version of the data request content (if not locally cached)" + "#### Retrieve latest version of the data request content, which downloads if not locally cached" ] }, { @@ -96,7 +96,7 @@ }, "outputs": [], "source": [ - "path_to_content_json = dc.retrieve('v1.1')\n", + "path_to_content_json = dc.retrieve('latest')\n", "print(path_to_content_json)" ] }, @@ -104,7 +104,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Download other versions of the data request content (if not locally cached)" + "#### Retrieve other versions of the data request content (again, they download if not already cached locally)" ] }, { @@ -113,7 +113,7 @@ "metadata": {}, "outputs": [], "source": [ - "path_to_content_json = dc.retrieve('v1.0')\n", + "path_to_content_json = dc.retrieve('v1.2')\n", "print(path_to_content_json)" ] }, @@ -123,7 +123,7 @@ "metadata": {}, "outputs": [], "source": [ - "path_to_content_json = dc.retrieve('v1.0alpha')\n", + "path_to_content_json = dc.retrieve('v1.1')\n", "print(path_to_content_json)" ] }, @@ -131,7 +131,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### List the version locally cashed (now they are 3 !)" + "#### List the version locally cached (now they are 3 !)" ] }, { @@ -147,7 +147,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Remove a useless cashed version" + "#### Remove a cached version" ] }, { @@ -156,7 +156,7 @@ "metadata": {}, "outputs": [], "source": [ - "dc.delete(version='v1.0alpha')" + "dc.delete(version='v1.2.1')" ] }, { @@ -179,7 +179,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "_Note: returned `content` is a dictionnary of the loaded json containing everything that is in the DR content, i.e. the Big json exported from DR airtables_" + "_Note: returned `content` is a dictionary of the loaded json containing everything that is in the DR content, i.e. the big json file exported from DR airtables_" ] }, { @@ -196,7 +196,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "_Note: now the latest_version v1.2 is also cashed_" + "_Note: now the latest_version is also cached_" ] }, { diff --git a/notebooks/HowTo-03b_Find_Experiments_and_Variables_for_given_Opportunities.ipynb b/notebooks/HowTo-03b_Find_Experiments_and_Variables_for_given_Opportunities.ipynb index 0e9789c6..0c90b4b2 100644 --- a/notebooks/HowTo-03b_Find_Experiments_and_Variables_for_given_Opportunities.ipynb +++ b/notebooks/HowTo-03b_Find_Experiments_and_Variables_for_given_Opportunities.ipynb @@ -39,7 +39,7 @@ "metadata": {}, "outputs": [], "source": [ - "used_dreq_version = 'v1.2'\n", + "used_dreq_version = 'v1.2.1'\n", "dreq_content = dc.load(version=used_dreq_version)\n", "dreq_tables = dq.create_dreq_tables_for_request(content=dreq_content, dreq_version=used_dreq_version)\n", "path_to_content = dc._dreq_content_loaded['json_path']" @@ -60,6 +60,7 @@ "source": [ "#- Or simply set use_opps = 'all' to support all opportunities\n", "used_opps = []\n", + "used_opps.append('Baseline Climate Variables for Earth System Modelling')\n", "used_opps.append(\"Energy System Impacts\")\n", "used_opps.append(\"Health Impacts\")" ] @@ -96,7 +97,7 @@ "#>>> issue: sounds like used_opps and priority_cutoff args are not taken into account\n", "expected_vars_per_expes = dq.get_requested_variables(content=dreq_tables, dreq_version=used_dreq_version,\n", " use_opps=used_opps, priority_cutoff=prio_cutoff, \n", - " verbose=False, check_core_variables=False)" + " verbose=False, check_core_variables=True)" ] }, { diff --git a/notebooks/HowTo-04b_View_Attributes_of_Variables.ipynb b/notebooks/HowTo-04b_View_Attributes_of_Variables.ipynb index 9abd801e..7752775f 100644 --- a/notebooks/HowTo-04b_View_Attributes_of_Variables.ipynb +++ b/notebooks/HowTo-04b_View_Attributes_of_Variables.ipynb @@ -39,7 +39,7 @@ "metadata": {}, "outputs": [], "source": [ - "used_dreq_version = 'v1.2'\n", + "used_dreq_version = 'v1.2.1'\n", "dreq_content = dc.load(version=used_dreq_version)\n", "dreq_tables = dq.create_dreq_tables_for_request(content=dreq_content, dreq_version=used_dreq_version)\n", "path_to_content = dc._dreq_content_loaded['json_path']" @@ -52,7 +52,8 @@ "outputs": [], "source": [ "#- Need to set an api version for writting results in json files\n", - "used_api_version = 'v1.2'" + "from data_request_api import version as used_api_version\n", + "print(used_api_version)" ] }, { diff --git a/notebooks/workflow_example.ipynb b/notebooks/workflow_example.ipynb deleted file mode 100644 index 7b8157d4..00000000 --- a/notebooks/workflow_example.ipynb +++ /dev/null @@ -1,250 +0,0 @@ - -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "provenance": [], - "authorship_tag": "ABX9TyPwdLfrQojfCGhN4oc+9j17", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "6THuOI2AO1Xh", - "outputId": "8b3460c2-09be-4591-f062-fe419e63eb24" - }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Collecting git+https://github.com/CMIP-Data-Request/CMIP7_DReq_Software.git\n", - " Cloning https://github.com/CMIP-Data-Request/CMIP7_DReq_Software.git to /tmp/pip-req-build-99b8_2te\n", - " Running command git clone --filter=blob:none --quiet https://github.com/CMIP-Data-Request/CMIP7_DReq_Software.git /tmp/pip-req-build-99b8_2te\n", - " Resolved https://github.com/CMIP-Data-Request/CMIP7_DReq_Software.git to commit 999ed53b3421d79caf2d20c3f2a87630ac148ea5\n", - " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", - " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", - " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", - "Requirement already satisfied: pooch in /usr/local/lib/python3.11/dist-packages (from CMIP7_data_request_api==1.1.3.dev5+g999ed53) (1.8.2)\n", - "Requirement already satisfied: openpyxl in /usr/local/lib/python3.11/dist-packages (from CMIP7_data_request_api==1.1.3.dev5+g999ed53) (3.1.5)\n", - "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from CMIP7_data_request_api==1.1.3.dev5+g999ed53) (2.32.3)\n", - "Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.11/dist-packages (from CMIP7_data_request_api==1.1.3.dev5+g999ed53) (4.13.3)\n", - "Requirement already satisfied: pyyaml in /usr/local/lib/python3.11/dist-packages (from CMIP7_data_request_api==1.1.3.dev5+g999ed53) (6.0.2)\n", - "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (2.6)\n", - "Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (4.12.2)\n", - "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.11/dist-packages (from openpyxl->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (2.0.0)\n", - "Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.11/dist-packages (from pooch->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (4.3.7)\n", - "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from pooch->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (24.2)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (3.4.1)\n", - "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (3.10)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (2.3.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests->CMIP7_data_request_api==1.1.3.dev5+g999ed53) (2025.1.31)\n", - "Building wheels for collected packages: CMIP7_data_request_api\n", - " Building wheel for CMIP7_data_request_api (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", - " Created wheel for CMIP7_data_request_api: filename=cmip7_data_request_api-1.1.3.dev5+g999ed53-py3-none-any.whl size=1967096 sha256=af4cea104755582f60c6e5ab75f60c2b7b3e4cf75ac95d4d6ec855dd33301c42\n", - " Stored in directory: /tmp/pip-ephem-wheel-cache-k3luabwi/wheels/82/4b/9e/c54dd52a64f230188de02a4b8b2d4c8ea3744779914ceb4882\n", - "Successfully built CMIP7_data_request_api\n", - "Installing collected packages: CMIP7_data_request_api\n", - " Attempting uninstall: CMIP7_data_request_api\n", - " Found existing installation: CMIP7_data_request_api 1.1.3.dev4+g2788b60\n", - " Uninstalling CMIP7_data_request_api-1.1.3.dev4+g2788b60:\n", - " Successfully uninstalled CMIP7_data_request_api-1.1.3.dev4+g2788b60\n", - "Successfully installed CMIP7_data_request_api-1.1.3.dev5+g999ed53\n" - ] - } - ], - "source": [ - "# pip install CMIP7-data-request-api\n", - "# we need a new tag to release the fixes.\n", - "\n", - "!pip install git+https://github.com/CMIP-Data-Request/CMIP7_DReq_Software.git\n" - ] - }, - { - "cell_type": "code", - "source": [ - "import sys\n", - "import os\n", - "# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n", - "from data_request_api.stable.content import dreq_content as dc\n", - "from data_request_api.stable.query import dreq_query as dq\n", - "from importlib import reload\n", - "reload(dq)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "dsH2YDD8RouA", - "outputId": "9b621942-b8fb-4550-b31c-4464f7b068c8" - }, - "execution_count": 9, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "" - ] - }, - "metadata": {}, - "execution_count": 9 - } - ] - }, - { - "cell_type": "code", - "source": [ - "use_dreq_version = 'v1.1'\n", - "\n", - "# Download specified version of data request content (if not locally cached)\n", - "dc.retrieve(use_dreq_version)\n", - "\n", - "# Load content into python dict\n", - "content = dc.load(use_dreq_version)\n", - "\n", - "# Specify opportunities that modelling group chooses to support\n", - "# This can be a subset:\n", - "use_opps = []\n", - "use_opps.append('Baseline Climate Variables for Earth System Modelling')\n", - "use_opps.append('Synoptic systems')\n", - "\n", - "# Or, to support all opportunities in the data request:\n", - "use_opps = 'all'\n", - "\n", - "# Get consolidated list of requested variables that supports these opportunities\n", - "dq.DREQ_VERSION = use_dreq_version\n", - "priority_cutoff = 'Low'\n", - "\n" - ], - "metadata": { - "id": "aVazKS-lR-eQ" - }, - "execution_count": 11, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "content.keys(),\n", - "content = {'Data Request':content['Data Request v1.1'] }" - ], - "metadata": { - "id": "hrVbi_2AU0gK" - }, - "execution_count": 18, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "expt_vars = dq.get_requested_variables(content, use_opps, priority_cutoff=priority_cutoff, verbose=False)\n", - "\n" - ], - "metadata": { - "id": "9VduvVTbUzTA" - }, - "execution_count": 19, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "\n", - "if len(expt_vars['experiment']) > 0:\n", - " # Show user what was found\n", - " dq.show_requested_vars_summary(expt_vars, use_opps)" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "_ua6KJc5VX7I", - "outputId": "91741ee9-58a6-4bf6-9094-e1701fe596f2" - }, - "execution_count": 20, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "\n", - "For data request version all, number of requested variables found by experiment:\n", - " 1pctCO2 : Core=139 ,High=788 ,Medium=132 ,Low=93, TOTAL=1152\n", - " 1pctCO2-bgc : Core=139 ,High=682 ,Medium=190 ,Low=79, TOTAL=1090\n", - " 1pctCO2-rad : Core=139 ,High=682 ,Medium=190 ,Low=79, TOTAL=1090\n", - " High scenario : Core=139 ,High=953 ,Medium=417 ,Low=101, TOTAL=1610\n", - " Initialised prediction (2025-2036) : Core=139 ,High=751 ,Medium=230 ,Low=87, TOTAL=1207\n", - " Low scenario : Core=139 ,High=920 ,Medium=395 ,Low=101, TOTAL=1555\n", - " Medium low scenario : Core=139 ,High=920 ,Medium=395 ,Low=101, TOTAL=1555\n", - " Medium scenario : Core=139 ,High=963 ,Medium=439 ,Low=98, TOTAL=1639\n", - " SSPX-SLCF : Core=139 ,High=672 ,Medium=181 ,Low=67, TOTAL=1059\n", - " Very low after high overshoot scenario : Core=139 ,High=920 ,Medium=395 ,Low=101, TOTAL=1555\n", - " Very low with limited overshoot scenario : Core=139 ,High=920 ,Medium=395 ,Low=101, TOTAL=1555\n", - " abrupt-0p5CO2 : Core=139 ,High=825 ,Medium=157 ,Low=81, TOTAL=1202\n", - " abrupt-127k : Core=139 ,High=761 ,Medium=158 ,Low=63, TOTAL=1121\n", - " abrupt-2xCO2 : Core=139 ,High=825 ,Medium=157 ,Low=81, TOTAL=1202\n", - " abrupt-4xCO2 : Core=139 ,High=788 ,Medium=132 ,Low=93, TOTAL=1152\n", - " amip : Core=139 ,High=835 ,Medium=203 ,Low=95, TOTAL=1272\n", - " amip-p4k : Core=139 ,High=906 ,Medium=218 ,Low=97, TOTAL=1360\n", - " amip-piForcing : Core=139 ,High=742 ,Medium=187 ,Low=97, TOTAL=1165\n", - " esm-flat10 : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " esm-flat10-cdr : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " esm-flat10-zec : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " esm-hist : Core=139 ,High=1012 ,Medium=438 ,Low=111, TOTAL=1700\n", - " esm-piControl : Core=139 ,High=924 ,Medium=307 ,Low=95, TOTAL=1465\n", - " hist-GHG : Core=139 ,High=735 ,Medium=238 ,Low=79, TOTAL=1191\n", - " hist-aer : Core=139 ,High=735 ,Medium=238 ,Low=79, TOTAL=1191\n", - " hist-nat : Core=139 ,High=735 ,Medium=238 ,Low=79, TOTAL=1191\n", - " hist-piAer : Core=139 ,High=678 ,Medium=188 ,Low=79, TOTAL=1084\n", - " hist-piSLCF : Core=139 ,High=678 ,Medium=188 ,Low=79, TOTAL=1084\n", - " historical : Core=139 ,High=1012 ,Medium=438 ,Low=111, TOTAL=1700\n", - " land-hist : Core=139 ,High=703 ,Medium=212 ,Low=65, TOTAL=1119\n", - " newGeoMIP : Core=139 ,High=729 ,Medium=223 ,Low=65, TOTAL=1156\n", - " piClim-4xCO2 : Core=139 ,High=695 ,Medium=104 ,Low=89, TOTAL=1027\n", - " piClim-X : Core=139 ,High=672 ,Medium=181 ,Low=67, TOTAL=1059\n", - " piClim-aer : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " piClim-anthro : Core=139 ,High=700 ,Medium=120 ,Low=89, TOTAL=1048\n", - " piClim-control : Core=139 ,High=695 ,Medium=104 ,Low=89, TOTAL=1027\n", - " piClim-histaer : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " piClim-histall : Core=139 ,High=669 ,Medium=181 ,Low=64, TOTAL=1053\n", - " piControl : Core=139 ,High=924 ,Medium=307 ,Low=95, TOTAL=1465\n" - ] - } - ] - }, - { - "cell_type": "code", - "source": [], - "metadata": { - "id": "sgS0cg2fVY8-" - }, - "execution_count": null, - "outputs": [] - } - ] -}