diff --git a/doc/jupyter/Demo/Demo_0_download_data.ipynb b/doc/jupyter/Demo/Demo_0_download_data.ipynb index c1cd9a83f..15a63e60e 100644 --- a/doc/jupyter/Demo/Demo_0_download_data.ipynb +++ b/doc/jupyter/Demo/Demo_0_download_data.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -50,9 +50,7 @@ "output_type": "stream", "text": [ "MD5: data_files.txt\n", - "Downloading: 'pmpobs_v1.0/atm/mo/rlut/CERES/ac/rlut_CERES_000001-000012_ac.nc' from 'https://pcmdiweb.llnl.gov/pss/pmpdata/' in: demo_data/pmpobs_v1.0/atm/mo/rlut/CERES/ac/rlut_CERES_000001-000012_ac.nc\n", - "Downloading: 'example_data/atm/mo/rlut/ac/CMIP5.historical.ACCESS1-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc' from 'https://pcmdiweb.llnl.gov/pss/pmpdata/' in: demo_data/example_data/atm/mo/rlut/ac/CMIP5.historical.ACCESS1-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc\n", - "Downloading: 'example_data/atm/mo/rlut/ac/CMIP5.historical.CSIRO-Mk3-6-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc' from 'https://pcmdiweb.llnl.gov/pss/pmpdata/' in: demo_data/example_data/atm/mo/rlut/ac/CMIP5.historical.CSIRO-Mk3-6-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc\n" + "Downloading: 'PCMDIobs2.0/atmos/mon/pr/GPCP-2-3/gn/v20190301//pr_mon_GPCP-2-3_BE_gn_197901-201803.nc' from 'https://pcmdiweb.llnl.gov/pss/pmpdata/' in: demo_data/PCMDIobs2.0/atmos/mon/pr/GPCP-2-3/gn/v20190301//pr_mon_GPCP-2-3_BE_gn_197901-201803.nc\n" ] } ], @@ -69,13 +67,6 @@ "You're done!\n", "Please proceed to the next tutorial" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/doc/jupyter/Demo/Demo_1_mean_climate.ipynb b/doc/jupyter/Demo/Demo_1_mean_climate.ipynb index 17a0ce42e..c49010beb 100644 --- a/doc/jupyter/Demo/Demo_1_mean_climate.ipynb +++ b/doc/jupyter/Demo/Demo_1_mean_climate.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -27,17 +27,9 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Preparing parameter file: basic_param.py\n" - ] - } - ], + "outputs": [], "source": [ "# this prepares the various parameter files used in this demo notebooks to reflect where you downloaded the data\n", "import glob\n", @@ -67,72 +59,9 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 3, "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", - "# RUN IDENTIFICATION\n", - "# DEFINES A SUBDIRECTORY TO METRICS OUTPUT RESULTS SO MULTIPLE CASES CAN\n", - "# BE COMPARED\n", - "case_id = 'basicTest'\n", - "\n", - "# LIST OF MODEL VERSIONS TO BE TESTED - WHICH ARE EXPECTED TO BE PART OF\n", - "# CLIMATOLOGY FILENAME\n", - "test_data_set = ['ACCESS1-0', 'CSIRO-Mk3-6-0']\n", - "\n", - "\n", - "# VARIABLES TO USE\n", - "vars = ['rlut']\n", - "\n", - "\n", - "# Observations to use at the moment \"default\" or \"alternate\"\n", - "reference_data_set = ['all']\n", - "#ext = '.nc'\n", - "\n", - "# INTERPOLATION OPTIONS\n", - "target_grid = '2.5x2.5' # OPTIONS: '2.5x2.5' or an actual cdms2 grid object\n", - "regrid_tool = 'regrid2' # 'regrid2' # OPTIONS: 'regrid2','esmf'\n", - "# OPTIONS: 'linear','conservative', only if tool is esmf\n", - "regrid_method = 'linear'\n", - "regrid_tool_ocn = 'esmf' # OPTIONS: \"regrid2\",\"esmf\"\n", - "# OPTIONS: 'linear','conservative', only if tool is esmf\n", - "regrid_method_ocn = 'linear'\n", - "\n", - "# Templates for climatology files\n", - "# %(param) will subsitute param with values in this file\n", - "filename_template = \"CMIP5.historical.r1i1p1.mon.%(variable)_198101-200512.AC.v20190225.nc\"\n", - "\n", - "# filename template for landsea masks ('sftlf')\n", - "sftlf_filename_template = \"sftlf_%(model_version).nc\"\n", - "generate_sftlf = True # if land surface type mask cannot be found, generate one\n", - "\n", - "\n", - "pth = os.path.dirname(__file__)\n", - "# ROOT PATH FOR MODELS CLIMATOLOGIES\n", - "test_data_path = 'demo_data/example_data/atm/mo/rlut/ac/'\n", - "# ROOT PATH FOR OBSERVATIONS\n", - "# Note that atm/mo/%(variable)/ac will be added to this\n", - "reference_data_path = 'demo_data/pmpobs_v1.0'\n", - "\n", - "# DIRECTORY WHERE TO PUT RESULTS\n", - "metrics_output_path = os.path.join(\n", - " 'demo_output',\n", - " \"%(case_id)\")\n", - "\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "with open(\"basic_param.py\") as f:\n", " print(f.read())" @@ -150,31 +79,927 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1" + "CompletedProcess(args=['mean_climate_driver.py', '-p', 'basic_param.py'], returncode=0)" ] }, - "execution_count": 9, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "import subprocess\n", - "subprocess.call(\"mean_climate_driver.py -p basic_param.py\".split())" + "from subprocess import run, PIPE\n", + "run(\"mean_climate_driver.py -p basic_param.py\".split())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], - "source": [] + "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", + " \"RESULTS\": {\n", + " \"ACCESS1-0\": {\n", + " \"units\": \"W m-2\",\n", + " \"SimulationDescription\": {\n", + " \"MIPTable\": \"Amon\",\n", + " \"Model\": \"ACCESS1-0\",\n", + " \"ModelActivity\": \"CMIP5\",\n", + " \"ModellingGroup\": \"CSIRO-BOM\",\n", + " \"Experiment\": \"historical\",\n", + " \"ModelFreeSpace\": \"N/A\",\n", + " \"Realization\": \"\",\n", + " \"creation_date\": \"2012-01-15T12:34:39Z\"\n", + " },\n", + " \"InputClimatologyFileName\": \"CMIP5.historical.ACCESS1-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc\",\n", + " \"InputClimatologyMD5\": \"bad136e97d7f13dc5af4ac019c8ca9c2\",\n", + " \"InputRegionFileName\": null,\n", + " \"InputRegionMD5\": null,\n", + " \"default\": {\n", + " \"source\": \"CERES\",\n", + " \"\": {\n", + " \"global\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"1.767\",\n", + " \"djf\": \"2.345\",\n", + " \"mam\": \"1.867\",\n", + " \"jja\": \"1.411\",\n", + " \"son\": \"1.445\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.970\",\n", + " \"djf\": \"0.96\",\n", + " \"mam\": \"0.95\",\n", + " \"jja\": \"0.96\",\n", + " \"son\": \"0.96\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"5.664\",\n", + " \"djf\": \"7.173\",\n", + " \"mam\": \"7.240\",\n", + " \"jja\": \"7.343\",\n", + " \"son\": \"6.208\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"239.688\",\n", + " \"djf\": \"236.870\",\n", + " \"mam\": \"238.852\",\n", + " \"jja\": \"243.327\",\n", + " \"son\": \"239.721\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"241.455\",\n", + " \"djf\": \"239.215\",\n", + " \"mam\": \"240.719\",\n", + " \"jja\": \"244.738\",\n", + " \"son\": \"241.166\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"5.676\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"8.091\",\n", + " \"djf\": \"10.277\",\n", + " \"mam\": \"10.926\",\n", + " \"jja\": \"10.319\",\n", + " \"son\": \"9.136\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"11.408\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"4.855\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"7.896\",\n", + " \"djf\": \"10.006\",\n", + " \"mam\": \"10.766\",\n", + " \"jja\": \"10.222\",\n", + " \"son\": \"9.021\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"29.604\",\n", + " \"djf\": \"32.594\",\n", + " \"mam\": \"30.782\",\n", + " \"jja\": \"35.277\",\n", + " \"son\": \"31.261\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"12.839\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"33.390\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"31.968\",\n", + " \"djf\": \"36.193\",\n", + " \"mam\": \"34.091\",\n", + " \"jja\": \"37.566\",\n", + " \"son\": \"33.816\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"12.478\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"36.441\"\n", + " }\n", + " },\n", + " \"NHEX\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-2.145\",\n", + " \"djf\": \"-4.989\",\n", + " \"mam\": \"-2.742\",\n", + " \"jja\": \"2.021\",\n", + " \"son\": \"-2.859\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.989\",\n", + " \"djf\": \"0.99\",\n", + " \"mam\": \"0.98\",\n", + " \"jja\": \"0.97\",\n", + " \"son\": \"0.98\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"3.233\",\n", + " \"djf\": \"5.701\",\n", + " \"mam\": \"3.841\",\n", + " \"jja\": \"4.593\",\n", + " \"son\": \"3.819\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"223.337\",\n", + " \"djf\": \"202.171\",\n", + " \"mam\": \"219.724\",\n", + " \"jja\": \"246.610\",\n", + " \"son\": \"225.013\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"221.192\",\n", + " \"djf\": \"197.182\",\n", + " \"mam\": \"216.982\",\n", + " \"jja\": \"248.632\",\n", + " \"son\": \"222.154\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"3.032\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"3.801\",\n", + " \"djf\": \"6.547\",\n", + " \"mam\": \"4.733\",\n", + " \"jja\": \"6.115\",\n", + " \"son\": \"4.901\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"6.445\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"2.409\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"3.138\",\n", + " \"djf\": \"4.239\",\n", + " \"mam\": \"3.858\",\n", + " \"jja\": \"5.771\",\n", + " \"son\": \"3.980\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"19.684\",\n", + " \"djf\": \"22.177\",\n", + " \"mam\": \"17.760\",\n", + " \"jja\": \"20.495\",\n", + " \"son\": \"22.654\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"9.043\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"27.494\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"20.481\",\n", + " \"djf\": \"24.144\",\n", + " \"mam\": \"19.008\",\n", + " \"jja\": \"21.958\",\n", + " \"son\": \"22.049\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"10.258\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"30.092\"\n", + " }\n", + " },\n", + " \"SHEX\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-2.243\",\n", + " \"djf\": \"0.971\",\n", + " \"mam\": \"-2.909\",\n", + " \"jja\": \"-4.873\",\n", + " \"son\": \"-2.180\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.995\",\n", + " \"djf\": \"0.98\",\n", + " \"mam\": \"1.00\",\n", + " \"jja\": \"1.00\",\n", + " \"son\": \"0.99\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"3.141\",\n", + " \"djf\": \"3.655\",\n", + " \"mam\": \"3.598\",\n", + " \"jja\": \"5.266\",\n", + " \"son\": \"3.173\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"216.078\",\n", + " \"djf\": \"229.049\",\n", + " \"mam\": \"216.155\",\n", + " \"jja\": \"204.913\",\n", + " \"son\": \"214.085\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"213.836\",\n", + " \"djf\": \"230.020\",\n", + " \"mam\": \"213.246\",\n", + " \"jja\": \"200.040\",\n", + " \"son\": \"211.905\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"2.412\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"3.724\",\n", + " \"djf\": \"4.609\",\n", + " \"mam\": \"4.270\",\n", + " \"jja\": \"5.957\",\n", + " \"son\": \"3.994\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"5.214\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"2.513\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"2.973\",\n", + " \"djf\": \"4.506\",\n", + " \"mam\": \"3.126\",\n", + " \"jja\": \"3.426\",\n", + " \"son\": \"3.347\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"28.241\",\n", + " \"djf\": \"22.542\",\n", + " \"mam\": \"30.392\",\n", + " \"jja\": \"33.462\",\n", + " \"son\": \"27.559\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"7.881\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"30.446\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"26.825\",\n", + " \"djf\": \"20.171\",\n", + " \"mam\": \"29.085\",\n", + " \"jja\": \"31.876\",\n", + " \"son\": \"27.748\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"7.068\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"30.163\"\n", + " }\n", + " },\n", + " \"TROPICS\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"5.728\",\n", + " \"djf\": \"6.699\",\n", + " \"mam\": \"6.559\",\n", + " \"jja\": \"4.248\",\n", + " \"son\": \"5.409\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.875\",\n", + " \"djf\": \"0.88\",\n", + " \"mam\": \"0.78\",\n", + " \"jja\": \"0.88\",\n", + " \"son\": \"0.88\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"8.141\",\n", + " \"djf\": \"9.668\",\n", + " \"mam\": \"10.760\",\n", + " \"jja\": \"9.756\",\n", + " \"son\": \"8.921\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"259.669\",\n", + " \"djf\": \"258.129\",\n", + " \"mam\": \"259.764\",\n", + " \"jja\": \"260.892\",\n", + " \"son\": \"259.893\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"265.396\",\n", + " \"djf\": \"264.828\",\n", + " \"mam\": \"266.323\",\n", + " \"jja\": \"265.140\",\n", + " \"son\": \"265.302\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"7.546\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"10.806\",\n", + " \"djf\": \"13.386\",\n", + " \"mam\": \"14.780\",\n", + " \"jja\": \"13.286\",\n", + " \"son\": \"12.122\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"15.031\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"7.501\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"9.164\",\n", + " \"djf\": \"11.589\",\n", + " \"mam\": \"13.245\",\n", + " \"jja\": \"12.589\",\n", + " \"son\": \"10.849\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"18.674\",\n", + " \"djf\": \"23.243\",\n", + " \"mam\": \"19.942\",\n", + " \"jja\": \"25.833\",\n", + " \"son\": \"21.783\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"16.054\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"24.016\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"17.735\",\n", + " \"djf\": \"23.310\",\n", + " \"mam\": \"20.153\",\n", + " \"jja\": \"25.506\",\n", + " \"son\": \"21.624\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"15.291\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"24.256\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " },\n", + " \"CSIRO-Mk3-6-0\": {\n", + " \"units\": \"W m-2\",\n", + " \"SimulationDescription\": {\n", + " \"MIPTable\": \"Amon\",\n", + " \"Model\": \"CSIRO-Mk3-6-0\",\n", + " \"ModelActivity\": \"CMIP5\",\n", + " \"ModellingGroup\": \"CSIRO-QCCCE\",\n", + " \"Experiment\": \"historical\",\n", + " \"ModelFreeSpace\": \"N/A\",\n", + " \"Realization\": \"\",\n", + " \"creation_date\": \"2011-07-27T02:28:05Z\"\n", + " },\n", + " \"InputClimatologyFileName\": \"CMIP5.historical.CSIRO-Mk3-6-0.r1i1p1.mon.rlut.198101-200512.AC.v20190225.nc\",\n", + " \"InputClimatologyMD5\": \"ec61d7bf2f8480f8e7a18af62d61deff\",\n", + " \"InputRegionFileName\": null,\n", + " \"InputRegionMD5\": null,\n", + " \"default\": {\n", + " \"source\": \"CERES\",\n", + " \"\": {\n", + " \"global\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-5.452\",\n", + " \"djf\": \"-4.532\",\n", + " \"mam\": \"-5.693\",\n", + " \"jja\": \"-5.871\",\n", + " \"son\": \"-5.723\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.959\",\n", + " \"djf\": \"0.94\",\n", + " \"mam\": \"0.95\",\n", + " \"jja\": \"0.94\",\n", + " \"son\": \"0.96\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"8.670\",\n", + " \"djf\": \"9.974\",\n", + " \"mam\": \"9.765\",\n", + " \"jja\": \"11.048\",\n", + " \"son\": \"9.414\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"239.688\",\n", + " \"djf\": \"236.870\",\n", + " \"mam\": \"238.852\",\n", + " \"jja\": \"243.327\",\n", + " \"son\": \"239.721\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"234.236\",\n", + " \"djf\": \"232.337\",\n", + " \"mam\": \"233.159\",\n", + " \"jja\": \"237.456\",\n", + " \"son\": \"233.998\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"8.491\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"10.865\",\n", + " \"djf\": \"12.948\",\n", + " \"mam\": \"12.400\",\n", + " \"jja\": \"14.121\",\n", + " \"son\": \"11.720\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"13.699\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"7.423\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"9.397\",\n", + " \"djf\": \"12.129\",\n", + " \"mam\": \"11.016\",\n", + " \"jja\": \"12.842\",\n", + " \"son\": \"10.227\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"29.604\",\n", + " \"djf\": \"32.594\",\n", + " \"mam\": \"30.782\",\n", + " \"jja\": \"35.277\",\n", + " \"son\": \"31.261\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"12.839\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"33.390\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"32.591\",\n", + " \"djf\": \"36.368\",\n", + " \"mam\": \"34.025\",\n", + " \"jja\": \"38.828\",\n", + " \"son\": \"34.435\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"15.363\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"36.923\"\n", + " }\n", + " },\n", + " \"NHEX\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-7.231\",\n", + " \"djf\": \"-9.259\",\n", + " \"mam\": \"-8.068\",\n", + " \"jja\": \"-3.746\",\n", + " \"son\": \"-7.854\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.969\",\n", + " \"djf\": \"0.95\",\n", + " \"mam\": \"0.96\",\n", + " \"jja\": \"0.94\",\n", + " \"son\": \"0.97\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"7.816\",\n", + " \"djf\": \"9.976\",\n", + " \"mam\": \"8.527\",\n", + " \"jja\": \"8.566\",\n", + " \"son\": \"8.461\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"223.337\",\n", + " \"djf\": \"202.171\",\n", + " \"mam\": \"219.724\",\n", + " \"jja\": \"246.610\",\n", + " \"son\": \"225.013\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"216.107\",\n", + " \"djf\": \"192.913\",\n", + " \"mam\": \"211.655\",\n", + " \"jja\": \"242.864\",\n", + " \"son\": \"217.159\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"5.203\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"9.037\",\n", + " \"djf\": \"11.819\",\n", + " \"mam\": \"9.638\",\n", + " \"jja\": \"10.462\",\n", + " \"son\": \"9.839\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"10.945\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"8.221\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"5.421\",\n", + " \"djf\": \"7.347\",\n", + " \"mam\": \"5.272\",\n", + " \"jja\": \"9.768\",\n", + " \"son\": \"5.925\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"19.684\",\n", + " \"djf\": \"22.177\",\n", + " \"mam\": \"17.760\",\n", + " \"jja\": \"20.495\",\n", + " \"son\": \"22.654\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"9.043\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"27.494\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"21.448\",\n", + " \"djf\": \"22.486\",\n", + " \"mam\": \"18.885\",\n", + " \"jja\": \"25.768\",\n", + " \"son\": \"24.338\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"10.147\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"30.554\"\n", + " }\n", + " },\n", + " \"SHEX\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-7.928\",\n", + " \"djf\": \"-5.019\",\n", + " \"mam\": \"-8.705\",\n", + " \"jja\": \"-10.113\",\n", + " \"son\": \"-7.909\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.983\",\n", + " \"djf\": \"0.98\",\n", + " \"mam\": \"0.99\",\n", + " \"jja\": \"0.98\",\n", + " \"son\": \"0.97\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"8.799\",\n", + " \"djf\": \"6.536\",\n", + " \"mam\": \"9.311\",\n", + " \"jja\": \"10.699\",\n", + " \"son\": \"9.581\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"216.078\",\n", + " \"djf\": \"229.049\",\n", + " \"mam\": \"216.155\",\n", + " \"jja\": \"204.913\",\n", + " \"son\": \"214.085\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"208.150\",\n", + " \"djf\": \"224.030\",\n", + " \"mam\": \"207.451\",\n", + " \"jja\": \"194.800\",\n", + " \"son\": \"206.176\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"3.632\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"9.796\",\n", + " \"djf\": \"7.436\",\n", + " \"mam\": \"10.270\",\n", + " \"jja\": \"12.078\",\n", + " \"son\": \"10.857\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"10.522\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"8.470\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"5.754\",\n", + " \"djf\": \"5.487\",\n", + " \"mam\": \"5.450\",\n", + " \"jja\": \"6.603\",\n", + " \"son\": \"7.438\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"28.241\",\n", + " \"djf\": \"22.542\",\n", + " \"mam\": \"30.392\",\n", + " \"jja\": \"33.462\",\n", + " \"son\": \"27.559\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"7.881\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"30.446\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"30.236\",\n", + " \"djf\": \"24.968\",\n", + " \"mam\": \"32.417\",\n", + " \"jja\": \"33.941\",\n", + " \"son\": \"30.774\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"8.482\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"32.940\"\n", + " }\n", + " },\n", + " \"TROPICS\": {\n", + " \"bias_xy\": {\n", + " \"ann\": \"-3.325\",\n", + " \"djf\": \"-1.926\",\n", + " \"mam\": \"-3.000\",\n", + " \"jja\": \"-4.813\",\n", + " \"son\": \"-3.565\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"ann\": \"0.834\",\n", + " \"djf\": \"0.82\",\n", + " \"mam\": \"0.78\",\n", + " \"jja\": \"0.84\",\n", + " \"son\": \"0.86\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"ann\": \"9.033\",\n", + " \"djf\": \"11.692\",\n", + " \"mam\": \"10.611\",\n", + " \"jja\": \"12.464\",\n", + " \"son\": \"9.806\"\n", + " },\n", + " \"mean-obs_xy\": {\n", + " \"ann\": \"259.669\",\n", + " \"djf\": \"258.129\",\n", + " \"mam\": \"259.764\",\n", + " \"jja\": \"260.892\",\n", + " \"son\": \"259.893\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"ann\": \"256.343\",\n", + " \"djf\": \"256.204\",\n", + " \"mam\": \"256.764\",\n", + " \"jja\": \"256.080\",\n", + " \"son\": \"256.328\"\n", + " },\n", + " \"rms_devzm\": {\n", + " \"ann\": \"11.138\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"ann\": \"12.135\",\n", + " \"djf\": \"15.421\",\n", + " \"mam\": \"14.434\",\n", + " \"jja\": \"16.466\",\n", + " \"son\": \"12.937\"\n", + " },\n", + " \"rms_xyt\": {\n", + " \"ann\": \"16.127\"\n", + " },\n", + " \"rms_y\": {\n", + " \"ann\": \"4.792\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"ann\": \"11.671\",\n", + " \"djf\": \"15.301\",\n", + " \"mam\": \"14.119\",\n", + " \"jja\": \"15.747\",\n", + " \"son\": \"12.436\"\n", + " },\n", + " \"std-obs_xy\": {\n", + " \"ann\": \"18.674\",\n", + " \"djf\": \"23.243\",\n", + " \"mam\": \"19.942\",\n", + " \"jja\": \"25.833\",\n", + " \"son\": \"21.783\"\n", + " },\n", + " \"std-obs_xy_devzm\": {\n", + " \"ann\": \"16.054\"\n", + " },\n", + " \"std-obs_xyt\": {\n", + " \"ann\": \"24.016\"\n", + " },\n", + " \"std_xy\": {\n", + " \"ann\": \"21.070\",\n", + " \"djf\": \"26.449\",\n", + " \"mam\": \"22.198\",\n", + " \"jja\": \"28.912\",\n", + " \"son\": \"23.966\"\n", + " },\n", + " \"std_xy_devzm\": {\n", + " \"ann\": \"19.611\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"ann\": \"26.907\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }\n", + " },\n", + " \"Variable\": {\n", + " \"id\": \"rlut\"\n", + " },\n", + " \"json_version\": 3.0,\n", + " \"References\": {\n", + " \"default\": {\n", + " \"CMIP_CMOR_TABLE\": \"Amon\",\n", + " \"MD5sum\": \"146eec5e8a734fedbbdd0909921530f2\",\n", + " \"RefName\": \"CERES\",\n", + " \"RefTrackingDate\": \"Wed Aug 31 17:45:45 2016\",\n", + " \"filename\": \"rlut_CERES_000001-000012_ac.nc\",\n", + " \"period\": \"000001-000012\",\n", + " \"shape\": \"(12, 180, 360)\"\n", + " }\n", + " },\n", + " \"RegionalMasking\": {\n", + " \"global\": {\n", + " \"id\": \"global\"\n", + " },\n", + " \"NHEX\": {\n", + " \"domain\": {\n", + " \"NHEX\": \"cdutil.region.domain(latitude=(30.0, 90))\"\n", + " },\n", + " \"id\": \"NHEX\"\n", + " },\n", + " \"SHEX\": {\n", + " \"domain\": {\n", + " \"SHEX\": \"cdutil.region.domain(latitude=(-90.0, -30))\"\n", + " },\n", + " \"id\": \"SHEX\"\n", + " },\n", + " \"TROPICS\": {\n", + " \"domain\": {\n", + " \"TROPICS\": \"cdutil.region.domain(latitude=(-30.0, 30))\"\n", + " },\n", + " \"id\": \"TROPICS\"\n", + " }\n", + " },\n", + " \"GridInfo\": {\n", + " \"RegridMethod\": \"linear\",\n", + " \"RegridTool\": \"regrid2\",\n", + " \"GridName\": \"2.5x2.5\",\n", + " \"GridResolution\": [\n", + " 25,\n", + " 144\n", + " ]\n", + " },\n", + " \"METRICS\": {\n", + " \"rms_xyt\": {\n", + " \"Name\": \"Spatio-Temporal Root Mean Square\",\n", + " \"Abstract\": \"Compute Spatial and Temporal Root Mean Square\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"rms_xy\": {\n", + " \"Name\": \"Spatial Root Mean Square\",\n", + " \"Abstract\": \"Compute Spatial Root Mean Square\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"rmsc_xy\": {\n", + " \"Name\": \"Spatial Root Mean Square\",\n", + " \"Abstract\": \"Compute Centered Spatial Root Mean Square\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"bias_xy\": {\n", + " \"Name\": \"Bias\",\n", + " \"Abstract\": \"Compute Full Average of Model - Observation\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"mae_xy\": {\n", + " \"Name\": \"Mean Absolute Error\",\n", + " \"Abstract\": \"Compute Full Average of Absolute Difference Between Model And Observation\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"cor_xy\": {\n", + " \"Name\": \"Spatial Correlation\",\n", + " \"Abstract\": \"Compute Spatial Correlation\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"mean_xy\": {\n", + " \"Name\": \"Mean\",\n", + " \"Abstract\": \"Area Mean (area weighted)\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"std_xy\": {\n", + " \"Name\": \"Spatial Standard Deviation\",\n", + " \"Abstract\": \"Compute Spatial Standard Deviation\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"std_xyt\": {\n", + " \"Name\": \"Spatial-temporal Standard Deviation\",\n", + " \"Abstract\": \"Compute Space-Time Standard Deviation\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\"\n", + " },\n", + " \"seasonal_mean\": {\n", + " \"Name\": \"Seasonal Mean\",\n", + " \"Abstract\": \"Compute Seasonal Mean\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\",\n", + " \"Comments\": \"Assumes input are 12 months climatology\"\n", + " },\n", + " \"annual_mean\": {\n", + " \"Name\": \"Annual Mean\",\n", + " \"Abstract\": \"Compute Annual Mean\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\",\n", + " \"Comments\": \"Assumes input are 12 months climatology\"\n", + " },\n", + " \"zonal_mean\": {\n", + " \"Name\": \"Zonal Mean\",\n", + " \"Abstract\": \"Compute Zonal Mean\",\n", + " \"URI\": \"http://uvcdat.llnl.gov/documentation/utilities/utilities-2.html\",\n", + " \"Contact\": \"pcmdi-metrics@llnl.gov\",\n", + " \"Comments\": \"\"\n", + " }\n", + " },\n", + " \"json_structure\": [\n", + " \"model\",\n", + " \"reference\",\n", + " \"rip\",\n", + " \"region\",\n", + " \"statistic\",\n", + " \"season\"\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/mean_climate_driver.py -p basic_param.py\",\n", + " \"date\": \"2019-04-26 08:06:11\",\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,\"basicTest/rlut_2.5x2.5_regrid2_linear_metrics.json\")) as f:\n", + " print(\"JSON OUTPUT:\\n{}\".format(f.read()))" + ] } ], "metadata": { diff --git a/doc/jupyter/Demo/Demo_2_monsoon_wang.ipynb b/doc/jupyter/Demo/Demo_2_monsoon_wang.ipynb new file mode 100644 index 000000000..cff601c12 --- /dev/null +++ b/doc/jupyter/Demo/Demo_2_monsoon_wang.ipynb @@ -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 +} diff --git a/doc/jupyter/Demo/basic_monsoon_wang_param.py.in b/doc/jupyter/Demo/basic_monsoon_wang_param.py.in new file mode 100644 index 000000000..ab1309c1a --- /dev/null +++ b/doc/jupyter/Demo/basic_monsoon_wang_param.py.in @@ -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 \ No newline at end of file diff --git a/doc/jupyter/Demo/basic_param.py b/doc/jupyter/Demo/basic_param.py new file mode 100644 index 000000000..5694f5278 --- /dev/null +++ b/doc/jupyter/Demo/basic_param.py @@ -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)") + diff --git a/doc/jupyter/Demo/data_files.txt b/doc/jupyter/Demo/data_files.txt new file mode 100644 index 000000000..e5ed7243a --- /dev/null +++ b/doc/jupyter/Demo/data_files.txt @@ -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 diff --git a/doc/jupyter/Jsons/JsonClass.html b/doc/jupyter/Jsons/JsonClass.html new file mode 100644 index 000000000..0933424cb --- /dev/null +++ b/doc/jupyter/Jsons/JsonClass.html @@ -0,0 +1,13965 @@ + + + + +JsonClass + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+

