landlab.components.species_evolution.record

Structure to store data over time for SpeciesEvolver.

class Record[source]

Bases: object

Structure to store data over time for SpeciesEvolver.

This object is intended to be used internally by the SpeciesEvolver component and its objects.

The record attribute, _dict is a dictionary that stores the data of the record. The dictionary key, ‘time’ is created when the record is initialized. All other dictionary keys are variables of the record.

The values of variables correspond to the time values elementwise. For example, if the time values are [0, 1, 2] and the values of var1 are [5, 6, 7] then the values of var 1 at time 0, 1, and 2 are 5, 6, and 7, respectively.

A new record entry is created by advancing the record time with the method, advance_time. Variables can be added to the record with the method, set_value. Variable values not set at a time have a value of nan.

Instantiate Record.

Parameters:

initial_time (float or int) – The initial time in the record.

__init__(initial_time=0)[source]

Instantiate Record.

Parameters:

initial_time (float or int) – The initial time in the record.

__len__()[source]

The count of record time steps.

__new__(**kwargs)
advance_time(dt)[source]

Advance the time in the record by a time step duration.

This method creates a new record entry. The new entry includes the time and all variables have a value of nan for this time. The time of the entry is the sum of the latest time of the record and the time step duration, dt.

Parameters:

dt (float or int) – The time step duration to advance time in the record.

property count_of_time_steps

The count of record time steps.

property data_frame

A Pandas DataFrame of the record.

property earliest_time

The earliest time in the record.

get_value(var_name, time=nan)[source]

Get the value of a variable.

Parameters:
  • var_name (string) – The name of the variable to get.

  • time (float or int, optional) – The time of the variable to get. The latest time in the record is the default.

Returns:

The value of var_name that has the type, T. nan is returned if var_name does not exist in the record.

Return type:

T

increment_value(var_name, increase, time=nan)[source]

Increment the value of a variable.

Parameters:
  • var_name (string) – The name of the variable to set. A new variable is created if var_name does not exist in the record.

  • increase (T) – The value to increase var_name. The type, T should be an appropriate type for var_name.

  • time (float or int, optional) – The time in the record to change a variable. The latest time in the record is the default.

property latest_time

The latest time in the record.

property prior_time

The penultimate time in the record.

nan is returned if the record stores only one time step.

set_value(var_name, value, time=nan)[source]

Set the value of a variable.

Parameters:
  • var_name (string) – The name of the variable to set. A new variable is created if var_name does not exist in the record.

  • value (T) – The value of var_name. The type, T should be an appropriate type for var_name.

  • time (float or int, optional) – The time in the record to change a variable. The latest time in the record is the default.

property times

The times stored in the record.

property variables

The variables in the record.