Utils

A collection of various miscelaneous functionality that helps visualize the profiles and other utilities.

lfd.analysis.utils.PERSISTENT_CACHE = ['/home/docs/checkouts/readthedocs.org/user_builds/linear-feature-detector/envs/latest/lib/python3.7/site-packages/lfd-2.0.0-py3.7.egg/lfd/analysis/profiles/data', '/home/docs/checkouts/readthedocs.org/user_builds/linear-feature-detector/envs/latest/lib/python3.7/site-packages/lfd-2.0.0-py3.7.egg/lfd/analysis/plotting/data']

Cache for data that ships with lfd. Contains Rabina profiles as well as data that recreates plots from published papers. This cache is not meant to be written to be the user, for that see EPHEMERAL_CACHE.

lfd.analysis.utils.EPHEMERAL_CACHE = '/home/docs/.lfd'

Ephemeral cache is used for data created by the user. If it doesn’t exist one will be created at import.

lfd.analysis.utils.search_cached(name, ephemeral=True, persistent=True)[source]

Returns a list of files matching the given name. By default both caches are searched. If no matches are found an error is raised.

Parameters:
  • names (str`) – Name of the desired data file.
  • ephemeral (bool, optional) – Search ephemeral cache. True by default.
  • persistent (bool, optional) – Search persistent cache. True by default.
Returns:

filePaths – List of paths to all cached files that matched the given name pattern.

Return type:

list

Raises:

FileNotFoundError: – No cached files match given name.

lfd.analysis.utils.cache_data(data, name)[source]

Caches given array-like data under the given name. Utilizes numpy.save function to store the array like data.

Use get_data to retrieve the saved array.

Not thread safe.

Parameters:
  • data (np.array) – Array like object to save to cache. The EPHEMERAL_CACHE variable stores the location of the cache, by default at ~/.lfd/.
  • name (str, list or tuple) – Name under which the data will be cached. If the name conflicts the current date will pre pre-pended to the name.
lfd.analysis.utils.get_data(fname)[source]

If fname is an existing file tries to load the data in it. If fname is a file name searches the cache for matches. If the match is unique, loads it.

Parameters:fname (str) – File path or file name of the file to load. Does not support loading.
Returns:data – A numpy array with the requested data.
Return type:np.array
Raises:FileNotFoundError: – When fname could not be found.