Skip to content

Commit

Permalink
missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
doutriaux1 committed Jun 21, 2019
1 parent f658932 commit 6fc4d81
Show file tree
Hide file tree
Showing 5 changed files with 14,316 additions and 0 deletions.
262 changes: 262 additions & 0 deletions doc/jupyter/Demo/Demo_2_monsoon_wang.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Monsoon Wang\n",
"\n",
"This notebook aims at inroducing new users on how to use the PCDMI monsoon Wang driver.\n",
"\n",
"It is expected that you have downloaded the sample data as demonstrated in [the download notebook](Demo_0_download_data.ipynb)\n",
"\n",
"Please edit the path in the following cell to reflect the location on your system where you downloaded the data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# This is where you downloaded the sample_data\n",
"demo_data_directory = \"demo_data\"\n",
"# this line is where your output will be stored\n",
"demo_output_directory = \"demo_output\""
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Preparing parameter file: basic_param.py\n",
"Preparing parameter file: basic_monsoon_wang_param.py\n"
]
}
],
"source": [
"# this prepares the various parameter files used in this demo notebooks to reflect where you downloaded the data\n",
"import glob\n",
"\n",
"# Dictionary for template_files substitutions \n",
"sub_dict = {\n",
" \"INPUT_DIR\": demo_data_directory,\n",
" \"OUTPUT_DIR\": demo_output_directory\n",
"}\n",
"for name in glob.glob(\"*.in\"):\n",
" with open(name) as template_file:\n",
" print(\"Preparing parameter file: {}\".format(name[:-3]))\n",
" template = template_file.read()\n",
" for key in sub_dict:\n",
" template = template.replace(\"${}$\".format(key), sub_dict[key])\n",
" with open(name[:-3], \"w\") as param_file:\n",
" param_file.write(template)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The PCMDI Median Driver is driven via parameter files reflecting your study and environment\n",
"in his bare minimum"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"import os\n",
"\n",
"#\n",
"# OPTIONS ARE SET BY USER IN THIS FILE AS INDICATED BELOW BY:\n",
"#\n",
"#\n",
"\n",
"# LIST OF MODEL VERSIONS TO BE TESTED\n",
"modnames = ['CNRM-CERFACS.CNRM-CM5-2',' NSF-DOE-NCAR.CESM1-WACCM']\n",
"\n",
"pth = os.path.dirname(__file__)\n",
"# ROOT PATH FOR MODELS CLIMATOLOGIES\n",
"#test_data_path = '../../../tests/monsoon/data/pr_1961_1999_MRI-CGCM3_regrid_MODS.nc'\n",
"test_data_path = 'demo_data/example_data/mo/pr/CMIP5.CMIP.historical.%(model).r1i1p1.mon.pr.atmos.glb-2d-gu.v%(version).0000000.0.nc'\n",
"# ROOT PATH FOR OBSERVATIONS\n",
"# Note that atm/mo/%(variable)/ac will be added to this\n",
"#reference_data_path = '../../../tests/monsoon/obs/pr_gpcp_79_07_mseas.nc'\n",
"reference_data_path = 'demo_data/PCMDIobs2.0/atmos/mon/pr/GPCP-2-3/gn/v20190301/pr_mon_GPCP-2-3_BE_gn_197901-201803.nc'\n",
"\n",
"# DIRECTORY WHERE TO PUT RESULTS\n",
"results_dir = 'demo_output/monsoon_wang'\n",
"\n",
"# Threshold\n",
"threshold = 2.5\n"
]
}
],
"source": [
"with open(\"basic_monsoon_wang_param.py\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now to run this simply call the mean climate driver\n",
"```\n",
"mpindex_compute.py -p basic_monsoon_wang_param.py\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CompletedProcess(args=['mpindex_compute.py', '-p', 'basic_monsoon_wang_param.py'], returncode=0)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from subprocess import run, PIPE\n",
"run(\"mpindex_compute.py -p basic_monsoon_wang_param.py\".split())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"JSON OUTPUT:\n",
"{\n",
" \"DISCLAIMER\": \"USER-NOTICE: The results in this file were produced with the PMP v1.1 (https://github.com/PCMDI/pcmdi_metrics). They are for research purposes only. They are subject to ongoing quality control and change as the PMP software advances, interpolation methods are modified, observational data sets are updated, problems with model data are corrected, etc. Use of these results for research (presentation, publications, etc.) should reference: Gleckler, P. J., C. Doutriaux, P. J. Durack, K. E. Taylor, Y. Zhang, and D. N. Williams, E. Mason, and J. Servonnat (2016), A more powerful reality test for climate models, Eos, 97, doi:10.1029/2016EO051663. If any problems are uncovered in using these results please contact the PMP development team at pcmdi-metrics@llnl.gov\\n\",\n",
" \"REFERENCE\": \"The statistics in this file are based on Wang, B., Kim, HJ., Kikuchi, K. et al. Clim Dyn (2011) 37: 941. doi:10.1007/s00382-010-0877-0\",\n",
" \"RESULTS\": {\n",
" \"xa\": {\n",
" \"AllMW\": {\n",
" \"cor\": \"0.768\",\n",
" \"rmsn\": \"0.703\",\n",
" \"threat_score\": \"0.494\"\n",
" },\n",
" \"AllM\": {\n",
" \"cor\": \"0.773\",\n",
" \"rmsn\": \"0.697\",\n",
" \"threat_score\": \"0.494\"\n",
" },\n",
" \"NAMM\": {\n",
" \"cor\": \"0.778\",\n",
" \"rmsn\": \"0.742\",\n",
" \"threat_score\": \"0.602\"\n",
" },\n",
" \"SAMM\": {\n",
" \"cor\": \"0.850\",\n",
" \"rmsn\": \"0.582\",\n",
" \"threat_score\": \"0.489\"\n",
" },\n",
" \"NAFM\": {\n",
" \"cor\": \"0.732\",\n",
" \"rmsn\": \"0.763\",\n",
" \"threat_score\": \"0.454\"\n",
" },\n",
" \"SAFM\": {\n",
" \"cor\": \"0.857\",\n",
" \"rmsn\": \"0.574\",\n",
" \"threat_score\": \"0.614\"\n",
" },\n",
" \"ASM\": {\n",
" \"cor\": \"0.711\",\n",
" \"rmsn\": \"0.776\",\n",
" \"threat_score\": \"0.450\"\n",
" },\n",
" \"AUSM\": {\n",
" \"cor\": \"0.895\",\n",
" \"rmsn\": \"0.539\",\n",
" \"threat_score\": \"0.607\"\n",
" }\n",
" }\n",
" },\n",
" \"json_version\": 3.0,\n",
" \"json_structure\": [\n",
" \"model\",\n",
" \"domain\",\n",
" \"statistic\"\n",
" ],\n",
" \"provenance\": {\n",
" \"platform\": {\n",
" \"OS\": \"Darwin\",\n",
" \"Version\": \"17.7.0\",\n",
" \"Name\": \"loki\"\n",
" },\n",
" \"userId\": \"doutriaux1\",\n",
" \"osAccess\": false,\n",
" \"commandLine\": \"/Users/doutriaux1/miniconda3/envs/nightly_py3.6/bin/mpindex_compute.py -p basic_monsoon_wang_param.py\",\n",
" \"date\": \"2019-04-26 10:08:15\",\n",
" \"conda\": {},\n",
" \"packages\": {},\n",
" \"openGL\": {\n",
" \"GLX\": {\n",
" \"server\": {},\n",
" \"client\": {}\n",
" }\n",
" }\n",
" }\n",
"}\n"
]
}
],
"source": [
"import os\n",
"with open(os.path.join(demo_output_directory,\"monsoon_wang/monsoon_wang.json\")) as f:\n",
" print(\"JSON OUTPUT:\\n{}\".format(f.read()))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
27 changes: 27 additions & 0 deletions doc/jupyter/Demo/basic_monsoon_wang_param.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

#
# OPTIONS ARE SET BY USER IN THIS FILE AS INDICATED BELOW BY:
#
#

# LIST OF MODEL VERSIONS TO BE TESTED
modnames = ['CNRM-CERFACS.CNRM-CM5-2',' NSF-DOE-NCAR.CESM1-WACCM']

pth = os.path.dirname(__file__)
# ROOT PATH FOR MODELS CLIMATOLOGIES
#test_data_path = '../../../tests/monsoon/data/pr_1961_1999_MRI-CGCM3_regrid_MODS.nc'
test_data_path = '$INPUT_DIR$/example_data/atm/mo/pr/CMIP5.CMIP.historical.%(model).r1i1p1.mon.pr.atmos.glb-2d-gu.v%(version).0000000.0.nc'
# ROOT PATH FOR OBSERVATIONS
# Note that atm/mo/%(variable)/ac will be added to this
#reference_data_path = '../../../tests/monsoon/obs/pr_gpcp_79_07_mseas.nc'
reference_data_path = '$INPUT_DIR$/PCMDIobs2.0/atmos/mon/pr/GPCP-2-3/gn/v20190301/pr_mon_GPCP-2-3_BE_gn_197901-201803.nc'

# DIRECTORY WHERE TO PUT RESULTS
results_dir = '$OUTPUT_DIR$/monsoon_wang'

# Version for each model
version = ['20130401', '20130314']

# Threshold
threshold = 2.5
55 changes: 55 additions & 0 deletions doc/jupyter/Demo/basic_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os

#
# OPTIONS ARE SET BY USER IN THIS FILE AS INDICATED BELOW BY:
#
#

# RUN IDENTIFICATION
# DEFINES A SUBDIRECTORY TO METRICS OUTPUT RESULTS SO MULTIPLE CASES CAN
# BE COMPARED
case_id = 'basicTest'

# LIST OF MODEL VERSIONS TO BE TESTED - WHICH ARE EXPECTED TO BE PART OF
# CLIMATOLOGY FILENAME
test_data_set = ['ACCESS1-0', 'CSIRO-Mk3-6-0']


# VARIABLES TO USE
vars = ['rlut']


# Observations to use at the moment "default" or "alternate"
reference_data_set = ['all']
#ext = '.nc'

# INTERPOLATION OPTIONS
target_grid = '2.5x2.5' # OPTIONS: '2.5x2.5' or an actual cdms2 grid object
regrid_tool = 'regrid2' # 'regrid2' # OPTIONS: 'regrid2','esmf'
# OPTIONS: 'linear','conservative', only if tool is esmf
regrid_method = 'linear'
regrid_tool_ocn = 'esmf' # OPTIONS: "regrid2","esmf"
# OPTIONS: 'linear','conservative', only if tool is esmf
regrid_method_ocn = 'linear'

# Templates for climatology files
# %(param) will subsitute param with values in this file
filename_template = "CMIP5.historical.%(model_version).r1i1p1.mon.%(variable).198101-200512.AC.v20190225.nc"

# filename template for landsea masks ('sftlf')
sftlf_filename_template = "sftlf_%(model_version).nc"
generate_sftlf = True # if land surface type mask cannot be found, generate one


pth = os.path.dirname(__file__)
# ROOT PATH FOR MODELS CLIMATOLOGIES
test_data_path = 'demo_data/example_data/atm/mo/rlut/ac/'
# ROOT PATH FOR OBSERVATIONS
# Note that atm/mo/%(variable)/ac will be added to this
reference_data_path = 'demo_data/pmpobs_v1.0'

# DIRECTORY WHERE TO PUT RESULTS
metrics_output_path = os.path.join(
'demo_output',
"%(case_id)")

7 changes: 7 additions & 0 deletions doc/jupyter/Demo/data_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
https://pcmdiweb.llnl.gov/pss/pmpdata/
0af0ddd3e998579c0e8773b24981331a PCMDIobs2.0/atmos/mon/pr/GPCP-2-3/gn/v20190301//pr_mon_GPCP-2-3_BE_gn_197901-201803.nc
146eec5e8a734fedbbdd0909921530f2 pmpobs_v1.0/atm/mo/rlut/CERES/ac/rlut_CERES_000001-000012_ac.nc
bad136e97d7f13dc5af4ac019c8ca9c2 example_data/atm/mo/rlut/ac/CMIP5.historical.ACCESS1-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc
ec61d7bf2f8480f8e7a18af62d61deff example_data/atm/mo/rlut/ac/CMIP5.historical.CSIRO-Mk3-6-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc
9f5938a7750156ef76905f8872fd0aee example_data/atm/mo/pr/CMIP5.CMIP.historical.CNRM-CERFACS.CNRM-CM5-2.r1i1p1.mon.pr.atmos.glb-2d-gu.v20130401.0000000.0.nc
080a39fb6861cb320d29eb5a6dbc9859 example_data/atm/mo/pr/CMIP5.CMIP.historical.NSF-DOE-NCAR.CESM1-WACCM.r1i1p1.mon.pr.atmos.glb-2d-gu.v20130314.0000000.0.nc
Loading

0 comments on commit 6fc4d81

Please sign in to comment.