The validate API

This section describes the validate Application Programming Interface (API).

data_loader

THis module contains functions that will load data from netCDF files needed to produce plots. It uses various cdo commands to manipulate the netCDF files if they need to be processed before the data is extracted.

validate.data_loader.already_calculated(name)[source]
validate.data_loader.cdos(name, string)[source]
validate.data_loader.dataload(ifile, var, dates, realm='atmos', scale=1, shift=0, remapf='remapdis', remapgrid='r360x180', seasons=None, datatype='full', depthneeded=None, section=False, fieldmean=False, gridweights=False, cdostring=None, yearmean=False, external_function=None, external_function_args={})[source]
Manipulates a file used a series of cdo commands which produce intermediate files,
and returns data about the the final file produced based on the specified parameters.
Parameters:
ifile : string

the name of the original input file

var : string

variable name

dates : dictionary of the date range as strings of the form ‘yyyy-mm’

start_date and end_date keys should be specified

realm : string

realm category (used for masking data) default : ‘atmos’

scale : float

scales the data by this value default : 1

shift : float

shifts the data by this valee default : 0

remapf : string

name of the cdo remapping default : remapdis

remapgrid : string

grid to remap the data to default : ‘r360x180

seasons : list of strings

seasons to be selected out of [‘DJF’, ‘MAM’, ‘JJA’, ‘SON’] None will select all of the seasons default : None

datatype : string

cdo operation to perform all the time axis options are ‘climatology’, ‘trends’, ‘detrend’ anything else not perform any cdo operation default ‘full’

depthneeded : list of floats

list of the depths to interpolate the data to in z-axis default : None

section : boolean

set to True to take a zonal mean of the data default : False

fieldmean : boolean

set to True to take a fieldmean of the data default : False

gridweights : boolean

set to True to calculate the area weights of each grid cell

cdostring : string

custom to cdo string to be applied to the input file default : None

yearmean : boolean

take an annual mean of the data before manipulating default : False

external_function : string

name of external function to call default : None

external_function_args : dictionary

keyword arguments to pass to the external function

Returns:
numpy array of final data
numpy array of longitudinal cooridinates
numpy array of latitudinal coordinates
numpy array of depths
string of the units
numpy array of the time axis
numpy area of the area weights of the grid cells
validate.data_loader.depthstring(depthlist)[source]
validate.data_loader.detrend(name)[source]
validate.data_loader.field_mean(name)[source]
validate.data_loader.get_external_function(name)[source]

Returns a function from the external module based on the function name.

validate.data_loader.get_remap_function(remap)[source]

Returns a cdo function from string of the same name.

validate.data_loader.grid_weights(name)[source]
validate.data_loader.intlevel(name, depthlist)[source]
validate.data_loader.mask(name, realm)[source]
validate.data_loader.remap(name, remapname, remapgrid)[source]
validate.data_loader.season(name, seasonlist)[source]
validate.data_loader.sel_date(name, start_date, end_date, time_average=False)[source]
validate.data_loader.sel_var(name, variable)[source]
validate.data_loader.setc(name, realm='ocean')[source]
validate.data_loader.silent_remove(name)[source]

Removes a file if it exists and does nothing if it doesn’t exist

validate.data_loader.split(name)[source]

Returns the name of a file without the directory path

validate.data_loader.time_mean(name, time_average=False)[source]
validate.data_loader.trend(name)[source]
validate.data_loader.year_mean(name)[source]
validate.data_loader.year_mon_day(datestring)[source]

Seperates a string of from yyyy-mm-dd in to three integers and returns the tuple year,mon,day

validate.data_loader.zonal_mean(name)[source]

defaults

This module fills the plots with values specified in defaults and fills the remaining options with placeholders so that existence checks will not be needed later.

..moduleauthor:: David Fallis

validate.defaults.fill(plots, run, experiment, cmip6_verification=False, defaults={})[source]

Fills the blank spaces in plots with default values.

Parameters:
plots : list of dictionaries
model_run : string

run ID

experiment : string

experiment name

defaults : dictionary

values to fill plots

Returns:
list of dictionaries
validate.defaults.filltitle(p)[source]

pdf_organizer

This module contains tools to produce a multipage pdf in an organized and labelled format specific to model plots.

validate.pdf_organizer.arrange(plotnames)[source]
Outputs a pdf named plots/joined.pdf with all of the plots
organized and bookmarked
Parameters:
plotnames : list of tuples

(name of plot, plot dictionary, plot type)

validate.pdf_organizer.orderplots(plotnames)[source]

Organizes the names into a dictionary that can be used to cycle through the plots

Parameters:
plotnames : list of tuples

(name of plot, plot dictionary, plot type)

Returns
——-
dictionary
validate.pdf_organizer.pdfmarks(plotdict)[source]

Writes to pdfmarks file to organize the plots under bookmarks

Parameters:
plotdict : dictionary

organized into the bookmark levels

Returns
——-
string with all of the plot names in the order they will be in joined.pdf

taylor

class validate.taylor.TaylorDiagram(refstd, fig=None, rect=111, label='_', srange=(0, 1.5))[source]

Bases: object

Taylor diagram.

Plot model standard deviation and correlation to reference (data) sample in a single-quadrant polar plot, with r=stddev and theta=arccos(correlation).

Methods

add_contours(self[, levels]) Add constant centered RMS difference contours, defined by levels.
add_grid(self, \*args, \*\*kwargs) Add a grid.
add_sample(self, stddev, corrcoef, \*args, …) Add sample (stddev,*corrcoeff*) to the Taylor diagram.
add_contours(self, levels=5, **kwargs)[source]

Add constant centered RMS difference contours, defined by levels.

add_grid(self, *args, **kwargs)[source]

Add a grid.

add_sample(self, stddev, corrcoef, *args, **kwargs)[source]

Add sample (stddev,*corrcoeff*) to the Taylor diagram. args and kwargs are directly propagated to the Figure.plot command.

validate.taylor.test1()[source]

Display a Taylor diagram in a separate axis.

validate.taylor.test2()[source]

Climatology-oriented example (after iteration w/ Michael A. Rawlins).