Reference 〉 Class

Data( Helipad model )

The Data class is an interface for all the data to be collected during a model’s run. The object is subscriptable: data[key] will return the column of the data labelled key.

This class should not be instantiated by user code; it is initialized during model setup and stored as model.data.

Initialization Parameters

  • model Helipad, required

    The model object.

Methods

Click a method name for more detailed documentation.

  • addReporter( key, func, smooth )

    Registers a column in the data to be collected each period. Typically used in conjunction with the various reporter methods of the Data class, but open-ended user functions can also be used with the @reporter decorator.

  • agentReporter( key, prim, breed, … )

    Generates a reporter function that takes the model object and returns a summary statistic over all the values of an agent property.

  • getLast( key, n )

    Returns the latest recorded value or values from the model's data.

  • modelReporter( key )

    Generates a reporter function that takes the model object and returns the named attribute of the model.

  • removeReporter( key )

    Removes a column and its subsidiaries (e.g. percentiles) from the data collection, stops its reporter, and removes any associated series. This function should not be used while a model is active.

  • reset( )

    Clears all model data. Generally used to clean up between model runs. This function takes no arguments.

  • saveCSV( filename )

    Outputs the model's data to a CSV file in the same directory as the running program. CSV output can be modified immediately prior to saving using the saveCSV hook.

  • collect( model )

    Iterates over all the registered reporters and collects model data each period.

    This function is called from model.step() and should not be called from user code.

Properties

  • all dict

    A dict of all model data, with keys corresponding to registered reporters. See data.addReporter().

    Initial value: {}

  • dataframe Pandas.DataFrame

    A Pandas dataframe with the model run data. Useful for statistical functions.

    Initial value: Pandas.DataFrame({})

  • reporters dict{str:Reporter}

    Contains the registered data reporters. See data.addReporter().

    Initial value: {}

  • columns dict{str:Reporter}

    A dict of columns and the Reporter object associated with it. Calling Data.columns.keys() is less computationally expensive than calling Data.all.keys(). It also does not correspond to Data.reporters.keys(), because multiple columns may be associated with the same reporter (e.g. with percentile bars, smoothing, or ± standard deviations).

Hooks

Click a hook name for more detailed documentation.

  • saveCSV( data, model )

    Allows CSV output to be filtered immediately before saving.

  • dataCollect( data, t )

    Runs at the end of each model step immediately before the period's data is collected.

    If you need a hook immediately after data is collected, use modelPostStep and access the Data object with model.data.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.

History