ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
utils.py File Reference

Namespaces

namespace  wasatch
 This package provides control of Wasatch Photonics spectrometers.
 
namespace  wasatch.utils
 

Functions

 wasatch.utils.all_same (a)
 
 wasatch.utils.apply_boxcar (a, half_width)
 apply a boxcar convolution of the given half_width to input array 'a'
 
 wasatch.utils.area_under_peak (spectrum, x_axis, x_index, boxcar_half_width=0)
 integrate the 'area under the curve' for the given spectrum and x_axis, using the peak centered on x_axis, with optional smoothing given the boxcar width.
 
 wasatch.utils.ascii_spectrum (spectrum, rows, cols, x_axis, x_unit)
 render a spectrum as ASCII-art
 
 wasatch.utils.check_admin ()
 
 wasatch.utils.clamp_to_int16 (n)
 
 wasatch.utils.clean_nan (a)
 
 wasatch.utils.coeffs_look_valid (coeffs, count=None)
 Can be used as a sanity-check for any set of coefficients.
 
 wasatch.utils.dict_get_norm (d, keys)
 Similar to dict.get(), but case-insensitive and normalizes-out spaces, underscores, periods and hyphens.
 
 wasatch.utils.dict_get_path (d, keys)
 Similar to dict.get(), but takes a list of keys to be traversed in sequence.
 
 wasatch.utils.dump (foo, indent=0)
 similar to Perl's Data::Dumper
 
 wasatch.utils.find_local_maxima (a, x_axis, center, tolerance=0)
 Given a spectrum (array 'a'), with an x_axis, a 'center' along that x_axis, and an allowed 'tolerance' (in same units as the x_axis), find the local maxima within 'tolerance' of 'center'.
 
 wasatch.utils.find_nearest_index (L, value)
 
 wasatch.utils.find_nearest_value (L, value)
 
 wasatch.utils.find_peak_feet_indices (spectrum, x_axis, x_index, boxcar_half_width=0)
 Given a spectrum and an x_axis, find the indexes of the left and right 'feet' of the peak centered on x_index.
 
 wasatch.utils.from_db_to_linear (x)
 
 wasatch.utils.from_linear_to_db (x)
 
 wasatch.utils.generate_excitation (wavelengths, wavenumbers)
 If we've loaded a CSV that had wavelength and wavenumber columns, but no metadata, use this to infer the excitation wavelength.
 
 wasatch.utils.generate_wavelengths (pixels, coeffs)
 expand 3rd-order wavelength polynomial into array of wavelengths
 
 wasatch.utils.generate_wavelengths_from_wavenumbers (excitation, wavenumbers)
 
 wasatch.utils.generate_wavenumbers (excitation, wavelengths, wavenumber_correction=0)
 convert wavelengths into Raman shifts in 1/cm wavenumbers from the given excitation wavelength
 
 wasatch.utils.get_default_data_dir ()
 copy of enlighten.common method of the same name
 
 wasatch.utils.get_pathnames_from_directory (rootdir, pattern=None, recursive=False)
 iterate down a directory, returning pathnames that match the given pattern
 
 wasatch.utils.interpolate_array (spectrum, old_axis, new_axis)
 Interpolate the passed spectrum over a fixed x-axis (e.g.
 
 wasatch.utils.interpolate_value (spectrum, old_axis, x)
 I might be making this more difficult than it needs to be.
 
 wasatch.utils.load_json (pathname)
 convenience wrapper to load a JSON file
 
 wasatch.utils.parabolic_approximation (pixel, x, y)
 Given an array of doubles and a peak index, use the peak and its two neighbors to form a parabola and return the interpolated maximum height of the parabola.
 
 wasatch.utils.peak_height_above_background (spectrum, x_axis, x_index, boxcar_half_width=0)
 
 wasatch.utils.pixel_to_wavelength (int x, list[float] coeffs)
 
 wasatch.utils.remove_unicode (s)
 convert unicode string to ascii
 
 wasatch.utils.resize_file (path, nbytes, ensure_no_overwrite=False)
 Keep only the last nbytes of a text file specified by path.
 
 wasatch.utils.stomp_first (a, count)
 "Stomps" the first "count" elements with the first non-stomped value.
 
 wasatch.utils.stomp_last (a, count)
 "stomps" the last "count" elements with the last non-stomped value
 
 wasatch.utils.timestamp ()
 
 wasatch.utils.to_bool (value)
 
 wasatch.utils.to_hex (a)
 
 wasatch.utils.truthy (flag)
 
 wasatch.utils.twos_complement (val, bits)
 
 wasatch.utils.uint16_to_little_endian (values)
 
 wasatch.utils.update_obj_from_dict (obj, d)
 given a destination object and a source dictionary, update any existing attributes of the destination object from like-named keys in the source dictionary
 
 wasatch.utils.vercmp (a, b, delim=None)
 
 wasatch.utils.wavelength_to_wavenumber (wavelength, excitation)
 convert a single wavelength to wavenumber
 
 wasatch.utils.wavenumber_to_wavelength (excitation, wavenumber)
 convert a single (uncorrected) wavenumber to wavelength
 

Variables

 wasatch.utils.log = logging.getLogger(__name__)