eviz.lib.iviz package

Submodules

eviz.lib.iviz.base_params module

class eviz.lib.iviz.base_params.BaseParams(*args: Any, **kwargs: Any)

Bases: Parameterized

The BaseParams class initializes all param and panel objects required by iviz.

Parameters:
  • dataInput (str) – input file information, either a param.Selector or a filename;

  • file (xr) – xarray DatArray or Dataset, ingested by data module;

  • model (str) – earth system model input or determined;

__init__(dataInput, file, model, **params)
Params class

DataSource class as input, use the DataSource.dataInput and the DataSource.yaml_model as inputs Open the file from datasource, either param.Selector, file path, Opendap object Once file is actually opened, get information needed to file parameter bounds, options, slider settings etc. Then pass the opened file and parameters to Dashboard class

all_variables = True
avg_by_lev = True
cmap = 'rainbow'
cmap_reverse = False
column_slider = 1
comparison_source = 'ccm'
custom_title = False
diff_types_1d = 'align'
gif_dim_opts = []
globallats = None
globallons = None
hmdir = '/root'
logy_z = False
multi_selector = '/root'
polar_coastlines = True
profile_invert_axes = True
profile_invert_yaxis = True
profile_logy = False
react(*events)
set_attributes(params)

Set attributes/parameters from an input dictionary.

Parameters:

params (param): dictionary of parameter values

set_dim_params(model, xc, yc, tc, zc)

Set all xc, yc, tc, and zc parameter objects according to the determined models xc, yc, tc, and zc labels found in the meta_coords.yml file.

Parameters:

xc (param): dimension yc (param): dimension tc (param): dimension zc (param): dimension

Returns:

xc (param): dimension yc (param): dimension tc (param): dimension zc (param): dimension

set_file_selector()

If a data dorectpry is being used, set the ‘multi_file’ parameter.

set_input()

Set the ‘input’ filename.

set_plot_types_on_var_change(file, field, xc, yc, tc, zc)

If the selected field changes or the file selected is changed, check and set what plot types are available using the data and dimensions available.

Sets:

plot_types.options (list): List of all possible plots plot_types.value (list): Default set of possible plots.

set_xy_clim = False
set_yz_clim = False
share_colorbar = True
show_coastlines = False
show_data = False
show_grid = False
show_lakes = False
show_rivers = False
show_states = False
show_statistics = False
tabs_switch = True
zero_clim = False

eviz.lib.iviz.config module

class eviz.lib.iviz.config.configIviz(specs_path=None, **kwargs)

Bases: object

The ConfigIviz class contains information needed to configure iviz for yaml based inputs to the tool. If kwargs are empty, set to defaults.

airmass_field_name = None
airmass_file_name = None
get_airmass()
get_species_db()
get_trop()
load(specs_path)
species_db = None

eviz.lib.iviz.dash_utils module

eviz.lib.iviz.dash_utils.cache_projection(proj_str)

Add the current Cartopy CRS projection method to the Panel cache.

Parameters:

proj_str (str) – input projection string.

Cached:

projection (method): Cartopy CRS projection method.

eviz.lib.iviz.dash_utils.cmap_examples(cms, provider, cols=4)

Returns a hv.Layout of hv.Images of colormaps. For each colormap available, create an image depicting color range available. Label each colormap above the image.

Parameters:
  • cms (list) – list of strings of name of colormaps.

  • provider (str) – Colormap provider.

  • cols (int) – number of columns for Layout.

Returns:

Layout out of filtered colormap Images.

Return type:

hv.Layout (hv)

eviz.lib.iviz.dash_utils.frange(start, stop=None, step=None)

Produce a range given a start, and optionally a stop and step.

Parameters:
  • start (int) – number to start range;

  • stop (int) – number to stop range, optinal;

  • step (int) – increment between each number in range, optional;

eviz.lib.iviz.dash_utils.get_regridded_ds(d1_size, d1, d2_size, d2)

Compare sizes of dataset 1 and dataset 2 and regrid large dataset to smaller dataset size.

Parameters:
  • d1_size (tuple) – tuple of dataset size

  • d1 (xr.Dataset) – Xarray dataset 1

  • d2_size (tuple) – tuple of dataset 2 size

  • d2 (xr.Dataset) – Xarray dataset 2

Returns:

2 dimensional array of regridded dataset. regridded_dataset_number (int): regridded ds #

Return type:

new_arr (array)

eviz.lib.iviz.dash_utils.get_ylim(d1, d2)

Return the y min and max between two datasets.

Parameters:
  • d1 – Xarray dataset

  • d2 – Xarray dataset

  • ymin – parameter to set clim min

  • ymax – parameter to set clim max

Returns:

Value of colorbar minimum for cbar limit clim_max (float): Value of colorbar maximum for cbar limit

Return type:

clim_min (float)

eviz.lib.iviz.dash_utils.set_clim(d1, d2)

