History – Reference Guide

This guide is for versions 1.0.0rc.6+ (Release Candidate)

Source code

Class History

        For the management of historical data of various types,
        each of which relies on a child class.
        This base (parent) class is NOT meant for the end user
        - and should NOT be directly instantiated;
        it provides common properties and methods.

        :param active:      Flag indicating whether the history is enabled
        :param chem_labels: List of chemicals for which history is to be kept; use None to mean all
        :param frequency:   How many simulation cycles to wait until taking another data snapshot
        
nameargumentsreturns
is_enabled
        Return True if the history-keeping is enabled

        :return:
        
nameargumentsreturns
get_history

        :return:    Object of one of the following types:
                        CollectionTabular, CollectionArray, Collection
        
nameargumentsreturns
enable_history_commonfrequency=1, chem_labels=NoneNone
        Activate the keeping of historical data (the specifics
        will depend on the child class)

        :param frequency:   How many simulation cycles to wait until taking another data snapshot
        :param chem_labels:
        :return:            None
        
nameargumentsreturns
disable_historyNone
        Inactivate any further captures related to this history.
        Nothing is deleted: neither the history nor its parameters;
        this history-keeping may later be resumed (possibly with different parameters)
        by a call to enable_history()

        :return:    None
        
nameargumentsreturns
to_capturestep_count=None, extra=Falsebool
        Return True if various criteria indicate that a snapshot should be taken at the give step_count;
        False otherwise

        Note that when step_count is 0 there's no capture, unless the frequency is 1

        :param step_count:  None means always capture
        :param extra:       [OPTIONAL] If True, it means that this is a special extra capture;
                                the capture frequency will NOT considered in the
                                decision about saving it, but an extra check will be performed
                                to make sure it's not a duplicate of the earlier capture
        :return:
        
nameargumentsreturns
start_csv_loglog_file :strNone
        Register the specified filename for all future CSV logs.
        Any existing file by that name will get over-written.

        :param log_file:Name of a file to use for the CSV logs
        :return:        None
        
nameargumentsreturns
save_snapshot_commonsystem_time, data_snapshot, step_count=None, caption=""str

        :param system_time:
        :param data_snapshot:   Data format will vary in different child classes
        :param step_count:
        :param caption:         [OPTIONAL] String to save alongside this snapshot; if not provided,
                                    the object property self.initial_caption is used, if that was set
        :return:                The caption that was actually used
        
nameargumentsreturns
set_caption_last_snapshotcaptionNone
        Add a caption to the very last entry in the system history.
        No action taken is caption is None

        :param caption:
        :return:        None
        



Class HistoryBinConcentration

    For the management of historical data for bin concentrations
    
nameargumentsreturns
__init__bins=None, *args, **kwargs

        :param bins:    List of bin addresses for which history is to be kept; use None to mean all
        :param args:
        :param kwargs:
        
nameargumentsreturns
enable_historyfrequency=1, chem_labels=None, bins=NoneNone
        Request history capture, with the specified parameters.
        If history was already enabled, this function can be used to alter its capture parameters.

        :param frequency:   [OPTIONAL] How many simulation cycles to wait until taking another data snapshot
        :param chem_labels: [OPTIONAL] List of chemicals to include in the history;
                                if None (default), include them all.
        :param bins:        [OPTIONAL] Bin address, or list of them;
                                if None (default), include them all.
        :return:            None
        
nameargumentsreturns
save_snapshotsystem_time, data_snapshot, step_count=None, caption=""None

           EXAMPLE of data_snapshot (for 1D) systems:
                { 5: {"A": 1.3, "B": 3.9},
                  8: {"A": 4.6, "B": 2.7}
                }

           EXAMPLE of data_snapshot (for 2D) systems:
                { (0,0): {"A": 1.3, "B": 3.9},
                  (3,5): {"A": 4.6, "B": 2.7}
                }
        :param system_time:     The time of this data snapshot
        :param data_snapshot:
        :param step_count:
        :param caption:         [OPTIONAL] String to save alongside this snapshot
        :return:                None
        
nameargumentsreturns
bin_history_sizeint
        Return the number of data points in the history kept so far

        :return:    An integer
        
nameargumentsreturns
bin_historybin_address, include_captions=False, downsize=1
        Return the history at the given bin, as a Pandas dataframe.
        The first column is "SYSTEM TIME", and the other ones are the various chemicals for which
        history had been enabled.
        If no historical data is located, an informational string is returned instead

        :param bin_address:         A single bin address.  EXAMPLES, in 1D:  8   In 2D :  (3,3)
        :param include_captions:    [OPTIONAL] If True, the captions are returned as an extra "caption" column at the end
        :param downsize:            [OPTIONAL] Pare down the returned history.
                                        If different from 1, include only every n-th entry, where n = downsize,
                                        starting with the initial (0-th) one.  The final row is also always included, regardless.
                                        Note: handy when the user unwisely collected an excessive amount of history!
        :return:                    A Pandas data frame,
                                        or a string with diagnostic suggestions if no historical data is present
        



Class HistoryReactionRate

    For the management of historical reaction-rate data for Uniform Compartments
    
nameargumentsreturns
__init__rxns=None, *args, **kwargs

        :param rxns:    List of reactions (identified by their index) for which history is to be kept;
                            use None to mean all
        :param args:
        :param kwargs:
        
nameargumentsreturns
enable_historyfrequency=1, chem_labels=None, rxns=NoneNone
        Request history capture, with the specified parameters.
        If history was already enabled, this function can be used to alter its capture parameters.

        :param frequency:   [OPTIONAL] How many simulation cycles to wait until taking another data snapshot
        :param chem_labels: [OPTIONAL] List of chemicals to include in the history;
                                if None (default), include them all.
        :param rxns:
        :return:            None
        
nameargumentsreturns
save_snapshotsystem_time, data_snapshot, step_count=None, caption=""None

           EXAMPLE of data_snapshot:
                {"rxn1_rate": 6.3, "rxn2_rate": 14.3}

        :param system_time:
        :param data_snapshot:
        :param step_count:
        :param caption:         [OPTIONAL] String to save alongside this snapshot
        :return:                None
        



Class HistoryUniformConcentration

    For the management of historical concentration data for Uniform Compartments
    
nameargumentsreturns
__init__*args, **kwargs

        :param args:
        :param kwargs:
        
nameargumentsreturns
enable_historyfrequency=1, chem_labels=NoneNone
        Request history capture, with the specified parameters.
        If history was already enabled, this function can be used to alter its capture parameters.

        :param frequency:   [OPTIONAL] How many simulation cycles to wait until taking another data snapshot
        :param chem_labels: [OPTIONAL] List of chemicals to include in the history;
                                if None (default), include them all.
        :return:            None
        
nameargumentsreturns
save_snapshotsystem_time, data_snapshot, step_count=None, caption=""None

        :param system_time:
        :param data_snapshot:   EXAMPLE: {"A": 1.3, "B": 4.9}
        :param step_count:
        :param caption:         [OPTIONAL] String to save alongside this snapshot
        :return:                None