cgeniepy#
Submodules#
Classes#
GenieModel is the interface to cGENIE output |
|
EcoModel is an subclass of GenieModel, as EcoGENIE to cGENIE |
|
A class to handle community-driven colormaps |
Functions#
|
|
|
|
Package Contents#
- class cgeniepy.GenieModel(model_path: str | List | Tuple, gemflag=None)#
Bases:
objectGenieModel is the interface to cGENIE output
- model_path#
- ncvar_dict#
- tsvar_list#
- __repr__()#
- get_var(var: str | List | Tuple, attrs=None)#
Get the data of target variable. A list of variables is supported as well.
- Parameters:
var – the name of target variable
unit – the unit of target variable, usually provided in the model output
Example#
>>> from cgeniepy.model import GenieModel >>> model = GenieModel("path_to_GENIE_output") >>> po4 = model.get_var("ocn_PO4")
- get_config(config_name='BIOGEM')#
- get_ts(var: str, to_ScatterData=False)#
read in time series output of GENIE
- Parameters:
var – the name of the target variable
- Returns:
a pandas DataFrame
- get_diag_avg(target_year, is_index=False, pattern_year='\\d+', pattern_year_digit='\\d{3}')#
read the diagnostic file of cGENIE
- Parameters:
target_year – the target year of the diagnostic file
is_index – if True, target_year is the index of the sorted years
pattern – the pattern of the diagnostic file name
- Returns:
a pandas DataFrame
Example#
>>> from cgeniepy.model import GenieModel >>> model = GenieModel("path_to_GENIE_output") >>> model.get_diag_avg(9999)
- grid_mask()#
cGENIE continent mask array (by setting zero values), either calculated from existing data or using biogem.grid_mask
- grid_category()#
an alogirthm to define surface grid catogories depending on the land-sea mask 0: coastal sea 1: land 2: open ocean
- grid_area()#
return the grid area array in used in this model experiment, unit: m2
- grid_mask_3d()#
return the 3d mask of the grid used in this model experiment
- grid_topo()#
return the topography of the grid used in this model experiment
- grid_zt_edges()#
return the depth edges of the grid used in this model experiment
- grid_lat_edges()#
return the latitude edges of the grid used in this model experiment
- grid_lon_edges()#
return the longitude edges of the grid used in this model experiment
- grid_zt_depths()#
return the depth of the grid used in this model experiment
- grid_volume()#
return the grid volume array (3d) in m3
- class cgeniepy.EcoModel(*args, **kwargs)#
Bases:
cgeniepy.model.GenieModelEcoModel is an subclass of GenieModel, as EcoGENIE to cGENIE
It facilitates the access of ecophysiological parameters and plankton variables
Initialise a EcoModel object with a path to cGENIE output directory
Example#
>>> from cgeniepy.ecology import EcoModel >>> model = EcoModel("path_to_GENIE_output")
- eco_varlist#
- plank_n#
- phyto_indices#
- zoo_indices#
- mixo_indices#
- phyto_n#
- zoo_n#
- mixo_n#
- eco_pars()#
Get all the ecophysiological parameters used in the model
- Returns:
a pandas DataFrame object
- get_pft(pft_index, prefix='Plankton', element='C')#
a variant of GenieModel’s get_var, to select plankton functional type
- Parameters:
pft_index – the index of plankton functional type
prefix – ‘Plankton’ or ‘Export’
element – ‘C’, ‘Fe’, ‘P’, ‘Si’, ‘N’
- Returns:
a GenieArray object
Example#
>>> from cgeniepy.ecology import EcoModel
>>> ### initialise a model object >>> model = EcoModel("path_to_GENIE_output")
>>> ### get PFT-1 carbon biomass data >>> model.get_pft(1, "Plankton", "C")
>>> ### get a list of PFT carbon biomass data >>> model.get_pft([1, 2, 3], "Plankton", "C")
>>> ### get all phytoplankton carbon biomass data >>> model.get_pft('phyto', "Plankton", "C")
>>> ### get all zooplankton carbon biomass data >>> model.get_pft('zoo', "Plankton", "C")
>>> ### get all plankton carbon biomass data >>> model.get_pft('all', "Plankton", "C")
- class cgeniepy.CommunityPalette(name=None, *args, **kwargs)#
A class to handle community-driven colormaps
- name = None#
- get_palette(cmap_name, N=256, reverse=False, alpha=None)#
community-driven colormaps with multiple sources
- Parameters:
cmap_name (str) – colormap name, can be found in avail_palette()
- Returns:
colormap
XML data: https://sciviscolor.org/colormaps/ txt data: from original packages
- avail_palettes(show_ferret_data=True)#
return a list of colormap names
- to_rgb()#
- to_hex(unique=True)#
- create_colormap(positions, colors)#
Create a colormap with specified positions and colors.
- Args:
positions (list): List of floats indicating the positions of colors in the colormap. colors (list): List of RGB tuples representing the colors.
- Returns:
LinearSegmentedColormap: The created colormap.
- __repr__()#
- cgeniepy.sample_model(model_type='GenieModel', *args, **kwargs)#
- cgeniepy.load_obs(grid='worjh2')#
- cgeniepy.register_cmap()#