Introduction and using CDP

Zeshawn Shaheen edited this page Nov 16, 2016 · 4 revisions
Clone this wiki locally

Introduction

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 basically ArgumentParser with a few default arguments such as -p for the parameter file. The CDPParser has the ability to override the values from the parameter file as well, so -p path/to/file -var new_var will set the var from the parameter file to new_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 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 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 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 read() and write() functions.

  • Provenance: Inherits from CDPProvenance. Must define the export_prov() function which exports the provenance.

  • More to come soon.

Using CDP

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

Examples

A fork of the PCMDI Metrics Package using CDP can be viewed here.