gnome.utilities.cache
¶
cache system for caching element data on disk for accessing again for output, etc.
Module Contents¶
Classes¶
Cache for element data -- i.e. the data associated with the particles. |
Functions¶
|
Deletes a cache dir. |
Attributes¶
- gnome.utilities.cache._cache_dir¶
- exception gnome.utilities.cache.CacheError¶
Bases:
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.
- gnome.utilities.cache.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
- class gnome.utilities.cache.ElementCache(cache_dir=None, enabled=True)¶
Bases:
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
- Parameters:
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
- __del__()¶
Clear out the cache when this object is deleted
- _make_filename(step_num, uncertain=False)¶
Returns a filename of the temp file generated from step_num
- Parameters:
step_num – the model step number that is saved/reloaded
This here so that loading and saving use the same code
- create_new_dir(cache_dir=None)¶
- save_timestep(step_num, spill_container_pair)¶
add a time step of data to the cache
- Parameters:
step_num – the step number of the data
spill_container – the spill container at this step
- load_timestep(step_num)¶
Returns a SpillContainer with the data arrays cached on disk
- Parameters:
step_num – the step number you want to load.
- _set_weathering_data(sc, data)¶
add mass balance data to arrays
- _get_weathering_data(data_arrays)¶
- rewind()¶
Rewinds the cache – clearing out everything