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:5438: 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()`
  warn(

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

Successfully retrieved the experimental data in 0.0004112720489501953s.

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:5438: 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()`
  warn(
Successfully refined the experimental data in 0.0004687309265136719s.
0.16s - Loaded database

Commence fitting process for LTE spectrum!

[[Fit Statistics]]
    # fitting method   = L-BFGS-B
    # function evals   = 301
    # data points      = 1
    # variables        = 4
    chi-square         = 3.6434e-08
    reduced chi-square = 3.6434e-08
    Akaike info crit   = -9.12775675
    Bayesian info crit = -17.1277567
##  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:           7230.79899 (init = 5000)
    mole_fraction:  0.11146169 (init = 0.05)
    pressure:       0.43709474 (init = 0.8)
    offsetcm1:     -0.01933016 (init = 0)

Successfully finished the fitting process in 5.103947877883911s.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:267: UserWarning: First spectrum has more resolution than 2nd. Reverse your spectra in interpolation/comparison for a better accuracy
  warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:267: UserWarning: First spectrum has more resolution than 2nd. Reverse your spectra in interpolation/comparison for a better accuracy
  warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/curve.py:240: UserWarning: Presence of NaN in curve_divide!
Think about interpolation=2
  warnings.warn(

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


Residual history:

[np.float64(0.003755866537856915), np.float64(0.003755866471962513), np.float64(0.0037558667059657638), np.float64(0.003755866566900882), np.float64(0.00375586656121449), np.float64(0.0020752112663694738), np.float64(0.0020752112489132845), np.float64(0.0020752112212900535), np.float64(0.0020752112741569823), np.float64(0.0020752112923019886), np.float64(0.0019054511989672635), np.float64(0.0019054512042492133), np.float64(0.0019054512259574353), np.float64(0.0019054511928986606), np.float64(0.0019054512065637182), np.float64(0.0017266637527855594), np.float64(0.0017266637572053184), np.float64(0.0017266637730979089), np.float64(0.0017266637463960275), np.float64(0.0017266637699433404), np.float64(0.02022325000417427), np.float64(0.0202232497205346), np.float64(0.020223249823578628), np.float64(0.020223250221598314), np.float64(0.020223249997313317), np.float64(0.0015455339721237111), np.float64(0.0015455339699175787), np.float64(0.0015455339695366695), np.float64(0.0015455339695891951), np.float64(0.001545534001151474), np.float64(0.0014508604040863), np.float64(0.001450860377947226), np.float64(0.0014508603435517053), np.float64(0.001450860420960268), np.float64(0.001450860434213333), np.float64(0.0011703623970066854), np.float64(0.0011703623835572587), np.float64(0.0011703623653701496), np.float64(0.0011703624040380455), np.float64(0.0011703624278555636), np.float64(0.0004432204320186382), np.float64(0.0004432204507653182), np.float64(0.00044322048416370736), np.float64(0.00044322041084712913), np.float64(0.00044322043995090695), np.float64(0.00034294293787457493), np.float64(0.00034294294148138195), np.float64(0.00034294294193012206), np.float64(0.000342942939309147), np.float64(0.00034294291880578064), np.float64(0.00029204458286897323), np.float64(0.000292044572213338), np.float64(0.00029204455042314325), np.float64(0.00029204459829127263), np.float64(0.0002920445949255552), np.float64(0.0002523259198179654), np.float64(0.0002523259300476412), np.float64(0.00025232594130028665), np.float64(0.0002523259123565588), np.float64(0.00025232592113525295), np.float64(0.00024145734230075422), np.float64(0.00024145734368195615), np.float64(0.00024145733863345408), np.float64(0.00024145734667773336), np.float64(0.0002414573406727198), np.float64(0.00023922690046057719), np.float64(0.00023922690287564324), np.float64(0.00023922690015268255), np.float64(0.00023922690292553132), np.float64(0.00023922690307570565), np.float64(0.00023687824000979865), np.float64(0.00023687824285788058), np.float64(0.00023687824089431046), np.float64(0.00023687824203147368), np.float64(0.00023687824069907595), np.float64(0.00021771603430745752), np.float64(0.000217716037619378), np.float64(0.00021771603829268425), np.float64(0.00021771603507868365), np.float64(0.000217716032390762), np.float64(0.00023621144683087328), np.float64(0.00023621144992303669), np.float64(0.00023621145570499967), np.float64(0.00023621144487543934), np.float64(0.00023621143644290542), np.float64(0.00020815016334095314), np.float64(0.0002081501658429728), np.float64(0.00020815016703886686), np.float64(0.00020815016425696848), np.float64(0.00020815015829113532), np.float64(0.00022802645723241408), np.float64(0.00022802646147605416), np.float64(0.00022802646721546316), np.float64(0.00022802645463576406), np.float64(0.00022802645057184303), np.float64(0.0002052438684371818), np.float64(0.00020524387074480165), np.float64(0.0002052438722604692), np.float64(0.0002052438692427739), np.float64(0.00020524386324339175), np.float64(0.0002334933287546405), np.float64(0.00023349333339964872), np.float64(0.00023349333853811235), np.float64(0.00023349332650290282), np.float64(0.00023349332226433643), np.float64(0.00020444206112530327), np.float64(0.0002044420633707415), np.float64(0.0002044420649800601), np.float64(0.00020444206189947658), np.float64(0.00020444205586990727), np.float64(0.00022324493303542842), np.float64(0.00022324494329792783), np.float64(0.00022324495553610574), np.float64(0.000223244921496266), np.float64(0.0002232449281405741), np.float64(0.00019780086390610796), np.float64(0.00019780086645270427), np.float64(0.000197800869307568), np.float64(0.00019780086367071831), np.float64(0.00019780085793241314), np.float64(0.00021386533393176675), np.float64(0.00021386534352747064), np.float64(0.00021386535507758123), np.float64(0.0002138653218376062), np.float64(0.00021386533367739557), np.float64(0.00022908169315033478), np.float64(0.00022908169863483703), np.float64(0.0002290817038995366), np.float64(0.00022908168994740103), np.float64(0.0002290816882588456), np.float64(0.00019743617803642593), np.float64(0.00019743618056588803), np.float64(0.00019743618343526556), np.float64(0.00019743617778745224), np.float64(0.00019743617210300757), np.float64(0.00019202503952302924), np.float64(0.0001920250419028102), np.float64(0.00019202504520418192), np.float64(0.00019202503887205314), np.float64(0.00019202503427476824), np.float64(0.00020654711380475467), np.float64(0.00020654712212806988), np.float64(0.00020654713149768572), np.float64(0.00020654710345553327), np.float64(0.00020654711254969825), np.float64(0.00022366004301950862), np.float64(0.00022366004806654473), np.float64(0.00022366005281926948), np.float64(0.0002236600400455401), np.float64(0.0002236600384261758), np.float64(0.00019179958215525216), np.float64(0.0001917995845038707), np.float64(0.00019179958778393395), np.float64(0.0001917995815191773), np.float64(0.00019179957692595534), np.float64(0.0002263595257400966), np.float64(0.00022635953086667625), np.float64(0.00022635953564430425), np.float64(0.00022635952285884843), np.float64(0.0002263595209073647), np.float64(0.00019171036922141583), np.float64(0.00019171037155779575), np.float64(0.0001917103748296371), np.float64(0.00019171036859179288), np.float64(0.00019171036399968797), np.float64(0.00022818966146290168), np.float64(0.0002281896666642981), np.float64(0.00022818967149374546), np.float64(0.0002281896586095289), np.float64(0.00022818965652997219), np.float64(0.00019167368227775042), np.float64(0.00019167368460911563), np.float64(0.00019167368787760856), np.float64(0.00019167368165075232), np.float64(0.0001916736770591458), np.float64(0.0002294176976568853), np.float64(0.00022941770291638313), np.float64(0.0002294177077948839), np.float64(0.0002294176948090231), np.float64(0.00022941769261883413), np.float64(0.00019165826568355896), np.float64(0.0001916582680128179), np.float64(0.00019165827127991107), np.float64(0.00019165826505804234), np.float64(0.00019165826046626877), np.float64(0.0002302366827691946), np.float64(0.00023023668807060853), np.float64(0.00023023669298769117), np.float64(0.00023023667992014198), np.float64(0.00023023667766659735), np.float64(0.0001916517012145275), np.float64(0.00019165170354289073), np.float64(0.00019165170680938875), np.float64(0.00019165170058781417), np.float64(0.00019165169599779725), np.float64(0.00019145942964002608), np.float64(0.00019145943194228058), np.float64(0.00019145943519163487), np.float64(0.00019145942902803613), np.float64(0.00019145942443978778), np.float64(0.00019094038304183004), np.float64(0.0001909403852749216), np.float64(0.00019094038848086896), np.float64(0.0001909403824642063), np.float64(0.00019094037788699398), np.float64(0.00023046598145893678), np.float64(0.0002304659867725128), np.float64(0.00023046599170120332), np.float64(0.00023046597860834674), np.float64(0.00023046597633853233), np.float64(0.00019093989929221927), np.float64(0.00019093990152524776), np.float64(0.00019093990473115615), np.float64(0.00019093989871423402), np.float64(0.00019093989413742629), np.float64(0.00023061760495502525), np.float64(0.0002306176102766488), np.float64(0.00023061761521329734), np.float64(0.00023061760210324505), np.float64(0.00023061759982860428), np.float64(0.0001909396894449798), np.float64(0.00019093969167798322), np.float64(0.00019093969488387236), np.float64(0.00019093968886700567), np.float64(0.0001909396842902053), np.float64(0.00019092115486666985), np.float64(0.00019092115709723971), np.float64(0.00019092116030165925), np.float64(0.00019092115428984605), np.float64(0.00019092114971354092), np.float64(0.00023075279078749048), np.float64(0.00023075279611643696), np.float64(0.00023075280106022234), np.float64(0.00023075278793431852), np.float64(0.00023075278564497229), np.float64(0.00019092115486666985), np.float64(0.00019092115709723971), np.float64(0.00019092116030165925), np.float64(0.00019092115428984605), np.float64(0.00019092114971354092), np.float64(0.00021654211263333887), np.float64(0.00021654212480979877), np.float64(0.00021654213730833388), np.float64(0.00021654209694067848), np.float64(0.00021654211245218804), np.float64(0.00022311817229925165), np.float64(0.0002231181778097644), np.float64(0.00022311818303977286), np.float64(0.00022311816870412496), np.float64(0.00022311816805853173), np.float64(0.00023063154703571745), np.float64(0.00023063155237012243), np.float64(0.0002306315573196042), np.float64(0.00023063154416923655), np.float64(0.00023063154190949104), np.float64(0.00019092097320525046), np.float64(0.00019092097543581347), np.float64(0.000190920978640237), np.float64(0.00019092097262881133), np.float64(0.00019092096805214506), np.float64(0.00019092079183485877), np.float64(0.00019092079406541558), np.float64(0.00019092079726984226), np.float64(0.00019092079125658697), np.float64(0.00019092078668749607), np.float64(0.00023075953323400895), np.float64(0.00023075953856932927), np.float64(0.00023075954351951846), np.float64(0.00023075953037349486), np.float64(0.00023075952809445868), np.float64(0.000190920746648077), np.float64(0.00019092074887863065), np.float64(0.0001909207520830595), np.float64(0.0001909207460716268), np.float64(0.00019092074149500076), np.float64(0.00019092070146136428), np.float64(0.0001909207036919185), np.float64(0.0001909207068963463), np.float64(0.00019092070088451912), np.float64(0.00019092069630829403), np.float64(0.00023082359246491777), np.float64(0.0002308235978007367), np.float64(0.00023082360275133765), np.float64(0.00023082358960743797), np.float64(0.00023082358731871743), np.float64(0.0001909206901801942), np.float64(0.00019092069241074655), np.float64(0.00019092069561517613), np.float64(0.00019092068960374257), np.float64(0.00019092068502712532), np.float64(0.00019092067890635544), np.float64(0.00019092068113690745), np.float64(0.00019092068434133698), np.float64(0.00019092067832990244), np.float64(0.00019092067375328794), np.float64(0.00019089469901275682), np.float64(0.0001908947012424602), np.float64(0.00019089470444733065), np.float64(0.000190894698434755), np.float64(0.00019089469386305031), np.float64(0.00019087756161705773)]

Fitted values history:

[5000.0, 0.04999999999999999, 0.8, 0.0]
[5000.000034641016, 0.04999999999999999, 0.8, 0.0]
[5000.0, 0.0500000021794495, 0.8, 0.0]
[5000.0, 0.04999999999999999, 0.8000000091651513, 0.0]
[5000.0, 0.04999999999999999, 0.8, 2.449489742983868e-10]
[6243.495178670389, 0.0521473786864709, 0.6593115431403286, -0.003135024602320055]
[6243.4952128715795, 0.0521473786864709, 0.6593115431403286, -0.003135024602320055]
[6243.495178670389, 0.05214737646322937, 0.6593115431403286, -0.003135024602320055]
[6243.495178670389, 0.0521473786864709, 0.659311551799789, -0.003135024602320055]
[6243.495178670389, 0.0521473786864709, 0.6593115431403286, -0.0031350243530166508]
[6485.215279479978, 0.022369751187722442, 0.6319950180215155, -0.005650981026904617]
[6485.215313064722, 0.022369751187722442, 0.6319950180215155, -0.005650981026904617]
[6485.215279479978, 0.02236974970889366, 0.6319950180215155, -0.005650981026904617]
[6485.215279479978, 0.022369751187722442, 0.6319950265524701, -0.005650981026904617]
[6485.215279479978, 0.022369751187722442, 0.6319950180215155, -0.005650980776989386]
[6491.321472959823, 0.032496623270245495, 0.6371041655244887, -0.006184686562962699]
[6491.321506526595, 0.032496623270245495, 0.6371041655244887, -0.006184686562962699]
[6491.321472959823, 0.03249662149709598, 0.6371041655244887, -0.006184686562962699]
[6491.321472959823, 0.032496623270245495, 0.6371041740802881, -0.006184686562962699]
[6491.321472959823, 0.032496623270245495, 0.6371041655244887, -0.006184686313243551]
[7023.430838599372, 0.6051043285486108, 0.7357351776525063, -0.023731738930066512]
[7023.430870109939, 0.6051043285486108, 0.7357351776525063, -0.023731738930066512]
[7023.430838599372, 0.6051043236603282, 0.7357351776525063, -0.023731738930066512]
[7023.430838599372, 0.6051043285486108, 0.7357351866176478, -0.023731738930066512]
[7023.430838599372, 0.6051043285486108, 0.7357351776525063, -0.023731738764500222]
[6521.504716660401, 0.047812077999929536, 0.6424220585730744, -0.007284977225773561]
[6521.504750136554, 0.047812077999929536, 0.6424220585730744, -0.007284977225773561]
[6521.504716660401, 0.04781207586624536, 0.6424220585730744, -0.007284977225773561]
[6521.504716660401, 0.047812077999929536, 0.6424220671543345, -0.007284977225773561]
[6521.504716660401, 0.047812077999929536, 0.6424220585730744, -0.007284976976819974]
[6692.681919535334, 0.0796999318009074, 0.6404526355551997, -0.010502475185183616]
[6692.6819524405155, 0.0796999318009074, 0.6404526355551997, -0.010502475185183616]
[6692.681919535334, 0.07969992909262652, 0.6404526355551997, -0.010502475185183616]
[6692.681919535334, 0.0796999318009074, 0.6404526441270779, -0.010502475185183616]
[6692.681919535334, 0.0796999318009074, 0.6404526355551997, -0.01050247494131423]
[6809.2215443825, 0.07335489340440915, 0.623608368753081, -0.011101850766097224]
[6809.221576841611, 0.07335489340440915, 0.623608368753081, -0.011101850766097224]
[6809.2215443825, 0.07335489079722768, 0.623608368753081, -0.011101850766097224]
[6809.2215443825, 0.07335489340440915, 0.6236083772424281, -0.011101850766097224]
[6809.2215443825, 0.07335489340440915, 0.623608368753081, -0.011101850523658072]
[7558.197765653631, 0.0899195237692137, 0.5404167569090096, -0.018072844978693017]
[7558.197793962325, 0.0899195237692137, 0.5404167569090096, -0.018072844978693017]
[7558.197765653631, 0.08991952090854943, 0.5404167569090096, -0.018072844978693017]
[7558.197765653631, 0.0899195237692137, 0.5404167649266459, -0.018072844978693017]
[7558.197765653631, 0.0899195237692137, 0.5404167569090096, -0.01807284476559662]
[7763.468238856098, 0.11435145590850299, 0.5277665478366693, -0.020537599886077215]
[7763.468265551999, 0.11435145590850299, 0.5277665478366693, -0.020537599886077215]
[7763.468238856098, 0.11435145272612651, 0.5277665478366693, -0.020537599886077215]
[7763.468238856098, 0.11435145590850299, 0.5277665557724883, -0.020537599886077215]
[7763.468238856098, 0.11435145590850299, 0.5277665478366693, -0.020537599690224465]
[7506.690181932523, 0.1056549520253513, 0.5572206196940434, -0.0181838577059016]
[7506.690210608636, 0.1056549520253513, 0.5572206196940434, -0.0181838577059016]
[7506.690181932523, 0.10565494895139649, 0.5572206196940434, -0.0181838577059016]
[7506.690181932523, 0.1056549520253513, 0.5572206278160412, -0.0181838577059016]
[7506.690181932523, 0.1056549520253513, 0.5572206196940434, -0.01818385749349023]
[7593.283306689331, 0.10339648195351342, 0.5400580400541268, -0.01888448790217349]
[7593.28333473958, 0.10339648195351342, 0.5400580400541268, -0.01888448790217349]
[7593.283306689331, 0.1033964789087532, 0.5400580400541268, -0.01888448790217349]
[7593.283306689331, 0.10339648195351342, 0.5400580480694822, -0.01888448790217349]
[7593.283306689331, 0.10339648195351342, 0.5400580400541268, -0.018884487694274237]
[7599.292645210451, 0.1073118730797264, 0.5417770006550352, -0.01908976092060305]
[7599.292673215755, 0.1073118730797264, 0.5417770006550352, -0.01908976092060305]
[7599.292645210451, 0.10731186998463299, 0.5417770006550352, -0.01908976092060305]
[7599.292645210451, 0.1073118730797264, 0.5417770086813007, -0.01908976092060305]
[7599.292645210451, 0.1073118730797264, 0.5417770006550352, -0.01908976071408945]
[7573.948453942942, 0.10557345772322335, 0.5431125717744298, -0.018857683088647284]
[7573.948482136448, 0.10557345772322335, 0.5431125717744298, -0.018857683088647284]
[7573.948453942942, 0.10557345465031426, 0.5431125717744298, -0.018857683088647284]
[7573.948453942942, 0.10557345772322335, 0.5431125798091367, -0.018857683088647284]
[7573.948453942942, 0.10557345772322335, 0.5431125717744298, -0.018857682880569264]
[7566.24615579425, 0.10577194290323011, 0.5393300773062681, -0.01892568816058434]
[7566.246184044252, 0.10577194290323011, 0.5393300773062681, -0.01892568816058434]
[7566.24615579425, 0.10577193982777505, 0.5393300773062681, -0.01892568816058434]
[7566.24615579425, 0.10577194290323011, 0.5393300853169875, -0.01892568816058434]
[7566.24615579425, 0.10577194290323011, 0.5393300773062681, -0.018925687952960832]
[7438.134913299218, 0.10582978162128709, 0.5077508178280148, -0.01916172144629518]
[7438.1349424430555, 0.10582978162128709, 0.5077508178280148, -0.01916172144629518]
[7438.134913299218, 0.10582977854509079, 0.5077508178280148, -0.01916172144629518]
[7438.134913299218, 0.10582978162128709, 0.5077508256284369, -0.01916172144629518]
[7438.134913299218, 0.10582978162128709, 0.5077508178280148, -0.01916172124027439]
[6982.99274849213, 0.1072363747447097, 0.410086523180501, -0.019759204447174477]
[6982.99278019502, 0.1072363747447097, 0.410086523180501, -0.019759204447174477]
[6982.99274849213, 0.10723637165057442, 0.410086523180501, -0.019759204447174477]
[6982.99274849213, 0.1072363747447097, 0.4100865302019734, -0.019759204447174477]
[6982.99274849213, 0.1072363747447097, 0.410086523180501, -0.019759204245390957]
[7346.612211448844, 0.1061219417020669, 0.48658687252270816, -0.01928712885543362]
[7346.612241181021, 0.1061219417020669, 0.48658687252270816, -0.01928712885543362]
[7346.612211448844, 0.10612193862213065, 0.48658687252270816, -0.01928712885543362]
[7346.612211448844, 0.1061219417020669, 0.4865868801716666, -0.01928712885543362]
[7346.612211448844, 0.1061219417020669, 0.48658687252270816, -0.019287128650280518]
[7082.588204660748, 0.10644629943171369, 0.43129203040655584, -0.019391247168512322]
[7082.588235878394, 0.10644629943171369, 0.43129203040655584, -0.019391247168512322]
[7082.588204660748, 0.10644629634763386, 0.43129203040655584, -0.019391247168512322]
[7082.588204660748, 0.10644629943171369, 0.4312920376155811, -0.019391247168512322]
[7082.588204660748, 0.10644629943171369, 0.43129203040655584, -0.019391246964088248]
[7316.608601421974, 0.10615960653700501, 0.47999609945078603, -0.019299245408810714]
[7316.608631338412, 0.10615960653700501, 0.47999609945078603, -0.019299245408810714]
[7316.608601421974, 0.10615960345658715, 0.47999609945078603, -0.019299245408810714]
[7316.608601421974, 0.10615960653700501, 0.4799961070507569, -0.019299245408810714]
[7316.608601421974, 0.10615960653700501, 0.47999609945078603, -0.01929924520374205]
[7163.264252244086, 0.10634878563227401, 0.4475617124761544, -0.019359999079592953]
[7163.264283039462, 0.10634878563227401, 0.4475617124761544, -0.019359999079592953]
[7163.264252244086, 0.10634878254943897, 0.4475617124761544, -0.019359999079592953]
[7163.264252244086, 0.10634878563227401, 0.4475617198216846, -0.019359999079592953]
[7163.264252244086, 0.10634878563227401, 0.4475617124761544, -0.019359998874949255]
[7307.698417376171, 0.1061707486052883, 0.4780547447748388, -0.019302828426752332]
[7307.698447346534, 0.1061707486052883, 0.4780547447748388, -0.019302828426752332]
[7307.698417376171, 0.106170745524728, 0.4780547447748388, -0.019302828426752332]
[7307.698417376171, 0.1061707486052883, 0.47805475236021044, -0.019302828426752332]
[7307.698417376171, 0.1061707486052883, 0.4780547447748388, -0.019302828221708652]
[7087.339937641347, 0.11920057438625004, 0.3722232574465152, -0.019449503746359613]
[7087.33996883486, 0.11920057438625004, 0.3722232574465152, -0.019449503746359613]
[7087.339937641347, 0.1192005711460063, 0.3722232574465152, -0.019449503746359613]
[7087.339937641347, 0.11920057438625004, 0.37222326410323137, -0.019449503746359613]
[7087.339937641347, 0.11920057438625004, 0.3722232574465152, -0.019449503542346903]
[7268.138115689803, 0.10850006724264849, 0.4577253242346586, -0.01932965927278857]
[7268.1381458952455, 0.10850006724264849, 0.4577253242346586, -0.01932965927278857]
[7268.138115689803, 0.10850006413253915, 0.4577253242346586, -0.01932965927278857]
[7268.138115689803, 0.10850006724264849, 0.45772533166238183, -0.01932965927278857]
[7268.138115689803, 0.10850006724264849, 0.4577253242346586, -0.019329659067932308]
[7039.009188951679, 0.12510285745888067, 0.3463200563899572, -0.019323473494987614]
[7039.009220386453, 0.12510285745888067, 0.3463200563899572, -0.019323473494987614]
[7039.009188951679, 0.12510285415052563, 0.3463200563899572, -0.019323473494987614]
[7039.009188951679, 0.12510285745888067, 0.3463200627722338, -0.019323473494987614]
[7039.009188951679, 0.12510285745888067, 0.3463200563899572, -0.0193234732900881]
[7219.837761632285, 0.11196972629838753, 0.43246852667658564, -0.019328334390497467]
[7219.837792115326, 0.11196972629838753, 0.43246852667658564, -0.019328334390497467]
[7219.837761632285, 0.11196972314509557, 0.43246852667658564, -0.019328334390497467]
[7219.837761632285, 0.11196972629838753, 0.4324685338956914, -0.019328334390497467]
[7219.837761632285, 0.11196972629838753, 0.43246852667658564, -0.01932833418563194]
[7266.236927662482, 0.10863633481857832, 0.4567131946279166, -0.01932960689309906]
[7266.236957879046, 0.10863633481857832, 0.4567131946279166, -0.01932960689309906]
[7266.236927662482, 0.10863633170675441, 0.4567131946279166, -0.01932960689309906]
[7266.236927662482, 0.10863633481857832, 0.45671320204755794, -0.01932960689309906]
[7266.236927662482, 0.10863633481857832, 0.4567131946279166, -0.01932960668824243]
[7235.65912217731, 0.11083142447456468, 0.4406370307020875, -0.019328767047585044]
[7235.6591525705435, 0.11083142447456468, 0.4406370307020875, -0.019328767047585044]
[7235.65912217731, 0.11083142133533203, 0.4406370307020875, -0.019328767047585044]
[7235.65912217731, 0.11083142447456468, 0.4406370379902751, -0.019328767047585044]
[7235.65912217731, 0.11083142447456468, 0.4406370307020875, -0.019328766842722542]
[7078.422109193853, 0.13133146909079857, 0.3365309139836717, -0.0193737767963764]
[7078.4221404325845, 0.13133146909079857, 0.3365309139836717, -0.0193737767963764]
[7078.422109193853, 0.1313314657131735, 0.3365309139836717, -0.0193737767963764]
[7078.422109193853, 0.13133146909079857, 0.33653092025632564, -0.0193737767963764]
[7078.422109193853, 0.13133146909079857, 0.3365309139836717, -0.01937377659182945]
[7205.327379885895, 0.11471218682012918, 0.4191254571746088, -0.019337552953930942]
[7205.327410450349, 0.11471218682012918, 0.4191254571746088, -0.019337552953930942]
[7205.327379885895, 0.11471218363338631, 0.4191254571746088, -0.019337552953930942]
[7205.327379885895, 0.11471218682012918, 0.41912546427740627, -0.019337552953930942]
[7205.327379885895, 0.11471218682012918, 0.4191254571746088, -0.01933755274912992]
[7234.703896574732, 0.11095308135046256, 0.43994929407808747, -0.01932904453575094]
[7234.7039269734205, 0.11095308135046256, 0.43994929407808747, -0.01932904453575094]
[7234.703896574732, 0.11095307820972228, 0.43994929407808747, -0.01932904453575094]
[7234.703896574732, 0.11095308135046256, 0.43994930136051946, -0.01932904453575094]
[7234.703896574732, 0.11095308135046256, 0.43994929407808747, -0.01932904433089038]
[7215.333303794627, 0.11342796139464084, 0.42614710835823866, -0.01933466036924779]
[7215.333334303039, 0.11342796139464084, 0.42614710835823866, -0.01933466036924779]
[7215.333303794627, 0.11342795822348872, 0.42614710835823866, -0.01933466036924779]
[7215.333303794627, 0.11342796139464084, 0.4261471155227874, -0.01933466036924779]
[7215.333303794627, 0.11342796139464084, 0.42614710835823866, -0.019334660164426525]
[7234.32421724256, 0.11100144720778088, 0.43967612040133164, -0.01932915481610929]
[7234.324247643413, 0.11100144720778088, 0.43967612040133164, -0.01932915481610929]
[7234.32421724256, 0.11100144406644163, 0.43967612040133164, -0.01932915481610929]
[7234.32421724256, 0.11100144720778088, 0.43967612768147435, -0.01932915481610929]
[7234.32421724256, 0.11100144720778088, 0.43967612040133164, -0.019329154611249504]
[7221.79773522896, 0.1126003758105234, 0.430722649655942, -0.019332788597345864]
[7221.797765700935, 0.1126003758105234, 0.430722649655942, -0.019332788597345864]
[7221.79773522896, 0.11260037264948675, 0.430722649655942, -0.019332788597345864]
[7221.79773522896, 0.1126003758105234, 0.4307226568600768, -0.019332788597345864]
[7221.79773522896, 0.1126003758105234, 0.430722649655942, -0.019332788392511496]
[7234.167800465546, 0.1110213742061098, 0.43956361148093925, -0.019329200245984446]
[7234.167830867293, 0.1110213742061098, 0.43956361148093925, -0.019329200245984446]
[7234.167800465546, 0.11102137106452381, 0.43956361148093925, -0.019329200245984446]
[7234.167800465546, 0.1110213742061098, 0.4395636187601386, -0.019329200245984446]
[7234.167800465546, 0.1110213742061098, 0.43956361148093925, -0.019329200041124976]
[7226.0067585903225, 0.11206242200416716, 0.43371828662475753, -0.019331568607223765]
[7226.006789038476, 0.11206242200416716, 0.43371828662475753, -0.019331568607223765]
[7226.0067585903225, 0.11206241884973484, 0.43371828662475753, -0.019331568607223765]
[7226.0067585903225, 0.11206242200416716, 0.4337182938545353, -0.019331568607223765]
[7226.0067585903225, 0.11206242200416716, 0.43371828662475753, -0.019331568402380858]
[7234.102021840579, 0.11102975448585267, 0.4395163029584216, -0.019329219350387394]
[7234.1020522427025, 0.11102975448585267, 0.4395163029584216, -0.019329219350387394]
[7234.102021840579, 0.11102975134416293, 0.4395163029584216, -0.019329219350387394]
[7234.102021840579, 0.11102975448585267, 0.43951631023722415, -0.019329219350387394]
[7234.102021840579, 0.11102975448585267, 0.4395163029584216, -0.019329219145528057]
[7228.760521950299, 0.1117108461209751, 0.4356852136182938, -0.01933076988104593]
[7228.760552382826, 0.1117108461209751, 0.4356852136182938, -0.01933076988104593]
[7228.760521950299, 0.11171084297087147, 0.4356852136182938, -0.01933076988104593]
[7228.760521950299, 0.1117108461209751, 0.435685220864792, -0.01933076988104593]
[7228.760521950299, 0.1117108461209751, 0.4356852136182938, -0.019330769676197436]
[7234.074004112457, 0.11103332403237776, 0.4394961533406918, -0.01932922748763577]
[7234.074034514739, 0.11103332403237776, 0.4394961533406918, -0.01932922748763577]
[7234.074004112457, 0.11103332089064383, 0.4394961533406918, -0.01932922748763577]
[7234.074004112457, 0.11103332403237776, 0.4394961606193253, -0.01932922748763577]
[7234.074004112457, 0.11103332403237776, 0.4394961533406918, -0.019329227282776487]
[7233.2510194898105, 0.11113818888331983, 0.43890454028518644, -0.019329466488727083]
[7233.251049896785, 0.11113818888331983, 0.43890454028518644, -0.019329466488727083]
[7233.2510194898105, 0.11113818574028805, 0.43890454028518644, -0.019329466488727083]
[7233.2510194898105, 0.11113818888331983, 0.43890454755885366, -0.019329466488727083]
[7233.2510194898105, 0.11113818888331983, 0.43890454028518644, -0.019329466283869473]
[7231.0062422248275, 0.11142435662267036, 0.4372933710107325, -0.01933011819213796]
[7231.006272644587, 0.11142435662267036, 0.4372933710107325, -0.01933011819213796]
[7231.0062422248275, 0.1114243534761013, 0.4372933710107325, -0.01933011819213796]
[7231.0062422248275, 0.11142435662267036, 0.43729337827083303, -0.01933011819213796]
[7231.0062422248275, 0.11142435662267036, 0.4372933710107325, -0.01933011798728491]
[7229.524172573367, 0.11161340360491939, 0.4362316487074648, -0.019330548308444488]
[7229.524203001554, 0.11161340360491939, 0.4362316487074648, -0.019330548308444488]
[7229.524172573367, 0.1116134004560172, 0.4362316487074648, -0.019330548308444488]
[7229.524172573367, 0.11161340360491939, 0.4362316559585918, -0.019330548308444488]
[7229.524172573367, 0.11161340360491939, 0.4362316487074648, -0.01933054810359445]
[7231.004134132523, 0.11142462546031279, 0.43729185967811124, -0.019330118804023494]
[7231.004164552294, 0.11142462546031279, 0.43729185967811124, -0.019330118804023494]
[7231.004134132523, 0.1114246223137404, 0.43729185967811124, -0.019330118804023494]
[7231.004134132523, 0.11142462546031279, 0.437291866938199, -0.019330118804023494]
[7231.004134132523, 0.11142462546031279, 0.43729185967811124, -0.01933011859917045]
[7230.027405439596, 0.11154920335893848, 0.4365919735113265, -0.019330402277648165]
[7230.027435864923, 0.11154920335893848, 0.4365919735113265, -0.019330402277648165]
[7230.027405439596, 0.11154920021082831, 0.4365919735113265, -0.019330402277648165]
[7230.027405439596, 0.11154920335893848, 0.4365919807655019, -0.019330402277648165]
[7230.027405439596, 0.11154920335893848, 0.4365919735113265, -0.019330402072797105]
[7231.003219628759, 0.11142474208383629, 0.43729120405348043, -0.019330119069463234]
[7231.003250048536, 0.11142474208383629, 0.43729120405348043, -0.019330119069463234]
[7231.003219628759, 0.11142473893726246, 0.43729120405348043, -0.019330119069463234]
[7231.003219628759, 0.11142474208383629, 0.43729121131356263, -0.019330119069463234]
[7231.003219628759, 0.11142474208383629, 0.43729120405348043, -0.01933011886461019]
[7230.922425911888, 0.11143504556093281, 0.4372332839610832, -0.019330142520094015]
[7230.922456332124, 0.11143504556093281, 0.4372332839610832, -0.019330142520094015]
[7230.922425911888, 0.1114350424142318, 0.4372332839610832, -0.019330142520094015]
[7230.922425911888, 0.11143504556093281, 0.43723329122067667, -0.019330142520094015]
[7230.922425911888, 0.11143504556093281, 0.4372332839610832, -0.019330142315241133]
[7230.474934397362, 0.11149211807119053, 0.4369125688855928, -0.01933027239915911]
[7230.474964820144, 0.11149211807119053, 0.4369125688855928, -0.01933027239915911]
[7230.474934397362, 0.11149211492378486, 0.4369125688855928, -0.01933027239915911]
[7230.474934397362, 0.11149211807119053, 0.4369125761424778, -0.01933027239915911]
[7230.474934397362, 0.11149211807119053, 0.4369125688855928, -0.019330272194307135]
[7230.922425911888, 0.11143504556093281, 0.4372332839610832, -0.019330142520094015]
[7230.922456332124, 0.11143504556093281, 0.4372332839610832, -0.019330142520094015]
[7230.922425911888, 0.1114350424142318, 0.4372332839610832, -0.019330142520094015]
[7230.922425911888, 0.11143504556093281, 0.43723329122067667, -0.019330142520094015]
[7230.922425911888, 0.11143504556093281, 0.4372332839610832, -0.019330142315241133]
[7123.964895483576, 0.13530616326957107, 0.32706566846385576, -0.019345443308442165]
[7123.964926487991, 0.13530616326957107, 0.32706566846385576, -0.019345443308442165]
[7123.964895483576, 0.13530615984906813, 0.32706566846385576, -0.019345443308442165]
[7123.964895483576, 0.13530616326957107, 0.3270656746271825, -0.019345443308442165]
[7123.964895483576, 0.13530616326957107, 0.32706566846385576, -0.01934544310369641]
[7211.387567911947, 0.11567880013538667, 0.4156283030561678, -0.019332959677107627]
[7211.38759844251, 0.11567880013538667, 0.4156283030561678, -0.019332959677107627]
[7211.387567911947, 0.11567879693699312, 0.4156283030561678, -0.019332959677107627]
[7211.387567911947, 0.11567880013538667, 0.4156283101277487, -0.019332959677107627]
[7211.387567911947, 0.11567880013538667, 0.4156283030561678, -0.01933295947227446]
[7230.332205013208, 0.1115624745876368, 0.4365710936400484, -0.01933022779082444]
[7230.332235436803, 0.1115624745876368, 0.4365710936400484, -0.01933022779082444]
[7230.332205013208, 0.11156247143936288, 0.4365710936400484, -0.01933022779082444]
[7230.332205013208, 0.1115624745876368, 0.43657110089404727, -0.01933022779082444]
[7230.332205013208, 0.1115624745876368, 0.4365710936400484, -0.01933022758597215]
[7230.921911813008, 0.11143515653358083, 0.4372327069209079, -0.019330142594371404]
[7230.921942233247, 0.11143515653358083, 0.4372327069209079, -0.019330142594371404]
[7230.921911813008, 0.11143515338687843, 0.4372327069209079, -0.019330142594371404]
[7230.921911813008, 0.11143515653358083, 0.43723271418049636, -0.019330142594371404]
[7230.921911813008, 0.11143515653358083, 0.4372327069209079, -0.019330142389518523]
[7230.921398523964, 0.11143526733145609, 0.43723213079015966, -0.01933014266853178]
[7230.921428944205, 0.11143526733145609, 0.43723213079015966, -0.01933014266853178]
[7230.921398523964, 0.1114352641847523, 0.43723213079015966, -0.01933014266853178]
[7230.921398523964, 0.11143526733145609, 0.43723213804974326, -0.01933014266853178]
[7230.921398523964, 0.11143526733145609, 0.43723213079015966, -0.019330142463678902]
[7230.626809882981, 0.11149886302727341, 0.4369015486230797, -0.01933018522970904]
[7230.6268403049, 0.11149886302727341, 0.4369015486230797, -0.01933018522970904]
[7230.626809882981, 0.11149885987978453, 0.4369015486230797, -0.01933018522970904]
[7230.626809882981, 0.11149886302727341, 0.4369015558798718, -0.01933018522970904]
[7230.626809882981, 0.11149886302727341, 0.4369015486230797, -0.01933018502485646]
[7230.921270633527, 0.11143529493771809, 0.4372319872422319, -0.019330142687009486]
[7230.921301053769, 0.11143529493771809, 0.4372319872422319, -0.019330142687009486]
[7230.921270633527, 0.11143529179101397, 0.4372319872422319, -0.019330142687009486]
[7230.921270633527, 0.11143529493771809, 0.4372319945018144, -0.019330142687009486]
[7230.921270633527, 0.11143529493771809, 0.4372319872422319, -0.019330142482156608]
[7230.921142753852, 0.11143532254165872, 0.4372318437064143, -0.019330142705485633]
[7230.921173174096, 0.11143532254165872, 0.4372318437064143, -0.019330142705485633]
[7230.921142753852, 0.11143531939495427, 0.4372318437064143, -0.019330142705485633]
[7230.921142753852, 0.11143532254165872, 0.4372318509659956, -0.019330142705485633]
[7230.921142753852, 0.11143532254165872, 0.4372318437064143, -0.01933014250063276]
[7230.773978343667, 0.11146709080467798, 0.4370666802986103, -0.019330163967605056]
[7230.774008764748, 0.11146709080467798, 0.4370666802986103, -0.019330163967605056]
[7230.773978343667, 0.11146708765758129, 0.4370666802986103, -0.019330163967605056]
[7230.773978343667, 0.11146709080467798, 0.4370666875567971, -0.019330163967605056]
[7230.773978343667, 0.11146709080467798, 0.4370666802986103, -0.019330163762752327]
[7230.921110830606, 0.11143532943256979, 0.4372318078748497, -0.019330142710097926]
[7230.921141250849, 0.11143532943256979, 0.4372318078748497, -0.019330142710097926]
[7230.921110830606, 0.11143532628586522, 0.4372318078748497, -0.019330142710097926]
[7230.921110830606, 0.11143532943256979, 0.43723181513443066, -0.019330142710097926]
[7230.921110830606, 0.11143532943256979, 0.4372318078748497, -0.01933014250524505]
[7230.921078915722, 0.11143533632167557, 0.4372317720526743, -0.01933014271470901]
[7230.921109335966, 0.11143533632167557, 0.4372317720526743, -0.01933014271470901]
[7230.921078915722, 0.11143533317497095, 0.4372317720526743, -0.01933014271470901]
[7230.921078915722, 0.11143533632167557, 0.43723177931225476, -0.01933014271470901]
[7230.921078915722, 0.11143533632167557, 0.4372317720526743, -0.01933014250985613]
[7230.84752913559, 0.11145121306863898, 0.4371492222130823, -0.01933015334115896]
[7230.847559556252, 0.11145121306863898, 0.4371492222130823, -0.01933015334115896]
[7230.84752913559, 0.11145120992173829, 0.4371492222130823, -0.01933015334115896]
[7230.84752913559, 0.11145121306863898, 0.437149229471966, -0.01933015334115896]
[7230.84752913559, 0.11145121306863898, 0.4371492222130823, -0.01933015313630616]
[7230.798985726441, 0.11146169226345293, 0.4370947436602661, -0.019330160354613816]

Total fitting time:
5.103947877883911 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",  # HITEMP is recommended
    "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 6.044 seconds)