pycopanlpjml.Cell#
- class pycopanlpjml.Cell(*args, **kwargs)[source]#
Bases:
DUMMYAn LPJmL-integrating cell entity.
Cell entity type (mixin) class for copan:LPJmL component. It inherits the copan:CORE cell entity and structure and integrates LPJmL input and output data (attributes) as well as grid, country and area information as pycoupler.LPJmLData and pycoupler.LPJmLDataSet instances. A cell instance should hold (numpy) views of attributes to the corresponding cell in the copan:LPJmL world instance.
- Parameters:
input (pycoupler.LPJmLDataSet) – Coupled LPJmL model input.
output (pycoupler.LPJmLData) – Coupled LPJmL model output.
grid (pycoupler.LPJmLData) – Grid of the LPJmL model.
country (str) – Country of the cell as a country code.
area (float) – Area of the cell in square meters.
kwargs (dict, optional) – Additional keyword arguments.
- Returns:
An instance of the copan:LPJmL Cell.
- Return type:
Examples
In this example, we will demonstate an exammplaric initialization of a pycopanlpjml.Cell instance independent of the pycopanlpjml.Component that automatizes the initializtion of all cells belonging to a world.
A prerequisite is the start of an LPJmL simulation in coupled mode described in … To connect to the LPJmL simulation we use the pycoupler.LPJmLCoupler class.
>>> from pycoupler.coupler import LPJmLCoupler >>> from pycopanlpjml import World
The configuration file is a json file that holds the configuration for the integrated copan:LPJmL model simulation.
>>> config_file = "path/to/config_file.json" >>> lpjml = LPJmLCoupler( ... config_file=config_file, ... host="localhost", ... port=2042, ... )
Initialize LPJmL world, all data is read/send from and to the LPJmL model >>> world = World( … input=lpjml.read_input(copy=False), … output=lpjml.read_historic_output(), … grid=lpjml.grid, … country=lpjml.country, … )
Initialize a (first) cell instance >>> cell_id = 0 >>> cell = Cell( … world=world, … input=world.input.isel(cell=cell_id), … output=world.output.isel(cell=cell_id), … grid=world.grid.isel(cell=cell_id), … country=world.country.isel(cell=cell_id), … area=world.area.isel(cell=cell_id) … )
>>> cell
- NEXTUID = 0#
- assert_valid()#
Make sure all variable values are valid.
By calling assert_valid for all Variables
- complete_values()#
assign default values to all unset Variables
- deactivate()#
Deactivate entity.
Remove Entity from its classes entities list and add it to its classes idle_entities list.
- delete()#
Delete entity from all lists.
- fossil_carbon = extensive variable 'fossil carbon stock' ((mass of C in any chemical compound, potentially accessible for human extraction and combustion)), not None, scale=ratio, datatype=<class 'float'>, unit=gigatonnes carbon [GtC], >=0#
- classmethod get_next_uid()#
Generate UIDs (Unique identifier).
- Returns:
current_uid – the current uid
- Return type:
- idle_entities = None#
- instances = None#
- land_area = variable 'land area', not None, scale=ratio, datatype=<class 'float'>, unit=square kilometers [km²], >0#
- location = variable 'location' (pair of coordinates?), scale=ratio, datatype=<class 'float'>#
- model = None#
- processes = []#
- reactivate()#
Reactivate entity.
Remove Entity from its classes idle_entities list and add it to its classes entities list.
- set_value(var, value)#
Dummy docstring
- terrestrial_carbon = extensive variable 'terrestrial carbon stock' ((mass of C in any chemical compound)), not None, scale=ratio, datatype=<class 'float'>, unit=gigatonnes carbon [GtC], >=0#
- variables = OrderedSet()#