Utility functions#
Submodule for utility functions in espresso.
Some of these functions are used by contributors to conveniently implement their problem class. Others can be utilised by users to perform analysis on inversion results.
Important
Please always use absolute_path or loadtxt when trying to load data
from a relative path into an Espresso problem class.
Functions
- utils.absolute_path()#
Returns the absolute path of a data file
Please always use this function or
loadtxtwhen trying to load data from a relative path into an Espresso problem class.- Parameters:
relative_path (str) – The relative path of the file you want the absoluate path for
Examples
>>> from espresso.utils import absolute_path >>> from PIL import Image >>> png = Image.open(absolute_path("data/csiro_logo.png"))
- utils.loadtxt(*args, **kwargs)#
Wrapper of
numpy.loadtxtgiven a relative pathPlease always use this function or
absolute_pathwhen trying to load data from a relative path into an Espresso problem class.- Parameters:
relative_path (str) – The relative path of the file you want to load
*args (any) – Passed directly into
numpy.loadtxt**kwargs (any) – Passed directly into
numpy.loadtxt
Examples
>>> from espresso.utils import loadtxt >>> data = loadtxt("data/example1.dat") >>> data array([[0. , 0.0323, 5.9987, 1. , 0.0323, 2.057 ], [0. , 0.0323, 6.3879, 1. , 0.0645, 2.1543], [0. , 0.0323, 1.8923, 1. , 0.0968, 0.6279], ..., [1. , 0. , 4.1087, 0. , 1. , 0.5583], [1. , 0. , 3.9118, 1. , 0. , 3.9118], [1. , 0. , 9.2198, 1. , 1. , 3.2873]])