Tutorial: using persistant data and accessing previous convolution steps

In this notebook we cover how to access and use persistent data, a dictionary that the user can use to store and retain data throughout the convolution, and the previous convolution results.

To use both persistent_data and previous_convolution_results, the user must configure the convolution to be sequential, rather than multiprocessed by setting

convolution_config['multiprocessing'] = False

The reason is that while the multiprocessing approach has its advantage of being fast, it also splits all the convolution steps into different processes, making it hard to access information about the (chronologically) previous convolution step. By performing the convolution sequentially, with a single core, we are able to store and pass information to the next convolution step.

Most of routines are handled just in the same way, except for that in the post_convolution_function one can now access persistent_data and previous_convolution_results. This functionality is available in all combinations of convolution-type, time-type, and input-data types. Lets look at an example.

def post_convolution_function(
    config,
    sfr_dict,
    data_dict,
    convolution_results,
    convolution_instruction,
    persistent_data,
    previous_convolution_results,
):
    """
    Example post-convolution code for persistent data and previous convolution results.

    """

    print(persistent_data)
    print(previous_convolution_results)

    if "test" not in persistent_data:
        persistent_data["test"] = 0
    persistent_data["test"] += 1

    return convolution_results
{'test': 1}
{'convolution_results': {'yield': <Quantity [1.e-05] 1 / yr>}}
{'test': 2}
{'convolution_results': {'yield': <Quantity [1.e-05] 1 / yr>}}
...

note: here we used a constant star formation rate.

Future functionality

While keeping track of some data during the convolution itself, unless any derived quantity from this data can affect the next timestep (be it total star formation rate, metallicity distribution, etc), this functionality is somewhat limited in its use-case potential. In future releases we plan to allow, in certain circumstances, to have the user update certain global and star-formation specific properties during the convolution.