pycopanlpjml.cell#
Cell entity type (mixin) class for copan:LPJmL component.
- class pycopanlpjml.cell.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