openairclim.gui.components.utils

Provides utility functions for the OpenAirClim GUI.

openairclim.gui.components.utils.auto_scale(max_val)[source]

Determine a scaling factor for clean axis labels.

Values in the range [0.1, 1000) are left unscaled. Otherwise, the appropriate power of 10 is extracted and returned as a label prefix using Unicode superscript characters.

Parameters:

max_val (float) – Maximum value on the axis.

Returns:

(divisor, label_prefix) where divisor is the power of 10

to divide data by, and label_prefix is a string like "10⁸ " or "" if no scaling is needed.

Return type:

tuple

openairclim.gui.components.utils.get_numeric_vars(ds)[source]

Return names of plottable numeric data variables. Allows for all numeric data within the inventories to be visualised, even if it is not used by OpenAirClim.

Parameters:

ds (xarray.Dataset) – Emission inventory.

Returns:

Names of numeric data variables, excluding spatial fields and ac.

Return type:

list

openairclim.gui.components.utils.load_inventory(working_dir: str, inv_dir: str, inv_file: str)[source]

Load a single emission inventory, promoting spatial fields to coords.

Parameters:
  • working_dir (str) – Project working directory.

  • inv_dir (str) – Inventory subdirectory from config.

  • inv_file (str) – Inventory filename.

Returns:

Loaded inventory with plev, lat, lon as coordinates.

Return type:

xarray.Dataset

openairclim.gui.components.utils.superscript(n: str)[source]

Convert an integer to Unicode superscript characters.

Parameters:

n (int) – Number to convert.

Returns:

Unicode superscript representation.

Return type:

str