-
Notifications
You must be signed in to change notification settings - Fork 5
Introduction and using CDP
The Community Diagnostics Package (CDP) is a framework for creating new climate diagnostic software. Any diagnostics software that uses CDP should contain the following classes which inherit from their CDP counterparts.
A basic diagram of the structure of CDP and any CDP derived diagnostics package
-
Parser: If needed for a given diagnostics package, a developer can implement a command line parser which inherits from
CDPParser
.CDPParser
is basicallyArgumentParser
with a few default arguments such as-p
for the parameter file. TheCDPParser
has the ability to override the values from the parameter file as well, so-p path/to/file -var new_var
will set thevar
from the parameter file tonew_var
for a given run. -
Parameter: Used to manage and store the user input. The
check_values()
function must be defined, which can check that the values are the correct types or even valid values for your diagnostics package. Your Parameter class (which should inherit fromCDPParameter
) can use your parser to get the user input from the command line. In addition, using thecdp_parameter.load_parameter_from_py(path)
function allows for the ability to load the values from a Python script. -
Driver: The driver class runs the diagnostics is the main part of any diagnostics software using CDP. It takes your parameter object, runs the diagnostics, and exports the results. Your class should inherit from
CDPDriver
and must define three functions:-
check_parameter()
: checks that the input Parameter object (the one you created) is valid for this driver. You can check if the needed variables are present and other such things. -
run_diags()
: Run the actual diags. -
export()
: Export the output data to the required format.
-
-
Metric: Metric classes calculate a given metric, all of which inherit from
CDPMetric
. A metric class must have a definedcompute()
function, which is called by the driver. One can create Metric classes to compute the root mean square, correlation, etc. -
IO: Used for file I/O and inherits from
CDPIO
. Must define theread()
andwrite()
functions. -
Provenance: Inherits from
CDPProvenance
. Must define theexport_prov()
function which exports the provenance. -
More to come soon.
To begin creating a diagnostics package using CDP, you'll need to have Anaconda installed.
Then, install CDP using the command below and import cdp
to begin.
conda install -c uvcdat cdp
A fork of the PCMDI Metrics Package using CDP can be viewed here.