API reference

Modules

plotting

scatfit.plotting.plot_center_scaling(t_df)

Plot the scaling of fitted center with frequency.

scatfit.plotting.plot_chains(fitresult_emcee)

Plot the MCMC chains from an emcee sampling run.

Parameters:

fitresult_emcee (MinimizerResult) – The minimizer result object from lmfit.

scatfit.plotting.plot_corner(fitresult_emcee, smodel, output, params)

Make a corner plot.

Parameters:
  • fitresult_emcee (MinimizerResult) – The minimizer result object from lmfit.

  • smodel (str) – The name of the scattering model used.

  • output (bool) – Whether to output the plot to a file.

  • params (dict) – Additional plotting parameters.

scatfit.plotting.plot_frb(cand, plot_range, profile, params)

Plot the FRB data.

scatfit.plotting.plot_profile_fit(fit_range, sub_profile, fitresult, iband, cfreq, params, fitresult2=None)

Plot the profile fit.

scatfit.plotting.plot_profile_models()

Plot and compare the profile scattering models.

scatfit.plotting.plot_width_scaling(t_df, cand, fitresult)

Plot the scaling of fitted widths with frequency.

scatfit.plotting.use_custom_matplotlib_formatting()

Adjust the matplotlib configuration parameters for custom format.

pulsemodels

scatfit.pulsemodels.boxcar(x, width)

A simple boxcar function.

Parameters:
  • x (array) – The running variable (time).

  • width (float) – The width of the boxcar function.

Returns:

res – The boxcar data.

Return type:

array

scatfit.pulsemodels.equivalent_width(x, amp)

Compute the boxcar equivalent width.

Parameters:
  • x (array) – The running variable (time).

  • amp (array) – The pulse amplitude.

Returns:

weq – The equivalent width.

Return type:

float

scatfit.pulsemodels.full_width_post(x, amp, level)

Compute the full pulse width post scattering numerically.

Parameters:
  • x (array) – The running variable (time).

  • amp (array) – The pulse amplitude.

  • level (float) – The level at which to evaluate the pulse width.

Returns:

width – The full pulse width at the given level.

Return type:

float

scatfit.pulsemodels.gaussian_fwhm(sigma)

The full width at half maximum (W50) of a Gaussian.

Parameters:

sigma (float) – The Gaussian standard deviation.

Returns:

res – The Gaussian W50.

Return type:

float

scatfit.pulsemodels.gaussian_fwtm(sigma)

The full width at tenth maximum (W10) of a Gaussian.

Parameters:

sigma (float) – The Gaussian standard deviation.

Returns:

res – The Gaussian W10.

Return type:

float

scatfit.pulsemodels.gaussian_scattered_afb_instrumental(x, fluence, center, sigma, taus, taui, taud, dc)

A Gaussian pulse scattered in the ISM and affected by analogue (single-sided exponential) instrumental effects from DM-smearing and the detector/signal chain.

This implements Eq. 7 from McKinnon 2014.

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

  • taus (float) – The scattering time in the ISM.

  • taui (float) – The scattering time due to instrumental effects in the receiver or signal chain (e.g. integration time constant).

  • taud (float) – The scattering time due to intra-channel dispersive smearing.

  • dc (float) – The vertical offset of the profile from the baseline.

Returns:

res – The profile data.

Return type:

array

scatfit.pulsemodels.gaussian_scattered_dfb_instrumental(x, fluence, center, sigma, taus, taud, dc)

A Gaussian pulse scattered in the ISM and affected by digital (boxcar-like) instrumental effects. Convolving approach. We neglect instumental receiver or signal chain effects.

This implements Eq. 2 from Loehmer et al. 2001.

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

  • taus (float) – The scattering time in the ISM.

  • taud (float) – The scattering time due to intra-channel dispersive smearing.

  • dc (float) – The vertical offset of the profile from the baseline.

Returns:

res – The profile data.

Return type:

array

scatfit.pulsemodels.pbf_isotropic(plot_range, taus)

A pulse broadening function for isotropic scattering.

Parameters:
  • plot_range (array) – The evaluation variable (time) in ms.

  • taus (float) – The scattering time in ms.

Returns:

res – The profile data.

Return type:

array

Raises:

RuntimeError – If the window array is too short to fit the vast majority of the exponential sweep, i.e. taus is too large for the given time span.

