burstfit.fit
BurstFit Objects
class BurstFit()
BurstFit class to perform spectro-temporal modeling on the burst data
Arguments:
sgram_model
- Spectrogram Model class objectsgram
- 2D array of spectrogramwidth
- width of the candidatedm
- DM of the candidatefoff
- frequency resolution of the datafch1
- Frequency of first channel (MHz))tsamp
- Sampling interval (seconds)clip_fac
- Clip factor based on nbits of dataoutname
- Outname for the outputsmask
- RFI channel mask arraymcmcfit
- To run MCMC after curve_fit
ncomponents
| @property
| def ncomponents()
Returns: number of components
validate
| def validate()
Validate the class attributes
Returns:
precalc
| def precalc()
Perform precalculations for fitting
Returns:
make_spectra
| def make_spectra()
Make the spectra by using the profile fitting parameters.
Returns:
fitcycle
| def fitcycle(plot=False, profile_bounds=[], spectra_bounds=[], sgram_bounds=[-np.inf, np.inf])
Run the fitting cycle to fit one component
Arguments:
profile_bounds
- Bounds for initial profile fitspectra_bounds
- Bounds for initial spectra fitplot
- To plotsgram_bounds
- Bounds for spectrogram fitting
Returns:
initial_profilefit
| def initial_profilefit(plot=False, bounds=[])
Perform initial profile fit on the pulse.
Arguments:
plot
- To plot the fit result.bounds
- Bounds for fitting.
Returns:
initial_spectrafit
| def initial_spectrafit(plot=False, bounds=[])
Perform initial spectra fit on the spectra.
Arguments:
plot
- To plot the fitting results.bounds
- Bounds for fitting.
Returns:
sgram_fit
| def sgram_fit(plot=False, bounds=[-np.inf, np.inf])
Perform fit on the spectrogram and updates the residual.
Arguments:
plot
- To plot the fitting results.bounds
- Bounds on the spectrogram fit.
Returns:
fit_all_components
| def fit_all_components(plot)
Fit all components together (used if num_comp > 1)
Arguments:
plot
- To plot the fitting results.
Returns:
fitall
| def fitall(plot=True, max_ncomp=5, profile_bounds=[], spectra_bounds=[], sgram_bounds=[-np.inf, np.inf], **mcmc_kwargs, ,)
Perform spectro-temporal fitting on the spectrogram for all the components.
Arguments:
spectra_bounds
- Bounds for initial profile fitprofile_bounds
- Bounds for initial spectra fitplot
- to plot the fitting results.max_ncomp
- maximum number of components to fit.sgram_bounds
- bounds on spectrogram fit.**mcmc_kwargs
- arguments for mcmc
Returns:
run_mcmc
| def run_mcmc(plot=False, nwalkers=30, nsteps=1000, skip=3000, ncores=10, start_pos_dev=0.01, prior_range=0.5, save_results=True, outname=None)
Runs MCMC using the final fit parameters.
Arguments:
plot
- To plot the outputs.nwalkers
- Number of walkers for MCMC.nsteps
- Number of iterations for MCMC.skip
- Number of samples to skip to remove burn-in.ncores
- Number of CPUs to use.start_pos_dev
- Percent deviation for start position of the samplesprior_range
- Percent of initial guess to set as prior rangesave_results
- Save MCMC samples to a fileoutname
- Name of output files
Returns:
get_off_pulse_region
| def get_off_pulse_region()
Returns off pulse region (2D) using fit parameters.
Returns:
run_tests
| @property
| def run_tests()
Run statistical tests to compare ON pulse residual with OFF pulse spectrogram distributions.
Returns:
True if either of the left or right OFF pulse regions are similar to the residual ON pulse region.
calc_redchisq
| def calc_redchisq()
Calculates reduced chi-square value of the fit using sgram, model and off pulse standard deviation.
Returns:
Reduced chi-square value of the fit
model
| @property
| def model()
Function to make the model.
Returns:
2D array of spectrogram model.
model_from_params
| def model_from_params(x, *params)
Function to make the model using spectrogram parameters.
Returns:
Flattened array of spectrogram model.
get_physical_parameters
| def get_physical_parameters(my_mapping)
Function to use the my_mapping function and convert fitted parameters to physical units
Arguments:
my_mapping
- function to map parameter dictionary to a mapping dictionary for parameters
Returns: