Example #2: multiparameters (T, x_CO, offset)

With the new fitting module introduced in fit_spectrum() function, and in the example of Tgas fitting using new fitting module, we can see its 1-temperature fitting performance for equilibrium condition.

This example features how new fitting module can fit an equilibrium spectrum, with multiple fit parameters, including gas temperature, mole fraction, and wavelength offset.

This example presents the fit of a real experiment (CO in argon) from Minesi et al. (2022) - doi:10.1007/s00340-022-07931-7 The data are stored in a MatLab file. It is worth noticing that, the result differ slightly from ground-truth (7515 K for index = 9), due to the fact that RADIS uses HITRAN air broadening parameters for calculation, while this experiment was originally conducted in argon. Future updates on other molecules’ broadening coefficients will increase the accuracy of these cases with non-air diluents.

  • plot2 fit Tgas molfrac
  • plot2 fit Tgas molfrac
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/spectrum/spectrum.py:4921: UserWarning:

Wavespace is not evenly spaced (0.000%) for absorbance. This may create problems if later convolving with slit function (`s.apply_slit()`). You can use `s.resample_even()`


======================= COMMENCE FITTING PROCESS =======================

Successfully retrieved the experimental data in 0.0006020069122314453s.

Acquired spectral quantity 'absorbance' from the spectrum.
NaN values successfully purged.Number of data points left: 1387 points.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/spectrum/spectrum.py:4921: UserWarning:

Wavespace is not evenly spaced (0.000%) for absorbance. This may create problems if later convolving with slit function (`s.apply_slit()`). You can use `s.resample_even()`

Successfully refined the experimental data in 0.0006628036499023438s.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/db/molparam.py:252: FutureWarning:

The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\s+'`` instead


Commence fitting process for LTE spectrum!

[[Fit Statistics]]
    # fitting method   = L-BFGS-B
    # function evals   = 301
    # data points      = 1
    # variables        = 3
    chi-square         = 1.8340e-07
    reduced chi-square = 1.8340e-07
    Akaike info crit   = -9.51157177
    Bayesian info crit = -15.5115718
##  Warning: uncertainties could not be estimated:
    this fitting method does not natively calculate uncertainties
    and numdifftools is not installed for lmfit to do this. Use
    `pip install numdifftools` for lmfit to estimate uncertainties
    with this fitting method.
[[Variables]]
    Tgas:           6947.24371 (init = 5000)
    mole_fraction:  0.04915117 (init = 0.05)
    offsetcm1:     -0.01765192 (init = 0)

Successfully finished the fitting process in 5.94312047958374s.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:268: UserWarning:

First spectrum has more resolution than 2nd. Reverse your spectra in interpolation/comparison for a better accuracy

/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:268: UserWarning:

First spectrum has more resolution than 2nd. Reverse your spectra in interpolation/comparison for a better accuracy

/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:241: UserWarning:

Presence of NaN in curve_divide!
Think about interpolation=2


======================== END OF FITTING PROCESS ========================


Residual history:

[0.004664059983082355, 0.004664059897805944, 0.004664060205172541, 0.004664060005769579, 0.002686397653677858, 0.0026863976134589304, 0.002686397544122818, 0.002686397678362386, 0.0020035890146651446, 0.0020035890191593317, 0.0020035890467810387, 0.002003589019848124, 0.0018019020360619217, 0.001801902040948572, 0.0018019020640354633, 0.00180190204479099, 0.014180327692702183, 0.01418032745436307, 0.014180327417346709, 0.014180327703290503, 0.0016460868119609813, 0.0016460868140534158, 0.0016460868244690136, 0.001646086827450828, 0.0017046178576576412, 0.0017046178260153686, 0.001704617768100842, 0.0017046178868358119, 0.0015311740774772461, 0.001531174069025548, 0.0015311740518817636, 0.0015311741040807765, 0.0013151465991833426, 0.0013151465775237362, 0.001315146535228595, 0.0013151466295568876, 0.0018446664539179091, 0.001844666404752743, 0.0018446663268011786, 0.0018446664405911458, 0.0010822628116529264, 0.0010822627760135334, 0.0010822627107722486, 0.0010822628322617683, 0.0006202530374704579, 0.0006202530107018738, 0.0006202529572128102, 0.0006202530316264627, 0.0006024396343290863, 0.0006024396509102153, 0.0006024397017138929, 0.0006024396312102256, 0.00044126213369603346, 0.0004412621353988636, 0.00044126214600143077, 0.0004412621329757946, 0.0004386480829657903, 0.0004386480787088171, 0.0004386480747217922, 0.00043864808132911833, 0.00043679643959324964, 0.00043679643709750113, 0.00043679643741095976, 0.00043679643946635977, 0.00043640003431171393, 0.000436400032867506, 0.00043640003561569115, 0.0004364000336360429, 0.00043577666442249724, 0.00043577666357495873, 0.00043577666761951005, 0.00043577666453772695, 0.0004334514336322067, 0.0004334514337112485, 0.0004334514392869527, 0.0004334514334212281, 0.00048697789709761184, 0.00048697790109226876, 0.00048697791124597406, 0.000486977904870192, 0.0004326754454339001, 0.00043267544566008933, 0.00043267545133518243, 0.0004326754459657199, 0.0004751553682573361, 0.0004751553707346953, 0.00047515537887740027, 0.0004751553707546882, 0.00043236541959664203, 0.00043236541984804076, 0.0004323654254854773, 0.0004323654201723634, 0.0004765274200347868, 0.00047652742233920525, 0.00047652743099815673, 0.0004765274222099448, 0.00043224055134725807, 0.00043224055160873094, 0.0004322405572311605, 0.00043224055086957833, 0.0004321179990889975, 0.0004321179993603283, 0.00043211800496803233, 0.0004321179986279535, 0.00042949736064902566, 0.00042949736114696394, 0.00042949736638270725, 0.00042949736038670066, 0.00047594641295630136, 0.0004759464150422153, 0.00047594641912395797, 0.0004759464169518193, 0.0004288828411321455, 0.00042888284164413406, 0.0004288828466754083, 0.00042888284107583057, 0.00047457691015104214, 0.0004745769123153825, 0.0004745769183874083, 0.0004745769133983055, 0.0004286936927596695, 0.00042869369327602324, 0.0004286936982407406, 0.0004286936926928825, 0.00047497539181278224, 0.00047497539398494865, 0.0004749754010302878, 0.00047497539454718587, 0.0004286172944601556, 0.00042861729497827966, 0.00042861729991571716, 0.000428617294405852, 0.00047555916170754527, 0.0004755591638741825, 0.00047555917152833984, 0.00047555916465247364, 0.0004285854355422443, 0.0004285854360611114, 0.0004285854409870905, 0.0004285854354629391, 0.00047610987726766883, 0.0004761098794263859, 0.00047610988746962335, 0.000476109879926257, 0.0004285718676583325, 0.000428571868177513, 0.0004285718730986105, 0.00042857186758386476, 0.0004735585733819303, 0.0004735585751378472, 0.0004735585797921944, 0.00047355857636195096, 0.00047733673410560115, 0.00047733673623124787, 0.00047733674489421816, 0.00047733673624071664, 0.0004285716814187914, 0.0004285716819379659, 0.00042857168685897534, 0.00042857168134436964, 0.00047741067267897404, 0.00047741067480765886, 0.000477410683508858, 0.0004774106747956965, 0.00042857160044195266, 0.0004285716009611246, 0.00042857160588209497, 0.0004285716003676294, 0.00047745985261438134, 0.0004774598547450451, 0.0004774598634714714, 0.0004774598547211926, 0.00042857156521122633, 0.00042857156573039784, 0.00042857157065135016, 0.0004285715651369118, 0.00047749247652586194, 0.0004774924786578465, 0.0004774924874008947, 0.00047749247862244993, 0.0004285715498768555, 0.00042857155039602676, 0.00042857155531697165, 0.0004285715498025447, 0.0004285660460682971, 0.00042856604658729724, 0.0004285660515056004, 0.000428566045995346, 0.00042853532145769885, 0.0004285353219757315, 0.00042853532687926055, 0.00042853532139235594, 0.0004285151065046105, 0.00042851510702200576, 0.0004285151119157812, 0.0004285151064442896, 0.00047749584383148123, 0.00047749584596359945, 0.00047749585470836065, 0.00047749584592945586, 0.00042851510634430443, 0.00042851510686169985, 0.0004285151117554747, 0.0004285151062839836, 0.00047749806701783456, 0.00047749806915004347, 0.0004774980778959334, 0.0004774980691130547, 0.00042851510634430443, 0.00042851510686169985, 0.0004285151117554747, 0.0004285151062839836, 0.00047270934722605247, 0.0004727093488103567, 0.0004727093529432929, 0.00047270935022323515, 0.00047724842588862005, 0.00047724842800649835, 0.000477248436622587, 0.000477248428014457, 0.000428514891806057, 0.00042851489232344323, 0.00042851489721710347, 0.0004285148917457635, 0.0004773339243859949, 0.0004773339265088124, 0.00047733393516975503, 0.00047733392650107153, 0.00042851479854563815, 0.0004285147990630194, 0.0004285148039566309, 0.00042851479848535657, 0.00047739075707914667, 0.0004773907592052178, 0.0004773907678957364, 0.0004773907591893495, 0.0004285147579762405, 0.00042851475849361797, 0.0004285147633872092, 0.00042851475791596394, 0.0004774284425932266, 0.00047742844472142734, 0.00047742845343147033, 0.00047742844469652343, 0.00042851474031990326, 0.00042851474083728167, 0.00042851474573086184, 0.00042851474025962916, 0.0004774533915607453, 0.0004774533936903587, 0.00047745340241327395, 0.0004774533936609527, 0.00042851473263330516, 0.00042851473315068346, 0.0004285147380442594, 0.00042851473257303203, 0.0004774698911309581, 0.00047746989326150616, 0.00047746990199291293, 0.0004774698932291269, 0.0004285147292862918, 0.0004285147298036688, 0.0004285147346972442, 0.000428514729226019, 0.00042851472594005434, 0.0004285147264574318, 0.0004285147313510047, 0.0004285147258797184, 0.0004774859292969024, 0.00047748593142835603, 0.00047748594016800203, 0.0004774859313930928, 0.00042851472510368934, 0.0004285147256210671, 0.00042851473051463973, 0.0004285147250434172, 0.0004285146555564098, 0.00042851465607378315, 0.0004285146609673197, 0.0004285146554961464, 0.0004774939224003561, 0.00047749392453225984, 0.0004774939332760068, 0.0004774939244955618, 0.00042851465534922965, 0.00042851465586660317, 0.00042851466076013905, 0.0004285146552889663, 0.0004774966414994679, 0.0004774966436315256, 0.00047749665237666684, 0.0004774966435943389, 0.0004282589039683439, 0.0004282589040788596, 0.0004282589079638983, 0.0004282589039102334, 0.00047576593456454723, 0.00047576593520304896, 0.0004757659402279097, 0.0004757659366723166, 0.0004282575100461418]

