Ejemplo n.º 1
0
    # >>> This is where the RADIS calculation is done!

    s = sf.non_eq_spectrum((T12, T12, T3),
                           Trot,
                           Ttrans=Trot,
                           vib_distribution='treanor',
                           name='treanor. fit')

    # <<<

    # ... output should be a Spectrum object
    return s


# Calculate initial Spectrum, by showing all steps.
sf.verbose = 3  # increase verbose level for more details.
theoretical_model(model_input).plot('transmittance_noslit',
                                    nfig='Initial spectrum')
sf.verbose = 0  # reduce verbose during calculation.

# %% Leastsq version

# %%
# User Params
# -----------

#T0 = 1000
fit_params = ['T12', 'T3', 'Trot']
bounds = np.array([[300, 2000], [300, 5000], [300, 2000]])
fit_units = ['K', 'K', 'K']
fit_variable = 'transmittance_noslit'
Ejemplo n.º 2
0
#ax.set_ylim((bounds[0]))

fit_values_min, fit_values_max = bounds.T
res0 = log_cost_function(fit_values_min)
res1 = log_cost_function(fit_values_max, plot=figSpec.get_label())
lineRes, = axRes.plot((1, 2), (res0, res1), '-ko')
lineLast, = axRes.plot(2, res0, 'or')          # last iteration in red
lineValues = {}
for i, k in enumerate(fit_params):
    lineValues[k] = axValues.plot((1, 2), (fit_values_min[i], fit_values_max[i]), '-', label=k)[0]
axRes.set_xlim((0, maxiter))
axRes.set_ylim(ymin=0)
axRes.set_xlabel('Iteration')
axRes.set_ylabel('Residual')
figRes.legend()
sf.verbose = False
sf.warnings['NegativeEnergiesWarning'] = 'ignore'

ite = 2
plot_every = 1   # plot spectra every # iterations

def cost_and_plot_function(fit_values):
    ''' Return error on Spectrum s vs experimental spectrum '''
    global ite
    ite += 1
    # Plot one spectrum every 10 ites
    plot = None
    if not ite % plot_every:    
        plot=figSpec.get_label()
    
    res = log_cost_function(fit_values, plot=plot)