PMP Json Formatted I/O

Reading in PMP's json files

This section will sohw how to read in json files generated by PMP and select pieces of it.

+

We are assuming you're running this notebook from its directory in the pcmdi_metrics repo

+ +
+
+
+
+
+
In [1]:
+
+
+
# Setup the notebook
+from __future__ import print_function
+import pcmdi_metrics
+json1 = "../../../tests/pcmdi_install_test_results/metrics_results/installationTest/tas_2.5x2.5_regrid2_linear_metrics.json"
+json2 = "../../../tests/pcmdi_install_test_results/metrics_results/installationTest/tos_2.5x2.5_esmf_linear_metrics_2.json"
+
+ +
+
+
+ +
+
+
+
+

Reader object

Let's create our Json reader object by pointing it to the desired files

+ +
+
+
+
+
+
In [2]:
+
+
+
J1 = pcmdi_metrics.io.base.JSONs([json1, json2])
+
+ +
+
+
+ +
+
+
+
+

Querying the reader object

Let's query the object, first what are the axes available? +i.e what is the overall json structure of the files read in

+ +
+
+
+
+
+
In [3]:
+
+
+
J1.getAxisIds()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[3]:
+ + + + +
+
['variable', 'model', 'reference', 'rip', 'region', 'statistic', 'season']
+
+ +
+ +
+
+ +
+
+
+
+

