Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENSO notebook data file update #796

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions doc/jupyter/Demo/Demo_6_ENSO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"cells": [
{
"cell_type": "markdown",
"id": "af662faf",
"metadata": {},
"source": [
"# ENSO"
]
},
{
"cell_type": "markdown",
"id": "161973d0",
"metadata": {},
"source": [
"This notebook provides an overview of running the ENSO metrics. More information can be found in the [README]( ). Example parameter files are located in the [PMP sample setups]( ). \n",
Expand All @@ -28,13 +30,15 @@
},
{
"cell_type": "markdown",
"id": "fc758afb",
"metadata": {},
"source": [
"## Download demo data"
]
},
{
"cell_type": "markdown",
"id": "fc164e01",
"metadata": {},
"source": [
"The ENSO metric requires a different set of sample data than the rest of the PMP metrics. This section of the notebook will download that data to your chosen location and generate a basic parameter file."
Expand All @@ -43,19 +47,20 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "ea19cd07",
"metadata": {},
"outputs": [],
"source": [
"# Lets get the file containing the data needed for this demo\n",
"import requests\n",
"#r = requests.get(\"https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_enso_tutorial_files.txt\")\n",
"r = requests.get(\"https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_enso_tutorial_files.v20210823.txt\")\n",
"r = requests.get(\"https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_enso_tutorial_files.txt\")\n",
"with open(\"enso_data_files.txt\",\"wb\") as f:\n",
" f.write(r.content)"
]
},
{
"cell_type": "markdown",
"id": "0bb7a8bb",
"metadata": {},
"source": [
"If you want to change the location where the demo data and output are stored, you can do so here:"
Expand All @@ -64,6 +69,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "b800cfe7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -75,6 +81,7 @@
},
{
"cell_type": "markdown",
"id": "e0880b21",
"metadata": {},
"source": [
"Then download the data. The total sample data size is 10.8 GB. This will take several minutes."
Expand All @@ -83,6 +90,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "2f8e10ad",
"metadata": {},
"outputs": [
{
Expand All @@ -105,6 +113,7 @@
},
{
"cell_type": "markdown",
"id": "13785525",
"metadata": {},
"source": [
"After downloading the data, we generate the parameter file for this demo."
Expand All @@ -113,6 +122,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "38fc987f",
"metadata": {},
"outputs": [
{
Expand All @@ -132,13 +142,15 @@
},
{
"cell_type": "markdown",
"id": "548d309b",
"metadata": {},
"source": [
"## Environment"
]
},
{
"cell_type": "markdown",
"id": "aec1bda9",
"metadata": {},
"source": [
"[ENSO Metrics package](https://github.com/CLIVAR-PRP/ENSO_metrics) and [scipy](https://www.scipy.org/) installations are needed. This section will clone the ENSO Metrics repository and *install ENSO Metrics and scipy in your current conda environment*. Set the `enso_install_location` below to chose where to clone the ENSO Metrics repository."
Expand All @@ -147,6 +159,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "23984aa1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -155,6 +168,7 @@
},
{
"cell_type": "markdown",
"id": "bf3f25eb",
"metadata": {},
"source": [
"To clone and install the ENSO Metrics package, un-comment the next cell and run it (delete quotes in lines 1 & 6)."
Expand All @@ -163,6 +177,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "3e2ceb0e",
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -190,6 +205,7 @@
},
{
"cell_type": "markdown",
"id": "f24b3f95",
"metadata": {},
"source": [
"To install scipy, un-comment the next cell and run it (delete quotes in lines 1 & 3)."
Expand All @@ -198,6 +214,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "4d1204d1",
"metadata": {},
"outputs": [
{
Expand All @@ -219,20 +236,23 @@
},
{
"cell_type": "markdown",
"id": "6dbcc822",
"metadata": {},
"source": [
"## Usage"
]
},
{
"cell_type": "markdown",
"id": "9a337b51",
"metadata": {},
"source": [
"The ENSO driver can be run from the command line as `enso_driver.py`. In this notebook, we will use bash cell magic (cells beginning with `%%bash`) to run the ENSO driver as a subprocess."
]
},
{
"cell_type": "markdown",
"id": "c92bfab3",
"metadata": {},
"source": [
"For help, type: \n",
Expand All @@ -244,6 +264,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "1c1abe78",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -328,13 +349,15 @@
},
{
"cell_type": "markdown",
"id": "160b96e1",
"metadata": {},
"source": [
"### Basic example"
]
},
{
"cell_type": "markdown",
"id": "3380307d",
"metadata": {},
"source": [
"Parameters for the ENSO Metrics can be set on the command line or using a parameter file. This first example will use a parameter file, which is shown below."
Expand All @@ -343,6 +366,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "49a4ac2c",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -390,6 +414,7 @@
},
{
"cell_type": "markdown",
"id": "19002649",
"metadata": {},
"source": [
"The next cell runs the ENSO driver using the basic parameter file. This may take several minutes."
Expand All @@ -398,6 +423,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "334a0272",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -683,6 +709,7 @@
},
{
"cell_type": "markdown",
"id": "46ff9996",
"metadata": {},
"source": [
"This run saved metrics to two files: \n",
Expand All @@ -696,6 +723,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "511a1809",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1091,6 +1119,7 @@
},
{
"cell_type": "markdown",
"id": "52d29412",
"metadata": {},
"source": [
"### ENSO Metrics Collections\n",
Expand All @@ -1108,6 +1137,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "6629c5d8",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1358,6 +1388,7 @@
},
{
"cell_type": "markdown",
"id": "22b4008b",
"metadata": {},
"source": [
"All of the results (netCDF and JSON) are located in the output directory, which uses the metrics collection name."
Expand All @@ -1366,6 +1397,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "f963d430",
"metadata": {},
"outputs": [
{
Expand All @@ -1388,6 +1420,7 @@
},
{
"cell_type": "markdown",
"id": "c48822c8",
"metadata": {},
"source": [
"Finally, this example runs the remaining metrics collection ENSO_proc:"
Expand All @@ -1396,6 +1429,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "71ad2751",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1842,7 +1876,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1856,7 +1890,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down