Utilities¶
Additional functions used within the CARSpy program.
-
carspy.utils.
comp_normalize
(comp_dict, target=1.0)[source]¶ Normalize gas composition saved in a dictionary.
- Parameters
- comp_dictdict
Gas composition in the measurement volume stored in a dictionary.
- targetfloat, optional
Normalization factor, by default 1.0.
- Returns
- dict
Normalized gas composition stored in a dictionary.
-
carspy.utils.
downsample
(w, w_fine, spec_fine, mode='local_mean')[source]¶ Downsample a fine spectrum according to specified coarse spectral axis.
- Parameters
- wsorted 1-D array of floats
Coarse spectral axis (must be sorted and evenly spaced).
- w_finesorted 1-D array of floats
Fine spectral axis (must be sorted and evenly spaced).
- spec_fine1-D array of floats
Spectrum with fine resolution, must be of the same size as w_fine.
- modestr, optional
Two modes to choose from: ‘local-mean’ or ‘interp’, by default ‘local_mean’.
- Returns
- 1-D array of floats
Downsampled spectrum of the same size as w.
-
carspy.utils.
eq_comp
(*args, **kwargs)[source]¶ Calculate equilibrium composition at given temperature and pressure.
Attention
This function is only intended as a “dummy” template for setting up custom equilibrium solvers with
cantera
. Please be aware of the applicabilities and uncertainties of various kinetic mechanisms.- Parameters
- temperaturefloat
Temperature in [K].
- pressure1, float, optional
Pressure in bars.
- init_compdict
Initial gas mole fractions in a dictionary.
- valid_fromfloat
Temperature lower boundary for when the mechanism is valid, default is 1200 [K]. This value is by no means valid for all cases.
-
carspy.utils.
loc_lines
(*args, **kwargs)[source]¶ [summary]
- Parameters
- spec1d array of floats
Spectrum containing distinct peaks.
- heightfloat
A threshold for the peaks. Chose a value between 0 and 1.
- peak_indiceslist of integer
List of indices of peaks to use for calculating conversion factor.
- w_peaks1d array of floats
List of targeted peaks in Angstrom.
- inpsectbool, optional
If true, the peaks will be displayed on top of the original spectrum.