:py:mod:`gnome.utilities.cache` =============================== .. py:module:: gnome.utilities.cache .. autoapi-nested-parse:: cache system for caching element data on disk for accessing again for output, etc. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.utilities.cache.ElementCache Functions ~~~~~~~~~ .. autoapisummary:: gnome.utilities.cache.clean_up_cache Attributes ~~~~~~~~~~ .. autoapisummary:: gnome.utilities.cache._cache_dir .. py:data:: _cache_dir .. py:exception:: CacheError Bases: :py:obj:`Exception` Here so we can be sure the user knows the error is coming from here Initialize self. See help(type(self)) for accurate signature. .. py:function:: clean_up_cache(dir_name=_cache_dir) Deletes a cache dir. Designed to be called at program exit. and/or when individual cache objects are deleted raises a warning if there is problem deleting a particular directory .. py:class:: ElementCache(cache_dir=None, enabled=True) Bases: :py:obj:`object` Cache for element data -- i.e. the data associated with the particles. This caches UncertainSpillContainerPair The cache can be accessed to re-draw the LE movies, etc. TODO: This is a really fragile module in terms of handling multiple instances. The __del__() method of previous instances can clear the _cache_dir at the whim of the GC. We may want to manage this differently. initialize a new cache object :param cache_dir=None: full path to the directory where the cache should be stored. If not provided, a temp dir will be created by the python tempfile module .. py:method:: __del__() Clear out the cache when this object is deleted .. py:method:: _make_filename(step_num, uncertain=False) Returns a filename of the temp file generated from step_num :param step_num: the model step number that is saved/reloaded This here so that loading and saving use the same code .. py:method:: create_new_dir(cache_dir=None) .. py:method:: save_timestep(step_num, spill_container_pair) add a time step of data to the cache :param step_num: the step number of the data :param spill_container: the spill container at this step .. py:method:: load_timestep(step_num) Returns a SpillContainer with the data arrays cached on disk :param step_num: the step number you want to load. .. py:method:: _set_weathering_data(sc, data) add mass balance data to arrays .. py:method:: _get_weathering_data(data_arrays) .. py:method:: rewind() Rewinds the cache -- clearing out everything