Return the colorbar min and max between two datasets.

Parameters:
  • d1 – Xarray dataset

  • d2 – Xarray dataset

  • clim_min – parameter to set clim min

  • clim_max – parameter to set clim max

Returns:

Value of colorbar minimum for cbar limit clim_max (float): Value of colorbar maximum for cbar limit

Return type:

clim_min (float)

eviz.lib.iviz.dataframe_params module

class eviz.lib.iviz.dataframe_params.DataframeParams(*args: Any, **kwargs: Any)

Bases: BaseParams

The DataframeParams class configures iviz parameters from an input pandas dataframe dimensions and fields.

Variables:
  • dataInput (str) – input file information, either a param.Selector or a filename;

  • file (xr) – pandas DataFrame, ingested by data module;

  • model (str) – earth system model input or determined;

describe = False
enable_basemap = False
get_avail_plot_types()
set_dim_params(model, xc, yc)

Set all xc, yc, tc, and zc parameter objects according to the determined models xc, yc, tc, and zc labels found in the meta_coords.yml file.

Parameters:
  • xc (param) – dimension

  • yc (param) – dimension

  • tc (param) – dimension

  • zc (param) – dimension

Returns:

dimension yc (param): dimension tc (param): dimension zc (param): dimension

Return type:

xc (param)

set_input()

Set the ‘input’ filename.

set_param_values()

Set all parameters for file. Includes configuring fields to the data’s columns, and seraching for longitude or latitude columns. If not found, sets x and y parameters to first and second column in dataframe.

set_xarray_dim_params(model, xc, yc, tc, zc)

Set all xc, yc, tc, and zc parameter objects according to the determined models xc, yc, tc, and zc labels found in the meta_coords.yml file.

Parameters:
  • xc (param) – dimension

  • yc (param) – dimension

  • tc (param) – dimension

  • zc (param) – dimension

Returns:

dimension yc (param): dimension tc (param): dimension zc (param): dimension

Return type:

xc (param)

eviz.lib.iviz.notyf module

class eviz.lib.iviz.notyf.Notyf(*args: Any, **kwargs: Any)

Bases: ReactiveHTML

A notification pane made using Panel and ReacticeHTML components. Produces warning, success, and error messages with configurable durations, positions, etc.

dismiss_all()
dismissible = False
duration = 2000
error(message)
ripple = True
success(message)
types = []

eviz.lib.iviz.params module

class eviz.lib.iviz.params.DatasetParams(*args: Any, **kwargs: Any)

Bases: BaseParams

The DatasetParams class configures iviz parameters from an input Xarray Dataset or DataArray’s dimensions and fields.

Variables:
  • dataInput (str) – input file information, either a param.Selector or a filename;

  • file (xr) – xarray DatArray or Dataset, ingested by data module;

  • model (str) – earth system model input or determined;

check_for2d_file2(ndims)

For second file, check for 4 dimensions.

Parameters:

ndims (int): number of dimensions

check_for_zeros(data)

If all values are zero, contours and filled contours can not be plotted. Check for all 0’s by calculating the mean of the input data.

Parameters:

data (xr) – xarray DataArray or Dataset;

format_tc()

Try and except bloc to format the time coordinate of the data.

Sets:

file (xr): opened xarray file time dimension

get_3d_fields(data)

Given input data, filter out any fields that have more than 3 dimensions. Only use 3d fields for plotting.

Parameters:

data (xarray) – xarray dataset

Returns:

list of strings of each field with >= 3d

Return type:

plotting_fields (list)

get_avail_plot_types(data, xc, yc, tc, zc)

Evaluate data x, y, t, and z values to determine what plot types are available.

Parameters:
  • data (xarray) – data

  • xc (str) – x coordinate

  • yc (str) – y coordinate

  • tc (str) – t coordinate

  • zc (str) – z coordinate

set_attrs()

Check that all attributes that are needed by tool are provided in the Dataset.attrs

set_avail_plot_types(plot_types, default_plots, current_plots=None)

Set plot types widgets options for suer selection.

Parameters:
  • plot_types (dict) – plot types available;

  • default_plots (dict) – default plots;

set_f2_field(f1keys, f2keys)

Set the variable value for the secondary file.

Parameters:
  • f1keys (list) – file 1 keys

  • f2keys (list) – file 2 keys

Returns:

default variable for file 2.

Return type:

plotval (str)

set_param_values()

Set all parameters for file. Includes configuring fields to the data’s variables, the x and y extents, and defining dimensions that can iterated over for a gif.

set_proj_from_attrs()

Get the projection attribute from the data if it is provided, and set proj parameter.

Parameters:

proj (str): cartopy projection parameter

set_tc_bounds(tc, data, coords)

Set time coordinate slider values and bounds according to data tc limits.

Parameters:
  • tc (str) – time coordinate

  • data (xarray) – data

  • coords (list) – list of coords from data

