Utility¶
- rascal.util.edlen_refraction(wavelengths, temperature, pressure, vapour_partial_pressure)[source]¶
Appendix A.IV of https://emtoolbox.nist.gov/Wavelength/Documentation.asp
- rascal.util.filter_intensity(lines, min_intensity=0)[source]¶
Filters a line list by an intensity threshold
- Parameters
lines (list[tuple (str, float, float)]) – A list of input lines where the 2nd parameter is intensity
min_intensity (int) – Intensity threshold
- Returns
lines – Filtered line list
- Return type
list
- rascal.util.filter_separation(wavelengths, min_separation=0)[source]¶
Filters a wavelength list by a separation threshold.
- Parameters
wavelengths (list) – List of input wavelengths
min_separation (int) – Separation threshold, Ansgtrom
- Returns
distance_mask – Mask of values which satisfy the separation criteria
- Return type
list
- rascal.util.filter_wavelengths(lines, min_atlas_wavelength, max_atlas_wavelength)[source]¶
Filters a wavelength list to a minimum and maximum range.
- Parameters
lines (list) – List of input wavelengths
min_atlas_wavelength (int) – Min wavelength, Ansgtrom
max_atlas_wavelength (int) – Max wavelength, Angstrom
- Returns
lines – Filtered wavelengths within specified range limit
- Return type
list
- rascal.util.gauss(x, a, x0, sigma)[source]¶
1D Gaussian
- Parameters
x – value or values to evaluate the Gaussian at
a (float) – Magnitude
x0 (float) – Gaussian centre
sigma (float) – Standard deviation (spread)
- Returns
out – The Gaussian function evaluated at provided x
- Return type
list
- rascal.util.get_vapour_partial_pressure(relative_humidity, vapour_pressure)[source]¶
Appendix A.II of https://emtoolbox.nist.gov/Wavelength/Documentation.asp
- rascal.util.get_vapour_pressure(temperature)[source]¶
Appendix A.I of https://emtoolbox.nist.gov/Wavelength/Documentation.asp
- rascal.util.load_calibration_lines(elements=[], min_atlas_wavelength=3000, max_atlas_wavelength=15000, min_intensity=10, min_distance=10, vacuum=False, pressure=101325.0, temperature=273.15, relative_humidity=0.0)[source]¶
Load calibration lines from the standard NIST atlas. Rascal provides a cleaned set of NIST lines that can be used for general purpose calibration. It is recommended however that for repeated and robust calibration, the user should specify an instrument-specific atlas.
Provide a wavelength range suitable to your calibration source. You can also specify a minimum intensity that corresponds to the values listed in the NIST tables.
If you want air wavelengths (default), you can provide atmospheric conditions for your system. In most cases the default values of standard temperature and pressure should be sufficient.
- Parameters
elements (list) – List of short element names, e.g. He as per NIST
min_atlas_wavelength (int) – Minimum wavelength to search, Angstrom
max_atlas_wavelength (int) – Maximum wavelength to search, Angstrom
min_intensity (int) – Minimum intensity to search, per NIST
max_intensity (int) – Maximum intensity to search, per NIST
vacuum (bool) – Return vacuum wavelengths
pressure (float) – Atmospheric pressure, Pascal
temperature (float) – Temperature in Kelvin, default room temp
relative_humidity (float) – Relative humidity, percent
- Returns
out – Emission lines corresponding to the parameters specified
- Return type
list
- rascal.util.refine_peaks(spectrum, peaks, window_width=10, distance=None)[source]¶
Refine peak locations in a spectrum from a set of initial estimates.
This function attempts to fit a Gaussian to each peak in the provided list. It returns a list of sub-pixel refined peaks. If two peaks are very close, they can be refined to the same location. In this case only one of the peaks will be returned - i.e. this function will return a unique set of peak locations.
- Parameters
spectrum (list) – Input spectrum (list of intensities)
peaks (list) – A list of peak locations in pixels
window_width (int) – Size of window to consider in fit either side of initial peak location
- Returns
refined_peaks – A list of refined peak locations
- Return type
list
- rascal.util.vacuum_to_air_wavelength(wavelengths, temperature=273.15, pressure=101325, relative_humidity=0)[source]¶
The conversion follows the Modified Edlén Equations
https://emtoolbox.nist.gov/Wavelength/Documentation.asp
pressure drops by ~10% per 1000m above sea level temperature depends heavily on the location relative humidity is between 0-100, depends heavily on the location
- Parameters
wavelengths (float or numpy.array) – Wavelengths in vacuum
temperature (float) – In unit of Kelvin
pressure (float) – In unit of Pa
relative_humidity (float) – Unitless in percentage (i.e. 0 - 100)
- Returns
air wavelengths – The wavelengths in air given the condition
- Return type
float or numpy.array