Fitted values history:

[5000.0, 0.04999999999999999, 0.0]
[5000.000034641016, 0.04999999999999999, 0.0]
[5000.0, 0.0500000021794495, 0.0]
[5000.0, 0.04999999999999999, 2.449489742983868e-10]
[6241.5493433910715, 0.056111492765841875, -0.002344423358809942]
[6241.549377596487, 0.056111492765841875, -0.002344423358809942]
[6241.5493433910715, 0.05611149046447289, -0.002344423358809942]
[6241.5493433910715, 0.056111492765841875, -0.0023444231102243626]
[6490.000770395819, 0.011193054426132165, -0.00357342060365241]
[6490.000803966488, 0.011193054426132165, -0.00357342060365241]
[6490.000770395819, 0.011193053374097484, -0.00357342060365241]
[6490.000770395819, 0.011193054426132165, -0.0035734203540597684]
[6494.273561978768, 0.018744805057260727, -0.0038276614200316687]
[6494.273595536808, 0.018744805057260727, -0.0038276614200316687]
[6494.273561978768, 0.01874480370103665, -0.0038276614200316687]
[6494.273561978768, 0.018744805057260727, -0.003827661170306699]
[6301.675869719913, 0.2621601722182421, -0.013896991181100885]
[6301.6759037894235, 0.2621601722182421, -0.013896991181100885]
[6301.675869719913, 0.26216016782014917, -0.013896991181100885]
[6301.675869719913, 0.2621601722182421, -0.013896990947467939]
[6481.040327963142, 0.026991953422740578, -0.00453799870566135]
[6481.040361560105, 0.026991953422740578, -0.00453799870566135]
[6481.040327963142, 0.026991951802142367, -0.00453799870566135]
[6481.040327963142, 0.026991953422740578, -0.004537998455704038]
[6460.11784207372, 0.05479354931163605, -0.00851679275379981]
[6460.117875731072, 0.05479354931163605, -0.00851679275379981]
[6460.11784207372, 0.05479354703586775, -0.00851679275379981]
[6460.11784207372, 0.05479354931163605, -0.008516792506285734]
[6471.107445218596, 0.03903201781526794, -0.006432569142943705]
[6471.107478844405, 0.03903201781526794, -0.006432569142943705]
[6471.107445218596, 0.039032015878556314, -0.006432569142943705]
[6471.107445218596, 0.03903201781526794, -0.006432568893354494]
[6500.951762671112, 0.04892923128993265, -0.00975203762568089]
[6500.951796209292, 0.04892923128993265, -0.00975203762568089]
[6500.951762671112, 0.04892922913273168, -0.00975203762568089]
[6500.951762671112, 0.04892923128993265, -0.009752037380238814]
[6728.439815796557, 0.07549049642653155, -0.022336077024000003]
[6728.439848569924, 0.07549049642653155, -0.022336077024000003]
[6728.439815796557, 0.07549049378472006, -0.022336077024000003]
[6728.439815796557, 0.07549049642653155, -0.02233607684387215]
[6571.137247881832, 0.056488337312023296, -0.013976494241427901]
[6571.137281202494, 0.056488337312023296, -0.013976494241427901]
[6571.137247881832, 0.05648833500340028, -0.013976494241427901]
[6571.137247881832, 0.056488337312023296, -0.013976494008099253]
[6733.574326036031, 0.0533287770595296, -0.018877794870217478]
[6733.574358790105, 0.0533287770595296, -0.018877794870217478]
[6733.574326036031, 0.05332877481264692, -0.018877794870217478]
[6733.574326036031, 0.0533287770595296, -0.018877794662273538]
[6764.054503771046, 0.03816991014004273, -0.018523878026760872]
[6764.054536408703, 0.03816991014004273, -0.018523878026760872]
[6764.054503771046, 0.03816990822397992, -0.018523878026760872]
[6764.054503771046, 0.03816991014004273, -0.01852387781649801]
[6749.209097441401, 0.04474413784885428, -0.018035993336479365]
[6749.209130136167, 0.04474413784885428, -0.018035993336479365]
[6749.209097441401, 0.044744135781438044, -0.018035993336479365]
[6749.209097441401, 0.04474413784885428, -0.01803599312315733]
[6755.3867998886735, 0.046441429966194325, -0.017943301482990857]
[6755.386832559769, 0.046441429966194325, -0.017943301482990857]
[6755.3867998886735, 0.046441427861803164, -0.017943301482990857]
[6755.3867998886735, 0.046441429966194325, -0.01794330126910515]
[6754.018854616524, 0.04595161843685741, -0.017791825872119943]
[6754.01888729287, 0.04595161843685741, -0.017791825872119943]
[6754.018854616524, 0.0459516163430555, -0.017791825872119943]
[6754.018854616524, 0.04595161843685741, -0.01779182565732488]
[6761.114330557005, 0.04581868417852941, -0.01783068849962128]
[6761.114363206034, 0.04581868417852941, -0.01783068849962128]
[6761.114330557005, 0.04581868208761258, -0.01783068849962128]
[6761.114330557005, 0.04581868417852941, -0.017830688285058134]
[6774.082927596034, 0.04591454872300477, -0.017772120458042606]
[6774.0829601946725, 0.04591454872300477, -0.017772120458042606]
[6774.082927596034, 0.04591454663000688, -0.017772120458042606]
[6774.082927596034, 0.04591454872300477, -0.017772120243130317]
[6826.476984969728, 0.046701739516777474, -0.017717999022952576]
[6826.477017358706, 0.046701739516777474, -0.017717999022952576]
[6826.476984969728, 0.046701737406784904, -0.017717999022952576]
[6826.476984969728, 0.046701739516777474, -0.017717998807719564]
[7176.499511301382, 0.05325261317985147, -0.017165951384614752]
[7176.499542024906, 0.05325261317985147, -0.017165951384614752]
[7176.499511301382, 0.05325261093448358, -0.017165951384614752]
[7176.499511301382, 0.05325261317985147, -0.017165951166213826]
[6844.6231586394715, 0.04702353960196837, -0.01769024939116975]
[6844.623190953537, 0.04702353960196837, -0.01769024939116975]
[6844.6231586394715, 0.047023537485076206, -0.01769024939116975]
[6844.6231586394715, 0.04702353960196837, -0.017690249175773005]
[7051.845284338811, 0.05110481612313483, -0.01762877709523048]
[7051.845315710416, 0.05110481612313483, -0.01762877709523048]
[7051.845284338811, 0.051104813921019676, -0.01762877709523048]
[7051.845284338811, 0.05110481612313483, -0.01762877687947275]
[6851.53155794352, 0.04715516046799384, -0.017688229929421855]
[6851.531590228753, 0.04715516046799384, -0.017688229929421855]
[6851.53155794352, 0.04715515834828754, -0.017688229929421855]
[6851.53155794352, 0.04715516046799384, -0.01768822971401321]
[6984.388342821964, 0.04974504137146951, -0.0176490018578064]
[6984.388374518322, 0.04974504137146951, -0.0176490018578064]
[6984.388342821964, 0.049745039197292173, -0.0176490018578064]
[6984.388342821964, 0.04974504137146951, -0.01764900164216717]
[6854.290684355536, 0.04720780997013169, -0.017687422846059047]
[6854.290716629203, 0.04720780997013169, -0.017687422846059047]
[6854.290684355536, 0.04720780784930095, -0.017687422846059047]
[6854.290684355536, 0.04720780997013169, -0.01768742263064565]
[6856.994127758864, 0.04725944234914364, -0.017686631752600546]
[6856.994160021175, 0.04725944234914364, -0.017686631752600546]
[6856.994127758864, 0.0472594402272109, -0.017686631752600546]
[6856.994127758864, 0.04725944234914364, -0.017686631537182487]
[6920.973026354686, 0.04849468514099997, -0.017667821632097236]
[6920.9730583403625, 0.04849468514099997, -0.017667821632097236]
[6920.973026354686, 0.04849468299290899, -0.017667821632097236]
[6920.973026354686, 0.04849468514099997, -0.017667821416568516]
[7268.409662507174, 0.05598180910994899, -0.017450829997227645]
[7268.409692711028, 0.05598180910994899, -0.017450829997227645]
[7268.409662507174, 0.05598180681108306, -0.017450829997227645]
[7268.409662507174, 0.05598180910994899, -0.017450829780438153]
[6937.196039752975, 0.048824236385127895, -0.017657977893433038]
[6937.196071666087, 0.048824236385127895, -0.017657977893433038]
[6937.196039752975, 0.048824234230123775, -0.017657977893433038]
[6937.196039752975, 0.048824236385127895, -0.01765797767784649]
[7140.606137499405, 0.05311759294538143, -0.017532266491028445]
[7140.606168416085, 0.05311759294538143, -0.017532266491028445]
[7140.606137499405, 0.053117590702701944, -0.017532266491028445]
[7140.606137499405, 0.05311759294538143, -0.0175322662747087]
[6942.436932050136, 0.048931086316012895, -0.01765479247748251]
[6942.436963939595, 0.048931086316012895, -0.01765479247748251]
[6942.436932050136, 0.04893108415877312, -0.01765479247748251]
[6942.436932050136, 0.048931086316012895, -0.017654792261877265]
[7073.921914403947, 0.05167594746196735, -0.017573970784781897]
[7073.921945665377, 0.05167594746196735, -0.017573970784781897]
[7073.921914403947, 0.05167594524824781, -0.017573970784781897]
[7073.921914403947, 0.05167594746196735, -0.017573970568704307]
[6944.578834395112, 0.04897480961395012, -0.01765348986789437]
[6944.578866274873, 0.04897480961395012, -0.01765348986789437]
[6944.578834395112, 0.04897480745579641, -0.01765348986789437]
[6944.578834395112, 0.04897480961395012, -0.017653489652281473]
[7030.23076853361, 0.05074985925653264, -0.01760102647509652]
[7030.230800011212, 0.05074985925653264, -0.01760102647509652]
[7030.23076853361, 0.05074985706166796, -0.01760102647509652]
[7030.23076853361, 0.05074985925653264, -0.017601026259176596]
[6945.477285875465, 0.04899315945164057, -0.0176529433379482]
[6945.477317751154, 0.04899315945164057, -0.0176529433379482]
[6945.477285875465, 0.048993157293103384, -0.0176529433379482]
[6945.477285875465, 0.04899315945164057, -0.0176529431223321]
[7001.5344479919095, 0.05014929254386735, -0.01761868640895748]
[7001.534479607403, 0.05014929254386735, -0.01761868640895748]
[7001.5344479919095, 0.050149290361338084, -0.01761868640895748]
[7001.5344479919095, 0.05014929254386735, -0.017618686193140713]
[6945.860128385985, 0.04900098027257627, -0.017652710430342076]
[6945.860160259938, 0.04900098027257627, -0.017652710430342076]
[6945.860128385985, 0.049000978113875715, -0.017652710430342076]
[6945.860128385985, 0.04900098027257627, -0.017652710214724608]
[7167.84539452417, 0.05385436974345548, -0.01755587257169426]
[7167.8454252947595, 0.05385436974345548, -0.01755587257169426]
[7167.84539452417, 0.05385436748615452, -0.01755587257169426]
[7167.84539452417, 0.05385436974345548, -0.01755587235551145]
[6952.21007485907, 0.049134560707702446, -0.01764998940164729]
[6952.210106704141, 0.049134560707702446, -0.01764998940164729]
[6952.21007485907, 0.04913455854621329, -0.01764998940164729]
[6952.21007485907, 0.049134560707702446, -0.01764998918601386]
[6945.865187058368, 0.04900108657242247, -0.017652708263700634]
[6945.865218932297, 0.04900108657242247, -0.017652708263700634]
[6945.865187058368, 0.04900108441371964, -0.017652708263700634]
[6945.865187058368, 0.04900108657242247, -0.01765270804808316]
[6950.053457983171, 0.04908916018445586, -0.017650913837313736]
[6950.053489838069, 0.04908916018445586, -0.017650913837313736]
[6950.053457983171, 0.049089158023914004, -0.017650913837313736]
[6950.053457983171, 0.04908916018445586, -0.017650913621685728]
[6945.867386599174, 0.04900113279228513, -0.01765270732163154]
[6945.8674184730935, 0.04900113279228513, -0.01765270732163154]
[6945.867386599174, 0.0490011306335813, -0.01765270732163154]
[6945.867386599174, 0.04900113279228513, -0.017652707106014055]
[6948.630474138429, 0.04905922246488853, -0.017651523631802623]
[6948.6305059998, 0.04905922246488853, -0.017651523631802623]
[6948.630474138429, 0.04905922030497156, -0.017651523631802623]
[6948.630474138429, 0.04905922246488853, -0.01765152341617819]
[6945.8683435655485, 0.04900115290142715, -0.017652706911760234]
[6945.868375439463, 0.04900115290142715, -0.017652706911760234]
[6945.8683435655485, 0.04900115074272299, -0.017652706911760234]
[6945.8683435655485, 0.04900115290142715, -0.017652706696142745]
[6947.691471746208, 0.0490394751539594, -0.017651925951263317]
[6947.691503611847, 0.0490394751539594, -0.017651925951263317]
[6947.691471746208, 0.049039472994454714, -0.017651925951263317]
[6947.691471746208, 0.0490394751539594, -0.017651925735641248]
[6945.868760090337, 0.04900116165404206, -0.017652706733361515]
[6945.868791964251, 0.04900116165404206, -0.017652706733361515]
[6945.868760090337, 0.049001159495337676, -0.017652706733361515]
[6945.868760090337, 0.04900116165404206, -0.017652706517744025]
[6946.018308029958, 0.04900430425080182, -0.017652642680824913]
[6946.018339903192, 0.04900430425080182, -0.017652642680824913]
[6946.018308029958, 0.04900430209203177, -0.017652642680824913]
[6946.018308029958, 0.04900430425080182, -0.01765264246520705]
[6946.854939737844, 0.049021888206585984, -0.017652284317791596]
[6946.854971607281, 0.049021888206585984, -0.017652284317791596]
[6946.854939737844, 0.049021886047448615, -0.017652284317791596]
[6946.854939737844, 0.049021888206585984, -0.017652284102171623]
[6947.40706205323, 0.049033495256203374, -0.01765204779627506]
[6947.40709392016, 0.049033495256203374, -0.01765204779627506]
[6947.40706205323, 0.04903349309682359, -0.01765204779627506]
[6947.40706205323, 0.049033495256203374, -0.017652047580653703]
[6947.594773744364, 0.04903744194992177, -0.01765196737861264]
[6947.594805610443, 0.04903744194992177, -0.01765196737861264]
[6947.594773744364, 0.04903743979045955, -0.01765196737861264]
[6947.594773744364, 0.04903744194992177, -0.017651967162990813]
[6947.407066437349, 0.049033495348377754, -0.017652047794396882]
[6947.40709830428, 0.049033495348377754, -0.017652047794396882]
[6947.407066437349, 0.04903349318899797, -0.017652047794396882]
[6947.407066437349, 0.049033495348377754, -0.017652047578775525]
[6947.530953823498, 0.049036100088496015, -0.017651994719999023]
[6947.530985689866, 0.049036100088496015, -0.017651994719999023]
[6947.530953823498, 0.04903609792906183, -0.017651994719999023]
[6947.530953823498, 0.049036100088496015, -0.017651994504377357]
[6947.407066437349, 0.049033495348377754, -0.017652047794396882]
[6947.40709830428, 0.049033495348377754, -0.017652047794396882]
[6947.407066437349, 0.04903349318899797, -0.017652047794396882]
[6947.407066437349, 0.049033495348377754, -0.017652047578775525]
[7174.584449185876, 0.05406105440123099, -0.01760154867200092]
[7174.584479919843, 0.05406105440123099, -0.01760154867200092]
[7174.584449185876, 0.05406105213984963, -0.01760154867200092]
[7174.584449185876, 0.05406105440123099, -0.01760154845608404]
[6954.176572458, 0.049177476357310235, -0.017650569375154905]
[6954.176604294095, 0.049177476357310235, -0.017650569375154905]
[6954.176572458, 0.049177474194926074, -0.017650569375154905]
[6954.176572458, 0.049177476357310235, -0.017650569159524877]
[6947.412855451139, 0.04903361833028691, -0.01765204653074728]
[6947.4128873180425, 0.04903361833028691, -0.01765204653074728]
[6947.412855451139, 0.04903361617090457, -0.01765204653074728]
[6947.412855451139, 0.04903361833028691, -0.017652046315125916]
[6951.877642881327, 0.04912854220655666, -0.017651071614717892]
[6951.877674727914, 0.04912854220655666, -0.017651071614717892]
[6951.877642881327, 0.049128540045193014, -0.017651071614717892]
[6951.877642881327, 0.04912854220655666, -0.017651071399090806]
[6947.415371995425, 0.04903367179187451, -0.017652045981425363]
[6947.415403862318, 0.04903367179187451, -0.017652045981425363]
[6947.415371995425, 0.04903366963249106, -0.017652045981425363]
[6947.415371995425, 0.04903367179187451, -0.017652045765803995]
[6950.360789959923, 0.049096276509149106, -0.017651402902297008]
[6950.36082181342, 0.049096276509149106, -0.017651402902297008]
[6950.360789959923, 0.0490962743484587, -0.017651402902297008]
[6950.360789959923, 0.049096276509149106, -0.01765140268667187]
[6947.416466730326, 0.04903369504848998, -0.01765204574246194]
[6947.416498597214, 0.04903369504848998, -0.01765204574246194]
[6947.416466730326, 0.04903369288910603, -0.01765204574246194]
[6947.416466730326, 0.04903369504848998, -0.017652045526840573]
[6949.359858912876, 0.049074994565620256, -0.017651621469214784]
[6949.359890770929, 0.049074994565620256, -0.017651621469214784]
[6949.359858912876, 0.049074992405373996, -0.017651621469214784]
[6949.359858912876, 0.049074994565620256, -0.01765162125359093]
[6947.416943175617, 0.049033705170125674, -0.01765204563846141]
[6947.4169750425035, 0.049033705170125674, -0.01765204563846141]
[6947.416943175617, 0.0490337030107415, -0.01765204563846141]
[6947.416943175617, 0.049033705170125674, -0.01765204542284004]
[6948.699327992961, 0.049060954322058925, -0.01765176568730797]
[6948.699359854019, 0.049060954322058925, -0.01765176568730797]
[6948.699327992961, 0.049060952162105764, -0.01765176568730797]
[6948.699327992961, 0.049060954322058925, -0.017651765471684962]
[6947.4171505938675, 0.049033709576533524, -0.017652045593185256]
[6947.417182460753, 0.049033709576533524, -0.017652045593185256]
[6947.4171505938675, 0.04903370741714924, -0.017652045593185256]
[6947.4171505938675, 0.049033709576533524, -0.017652045377563888]
[6948.263413985753, 0.04905169030336198, -0.01765186085554546]
[6948.263445848793, 0.04905169030336198, -0.01765186085554546]
[6948.263413985753, 0.04905168814360222, -0.01765186085554546]
[6948.263413985753, 0.04905169030336198, -0.01765186063992301]
[6947.417240910501, 0.049033711495226395, -0.017652045573470554]
[6947.417272777386, 0.049033711495226395, -0.017652045573470554]
[6947.417240910501, 0.04903370933584211, -0.017652045573470554]
[6947.417240910501, 0.049033711495226395, -0.017652045357849182]
[6947.417331207912, 0.04903371341351109, -0.017652045553760043]
[6947.417363074796, 0.04903371341351109, -0.017652045553760043]
[6947.417331207912, 0.049033711254126755, -0.017652045553760043]
[6947.417331207912, 0.04903371341351109, -0.017652045338138675]
[6947.840385356213, 0.049042701467830296, -0.017651953204768794]
[6947.840417221175, 0.049042701467830296, -0.017651953204768794]
[6947.840385356213, 0.049042699308258275, -0.017651953204768794]
[6947.840385356213, 0.049042701467830296, -0.01765195298914688]
[6947.4173537761435, 0.04903371389295219, -0.017652045548833754]
[6947.417385643027, 0.04903371389295219, -0.017652045548833754]
[6947.4173537761435, 0.04903371173356785, -0.017652045548833754]
[6947.4173537761435, 0.04903371389295219, -0.017652045333212386]
[6947.419230475132, 0.04903375376169361, -0.017652045139179715]
[6947.419262342008, 0.04903375376169361, -0.017652045139179715]
[6947.419230475132, 0.04903375160230844, -0.017652045139179715]
[6947.419230475132, 0.04903375376169361, -0.017652044923558343]
[6947.629811076482, 0.0490382275179842, -0.017651999172003004]
[6947.6298429424005, 0.0490382275179842, -0.017651999172003004]
[6947.629811076482, 0.049038225358505605, -0.017651999172003004]
[6947.629811076482, 0.0490382275179842, -0.01765199895638136]
[6947.419236066428, 0.049033753880475595, -0.017652045137959226]
[6947.419267933304, 0.049033753880475595, -0.017652045137959226]
[6947.419236066428, 0.049033751721090424, -0.017652045137959226]
[6947.419236066428, 0.049033753880475595, -0.01765204492233785]
[6947.558216282266, 0.04903670645951541, -0.01765201480043457]
[6947.55824814851, 0.04903670645951541, -0.01765201480043457]
[6947.558216282266, 0.04903670430006857, -0.01765201480043457]
[6947.558216282266, 0.04903670645951541, -0.017652014584813018]
[6947.242186457791, 0.049150409084824376, -0.017651917729566334]
[6947.242218325471, 0.049150409084824376, -0.017651917729566334]
[6947.242186457791, 0.04915040692300465, -0.017651917729566334]
[6947.242186457791, 0.049150409084824376, -0.017651917513944217]
[6947.935086448593, 0.0494955806123375, -0.01765113600617043]
[6947.935118313125, 0.0494955806123375, -0.01765113600617043]
[6947.935086448593, 0.049495578443333854, -0.01765113600617043]
[6947.935086448593, 0.0494955806123375, -0.017651135790543723]
[6947.243709839755, 0.049151166671478175, -0.01765191601100374]

