fitroom.solver module¶
Created on Thu Aug 3 19:32:23 2017
@author: erwan
Machinery related to solving a specific Slabs configuration: parse the database, get the correct slab input, then calls the appropriate functions in neq.spec engine
- class SlabsConfigSolver(config, source=None, s_exp=None, plotquantity='radiance', unit='mW/cm2/sr/nm', slit=None, slit_options='default', crop=None, retrieve_mode='safe', verbose=True, retrieve_error='ignore')[source]¶
Bases:
object
Machinery related to solving a specific Slabs configuration: parse the database, get the correct slab input, then calls the appropriate functions in neq.spec engine
- Parameters
config (dict) – list of Slabs that represent the Spatial model (to solve RTE)
source (‘database’, ‘calculate’, ‘from_bands’) – Whether to calculate spectra from scratch, retrieve them from a database, or combine vibrational bands Mode can be overriden by a ‘source’ parameter in every slab
s_exp (
Spectrum
) – experimental spectrumplotquantity (‘radiance’, ‘transmittance_noslit’, etc.)
- Other Parameters
get_closest (bool) – when retrieving spectra from database, get cloest if set to True. Else get unique.
slit_options –
if
'default'
, use:{'norm_by':'area', 'shape':'triangular', 'unit':'nm', 'verbose':False}
and adapt
'shape'
to'trapezoidal'
if a tuple was given for slitcrop (tuple, or None) – if not
None
, restrain to the given fitted interval.retrieve_error (‘ignore’, ‘raise’) – if Spectrum cannot be calculated or retrieved from Database, then returns
None
as a Spectrum object. The rest of the code should deal with it. Else, raises an error immediatly.retrieve_mode (‘safe’, ‘strict’, ‘closest’) –
how to retrieve spectra when reading from database:
if ‘strict’, only retrieve the spectra that exactly match
the given conditions (allow scaling path_length or mole_fraction, still)
if ‘safe’, requires an exact match for all conditions (as in
‘strict’), except for the 2 user defined variable conditions
xparam
andyparam
if ‘closest’, retrieves the closest spectrum in the database
Warning
‘closest’ can induce user errors!!!. Ex: a Trot=1500 K spectrum can be used instead of a Trot=1550 K spectrum if the latter is not available, without user necessarily noticing. If you have any doubt, print the conditions of the spectra used in the tools. Ex:
for s in gridTool.spectra: print(s)
Examples
- calc_slabs(**slabsconfig) Union[radis.spectrum.spectrum.Spectrum, dict] [source]¶
- Parameters
slabsconfig – list of dictionaries. Each dictionary as a database key
db
and as many conditions to filter the database
- get_residual(s: radis.spectrum.spectrum.Spectrum, normalize=False, normalize_how='max')[source]¶
Returns difference between experimental and simulated spectra By default, uses
get_residual()
function You can change the residual by overriding this function.Examples
Replace get_residual with new_residual:
solver.get_residual = lambda s: new_residual(solver.s_exp, s, 'radiance')
Note that default solver would be written:
from radis import get_residual solver.get_residual = lambda s: get_residual(solver.s_exp, s, solver.plotquantity, ignore_nan=True)
- Parameters
s (Spectrum object) – simulated spectrum to compare with (stored) experimental spectrum
normalize (bool) – not implemented yet # TODO
Notes
Implementation:
interpolate experimental is harder (because of noise, and overlapping) we interpolate each new spectrum on the experiment