scatfit.pulsemodels.scattered_profile(x, fluence, center, sigma, taus, dc)

A scattered pulse profile.

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

  • taus (float) – The scattering time.

  • dc (float) – The vertical offset of the profile from the baseline.

Returns:

res – The profile data.

Return type:

array

pulsemodels_python

scatfit.pulsemodels_python.bandintegrated_model(x, fluence, center, sigma, taus, dc, f_lo, f_hi, nfreq)

A true frequency band-integrated profile model.

The total (sub-)band-integrated profile is the superposition (weighted sum or weighted mean) of several profiles that evolve with frequency across the bandwidth of the frequency (sub-)band, one for each frequency channel. Namely, the individual profiles evolve with frequency (scattering, pulse width, fluence). For large fractional bandwidths or at low frequencies (< 1 GHz), the profile evolution across the band cannot be neglected, i.e. the narrow-band approximation fails.

We compute the frequency evolution across the band between f_lo and f_hi at nfreq centre frequencies. The total profile is then the weighted sum over the finite frequency grid. Ideally, one would use an infinitesimally narrow grid here.

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

  • taus (float) – The scattering time.

  • dc (float) – The vertical offset of the profile from the baseline.

  • f_lo (float) – The centre frequency of the lowest channel in the sub-band.

  • f_hi (float) – The centre frequency of the highest channel in the sub-band.

  • nfreq (int) – The number of centre frequencies to evaluate.

Returns:

res – The profile data.

Return type:

array

scatfit.pulsemodels_python.gaussian_normed(x, fluence, center, sigma)

A normed Gaussian function.

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

Returns:

res – The profile data.

Return type:

array

scatfit.pulsemodels_python.scattered_gaussian_pulse(x, fluence, center, sigma, taus, dc)

A scattered Gaussian pulse. Analytical approach, assuming thin screen scattering.

We use a standard implementation of an exponentially modified Gaussian here, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.exponnorm.html

Parameters:
  • x (array) – The running variable (time).

  • fluence (float) – The fluence of the pulse, i.e. the area under it.

  • center (float) – The mean of the Gaussian, i.e. its location.

  • sigma (float) – The Gaussian standard deviation.

  • taus (float) – The scattering time.

  • dc (float) – The vertical offset of the profile from the baseline.

Returns:

res – The profile data.

Return type:

array

sigproc

scatfit.sigproc.load_frb_data(filename, dm, fscrunch, tscrunch)

Load the FRB data from a SIGPROC filterbank file.

Parameters:
  • filname (str) – The filterbank file to load.

  • dm (float) – The dispersion measure to use to dedisperse the data.

  • fscrunch (int) – The number of frequency channels to sum.

  • tscrunch (int) – The number of time samples to sum.

Returns:

cand – The candidate FRB data.

Return type:

Candidate

Applications

apps.fit_frb

scatfit.apps.fit_frb.check_args(args)

Sanity check the commandline arguments.

Parameters:

args (populated namespace) – The commandline arguments.

scatfit.apps.fit_frb.compute_post_widths(fit_range, t_fitresult)

Compute the full post-scattering widths numerically from the Markov chain samples.

scatfit.apps.fit_frb.compute_updated_dm(t_df, dm, params)

Compute an updated dispersion measure by fitting the center versus frequency curve.

scatfit.apps.fit_frb.fit_powerlaw(x, y, err_y, params)

Fit a power law to data.

scatfit.apps.fit_frb.fit_profile(cand, plot_range, fscrunch_factor, smodel, params)

Fit an FRB profile.

scatfit.apps.fit_frb.fit_profile_model(fit_range, profile, smodel, params)

Fit a profile model to data.

scatfit.apps.fit_frb.linear(x, x0, slope, intercept)

A linear function.

Parameters:
  • x (array) – The running variable.

  • x0 (float) – The reference location.

  • slope (float) – The slope of the line.

  • intercept (float) – The y value at x0.

Returns:

res – The model data.

Return type:

array

scatfit.apps.fit_frb.parse_args()

Parse the commandline arguments.

Returns:

args – The commandline arguments.

Return type:

populated namespace

apps.simulate_pulse

scatfit.apps.simulate_pulse.parse_args()

Parse the commandline arguments.

Returns:

args – The commandline arguments.

Return type:

populated namespace