set_xc_xyplot_limits_sliders(data, xc)

Set x-coordinate(xc) xyplot sliders bounds according to data x and y values.

Parameters:
  • xc (str) – x coordinate

  • data (xarray) – data

set_yc_xyplot_limits_sliders(data, yc)

Set y-coordinate(yc) xyplot sliders bounds according to data x and y values.

Parameters:
  • yz (str) – y coordinate

  • data (xarray) – data

set_yc_yzplot_limits_sliders(data, yc)

Set x-coordinate(xc) for yzplot sliders bounds according to data x and y values.

Parameters:
  • xc (str) – x coordinate

  • data (xarray) – data

set_zc_bounds(yc, zc, data, coords)

Set z coordinate slider values and bounds according to data zc limits.

Parameters:
  • zc (str) – vertical coordinate

  • data (xarray) – data

  • coords (list) – list of coords from data

set_zc_yzplot_limits_sliders(data, zc)

Set x-coordinate(xc) for yzplot sliders bounds according to data x and y values.

Parameters:
  • xc (str) – x coordinate

  • data (xarray) – data

update_files()

On file selection change, update coordinate parameters for data, replace variable and dimension values, re-set parameters. Triggered by ‘multi_file’ param.

eviz.lib.iviz.params_util module

eviz.lib.iviz.params_util.coastlines360(resolution='110m', lon_360=False)

Using cartopy natural earth features, return a Holoviews overlay of 0-360 latitude coastlines.

eviz.lib.iviz.params_util.get_coords(file)

Get coordinates of input file.

Parameters:

file (xr) – data;

Returns:

list of coords found

Return type:

list

eviz.lib.iviz.params_util.get_dims(file)

Get coordinates of input file.

Parameters:

file (xr) – data;

Returns:

list of coords found

Return type:

list

eviz.lib.iviz.params_util.get_keys(file)

Get coordinates of input file.

Parameters:

file (xr) – data;

Returns:

list of coords found

Return type:

list

eviz.lib.iviz.params_util.get_model_type(coords)

Match the provided coordinates with the coordinates of known models in case model type is not provided by user. If coordinates match a known model type, return the model. If not, return None.

Parameters:

coords (list) – all data coordinates;

Returns:

model type if known

Return type:

model (str)

eviz.lib.iviz.params_util.get_ndims(file, field=None)

Get number of dimensions of input file, if provided a field, get dimensions of that fields array.

Parameters:
  • file (xr) – data

  • field (str) – variable, optional;

Returns:

number of dimensions found

Return type:

ndims (int)

eviz.lib.iviz.params_util.load_model_coords()

Load the coordinates of all known models types using the config/meta_coordinates.yaml file.

Returns:

coordinates of all known models;

Return type:

meta_coordinates (dict)

eviz.lib.iviz.params_util.regrid_xr(ref_arr, in_arr, regrid_dims=(0, 0))

Regrids input 2D array with respect to the reference ref_arr using scipy interp1d function.

Parameters:
  • ref_arr (array) – 2d array to map to;

  • in_arr (array) – 2d array to regrid;

  • regrid_dims (tuple) – dimension of array being regridded;

Returns:

Regridded 2d array

Return type:

new_array (array)

eviz.lib.iviz.params_util.regrid_xr_yz(ref_arr, in_arr, regrid_dims=(0, 0))

Regrids input 2D array with respect to the reference ref_arr using scipy interp1d function for the yz data. c

Parameters:
  • ref_arr (array) – 2d array to map to;

  • in_arr (array) – 2d array to regrid;

  • regrid_dims (tuple) – dimension of array being regridded;

Returns:

Regridded 2d array

Return type:

new_array (array)

eviz.lib.iviz.params_util.set_long_name_in_attrs(file, keys)

For all keys in xarray Dataset, set the ‘long_name’ attribute if not provided.

eviz.lib.iviz.params_util.set_units_in_attrs(file, keys)

For all keys in xarray Dataset, set the ‘units’ attribute if not provided.

eviz.lib.iviz.time_average module

class eviz.lib.iviz.time_average.TimeAvg(files, run, tc, all_vars, var_inp)

Bases: object

Create a time averaged file.

Parameters:
  • files (list) – all files to average over;

  • run (pn.widgets.Butoon) – panel button to trigger averaging;

  • all_vars (bool) – whether to use all variables in provided file;

  • var_inp (str) – variables to use;

average_by_time()

Calculate the mean over the time dimension. Write the file to disk, and set the class variable output to the result.

Parameters:
  • files (list) – all files to average over;

  • run (pn.widgets.Butoon) – panel button to trigger averaging;

  • all_vars (bool) – whether to use all variables in provided file;

  • var_inp (str) – variables to use;

Sets:

output (xr): averaged dataset

label = None
set_ds()

Determines the input data and opens with xarray, whether provided a filename or a directory path.

Module contents