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/master/radis/spectrum/spectrum.py:5425: 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.0004737377166748047s.

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/master/radis/spectrum/spectrum.py:5425: 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.0004410743713378906s.

Commence fitting process for LTE spectrum!

[[Fit Statistics]]
    # fitting method   = L-BFGS-B
    # function evals   = 301
    # data points      = 1
    # variables        = 4
    chi-square         = 3.5602e-08
    reduced chi-square = 3.5602e-08
    Akaike info crit   = -9.15086785
    Bayesian info crit = -17.1508679
##  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.66041 (init = 5000)
    mole_fraction:  0.11217647 (init = 0.05)
    pressure:       0.43714675 (init = 0.8)
    offsetcm1:     -0.01916705 (init = 0)

Successfully finished the fitting process in 5.141255140304565s.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/master/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/master/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/master/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.0002362114468308734), np.float64(0.00023621144992303669), np.float64(0.00023621145570499978), np.float64(0.00023621144487543936), np.float64(0.00023621143644290548), np.float64(0.00020815016320262144), np.float64(0.0002081501657046417), np.float64(0.0002081501669005356), np.float64(0.00020815016411863697), np.float64(0.00020815015815280356), np.float64(0.00022802644642738328), np.float64(0.00022802645067102303), np.float64(0.00022802645641043255), np.float64(0.00022802644383073265), np.float64(0.00022802643975939978), np.float64(0.00020524377665607206), np.float64(0.00020524377896368582), np.float64(0.0002052437804793633), np.float64(0.00020524377746183065), np.float64(0.00020524377146227457), np.float64(0.00023349328973539871), np.float64(0.00023349329438040537), np.float64(0.00023349329951887252), np.float64(0.0002334932874853045), np.float64(0.00023349328324509096), np.float64(0.00020444199217437893), np.float64(0.00020444199441981253), np.float64(0.00020444199602913846), np.float64(0.00020444199294694242), np.float64(0.00020444198691897688), np.float64(0.0002231187688182481), np.float64(0.00022311877900411345), np.float64(0.00022311879114778377), np.float64(0.00022311875740933858), np.float64(0.00022311876395463516), np.float64(0.00019787538609462749), np.float64(0.00019787538863148016), np.float64(0.00019787539146172412), np.float64(0.0001978753858800741), np.float64(0.00019787538012758455), np.float64(0.00021403319809606367), np.float64(0.0002140332077742035), np.float64(0.00021403321941573097), np.float64(0.00021403318585747918), np.float64(0.0002140331979208991), np.float64(0.00022898119497762075), np.float64(0.00022898120046075797), np.float64(0.0002289812057263655), np.float64(0.00022898119176935128), np.float64(0.00022898119011684575), np.float64(0.00019749512532235417), np.float64(0.00019749512784154953), np.float64(0.00019749513068710356), np.float64(0.00019749512509349386), np.float64(0.0001974951193974558), np.float64(0.00019198450161311625), np.float64(0.00019198450398544945), np.float64(0.00019198450727794933), np.float64(0.0001919845009668661), np.float64(0.00019198449639001722), np.float64(0.0002064485687598686), np.float64(0.00020644857700077076), np.float64(0.00020644858629179194), np.float64(0.0002064485585399882), np.float64(0.000206448567523838), np.float64(0.00022371048170477634), np.float64(0.0002237104867450698), np.float64(0.00022371049148793063), np.float64(0.0002237104787450776), np.float64(0.00022371047712297425), np.float64(0.0001917651899324085), np.float64(0.0001917651922742869), np.float64(0.00019176519554597282), np.float64(0.0001917651893029303), np.float64(0.0001917651847279033), np.float64(0.00022638232007802877), np.float64(0.00022638232519952268), np.float64(0.00022638232996985162), np.float64(0.0002263823172064831), np.float64(0.00022638231525825338), np.float64(0.0001916782124655449), np.float64(0.00019167821479543375), np.float64(0.00019167821805906248), np.float64(0.00019167821184241108), np.float64(0.0001916782072684757), np.float64(0.0002281932341050898), np.float64(0.0002281932393018268), np.float64(0.0002281932441248615), np.float64(0.0002281932312611753), np.float64(0.0002281932291861997), np.float64(0.00019164241866161127), np.float64(0.00019164242098658092), np.float64(0.00019164242424692652), np.float64(0.00019164241804067923), np.float64(0.0001916424134676125), np.float64(0.00022940797202814197), np.float64(0.00022940797728300603), np.float64(0.00022940798215521), np.float64(0.0002294079691856649), np.float64(0.00022940796701023734), np.float64(0.00019162737261142036), np.float64(0.00019162737493432614), np.float64(0.00019162737819329606), np.float64(0.00019162737199195236), np.float64(0.00019162736741871404), np.float64(0.00023021798897536377), np.float64(0.0002302179942720592), np.float64(0.00023021799918276125), np.float64(0.000230217986131218), np.float64(0.00023021798389330419), np.float64(0.00019162096416743717), np.float64(0.00019162096648946201), np.float64(0.00019162096974784953), np.float64(0.0001916209635463684), np.float64(0.0001916209589752817), np.float64(0.00019146571477498438), np.float64(0.00019146571707579383), np.float64(0.00019146572032022004), np.float64(0.00019146571416697096), np.float64(0.00019146570959623223), np.float64(0.0001909351610974728), np.float64(0.0001909351633270775), np.float64(0.00019093516652659954), np.float64(0.00019093516052437015), np.float64(0.000190935155965398), np.float64(0.0002304524018264077), np.float64(0.00023045240713563824), np.float64(0.00023045241205829918), np.float64(0.00023045239898057432), np.float64(0.00023045239672605256), np.float64(0.0001909346559083183), np.float64(0.0001909346581378578), np.float64(0.0001909346613373376), np.float64(0.00019093465533564168), np.float64(0.00019093465077628862), np.float64(0.0001909341521157978), np.float64(0.0001909341543452701), np.float64(0.00019093415754470983), np.float64(0.00019093415154132834), np.float64(0.00019093414698381317), np.float64(0.0002306801714072372), np.float64(0.00023068017672873327), np.float64(0.0002306801816634482), np.float64(0.0002306801685594512), np.float64(0.00023068016628921925), np.float64(0.00019093402683951843), np.float64(0.00019093402906897474), np.float64(0.00019093403226840366), np.float64(0.00019093402626648733), np.float64(0.00019093402170754497), np.float64(0.0001909339016703317), np.float64(0.00019093390389977066), np.float64(0.0001909339070991905), np.float64(0.00019093390109770186), np.float64(0.00019093389653836943), np.float64(0.00023079422716971675), np.float64(0.00023079423249746742), np.float64(0.00023079423743829481), np.float64(0.00023079422432083885), np.float64(0.00023079422204289583), np.float64(0.00019139629361862538), np.float64(0.00019139629527548517), np.float64(0.00019139629762004879), np.float64(0.00019139629383861187), np.float64(0.0001913962886972348), np.float64(0.0001896849328028445), np.float64(0.00018968493204976622), np.float64(0.0001896849312118248), np.float64(0.00018968493582610747), np.float64(0.0001896849311386865), np.float64(0.0001891569006530621), np.float64(0.00018915690031173397), np.float64(0.00018915690000480633), np.float64(0.00018915690308528042), np.float64(0.00018915690054454237), np.float64(0.00022620621797987426), np.float64(0.0002262062216635926), np.float64(0.00022620622439294515), np.float64(0.0002262062168672259), np.float64(0.00022620621701958867), np.float64(0.000189154066080167), np.float64(0.00018915406574077833), np.float64(0.0001891540654364811), np.float64(0.00018915406850900045), np.float64(0.00018915406597699147), np.float64(0.00018870547707181232), np.float64(0.00018870547709511418), np.float64(0.00018870547728122675), np.float64(0.00018870547897651077), np.float64(0.00018870547789947545), np.float64(0.00022450157729125974), np.float64(0.00022450158140783813), np.float64(0.0002245015847583501), np.float64(0.00022450157541430244), np.float64(0.00022450157771384608), np.float64(0.00018869097964200067), np.float64(0.00018869097967218792), np.float64(0.00018869097986814898), np.float64(0.0001886909815385471), np.float64(0.0001886909804891419), np.float64(0.0002261398057272737), np.float64(0.00022613980937356414), np.float64(0.00022613981205195127), np.float64(0.00022613980466689416), np.float64(0.00022613980463514978), np.float64(0.00018869071981274775), np.float64(0.00018869071984305722), np.float64(0.0001886907200391964), np.float64(0.00018869072170910801), np.float64(0.0001886907206602388), np.float64(0.00022624413370760332), np.float64(0.00022624413732975394), np.float64(0.00022624413997354045), np.float64(0.00022624413268952084), np.float64(0.00022624413252754532), np.float64(0.0001886906069783772), np.float64(0.0001886906070087411), np.float64(0.00018869060720495655), np.float64(0.00018869060887400442), np.float64(0.00018869060782602027), np.float64(0.00018868456107580533)]

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.612209755508, 0.1061219417074225, 0.4865868721388049, -0.01928712885772626]
[7346.612239487685, 0.1061219417074225, 0.4865868721388049, -0.01928712885772626]
[7346.612209755508, 0.10612193862748626, 0.4865868721388049, -0.01928712885772626]
[7346.612209755508, 0.1061219417074225, 0.4865868797877634, -0.01928712885772626]
[7346.612209755508, 0.1061219417074225, 0.4865868721388049, -0.019287128652573156]
[7082.5879341742775, 0.10644629917600101, 0.431291979628035, -0.01939124737817717]
[7082.5879653919255, 0.10644629917600101, 0.431291979628035, -0.01939124737817717]
[7082.5879341742775, 0.10644629609192119, 0.431291979628035, -0.01939124737817717]
[7082.5879341742775, 0.10644629917600101, 0.43129198683705994, -0.01939124737817717]
[7082.5879341742775, 0.10644629917600101, 0.431291979628035, -0.019391247173753103]
[7316.607594479431, 0.10615960773275596, 0.479995879994889, -0.019299245827853168]
[7316.607624395875, 0.10615960773275596, 0.479995879994889, -0.019299245827853168]
[7316.607594479431, 0.10615960465233809, 0.479995879994889, -0.019299245827853168]
[7316.607594479431, 0.10615960773275596, 0.47999588759485823, -0.019299245827853168]
[7316.607594479431, 0.10615960773275596, 0.479995879994889, -0.019299245622784504]
[7163.263723718895, 0.1063487858704461, 0.447561606210779, -0.019359999360299605]
[7163.263754514273, 0.1063487858704461, 0.447561606210779, -0.019359999360299605]
[7163.263723718895, 0.10634878278761106, 0.447561606210779, -0.019359999360299605]
[7163.263723718895, 0.1063487858704461, 0.4475616135563082, -0.019359999360299605]
[7163.263723718895, 0.1063487858704461, 0.447561606210779, -0.019359999155655908]
[7307.697630273523, 0.1061707495041217, 0.47805457404987683, -0.019302828760282997]
[7307.697660243891, 0.1061707495041217, 0.47805457404987683, -0.019302828760282997]
[7307.697630273523, 0.10617074642356139, 0.47805457404987683, -0.019302828760282997]
[7307.697630273523, 0.1061707495041217, 0.4780545816352473, -0.019302828760282997]
[7307.697630273523, 0.1061707495041217, 0.47805457404987683, -0.01930282855523932]
[7088.867255346642, 0.1191023668298995, 0.37295195947665893, -0.01944737798513782]
[7088.867286532377, 0.1191023668298995, 0.37295195947665893, -0.01944737798513782]
[7088.867255346642, 0.11910236359081028, 0.37295195947665893, -0.01944737798513782]
[7088.867255346642, 0.1191023668298995, 0.3729519661407865, -0.01944737798513782]
[7088.867255346642, 0.1191023668298995, 0.37295195947665893, -0.01944737778111006]
[7268.65811219417, 0.10846809577417205, 0.45800045856660965, -0.019329101942137134]
[7268.658142396569, 0.10846809577417205, 0.45800045856660965, -0.019329101942137134]
[7268.65811219417, 0.10846809266446522, 0.45800045856660965, -0.019329101942137134]
[7268.65811219417, 0.10846809577417205, 0.4580004659965259, -0.019329101942137134]
[7268.65811219417, 0.10846809577417205, 0.45800045856660965, -0.019329101737276977]
[7037.68230590494, 0.1252174035661277, 0.34563271756161534, -0.019322117705209862]
[7037.682337346207, 0.1252174035661277, 0.34563271756161534, -0.019322117705209862]
[7037.68230590494, 0.1252174002564751, 0.34563271756161534, -0.019322117705209862]
[7037.68230590494, 0.1252174035661277, 0.3456327239363054, -0.019322117705209862]
[7037.68230590494, 0.1252174035661277, 0.34563271756161534, -0.01932211750030087]
[7219.492330803205, 0.11200238047476413, 0.43226435482238756, -0.01932759131082188]
[7219.492361288195, 0.11200238047476413, 0.43226435482238756, -0.01932759131082188]
[7219.492330803205, 0.11200237732107032, 0.43226435482238756, -0.01932759131082188]
[7219.492330803205, 0.11200238047476413, 0.4322643620397465, -0.01932759131082188]
[7219.492330803205, 0.11200238047476413, 0.43226435482238756, -0.019327591105951156]
[7266.681191167734, 0.10860988410285277, 0.45694658347311434, -0.019329040928424003]
[7266.6812213817, 0.10860988410285277, 0.45694658347311434, -0.019329040928424003]
[7266.681191167734, 0.10860988099136154, 0.45694658347311434, -0.019329040928424003]
[7266.681191167734, 0.10860988410285277, 0.4569465908946214, -0.019329040928424003]
[7266.681191167734, 0.10860988410285277, 0.45694658347311434, -0.01932904072356342]
[7235.583755512677, 0.11084380613537131, 0.44057890978431624, -0.01932808418885583]
[7235.583785906343, 0.11084380613537131, 0.44057890978431624, -0.01932808418885583]
[7235.583755512677, 0.11084380299598512, 0.44057890978431624, -0.01932808418885583]
[7235.583755512677, 0.11084380613537131, 0.4405789170720177, -0.01932808418885583]
[7235.583755512677, 0.11084380613537131, 0.44057890978431624, -0.019328083983988553]
[7078.692265502514, 0.13119562125764056, 0.33706137605895903, -0.019372235115734368]
[7078.6922967398805, 0.13119562125764056, 0.33706137605895903, -0.019372235115734368]
[7078.692265502514, 0.13119561788149886, 0.33706137605895903, -0.019372235115734368]
[7078.692265502514, 0.13119562125764056, 0.33706138233764155, -0.019372235115734368]
[7078.692265502514, 0.13119562125764056, 0.33706137605895903, -0.019372234911176588]
[7205.529176652791, 0.11467027632901194, 0.4193439039532787, -0.019336642376131183]
[7205.529207216118, 0.11467027632901194, 0.4193439039532787, -0.019336642376131183]
[7205.529176652791, 0.11467027314277589, 0.4193439039532787, -0.019336642376131183]
[7205.529176652791, 0.11467027632901194, 0.41934391105801583, -0.019336642376131183]
[7205.529176652791, 0.11467027632901194, 0.4193439039532787, -0.019336642171323786]
[7234.650817597752, 0.11096205143624815, 0.4399098603169652, -0.019328350605473023]
[7234.650847996743, 0.11096205143624815, 0.4399098603169652, -0.019328350605473023]
[7234.650817597752, 0.1109620482953968, 0.4399098603169652, -0.019328350605473023]
[7234.650817597752, 0.11096205143624815, 0.4399098675990668, -0.019328350605473023]
[7234.650817597752, 0.11096205143624815, 0.4399098603169652, -0.01932835040060761]
[7215.448134784594, 0.11340351406435206, 0.426279336698531, -0.019333823437624253]
[7215.44816529236, 0.11340351406435206, 0.426279336698531, -0.019333823437624253]
[7215.448134784594, 0.11340351089349804, 0.426279336698531, -0.019333823437624253]
[7215.448134784594, 0.11340351406435206, 0.42627934386423094, -0.019333823437624253]
[7215.448134784594, 0.11340351406435206, 0.426279336698531, -0.019333823232797125]
[7234.279198087369, 0.11100916197922489, 0.4396435320521198, -0.019328456714205338]
[7234.279228488481, 0.11100916197922489, 0.4396435320521198, -0.019328456714205338]
[7234.279198087369, 0.11100915883779006, 0.4396435320521198, -0.019328456714205338]
[7234.279198087369, 0.11100916197922489, 0.4396435393319892, -0.019328456714205338]
[7234.279198087369, 0.11100916197922489, 0.4396435320521198, -0.019328456509340668]
[7221.858091374396, 0.11258693106524609, 0.43079943445814417, -0.019331998862030582]
[7221.85812184603, 0.11258693106524609, 0.43079943445814417, -0.019331998862030582]
[7221.858091374396, 0.11258692790437419, 0.43079943445814417, -0.019331998862030582]
[7221.858091374396, 0.11258693106524609, 0.4307994416629388, -0.019331998862030582]
[7221.858091374396, 0.11258693106524609, 0.43079943445814417, -0.019331998657190687]
[7234.125995940331, 0.11102858514524871, 0.4395337659650804, -0.019328500455836443]
[7234.126026342316, 0.11102858514524871, 0.4395337659650804, -0.019328500455836443]
[7234.125995940331, 0.1110285820035734, 0.4395337659650804, -0.019328500455836443]
[7234.125995940331, 0.11102858514524871, 0.4395337732440294, -0.019328500455836443]
[7234.125995940331, 0.11102858514524871, 0.4395337659650804, -0.019328500250972075]
[7226.032327488392, 0.11205602857032482, 0.43375906487907123, -0.019330809450817978]
[7226.032357936402, 0.11205602857032482, 0.43375906487907123, -0.019330809450817978]
[7226.032327488392, 0.1120560254159711, 0.43375906487907123, -0.019330809450817978]
[7226.032327488392, 0.11205602857032482, 0.4337590721091965, -0.019330809450817978]
[7226.032327488392, 0.11205602857032482, 0.43375906487907123, -0.019330809245969763]
[7234.061549795966, 0.11103675598809865, 0.4394875967604831, -0.019328518855832654]
[7234.0615801983195, 0.11103675598809865, 0.4394875967604831, -0.019328518855832654]
[7234.061549795966, 0.1110367528463222, 0.4394875967604831, -0.019328518855832654]
[7234.061549795966, 0.11103675598809865, 0.43948760403904485, -0.019328518855832654]
[7234.061549795966, 0.11103675598809865, 0.4394875967604831, -0.019328518650968417]
[7228.763614596672, 0.11170901905227304, 0.43570247208431234, -0.019330030668624577]
[7228.763645029181, 0.11170901905227304, 0.43570247208431234, -0.019330030668624577]
[7228.763614596672, 0.1117090159021919, 0.43570247208431234, -0.019330030668624577]
[7228.763614596672, 0.11170901905227304, 0.43570247933095674, -0.019330030668624577]
[7228.763614596672, 0.11170901905227304, 0.43570247208431234, -0.019330030463770916]
[7234.034092298809, 0.11104023725316348, 0.43946792713091376, -0.019328526695142005]
[7234.034122701319, 0.11104023725316348, 0.43946792713091376, -0.019328526695142005]
[7234.034092298809, 0.11104023411134395, 0.43946792713091376, -0.019328526695142005]
[7234.034092298809, 0.11104023725316348, 0.43946793440931065, -0.019328526695142005]
[7234.034092298809, 0.11104023725316348, 0.43946792713091376, -0.019328526490277817]
[7233.367360460167, 0.11112477961179368, 0.4389904707917167, -0.019328717038754356]
[7233.367390866479, 0.11112477961179368, 0.4389904707917167, -0.019328717038754356]
[7233.367360460167, 0.11112477646892782, 0.4389904707917167, -0.019328717038754356]
[7233.367360460167, 0.11112477961179368, 0.4389904780661059, -0.019328717038754356]
[7233.367360460167, 0.11112477961179368, 0.4389904707917167, -0.019328716833891507]
[7231.065983143541, 0.11141673186574308, 0.4373449008849485, -0.019329373861054527]
[7231.066013562961, 0.11141673186574308, 0.4373449008849485, -0.019329373861054527]
[7231.065983143541, 0.11141672871926822, 0.4373449008849485, -0.019329373861054527]
[7231.065983143541, 0.11141673186574308, 0.43734490814548377, -0.019329373861054527]
[7231.065983143541, 0.11141673186574308, 0.4373449008849485, -0.01932937365619627]
[7229.546531036804, 0.11160960384505225, 0.4362605449212885, -0.019329807355703523]
[7229.546561464864, 0.11160960384505225, 0.4362605449212885, -0.019329807355703523]
[7229.546531036804, 0.11160960069619691, 0.4362605449212885, -0.019329807355703523]
[7229.546531036804, 0.11160960384505225, 0.43626055217266, -0.019329807355703523]
[7229.546531036804, 0.11160960384505225, 0.4362605449212885, -0.019329807150848297]
[7231.063774650937, 0.11141701213512079, 0.43734332357846817, -0.019329374491224183]
[7231.063805070368, 0.11141701213512079, 0.43734332357846817, -0.019329374491224183]
[7231.063774650937, 0.11141700898864243, 0.43734332357846817, -0.019329374491224183]
[7231.063774650937, 0.11141701213512079, 0.43734333083899024, -0.019329374491224183]
[7231.063774650937, 0.11141701213512079, 0.43734332357846817, -0.019329374286365934]
[7231.061572235217, 0.11141729163350172, 0.43734175061562974, -0.019329375119659594]
[7231.061602654661, 0.11141729163350172, 0.43734175061562974, -0.019329375119659594]
[7231.061572235217, 0.11141728848701993, 0.43734175061562974, -0.019329375119659594]
[7231.061572235217, 0.11141729163350172, 0.4373417578761385, -0.019329375119659594]
[7231.061572235217, 0.11141729163350172, 0.43734175061562974, -0.01932937491480135]
[7230.304105271933, 0.11151342961245297, 0.4368009775759043, -0.019329591238478973]
[7230.304135695686, 0.11151342961245297, 0.4368009775759043, -0.019329591238478973]
[7230.304105271933, 0.11151342646478424, 0.4368009775759043, -0.019329591238478973]
[7230.304105271933, 0.11151342961245297, 0.4368009848318466, -0.019329591238478973]
[7230.304105271933, 0.11151342961245297, 0.4368009775759043, -0.019329591033622237]
[7231.061024570338, 0.11141736113514528, 0.43734135947453445, -0.019329375275929775]
[7231.061054989786, 0.11141736113514528, 0.43734135947453445, -0.019329375275929775]
[7231.061024570338, 0.11141735798866265, 0.43734135947453445, -0.019329375275929775]
[7231.061024570338, 0.11141736113514528, 0.43734136673503987, -0.019329375275929775]
[7231.061024570338, 0.11141736113514528, 0.43734135947453445, -0.01932937507107153]
[7231.060477363275, 0.11141743057870135, 0.4373409686606273, -0.019329375432069314]
[7231.060507782725, 0.11141743057870135, 0.4373409686606273, -0.019329375432069314]
[7231.060477363275, 0.11141742743221783, 0.4373409686606273, -0.019329375432069314]
[7231.060477363275, 0.11141743057870135, 0.4373409759211295, -0.019329375432069314]
[7231.060477363275, 0.11141743057870135, 0.4373409686606273, -0.019329375227211065]
[7230.682304690768, 0.11146542557640488, 0.4370709307117241, -0.01932948333547292]
[7230.682335112371, 0.11146542557640488, 0.4370709307117241, -0.01932948333547292]
[7230.682304690768, 0.11146542242932872, 0.4370709307117241, -0.01932948333547292]
[7230.682304690768, 0.11146542557640488, 0.4370709379699468, -0.01932948333547292]
[7230.682304690768, 0.11146542557640488, 0.4370709307117241, -0.01932948313061543]
[7234.862667664916, 0.11102170955527041, 0.4406260078381654, -0.019317381814348493]
[7234.862698062699, 0.11102170955527041, 0.4406260078381654, -0.019317381814348493]
[7234.862667664916, 0.11102170641368025, 0.4406260078381654, -0.019317381814348493]
[7234.862667664916, 0.11102170955527041, 0.44062601512626076, -0.019317381814348493]
[7234.862667664916, 0.11102170955527041, 0.4406260078381654, -0.019317381609406405]
[7231.9185693656855, 0.11177164392698968, 0.4400416185624063, -0.019232130505930728]
[7231.9185997802515, 0.11177164392698968, 0.4400416185624063, -0.019232130505930728]
[7231.9185693656855, 0.11177164077613677, 0.4400416185624063, -0.019232130505930728]
[7231.9185693656855, 0.11177164392698968, 0.4400416258456116, -0.019232130505930728]
[7231.9185693656855, 0.11177164392698968, 0.4400416185624063, -0.019232130300395705]
[7231.550598585981, 0.11189786793473588, 0.43896734149115957, -0.01919157914716598]
[7231.550629002642, 0.11189786793473588, 0.43896734149115957, -0.01919157914716598]
[7231.550598585981, 0.11189786478232833, 0.43896734149115957, -0.01919157914716598]
[7231.550598585981, 0.11189786793473588, 0.43896734876535437, -0.01919157914716598]
[7231.550598585981, 0.11189786793473588, 0.43896734149115957, -0.019191578941350748]
[7230.276963416176, 0.11229690555893646, 0.4363443711074131, -0.019155396801544204]
[7230.276993840083, 0.11229690555893646, 0.4363443711074131, -0.019155396801544204]
[7230.276963416176, 0.11229690240162254, 0.4363443711074131, -0.019155396801544204]
[7230.276963416176, 0.11229690555893646, 0.436344378359494, -0.019155396801544204]
[7230.276963416176, 0.11229690555893646, 0.4363443711074131, -0.019155396595479955]
[7231.54608747814, 0.11189928036455604, 0.438958035964798, -0.019191451054398102]
[7231.546117894827, 0.11189928036455604, 0.438958035964798, -0.019191451054398102]
[7231.54608747814, 0.11189927721213111, 0.438958035964798, -0.019191451054398102]
[7231.54608747814, 0.11189928036455604, 0.4389580432389145, -0.019191451054398102]
[7231.54608747814, 0.11189928036455604, 0.438958035964798, -0.019191450848581988]
[7230.708499398434, 0.1121616438613452, 0.43723212724886285, -0.019167660120997472]
[7230.708529819886, 0.1121616438613452, 0.43723212724886285, -0.019167660120997472]
[7230.708499398434, 0.11216164070569301, 0.43723212724886285, -0.019167660120997472]
[7230.708499398434, 0.1121616438613452, 0.43723213450844645, -0.019167660120997472]
[7230.708499398434, 0.1121616438613452, 0.43723212724886285, -0.019167659915017517]
[7226.576384532755, 0.11343819534517285, 0.4299295476173498, -0.019114919286131384]
[7226.57641497768, 0.11343819534517285, 0.4299295476173498, -0.019114919286131384]
[7226.576384532755, 0.113438192173896, 0.4299295476173498, -0.019114919286131384]
[7226.576384532755, 0.11343819534517285, 0.42992955481465933, -0.019114919286131384]
[7226.576384532755, 0.11343819534517285, 0.4299295476173498, -0.019114919079789662]
[7230.675200795987, 0.1121719096525326, 0.4371730059108919, -0.019167235317124727]
[7230.6752312176295, 0.1121719096525326, 0.4371730059108919, -0.019167235317124727]
[7230.675200795987, 0.11217190649675424, 0.4371730059108919, -0.019167235317124727]
[7230.675200795987, 0.1121719096525326, 0.4371730131699765, -0.019167235317124727]
[7230.675200795987, 0.1121719096525326, 0.4371730059108919, -0.01916723511114185]
[7230.117347273406, 0.11234394459378566, 0.436183201961869, -0.019160118049328927]
[7230.117377698222, 0.11234394459378566, 0.436183201961869, -0.019160118049328927]
[7230.117347273406, 0.11234394143589427, 0.436183201961869, -0.019160118049328927]
[7230.117347273406, 0.11234394459378566, 0.4361832092125857, -0.019160118049328927]
[7230.117347273406, 0.11234394459378566, 0.436183201961869, -0.019160117843297117]
[7230.674602665918, 0.11217209405618361, 0.43717194397742365, -0.01916722768650423]
[7230.674633087565, 0.11217209405618361, 0.43717194397742365, -0.01916722768650423]
[7230.674602665918, 0.11217209090040298, 0.43717194397742365, -0.01916722768650423]
[7230.674602665918, 0.11217209405618361, 0.4371719512364992, -0.01916722768650423]
[7230.674602665918, 0.11217209405618361, 0.43717194397742365, -0.019167227480521305]
[7230.306820620576, 0.11228550251891634, 0.43651924642016604, -0.01916253551524058]
[7230.3068510443145, 0.11228550251891634, 0.43651924642016604, -0.01916253551524058]
[7230.306820620576, 0.11228549936174248, 0.43651924642016604, -0.01916253551524058]
[7230.306820620576, 0.11228550251891634, 0.43651925367372635, -0.01916253551524058]
[7230.306820620576, 0.11228550251891634, 0.43651924642016604, -0.01916253530922539]
[7230.674342905083, 0.11217217414054986, 0.4371714827926839, -0.019167224372615376]
[7230.674373326729, 0.11217217414054986, 0.4371714827926839, -0.019167224372615376]
[7230.674342905083, 0.11217217098476823, 0.4371714827926839, -0.019167224372615376]
[7230.674342905083, 0.11217217414054986, 0.4371714900517556, -0.019167224372615376]
[7230.674342905083, 0.11217217414054986, 0.4371714827926839, -0.019167224166632423]
[7230.660411289116, 0.11217646929403075, 0.4371467487099433, -0.019167046640260456]

Total fitting time:
5.141255140304565 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.039 seconds)