module documentation

Generic class for LIVVkit Extensions.

This supplies several common methods for plotting and data analysis.

Class LEX Define a LIVVkit extension.
Function annotate_plot Add land / ocean, gridlines, colourbar.
Function area_avg Compute a masked and weighted area average of some field.
Function check_longitude Check that longitudes are -180 - +180.
Function closest_points Determine closest model points to set of observation x/y points.
Function compute_clevs Compute reasonable min / max levels for one to three arrays which are comparable.
Function gen_file_list Undocumented
Function gen_file_list_old Undocumented
Function gen_file_list_timeseries Undocumented
Function get_cycle Get the name of which type of averaging is used (annual, seasonal, monthly).
Function get_season_bounds Determine season bounds for climatology files.
Function img_file_prefix Convert the module name into a file prefix for the image output.
Function load_obs Undocumented
Function load_timeseries_data Load data for timeseries.
Function parse_var Undocumented
Function parse_var_name Undocumented
Function plot_grid Undocumented
Function plot_points Undocumented
Function proc_climo_file Process the climatology file to maintain backward compatibility with standalone LEX.
Function summarize_result Provides a snapshot of the extension's results to be provided on the summary webpage and printed to STDOUT via the print_summary method
Function var_filename_format Undocumented
Constant DAYS_PER_MONTH Undocumented
Constant DAYS_PER_SEASON Undocumented
Constant MON_NAMES Undocumented
Constant SEASON_NAME Undocumented
Constant TFORM Undocumented
def annotate_plot(axis, color_field=None, label=None): (source)

Add land / ocean, gridlines, colourbar.

def area_avg(data, config, area_file, area_var, mask_file=None, mask_var=None, sum_out=False, land_only=False): (source)

Compute a masked and weighted area average of some field.

data : array_like
Array of data to be averaged
config : dict
LIVVkit configuration dictionary, at least contains the variable maskv if mask_var is not set
area_file : Path
Path to a netCDF file containing the grid cell area which matches data
area_var : str
Name of the netCDF variable which contains the area data
mask_file : Path, optional
Path to a netCDF file containing the ice sheet mask whose shape matches data. If not set, the mask is assumed to be in the area_file file
mask_var : str, optional
Name of the netCDF variable which contains the ice sheet mask data, if not set, then use maskv from config
Returns
  • avg: float - Masked and area-weighted average of data
  • isheet_mask: array_like - Mask of ice sheet used in generating avg
  • area_maskice: array_like - Masked area used in generating avg
  • _data: array_like - Input data masked by isheet_mask
def check_longitude(data, lon_coord='lon'): (source)

Check that longitudes are -180 - +180.

def closest_points(model_x, model_y, obs_x, obs_y): (source)

Determine closest model points to set of observation x/y points.

def compute_clevs(data, bnds=(5, 95), even=False, round=True, keys=None): (source)

Compute reasonable min / max levels for one to three arrays which are comparable.

Parameters
data:dictionaryMasked array of data for which to compute contour levels
bnds:tuple, optionalUpper / lower percentiles to use for bounds (default: (5%, 95%))
even:bool, optionalUse an even interval about 0 (default: False)
roundUndocumented
keys:list, optionalList of keys within data for which bounds will be computed, default is all keys in data
Returns
floatbnd_l, bnd_h - Lower, upper bounds for contouring
def gen_file_list(config: dict, var_name: list | tuple | str, overs: str, sea: list | tuple | str, cycle: str): (source)

Undocumented

def gen_file_list_old(config: dict, var_name: list | tuple | str, overs: str, sea: list | tuple | str, cycle: str, mode: str): (source)

Undocumented

def gen_file_list_timeseries(config: dict, var_name: list | tuple | str, overs: str): (source)

Undocumented

def get_cycle(sea): (source)

Get the name of which type of averaging is used (annual, seasonal, monthly).

def get_season_bounds(season, year_s, year_e): (source)

Determine season bounds for climatology files.

def img_file_prefix(config): (source)

Convert the module name into a file prefix for the image output.

def load_obs(config, sea='ANN', mode='climoS', single_ds=None, expect_one_time=True): (source)

Undocumented

@logger.catch
def load_timeseries_data(config): (source)

Load data for timeseries.

def parse_var(data_var, dataset, scale): (source)

Undocumented

def parse_var_name(data_var): (source)

Undocumented

def plot_grid(lon, lat, data, axis, cmap=None, vmin=None, vmax=None, outline=False): (source)

Undocumented

def plot_points(lon, lat, data, axis, cmap=None, vmin=None, vmax=None, outline=False): (source)

Undocumented

def proc_climo_file(config, file_tag, sea): (source)

Process the climatology file to maintain backward compatibility with standalone LEX.

Parameters
config:dictLIVVkit /LEX configuration dict
file_tag:strConfiguration item which points to climatology filename to be formatted, usually climo or climo_remap
sea:strSeason identifier
Returns
strclimo_file - Formatted name of climatology file
def summarize_result(result): (source)

Provides a snapshot of the extension's results to be provided on the summary webpage and printed to STDOUT via the print_summary method

def var_filename_format(file_pattern, _var, isheet, _sea, year_s, year_e, sep='_'): (source)

Undocumented

DAYS_PER_MONTH = (source)

Undocumented

Value
np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])
DAYS_PER_SEASON = (source)

Undocumented

Value
{'DJF': 31 + 31 + 28,
 'MAM': 31 + 30 + 31,
 'JJA': 30 + 31 + 31,
 'SON': 30 + 31 + 30,
 'JFM': 31 + 28 + 31,
 'AMJ': 30 + 31 + 30,
 'JAS': 31 + 31 + 30,
...
MON_NAMES = (source)

Undocumented

Value
[dt.datetime(2000, mon, 1).strftime('%b') for mon in range(1, 12 + 1)]
SEASON_NAME: dict[str, str] = (source)

Undocumented

Value
{'ANN': 'annual',
 'DJF': 'winter',
 'JJA': 'summer',
 'MAM': 'spring',
 'SON': 'autumn'}

Undocumented

Value
ccrs.PlateCarree()