Now we get a little more info by getting the actual cdms2 axes that would be generated by reading everything in.

+

Note now that the axes length include the total possible number of values, for example in this example each file contains ONE variable , but the resulting reading would have TWO variables

+ +
+
+
+
+
+
In [4]:
+
+
+
J1.getAxisList()
+
+ +
+
+
+ +
+
+ + +
+ +
Out[4]:
+ + + + +
+
[   id: variable
+    Length: 2
+    First:  tas
+    Last:   tos
+    Python id:  0x10631b358,    id: model
+    Length: 2
+    First:  GFDL-ESM2G
+    Last:   GFDL-ESM2Gb
+    Python id:  0x121760160,    id: reference
+    Length: 2
+    First:  SimulationDescription
+    Last:   defaultReference
+    Python id:  0x121760198,    id: rip
+    Length: 2
+    First:  r1i1p1
+    Last:   r2i1p1
+    Python id:  0x1217601d0,    id: region
+    Length: 6
+    First:  NHEX
+    Last:   terre
+    Python id:  0x121760128,    id: statistic
+    Length: 16
+    First:  bias_xy
+    Last:   std_xyt
+    Python id:  0x121760390,    id: season
+    Length: 5
+    First:  ann
+    Last:   son
+    Python id:  0x121760438]
+
+ +
+ +
+
+ +
+
+
+
+

