Introduction and using CDP
Clone this wiki locally
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.
Parser: If needed for a given diagnostics package, a developer can implement a command line parser which inherits from
ArgumentParserwith a few default arguments such as
-pfor the parameter file. The
CDPParserhas the ability to override the values from the parameter file as well, so
-p path/to/file -var new_varwill set the
varfrom the parameter file to
new_varfor 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 from
CDPParameter) can use your parser to get the user input from the command line. In addition, using the
cdp_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
CDPDriverand 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 defined
compute()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 the
Provenance: Inherits from
CDPProvenance. Must define the
export_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.