-
Notifications
You must be signed in to change notification settings - Fork 40
PMP using CDP Guide
#Introduction
This guide is intended to bring developers (and maybe users) up to speed with the changes done when refactoring pmp to use cdp. If you don't know what cdp is, look here.
Vocabulary for the parameter has changed to account for the new paradigm of reference data set vs test data set, instead of just observation vs model. See here
All other cdp related stuff is in the src/python/pcmdi/scripts/driver/
folder. This include the pmp_parser
, which is no longer in src/python/pcmdi/
.
The majority of the work was done to the pcmdi_metrics_driver.py
, which is now named pcmdi_metrics_driver_legacy.py
. The new driver is now named pcmdi_metrics_driver.py
. Both are executable via the command line. The next section details the changes done to the driver.
Though not a requirement of cdp, the driver is now programmed in an object-oriented fashion. There are many good reasons to this, which you can see by googling it. Below is an explanation of the classes, which are located in src/python/pcmdi/scripts/driver/
.
-
PMPParameter
: Inherits fromCDPParameter
. Contains the stuff that's usually in a Python parameter script. Eventually, we want to add error checking to thecheck_values()
function. -
PMPParser
: Inherits fromCDPParser
, which it based onArgumentParser
. You can add/remove/change the arguments in theload_default_args()
function if needed. -
DataSet
: One of the largest forthcoming changes to pmp is that observations and models can be used interchangeably. To do so, both must be of the same class, which isDataSet
.DataSet
is an abstract class that acts as an interface, with some functionality through static methods. EachDataSet
object also has an attribute of typepmp_io
. -
Model
: A concrete version ofDataSet
. Looking at this from the legacy code, this is all of the stuff in themodel_versions
loop. It just does stuff related to_model_file
, which was calledMODEL
in the legacy version. -
Observation
: Another concrete version ofDataSet
. Looking at this from the legacy code, this is all of the stuff in therefs
loop. It just does stuff related to_obs_file
, which was calledOBS
in the legacy version. -
PMPDriver
: Inherits fromCDPDriver
. Has aPMPParser
to get command line arguments. Composed of three functions,check_parameter()
,run_diags()
,export()
.check_parameter()
checks that theself.parameter
has all of the stuff needed for this driver.run_diags()
runs the diags.export()
should export the results, but doesn't do that yet because that's already done inrun_diags
(but eventually will do it). -
RunDiags
: The actual work forPMPDriver.run_diags()
is done by this class. This is where the main functionality is. This loops through all of thevars
,regions
,reference_data_set
andtest_data_set
in that order. This also determines if the comparison is obs vs obs, obs vs model, or model vs model. -
OutputMetrics
WhenRunDiags
gets the data fromModel
orObservation
(viaDataSet.get()
), these get sent toOutputMetrics
which creates themetrics_dictionary
, computes the metrics needed, and outputs the results. Also has anout_file
andclim_file
, which were respectivelyOUT
andCLIM
previously.