We can also retrieve only a specific axis

+ +
+
+
+
+
+
In [5]:
+
+
+
J1.getAxis("statistic")
+
+ +
+
+
+ +
+
+ + +
+ +
Out[5]:
+ + + + +
+
   id: statistic
+   Length: 16
+   First:  bias_xy
+   Last:   std_xyt
+   Python id:  0x121760470
+
+ +
+ +
+
+ +
+
+
+
+

Let's print all the values in the axis

+ +
+
+
+
+
+
In [6]:
+
+
+
J1.getAxis("statistic")[:]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[6]:
+ + + + +
+
array(['bias_xy', 'cor_xy', 'mae_xy', 'mean-obs_xy', 'mean_xy',
+       'rms_devzm', 'rms_xy', 'rms_xyt', 'rms_y', 'rmsc_xy', 'std-obs_xy',
+       'std-obs_xy_devzm', 'std-obs_xyt', 'std_xy', 'std_xy_devzm',
+       'std_xyt'], dtype='<U16')
+
+ +
+ +
+
+ +
+
+
+
+

Reading in data

All of it

Now let's read everything in

+ +
+
+
+
+
+
In [7]:
+
+
+
data = J1()
+data.shape
+
+ +
+
+
+ +
+
+ + +
+ +
Out[7]:
+ + + + +
+
(2, 2, 2, 2, 6, 16, 5)
+
+ +
+ +
+
+ +
+
+
+
+

