yatsm.cache module¶
Functions related to writing to and retrieving from cache files
-
yatsm.cache.
get_line_cache_name
(dataset_config, n_images, row, nbands)[source]¶ Returns cache filename for specified config and line number
Parameters: Returns: filename of cache file
Return type:
-
yatsm.cache.
get_line_cache_pattern
(row, nbands, regex=False)[source]¶ Returns a pattern for a cache file from a certain row
This function is useful for finding all cache files from a line, ignoring the number of images in the file.
Parameters: Returns: filename pattern for cache files from line
row
Return type:
-
yatsm.cache.
read_cache_file
(cache_filename, image_IDs=None)[source]¶ Returns image data from a cache file
If
image_IDs
is not None this function will try to ensure data from cache file come from the list of image IDs provided. If cache file does not contain a list of image IDs, it will skip the check and return cache data.Parameters: Returns: - Return Y as np.ndarray if possible and if the
cache file passes the consistency check specified by
image_IDs
, else None
Return type: np.ndarray, or None
-
yatsm.cache.
test_cache
(dataset_config)[source]¶ Test cache directory for ability to read from or write to
Parameters: dataset_config¶ – dictionary of dataset configuration options Returns: - tuple of bools describing ability to read from and write to
- cache directory
Return type: tuple
-
yatsm.cache.
update_cache_file
(images, image_IDs, old_cache_filename, new_cache_filename, line, reader)[source]¶ Modify an existing cache file to contain data within images
This should be useful for updating a set of cache files to reflect modifications to the timeseries dataset without completely reading the data into another cache file.
For example, the cache file could be updated to reflect the deletion of a misregistered or cloudy image. Another common example would be for updating cache files to include newly acquired observations.
Note that this updater will not handle updating cache files to include new bands.
Parameters: - images¶ – list of new image filenames
- image_IDs¶ – list of new image identifying strings
- old_cache_filename¶ – filename of cache file to update
- new_cache_filename¶ – filename of new cache file which includes modified data
- line¶ – the line of data to be updated
- reader¶ – GDAL or BIP image reader function from
yatsm.io.stack_line_readers
Raises: ValueError
– Raise error if old cache file does not recordimage_IDs