Total fitting time:
5.94312047958374 s

import astropy.units as u
import scipy.io

from radis import Spectrum
from radis.test.utils import getTestFile
from radis.tools.new_fitting import fit_spectrum

# -------------------- Step 1. Load experimental spectrum -------------------- #

data_file = "trimmed_1857_VoigtCO_Minesi.mat"
data = scipy.io.loadmat(getTestFile(data_file), simplify_cells=True)["CO_resu_Voigt"]
index = (
    9  # Ground truth is 7515 K - Minesi et al. (2022) - doi:10.1007/s00340-022-07931-7
)
s_experimental = Spectrum.from_array(
    data["nu"], data["A_exp"][:, index], "absorbance", wunit="cm-1", unit=""
)  # adimensioned


# -------------------- Step 2. Fill ground-truths and data -------------------- #


# Experimental conditions which will be used for spectrum modeling. Basically, these are known ground-truths.
experimental_conditions = {
    "molecule": "CO",  # Molecule ID
    "isotope": "1",  # Isotope ID, can have multiple at once
    "wmin": 2010.6,  # Starting wavelength/wavenumber to be cropped out from the original experimental spectrum.
    "wmax": 2011.6,  # Ending wavelength/wavenumber for the cropping range.
    "wunit": "cm-1",  # Accompanying unit of those 2 wavelengths/wavenumbers above.
    "pressure": 1
    * u.bar,  # Total pressure of gas, in "bar" unit by default, but you can use Astropy units too.
    "path_length": 10
    * u.cm,  # Experimental path length, in "cm" unit by default, but you can use Astropy units too.
    "databank": "hitemp",  # Databank used for calculation. Must be stated.
    "wstep": "auto",
}