Getting only some elements

For one dimension

But we might not be interested in everything, let's subset the statistics dimension +Note that the output array now went from 16 in length for the dimenson, down to 2

+ +
+
+
+
+
+
In [8]:
+
+
+
data = J1(statistic=['rms_xy','std_xy'])
+print(data.shape)
+data.getAxis(-2)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 2, 2, 2, 6, 2, 5)
+
+
+
+ +
+ +
Out[8]:
+ + + + +
+
array(['rms_xy', 'std_xy'], dtype='<U6')
+
+ +
+ +
+
+ +
+
+
+
+

For multiple dimensions

Of course we can subset multiple axes at once. Notice that now region is smaller as well.

+ +
+
+
+
+
+
In [9]:
+
+
+
data = J1(statistic=['rms_xy','std_xy'], region=['NHEX', 'global', 'terre'])
+print(data.shape)
+data.getAxis(-3)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 2, 2, 2, 3, 2, 5)
+
+
+
+ +
+ +
Out[9]:
+ + + + +
+
array(['NHEX', 'global', 'terre'], dtype='<U6')
+
+ +
+ +
+
+ +
+
+
+
+

Reordering the elements

One can also re-order the axes as it is read in. Notice 'terre' is now first.

+ +
+
+
+
+
+
In [10]:
+
+
+
data = J1(statistic=['rms_xy','std_xy'], region=['terre', 'NHEX', 'global'])
+print(data.shape)
+data.getAxis(-3)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 2, 2, 2, 3, 2, 5)
+
+
+
+ +
+ +
Out[10]:
+ + + + +
+
array(['terre', 'NHEX', 'global'], dtype='<U6')
+
+ +
+ +
+
+ +
+
+
+
+

Sometimes it can be useful to join two or many dimensions together. +For example let's merge model and rip together.

+ +
+
+
+
+
+
In [11]:
+
+
+
#### Merging dimensions together
+
+##### Two dimensions merged in one
+
+data = J1(merge=['model','rip'])
+print(data.shape)
+data.getAxis(1)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 3, 1, 6, 16, 5)
+
+
+
+ +
+ +
Out[11]:
+ + + + +
+
array(['GFDL-ESM2G_r1i1p1', 'GFDL-ESM2Gb_r1i1p1', 'GFDL-ESM2Gb_r2i1p1'],
+      dtype='<U18')
+
+ +
+ +
+
+ +
+
+
+
+

Notice that the resulting array now has 6 dimensions rather than 7.

+

The newly constructed array takes all possible values of model and match them with all possible of rip.

+

Also notice that while it will create all possible combinations of model/rip, GFDL-ESM2G_r2i1p1 was excluded has the combination contained no valid data.

+

Order matters

Let's switch the order we combine these dimensions

+ +
+
+
+
+
+
In [12]:
+
+
+
data = J1(merge=['rip','model'])
+print(data.shape)
+data.getAxis(1)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 3, 1, 6, 16, 5)
+
+
+
+ +
+ +
Out[12]:
+ + + + +
+
array(['r1i1p1_GFDL-ESM2G', 'r1i1p1_GFDL-ESM2Gb', 'r2i1p1_GFDL-ESM2Gb'],
+      dtype='<U18')
+
+ +
+ +
+
+ +
+
+
+
+

Notice that the axis values now start with the values of rip combined with with model values. Which is the opposite of the previous example.

+

Combining more than 2 dimensions together

You can also merge more than 2 dimensions together, agin the axis values will be all the possible (not totally empy) matrix combinations

