This is a set of python codes for evaluating output from the Data Assimilation Research Testbed (DART), using popular Python libraries like matplotlib and basemap.
I developed these for my work using DART with the Community Atmosphere Model (CAM) and the Whole Atmosphere Community Climate Model (WACCM), so right now the codes are mostly written to accomodate those.
The foundation of these codes is that any experiment you do with DART plus some model is described in a Python dictionary.
The way to create an experiment dictionary is with the function basic_experiment_dict
in the DART.py
module:
import DART as dart
E = dart.basic_experiment_dict()
Currently the standard entries for an experiment dictionary are:
exp_name
- some string that uniquely defines that experiment, e.g. a short version of the CESM run name.diagn
- the DART diagnostic that you want to plot: "Prior", "Posterior", or "Truth"copystring
- a string corresponding to one of the available copies in DART output, e.g. "ensemble mean"variable
- the model variable that you want to be plotlevrange
- the range of model levels that you want to plot or average over, in the units of the DART output fileslonrange
- the range of longitudes that you want to plot or average over, in the units of the DART output fileslatrange
- the range of latitudes that you want to plot or average over, in the units of the DART output filesextras
- other interesting quantities to compute, e.g. "MSE" (mean squared error)obs_name
- an observation you might be interested in, e.g. when computing correlations to observationsrun_category
- an extra category that you can give different runs, for creating different file pathsdaterange
- the range of dates over which to load data, in Pythondatetime
formatclim
- the limits of the values to be plotted (depending on the plot, this could be the y-limits, x-limits, or color limits)
This module contains what you need to read in DART outout.
This module has the following subroutines:
load_covariance_file
loads netcdf files of covariance and correlation between the model state and a given observationload_DART_obs_epoch_series_as_dataframe
runs through DARTobs_epoch
files corresponding to a given date range, and turns them into a Pandas dataframeload_DART_obs_epoch_file_as_dataframe
read in a DARTobs_epoch
files and retuns a dataframeload_DART_obs_epoch_file
reads in a DARTobs_epoch
files and retuns a dataframeload_DART_diagnostic_file
read in a DARTPosterior_Diag
orPrior_Diag
file and return the desired variable field.get_ensemble_size
given a DART output diagnostic netcdf file that is already open, find the number of ensemble members in the outputget_obs_type_number
having opened a DART output diagnostic netcdf file, find the obs_type number that corresponds to a given obs_typestringget_copy
having opened a DART output diagnostic netcdf file, find the copy number that corresponds to a given copystringbasic_experiment_dict
loads a default Python dictionary containing the details of an experiment that we look at --date_to_gday
convert a datetime date to gregorian day count the way it is counted in DART (i.e. number of days since 1601-01-01daterange
generate a range of dates (in python datetime format), given some start date, a time delta, and the numper of periodsrank_hist
given a 1-D ensemble time series and a verification (usually the truth), compute the rank histogram over the desired block of timekurtosis
given a 1D ensemble of numbers (obs space, state space, whatever) return the kurtosis of the PDF represented by the ensembleskewness
given a 1D ensemble of numbers (obs space, state space, whatever) return the skewness of the PDF represented by the ensemblepoint_check_dictionaries
pre-defined experiment dictionaries that give various averaging regionsclimate_index_dictionaries
returns experiment dictionaries with the lat, long, and levranges needed to compute certain climate indices.
This module contains various subroutines to diagnose the Madden-Julian Oscillation in DART-constrained model simulations. Basically these are routines that I wrote in order to look at the MJO in DART-WACCM simulations, so they're tuned to deal with WACCM- and CAM-stye output files. Warning: this module contains a lot of kludges -- proceed at your own risk.
- netCDF4 python library
- datetime
- pandas
- dayconv.py tool for converting Gregorian to Julian day
For examples of how to use this code, see this iPython notebook