sdapy.snerun.snobject.run_fit¶
- snobject.run_fit(enginetype, source=None, **kwargs)¶
Run model fittings on varies of data from different engines.
- Parameters
- enginetypestr
which engine to be used, e.g.
multiband_main,bol_main, etc. Check all engines at https://github.com/saberyoung/HAFFET/tree/master/sdapy/engines, or one can define their own engine.- sourcestr
optional, which source to be used for fitting, e.g. for
bol_mainengine, if there’re multiple bolometric LCs available, fit on which of them, or forsedengine, which epochs to be fitted, etc.- fit_methodsstr
which fitting model to be used, e.g. bazin, gauss, etc
- fit_redobool
if False by default, when cached file exists, read samples from cached sample file. for mcmc, if given nsteps is larger than that of cached sample, continue fits to nsteps, otherwise return samples. if True, when cached file exists, redo everything for new fitting samples
- for engine ``x``
- x_typestr
what data to fit
- x_xrangelist
x range to fit the data
- x_xrangeplist
x range to predict the data
- x_yrangelist
y range to fit the data
- x_bandslist
data from which bands for the fit
- x_routine: `str`
Which technic to be used to realize optimization. Possible choices are: minimize, mcmc, leastsq
- if ``routine`` is **mcmc**
- ncoresint
how many cores to run multi-processing
- nwalkersint
number of walkers
- nstepsint
number of MC steps
- nsteps_burninint
number of MC burn in steps
- thin_byint
If you only want to store and yield every thin_by samples in the chain, set thin_by to an integer greater than 1. When this is set, iterations * thin_by proposals will be made.
- emcee_burninbool
if use emcee to burnin chains
- use_emcee_backendbool
if use emcee backend
- quantilelist
use 50 percentile as mean, and 1 sigma (68%% -> 16%% - 84%%) as errors
- if ``routine`` is **minimize**
- maxfevint
for scipy. The maximum number of calls to the function.
- scipysamplesint
generated sampling numbers for scipy approach
- quantilelist
use 50 percentile as mean, and 1 sigma (68%% -> 16%% - 84%%) as errors
Notes
- kwargsKeyword Arguments
see more parameters in https://github.com/saberyoung/HAFFET/blob/master/sdapy/data/default_par.txt, the snobject part.
kwargsare different for different engines:- for multi_main and multi_early engine:
- set_tpeak_methodstr
set t0 with peak from [gp] Gaussian process or [fit] multiband_main/Bazin fits or [bol] bol_main/Arnett fits or leave blanckt as with input jdpeak
- set_tpeak_filterstr
set t0 with peak of which band
- set_texp_methodstr
set texp with [fit] power law fits or [bolmain] bolometric LC fits or [bolearly] shock cooling fits or leave blanckt as with middle of last nondetection to the first detection
- set_texp_filterstr
set texp with peak of which band
for spectral engines :
- spec_snrint
if no error from spectra, add noise level of snr
- bin_methodstr
method used to bin spectrum
- bin_sizeint
size used to bin spectrum, in AA
- savgol_orderint
polynomial order for savgol filter
- continuum_methodstr
The function type for continumm fitting, valid functions are “scalar”, “linear”, “quadratic”, “cubic”, “poly”, and “exponential”
- continuum_degreeint
degree of polynomial when method=”poly”, for continuum fitting
- pfactorint
threshold used for peak detection
- sn_linestr
which line to fit, e.g. ‘H~$lpha$’, ‘He~5876$AA$’, ‘O~7774$AA$’
- specfit_phaselist
phase range to decide which spectra should be fitted
- v_pfloat
guessed velocity (unit: 1e3 km/s)
- v_boundslist
guessed velocity range (unit: 1e3 km/s)
- for sed engines:
sed_phaserange : list
- sed_abscal_bandslist
which photometry bands to be used to absolute calibrate the spectra
sed_abscal_method : str
[cal]ibrate
[mangle] the spetra
Examples
Define a
snobjectobject>>> a = snerun.snobject(objid='ZTF20aajcdad', aliasid='SN2020bcq', ... z=0.0186, dm=34.6, mkwebv=0.01387, hostebv=0, sntype='Ib', ... ra='13:26:29.65', dec='+36:00:31.1', jdpeak=2458888.02)
Run
bzmodel on g, r, and i band data prepared by themultiband_mainengine, withminimizeroutine.>>> a.run_fit('multiband_main', fit_methods=['bz'], ... multiband_main_bands=['g','r','i'], multiband_main_routine='minimize')
Run
plmodel on g, r, and i band data prepared by themultiband_earlyengine, withmcmcroutine. For themcmc, run maximum 5000 steps for burnin process, and after burnin, continue 30000 steps as maximum for samplings.>>> a.run_fit('multiband_early', fit_methods=['pl'], ... multiband_early_bands=['g','r','i'], multiband_early_routine='mcmc', ... nsteps_burnin=5000, nsteps=30000)
Run
bbmodel on SED data prepared bysnobject.bb_colorsand thesedengine, withminimizeroutine.fit_redowill remove the samplings obtained before.>>> a.run_fit('sed', fit_methods=['bb'], sed_routine='minimize', fit_redo=True)
Run
arnett_fit_taummodel on bolometric LCs that were prepared by thebol_mainengine, withminimizeroutine. The bolometric LCs for model fittings are selected from -18 to 40 rest frame days relative to peak epoch. After generating a number of samplings, the LC realization would be from -18 to 80 days.>>> a.run_fit('bol_main', fit_methods=['arnett_fit_taum'], fit_redo=True, ... bol_main_xrange=[-18, 40], bol_main_xrangep=[-18, 80], bol_main_routine='minimize')
Run
gaussmodel on spectral line minima prepared by thespeclineengine.>>> a.run_fit('specline', fit_methods=['gauss'])
Run
expmodel on spectral line minima prepared by thespecv_evolutionengine.>>> a.run_fit('specv_evolution', fit_methods=['exp'])