+ +
+
+
+
+
+
In [13]:
+
+
+
data = J1(merge=['statistic', 'region', 'season'])
+print(data.shape)
+data.getAxis(-1)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 2, 1, 2, 312)
+
+
+
+ +
+ +
Out[13]:
+ + + + +
+
array(['bias_xy_NHEX_ann', 'bias_xy_NHEX_djf', 'bias_xy_NHEX_jja',
+       'bias_xy_NHEX_mam', 'bias_xy_NHEX_son', 'bias_xy_SHEX_ann',
+       'bias_xy_SHEX_djf', 'bias_xy_SHEX_jja', 'bias_xy_SHEX_mam',
+       'bias_xy_SHEX_son', 'bias_xy_TROPICS_ann', 'bias_xy_TROPICS_djf',
+       'bias_xy_TROPICS_jja', 'bias_xy_TROPICS_mam',
+       'bias_xy_TROPICS_son', 'bias_xy_global_ann', 'bias_xy_global_djf',
+       'bias_xy_global_jja', 'bias_xy_global_mam', 'bias_xy_global_son',
+       'bias_xy_ocean_ann', 'bias_xy_ocean_djf', 'bias_xy_ocean_jja',
+       'bias_xy_ocean_mam', 'bias_xy_ocean_son', 'bias_xy_terre_ann',
+       'bias_xy_terre_djf', 'bias_xy_terre_jja', 'bias_xy_terre_mam',
+       'bias_xy_terre_son', 'cor_xy_NHEX_ann', 'cor_xy_NHEX_djf',
+       'cor_xy_NHEX_jja', 'cor_xy_NHEX_mam', 'cor_xy_NHEX_son',
+       'cor_xy_SHEX_ann', 'cor_xy_SHEX_djf', 'cor_xy_SHEX_jja',
+       'cor_xy_SHEX_mam', 'cor_xy_SHEX_son', 'cor_xy_TROPICS_ann',
+       'cor_xy_TROPICS_djf', 'cor_xy_TROPICS_jja', 'cor_xy_TROPICS_mam',
+       'cor_xy_TROPICS_son', 'cor_xy_global_ann', 'cor_xy_global_djf',
+       'cor_xy_global_jja', 'cor_xy_global_mam', 'cor_xy_global_son',
+       'cor_xy_ocean_ann', 'cor_xy_ocean_djf', 'cor_xy_ocean_jja',
+       'cor_xy_ocean_mam', 'cor_xy_ocean_son', 'cor_xy_terre_ann',
+       'cor_xy_terre_djf', 'cor_xy_terre_jja', 'cor_xy_terre_mam',
+       'cor_xy_terre_son', 'mae_xy_NHEX_ann', 'mae_xy_NHEX_djf',
+       'mae_xy_NHEX_jja', 'mae_xy_NHEX_mam', 'mae_xy_NHEX_son',
+       'mae_xy_SHEX_ann', 'mae_xy_SHEX_djf', 'mae_xy_SHEX_jja',
+       'mae_xy_SHEX_mam', 'mae_xy_SHEX_son', 'mae_xy_TROPICS_ann',
+       'mae_xy_TROPICS_djf', 'mae_xy_TROPICS_jja', 'mae_xy_TROPICS_mam',
+       'mae_xy_TROPICS_son', 'mae_xy_global_ann', 'mae_xy_global_djf',
+       'mae_xy_global_jja', 'mae_xy_global_mam', 'mae_xy_global_son',
+       'mae_xy_ocean_ann', 'mae_xy_ocean_djf', 'mae_xy_ocean_jja',
+       'mae_xy_ocean_mam', 'mae_xy_ocean_son', 'mae_xy_terre_ann',
+       'mae_xy_terre_djf', 'mae_xy_terre_jja', 'mae_xy_terre_mam',
+       'mae_xy_terre_son', 'mean-obs_xy_NHEX_ann', 'mean-obs_xy_NHEX_djf',
+       'mean-obs_xy_NHEX_jja', 'mean-obs_xy_NHEX_mam',
+       'mean-obs_xy_NHEX_son', 'mean-obs_xy_SHEX_ann',
+       'mean-obs_xy_SHEX_djf', 'mean-obs_xy_SHEX_jja',
+       'mean-obs_xy_SHEX_mam', 'mean-obs_xy_SHEX_son',
+       'mean-obs_xy_TROPICS_ann', 'mean-obs_xy_TROPICS_djf',
+       'mean-obs_xy_TROPICS_jja', 'mean-obs_xy_TROPICS_mam',
+       'mean-obs_xy_TROPICS_son', 'mean-obs_xy_global_ann',
+       'mean-obs_xy_global_djf', 'mean-obs_xy_global_jja',
+       'mean-obs_xy_global_mam', 'mean-obs_xy_global_son',
+       'mean-obs_xy_ocean_ann', 'mean-obs_xy_ocean_djf',
+       'mean-obs_xy_ocean_jja', 'mean-obs_xy_ocean_mam',
+       'mean-obs_xy_ocean_son', 'mean-obs_xy_terre_ann',
+       'mean-obs_xy_terre_djf', 'mean-obs_xy_terre_jja',
+       'mean-obs_xy_terre_mam', 'mean-obs_xy_terre_son',
+       'mean_xy_NHEX_ann', 'mean_xy_NHEX_djf', 'mean_xy_NHEX_jja',
+       'mean_xy_NHEX_mam', 'mean_xy_NHEX_son', 'mean_xy_SHEX_ann',
+       'mean_xy_SHEX_djf', 'mean_xy_SHEX_jja', 'mean_xy_SHEX_mam',
+       'mean_xy_SHEX_son', 'mean_xy_TROPICS_ann', 'mean_xy_TROPICS_djf',
+       'mean_xy_TROPICS_jja', 'mean_xy_TROPICS_mam',
+       'mean_xy_TROPICS_son', 'mean_xy_global_ann', 'mean_xy_global_djf',
+       'mean_xy_global_jja', 'mean_xy_global_mam', 'mean_xy_global_son',
+       'mean_xy_ocean_ann', 'mean_xy_ocean_djf', 'mean_xy_ocean_jja',
+       'mean_xy_ocean_mam', 'mean_xy_ocean_son', 'mean_xy_terre_ann',
+       'mean_xy_terre_djf', 'mean_xy_terre_jja', 'mean_xy_terre_mam',
+       'mean_xy_terre_son', 'rms_devzm_NHEX_ann', 'rms_devzm_SHEX_ann',
+       'rms_devzm_TROPICS_ann', 'rms_devzm_global_ann',
+       'rms_devzm_ocean_ann', 'rms_devzm_terre_ann', 'rms_xy_NHEX_ann',
+       'rms_xy_NHEX_djf', 'rms_xy_NHEX_jja', 'rms_xy_NHEX_mam',
+       'rms_xy_NHEX_son', 'rms_xy_SHEX_ann', 'rms_xy_SHEX_djf',
+       'rms_xy_SHEX_jja', 'rms_xy_SHEX_mam', 'rms_xy_SHEX_son',
+       'rms_xy_TROPICS_ann', 'rms_xy_TROPICS_djf', 'rms_xy_TROPICS_jja',
+       'rms_xy_TROPICS_mam', 'rms_xy_TROPICS_son', 'rms_xy_global_ann',
+       'rms_xy_global_djf', 'rms_xy_global_jja', 'rms_xy_global_mam',
+       'rms_xy_global_son', 'rms_xy_ocean_ann', 'rms_xy_ocean_djf',
+       'rms_xy_ocean_jja', 'rms_xy_ocean_mam', 'rms_xy_ocean_son',
+       'rms_xy_terre_ann', 'rms_xy_terre_djf', 'rms_xy_terre_jja',
+       'rms_xy_terre_mam', 'rms_xy_terre_son', 'rms_xyt_NHEX_ann',
+       'rms_xyt_SHEX_ann', 'rms_xyt_TROPICS_ann', 'rms_xyt_global_ann',
+       'rms_xyt_ocean_ann', 'rms_xyt_terre_ann', 'rms_y_NHEX_ann',
+       'rms_y_SHEX_ann', 'rms_y_TROPICS_ann', 'rms_y_global_ann',
+       'rms_y_ocean_ann', 'rms_y_terre_ann', 'rmsc_xy_NHEX_ann',
+       'rmsc_xy_NHEX_djf', 'rmsc_xy_NHEX_jja', 'rmsc_xy_NHEX_mam',
+       'rmsc_xy_NHEX_son', 'rmsc_xy_SHEX_ann', 'rmsc_xy_SHEX_djf',
+       'rmsc_xy_SHEX_jja', 'rmsc_xy_SHEX_mam', 'rmsc_xy_SHEX_son',
+       'rmsc_xy_TROPICS_ann', 'rmsc_xy_TROPICS_djf',
+       'rmsc_xy_TROPICS_jja', 'rmsc_xy_TROPICS_mam',
+       'rmsc_xy_TROPICS_son', 'rmsc_xy_global_ann', 'rmsc_xy_global_djf',
+       'rmsc_xy_global_jja', 'rmsc_xy_global_mam', 'rmsc_xy_global_son',
+       'rmsc_xy_ocean_ann', 'rmsc_xy_ocean_djf', 'rmsc_xy_ocean_jja',
+       'rmsc_xy_ocean_mam', 'rmsc_xy_ocean_son', 'rmsc_xy_terre_ann',
+       'rmsc_xy_terre_djf', 'rmsc_xy_terre_jja', 'rmsc_xy_terre_mam',
+       'rmsc_xy_terre_son', 'std-obs_xy_NHEX_ann', 'std-obs_xy_NHEX_djf',
+       'std-obs_xy_NHEX_jja', 'std-obs_xy_NHEX_mam',
+       'std-obs_xy_NHEX_son', 'std-obs_xy_SHEX_ann',
+       'std-obs_xy_SHEX_djf', 'std-obs_xy_SHEX_jja',
+       'std-obs_xy_SHEX_mam', 'std-obs_xy_SHEX_son',
+       'std-obs_xy_TROPICS_ann', 'std-obs_xy_TROPICS_djf',
+       'std-obs_xy_TROPICS_jja', 'std-obs_xy_TROPICS_mam',
+       'std-obs_xy_TROPICS_son', 'std-obs_xy_global_ann',
+       'std-obs_xy_global_djf', 'std-obs_xy_global_jja',
+       'std-obs_xy_global_mam', 'std-obs_xy_global_son',
+       'std-obs_xy_ocean_ann', 'std-obs_xy_ocean_djf',
+       'std-obs_xy_ocean_jja', 'std-obs_xy_ocean_mam',
+       'std-obs_xy_ocean_son', 'std-obs_xy_terre_ann',
+       'std-obs_xy_terre_djf', 'std-obs_xy_terre_jja',
+       'std-obs_xy_terre_mam', 'std-obs_xy_terre_son',
+       'std-obs_xy_devzm_NHEX_ann', 'std-obs_xy_devzm_SHEX_ann',
+       'std-obs_xy_devzm_TROPICS_ann', 'std-obs_xy_devzm_global_ann',
+       'std-obs_xy_devzm_ocean_ann', 'std-obs_xy_devzm_terre_ann',
+       'std-obs_xyt_NHEX_ann', 'std-obs_xyt_SHEX_ann',
+       'std-obs_xyt_TROPICS_ann', 'std-obs_xyt_global_ann',
+       'std-obs_xyt_ocean_ann', 'std-obs_xyt_terre_ann',
+       'std_xy_NHEX_ann', 'std_xy_NHEX_djf', 'std_xy_NHEX_jja',
+       'std_xy_NHEX_mam', 'std_xy_NHEX_son', 'std_xy_SHEX_ann',
+       'std_xy_SHEX_djf', 'std_xy_SHEX_jja', 'std_xy_SHEX_mam',
+       'std_xy_SHEX_son', 'std_xy_TROPICS_ann', 'std_xy_TROPICS_djf',
+       'std_xy_TROPICS_jja', 'std_xy_TROPICS_mam', 'std_xy_TROPICS_son',
+       'std_xy_global_ann', 'std_xy_global_djf', 'std_xy_global_jja',
+       'std_xy_global_mam', 'std_xy_global_son', 'std_xy_ocean_ann',
+       'std_xy_ocean_djf', 'std_xy_ocean_jja', 'std_xy_ocean_mam',
+       'std_xy_ocean_son', 'std_xy_terre_ann', 'std_xy_terre_djf',
+       'std_xy_terre_jja', 'std_xy_terre_mam', 'std_xy_terre_son',
+       'std_xy_devzm_NHEX_ann', 'std_xy_devzm_SHEX_ann',
+       'std_xy_devzm_TROPICS_ann', 'std_xy_devzm_global_ann',
+       'std_xy_devzm_ocean_ann', 'std_xy_devzm_terre_ann',
+       'std_xyt_NHEX_ann', 'std_xyt_SHEX_ann', 'std_xyt_TROPICS_ann',
+       'std_xyt_global_ann', 'std_xyt_ocean_ann', 'std_xyt_terre_ann'],
+      dtype='<U28')
+
+ +
+ +
+
+ +
+
+
+
+

