cgeniepy ======== .. py:module:: cgeniepy Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/cgeniepy/array/index /autoapi/cgeniepy/chem/index /autoapi/cgeniepy/data/index /autoapi/cgeniepy/ecology/index /autoapi/cgeniepy/grid/index /autoapi/cgeniepy/model/index /autoapi/cgeniepy/plot/index /autoapi/cgeniepy/skill/index /autoapi/cgeniepy/table/index /autoapi/cgeniepy/utils/index Classes ------- .. autoapisummary:: cgeniepy.GenieModel cgeniepy.EcoModel cgeniepy.CommunityPalette Functions --------- .. autoapisummary:: cgeniepy.sample_model cgeniepy.load_obs cgeniepy.register_cmap Package Contents ---------------- .. py:class:: GenieModel(model_path: Union[str, List, Tuple], gemflag=None) Bases: :py:obj:`object` GenieModel is the interface to cGENIE output .. py:attribute:: model_path .. py:attribute:: ncvar_dict .. py:attribute:: tsvar_list .. py:method:: __repr__() .. py:method:: get_var(var: Union[str, List, Tuple], attrs=None) Get the data of target variable. A list of variables is supported as well. :param var: the name of target variable :param 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") .. py:method:: get_config(config_name='BIOGEM') .. py:method:: get_ts(var: str, to_ScatterData=False) read in time series output of GENIE :param var: the name of the target variable :return: a pandas DataFrame .. py:method:: get_diag_avg(target_year, is_index=False, pattern_year='\\d+', pattern_year_digit='\\d{3}') read the diagnostic file of cGENIE :param target_year: the target year of the diagnostic file :param is_index: if True, target_year is the index of the sorted years :param pattern: the pattern of the diagnostic file name :return: a pandas DataFrame Example ---------- >>> from cgeniepy.model import GenieModel >>> model = GenieModel("path_to_GENIE_output") >>> model.get_diag_avg(9999) .. py:method:: grid_mask() cGENIE continent mask array (by setting zero values), either calculated from existing data or using biogem.grid_mask .. py:method:: grid_category() an alogirthm to define surface grid catogories depending on the land-sea mask 0: coastal sea 1: land 2: open ocean .. py:method:: grid_area() return the grid area array in used in this model experiment, unit: m2 .. py:method:: grid_mask_3d() return the 3d mask of the grid used in this model experiment .. py:method:: grid_topo() return the topography of the grid used in this model experiment .. py:method:: grid_zt_edges() return the depth edges of the grid used in this model experiment .. py:method:: grid_lat_edges() return the latitude edges of the grid used in this model experiment .. py:method:: grid_lon_edges() return the longitude edges of the grid used in this model experiment .. py:method:: grid_zt_depths() return the depth of the grid used in this model experiment .. py:method:: grid_volume() return the grid volume array (3d) in m3 .. py:class:: EcoModel(*args, **kwargs) Bases: :py:obj:`cgeniepy.model.GenieModel` EcoModel 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") .. py:attribute:: eco_varlist .. py:attribute:: plank_n .. py:attribute:: phyto_indices .. py:attribute:: zoo_indices .. py:attribute:: mixo_indices .. py:attribute:: phyto_n .. py:attribute:: zoo_n .. py:attribute:: mixo_n .. py:method:: eco_pars() Get all the ecophysiological parameters used in the model :return: a pandas DataFrame object .. py:method:: get_pft(pft_index, prefix='Plankton', element='C') a variant of GenieModel's `get_var`, to select plankton functional type :param pft_index: the index of plankton functional type :param prefix: 'Plankton' or 'Export' :param element: 'C', 'Fe', 'P', 'Si', 'N' :return: 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") .. py:class:: CommunityPalette(name=None, *args, **kwargs) A class to handle community-driven colormaps .. py:attribute:: name :value: None .. py:method:: get_palette(cmap_name, N=256, reverse=False, alpha=None) community-driven colormaps with multiple sources :param cmap_name: colormap name, can be found in avail_palette() :type cmap_name: str :returns: colormap XML data: https://sciviscolor.org/colormaps/ txt data: from original packages .. py:method:: avail_palettes(show_ferret_data=True) return a list of colormap names .. py:method:: to_rgb() .. py:method:: to_hex(unique=True) .. py:method:: 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. .. py:method:: __repr__() .. py:function:: sample_model(model_type='GenieModel', *args, **kwargs) .. py:function:: load_obs(grid='worjh2') .. py:function:: register_cmap()