# List of parameters to be fitted.
fit_parameters = {
    "Tgas": 5000,  # Fit parameter, accompanied by its initial value.
    "mole_fraction": 0.05,  # Species mole fraction, from 0 to 1.
    "offset": "0 cm-1",  # Experimental offset, must be a blank space separating offset amount and unit.
    # "pressure": 0.8,
}

# List of bounding ranges applied for those fit parameters above.
bounding_ranges = {
    "Tgas": [2000, 9000],
    "mole_fraction": [0, 1],
    "offset": [-0.03, 0.02],
    # "pressure": [0.1, 2],
}

# Fitting pipeline setups.
fit_properties = {
    "method": "lbfgsb",  # Preferred fitting method. By default, "leastsq".
    "fit_var": "absorbance",  # Spectral quantity to be extracted for fitting process, such as "radiance", "absorbance", etc.
    "normalize": False,  # Either applying normalization on both spectra or not.
    "max_loop": 300,  # Max number of loops allowed. By default, 100.
    "tol": 1e-20,  # Fitting tolerance, only applicable for "lbfgsb" method.
}

"""

For the fitting method, you can try one among 17 different fitting methods and algorithms of LMFIT,
introduced in `LMFIT method list <https://lmfit.github.io/lmfit-py/fitting.html#choosing-different-fitting-methods>`.

You can see the benchmark result of these algorithms here:
`RADIS Newfitting Algorithm Benchmark <https://github.com/radis/radis-benchmark/blob/master/manual_benchmarks/plot_newfitting_comparison_algorithm.py>`.

"""


# -------------------- Step 3. Run the fitting and retrieve results -------------------- #


# Conduct the fitting process!
s_best, result, log = fit_spectrum(
    s_exp=s_experimental,
    fit_params=fit_parameters,
    bounds=bounding_ranges,
    model=experimental_conditions,
    pipeline=fit_properties,
)


# Now investigate the log

print("\nResidual history: \n")
print(log["residual"])

print("\nFitted values history: \n")
for fit_val in log["fit_vals"]:
    print(fit_val)

print("\nTotal fitting time: ")
print(log["time_fitting"], end=" s\n")

Total running time of the script: (0 minutes 7.651 seconds)