Merging and subsetting can be combined

You can also shuffle the order and number of values for each dimension

+ +
+
+
+
+
+
In [14]:
+
+
+
data = J1(merge=['statistic', 'region', 'season'],
+          season=['mam','djf'], statistic=['rms_xy', 'cor_xy'], region=['global','TROPICS'])
+print(data.shape)
+data.getAxis(-1)[:]
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 2, 1, 2, 8)
+
+
+
+ +
+ +
Out[14]:
+ + + + +
+
array(['rms_xy_global_mam', 'rms_xy_global_djf', 'rms_xy_TROPICS_mam',
+       'rms_xy_TROPICS_djf', 'cor_xy_global_mam', 'cor_xy_global_djf',
+       'cor_xy_TROPICS_mam', 'cor_xy_TROPICS_djf'], dtype='<U18')
+
+ +
+ +
+
+ +
+
+
+
+

Multiple combined dimensions can be created (and subsetted) at once

You can also merge multiple dimensions at once:

+ +
+
+
+
+
+
In [15]:
+
+
+
data = J1(merge=[['model','rip'], ['statistic', 'region', 'season']],
+          season=['mam','djf'], statistic=['rms_xy', 'cor_xy'], region=['global','TROPICS'])
+print(data.shape)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
(2, 3, 1, 8)
+
+
+
+ +
+
+ +
+
+
+ + + + + + diff --git a/pcmdi_metrics/monsoon_wang/monsoon_wang_driver.py b/pcmdi_metrics/monsoon_wang/monsoon_wang_driver.py index 5947c9bbe..9d2c5752e 100644 --- a/pcmdi_metrics/monsoon_wang/monsoon_wang_driver.py +++ b/pcmdi_metrics/monsoon_wang/monsoon_wang_driver.py @@ -8,27 +8,22 @@ from pcmdi_metrics.monsoon_wang import mpd, mpi_skill_scores import pcmdi_metrics import collections -import glob import pkg_resources +import genutil def create_monsoon_wang_parser(): P = PMPParser() - P.use("--modpath") P.use("--modnames") P.use("--results_dir") P.use("--reference_data_path") + P.use("--test_data_path") - P.add_argument("--outpj", "--outpathjsons", - type=str, - dest='outpathjsons', - default='.', - help="Output path for jsons") P.add_argument("--outnj", "--outnamejson", type=str, - dest='jsonname', - default='out.json', + dest='outnamejson', + default='monsoon_wang.json', help="Output path for jsons") P.add_argument("-e", "--experiment", type=str, @@ -52,74 +47,25 @@ def create_monsoon_wang_parser(): default=2.5 / 86400., type=float, help="Threshold for a hit when computing skill score") + return P def monsoon_wang_runner(args): # args = P.parse_args(sys.argv[1:]) - modpath = args.modpath - outpathjsons = args.outpathjsons + modpath = genutil.StringConstructor(args.test_data_path) + modpath.variable = args.modvar outpathdata = args.results_dir if isinstance(args.modnames, str): mods = eval(args.modnames) else: mods = args.modnames - json_filename = args.jsonname + json_filename = args.outnamejson if json_filename == 'CMIP_MME': json_filename = '/MPI_' + args.mip + '_' + args.experiment - if args.mip == 'CMIP5' and args.experiment == 'historical' and mods is None: - mods = [ - 'ACCESS1-0', - 'ACCESS1-3', - 'bcc-csm1-1', - 'bcc-csm1-1-m', - 'BNU-ESM', - 'CanCM4', - 'CanESM2', - 'CCSM4', - 'CESM1-BGC', - 'CESM1-CAM5', - 'CESM1-FASTCHEM', - 'CESM1-WACCM', - 'CMCC-CESM', - 'CMCC-CM', - 'CMCC-CMS', - 'CNRM-CM5-2', - 'CNRM-CM5', - 'CSIRO-Mk3-6-0', - 'FGOALS-g2', - 'FIO-ESM', - 'GFDL-CM2p1', - 'GFDL-CM3', - 'GFDL-ESM2G', - 'GFDL-ESM2M', - 'GISS-E2-H', - 'GISS-E2-H-CC', - 'GISS-E2-R', - 'GISS-E2-R-CC', - 'HadCM3', - 'HadGEM2-AO', - 'HadGEM2-CC', - 'HadGEM2-ES', - 'inmcm4', - 'IPSL-CM5A-LR', - 'IPSL-CM5A-MR', - 'IPSL-CM5B-LR', - 'MIROC4h', - 'MIROC5', - 'MIROC-ESM', - 'MIROC-ESM-CHEM', - 'MPI-ESM-LR', - 'MPI-ESM-MR', - 'MPI-ESM-P', - 'MRI-CGCM3', - 'MRI-ESM1', - 'NorESM1-M', - 'NorESM1-ME'] - # VAR IS FIXED TO BE PRECIP FOR CALCULATING MONSOON PRECIPITATION INDICES var = args.modvar thr = args.threshold @@ -150,74 +96,30 @@ def monsoon_wang_runner(args): pass # SETUP WHERE TO OUTPUT RESULTS (json) - jout = outpathjsons + jout = outpathdata try: os.makedirs(nout) except BaseException: pass - modpathall = modpath.replace('MODS', '*') - lst = glob.glob(modpathall) - # CONFIRM DATA FOR MODS IS AVAIL AND REMOVE THOSE IT IS NOT - gmods = [] # "Got" these MODS - for mod in mods: - for l in lst: - l1 = modpath.replace('MODS', mod) - if os.path.isfile(l1) is True: - if mod not in gmods: - gmods.append(mod) - - if args.experiment == 'historical' and mods is None: - gmods = [ - 'ACCESS1-0', - 'ACCESS1-3', - 'bcc-csm1-1', - 'bcc-csm1-1-m', - 'BNU-ESM', - 'CanCM4', - 'CanESM2', - 'CCSM4', - 'CESM1-BGC', - 'CESM1-CAM5', - 'CESM1-FASTCHEM', - 'CESM1-WACCM', - 'CMCC-CESM', - 'CMCC-CM', - 'CMCC-CMS', - 'CNRM-CM5-2', - 'CNRM-CM5', - 'CSIRO-Mk3-6-0', - 'FGOALS-g2', - 'FIO-ESM', - 'GFDL-CM2p1', - 'GFDL-CM3', - 'GFDL-ESM2G', - 'GFDL-ESM2M', - 'GISS-E2-H', - 'GISS-E2-H-CC', - 'GISS-E2-R', - 'GISS-E2-R-CC', - 'HadCM3', - 'HadGEM2-AO', - 'HadGEM2-CC', - 'HadGEM2-ES', - 'inmcm4', - 'IPSL-CM5A-LR', - 'IPSL-CM5A-MR', - 'IPSL-CM5B-LR', - 'MIROC4h', - 'MIROC5', - 'MIROC-ESM', - 'MIROC-ESM-CHEM', - 'MPI-ESM-LR', - 'MPI-ESM-MR', - 'MPI-ESM-P', - 'MRI-CGCM3', - 'MRI-ESM1', - 'NorESM1-M', - 'NorESM1-ME'] - + for i, mod in enumerate(mods): + modpath.model = mod + for k in modpath.keys(): + try: + val = getattr(args, k) + except Exception: + continue + if not isinstance(val, (list, tuple)): + setattr(modpath, k, val) + else: + setattr(modpath, k, val[i]) + l1 = modpath() + if os.path.isfile(l1) is True: + gmods.append(mod) + + if len(gmods) == 0: + raise RuntimeError("No model file found!") ######################################### try: @@ -234,8 +136,18 @@ def monsoon_wang_runner(args): doms = ['AllMW', 'AllM', 'NAMM', 'SAMM', 'NAFM', 'SAFM', 'ASM', 'AUSM'] mpi_stats_dic = {} - for mod in gmods: - modelFile = modpath.replace('MODS', mod) + for i, mod in enumerate(gmods): + modpath.model = mod + for k in modpath.keys(): + try: + val = getattr(args, k) + except Exception: + continue + if not isinstance(val, (list, tuple)): + setattr(modpath, k, val) + else: + setattr(modpath, k, val[i]) + modelFile = modpath() mpi_stats_dic[mod] = {} diff --git a/pcmdi_metrics/monsoon_wang/scripts/mpindex_compute.py b/pcmdi_metrics/monsoon_wang/scripts/mpindex_compute.py index 71b857c25..c8d76a7fd 100644 --- a/pcmdi_metrics/monsoon_wang/scripts/mpindex_compute.py +++ b/pcmdi_metrics/monsoon_wang/scripts/mpindex_compute.py @@ -2,5 +2,5 @@ from pcmdi_metrics.monsoon_wang import create_monsoon_wang_parser, monsoon_wang_runner P = create_monsoon_wang_parser() -args = P.get_parameter() +args = P.get_parameter(argparse_vals_only=False) monsoon_wang_runner(args) diff --git a/pcmdi_metrics/version.py b/pcmdi_metrics/version.py index d6ec4dd01..9be5197f8 100644 --- a/pcmdi_metrics/version.py +++ b/pcmdi_metrics/version.py @@ -1,3 +1,3 @@ __version__ = 'v1.2' -__git_tag_describe__ = 'v1.2-50-gef54524' -__git_sha1__ = 'ef54524c9a3845afadc9f1312393d0f68734a4be' +__git_tag_describe__ = 'v1.2-44-g55606c7' +__git_sha1__ = '55606c7d422916a4ae0953b0db38f54e80ae3331' diff --git a/tests/test_monsoon_wang.py b/tests/test_monsoon_wang.py index fd986b638..e3e2ec96d 100644 --- a/tests/test_monsoon_wang.py +++ b/tests/test_monsoon_wang.py @@ -29,21 +29,19 @@ def checkAllClose(self, a, b): def testMonsoonWang(self): P = create_monsoon_wang_parser() - P.add_args_and_values(["--mp", - "tests/monsoon/data/pr_1961_1999_MRI-CGCM3_regrid_MODS.nc", + P.add_args_and_values(["--test_data_path", + "tests/monsoon/data/%(variable)_1961_1999_MRI-CGCM3_regrid_%(model).nc", "--reference_data_path", "tests/monsoon/obs/pr_gpcp_79_07_mseas.nc", "--mns", "['xa',]", "--results_dir", "test_monsoon", - "--outpj", - "test_monsoon", "--threshold=2.5"]) args = P.get_parameter() monsoon_wang_runner(args) - test_file = "test_monsoon/out.json" + test_file = "test_monsoon/monsoon_wang.json" correct_file = "tests/monsoon/mpi.json" self.compareJsons(test_file, correct_file)