Skip to content

burstfit.fit

[view_source]

BurstFit Objects

class BurstFit()

[view_source]

BurstFit class to perform spectro-temporal modeling on the burst data

Arguments:

  • sgram_model - Spectrogram Model class object
  • sgram - 2D array of spectrogram
  • width - width of the candidate
  • dm - DM of the candidate
  • foff - frequency resolution of the data
  • fch1 - Frequency of first channel (MHz))
  • tsamp - Sampling interval (seconds)
  • clip_fac - Clip factor based on nbits of data
  • outname - Outname for the outputs
  • mask - RFI channel mask array
  • mcmcfit - To run MCMC after curve_fit

ncomponents

 | @property
 | def ncomponents()

[view_source]

Returns: number of components

validate

 | def validate()

[view_source]

Validate the class attributes

Returns:

precalc

 | def precalc()

[view_source]

Perform precalculations for fitting

Returns:

make_spectra

 | def make_spectra()

[view_source]

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])

[view_source]

Run the fitting cycle to fit one component

Arguments:

  • profile_bounds - Bounds for initial profile fit
  • spectra_bounds - Bounds for initial spectra fit
  • plot - To plot
  • sgram_bounds - Bounds for spectrogram fitting

Returns:

initial_profilefit

 | def initial_profilefit(plot=False, bounds=[])

[view_source]

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=[])

[view_source]

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])

[view_source]

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)

[view_source]

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, ,)

[view_source]

Perform spectro-temporal fitting on the spectrogram for all the components.

Arguments:

  • spectra_bounds - Bounds for initial profile fit
  • profile_bounds - Bounds for initial spectra fit
  • plot - 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)

[view_source]

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 samples
  • prior_range - Percent of initial guess to set as prior range
  • save_results - Save MCMC samples to a file
  • outname - Name of output files

Returns:

get_off_pulse_region

 | def get_off_pulse_region()

[view_source]

Returns off pulse region (2D) using fit parameters.

Returns:

run_tests

 | @property
 | def run_tests()

[view_source]

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()

[view_source]

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()

[view_source]

Function to make the model.

Returns:

2D array of spectrogram model.

model_from_params

 | def model_from_params(x, *params)

[view_source]

Function to make the model using spectrogram parameters.

Returns:

Flattened array of spectrogram model.

get_physical_parameters

 | def get_physical_parameters(my_mapping)

[view_source]

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: