aztools.lcurve

A module for handling light curves.

Classes

LCurve

Light curve class

Module Contents

class LCurve(tarr: numpy.ndarray, rarr: numpy.ndarray, rerr: numpy.ndarray = None, **kwargs)[source]

Light curve class

time[source]
rate[source]
rerr[source]
fexp[source]
deltat[source]
iseven[source]
npoints[source]
__repr__()[source]

LCurve as a str

make_even(fill: float = np.nan)[source]

Make the light curve even in time, filling gaps with fill

Parameters:

fill (float) – The value to use in gaps.

Return type:

a new LCurve object

rebin(factor: int, error: str = 'norm', min_exp: float = 0.0)[source]

Rebin the light curve to so new_deltat = deltat*factor

Parameters:
  • factor (int) – Rebinning factor. deltat_new = factor * deltat

  • error (str) – Error type (poiss|norm). If poiss: rerr = sqrt(rate*dt)/dt, otherwise, errors are summed quadratically

  • min_exp (float) – Minimum fractional exposure to leave [0-1]

  • Return – new binned LCurve

interp_small_gaps(maxgap: int = None, noise: str = 'poiss', seed: int = None)[source]
Interpolate small gaps in the lightcurve if the gap

is <maxgap; applying noise if requested

Parameters:
  • maxgap (int) – The maximum length of a gap to be interpolated.

  • noise (str:) – poiss|norm|None

  • seed (int) – Random seed if noise is requested

static calculate_psd(rate: list | numpy.ndarray, deltat: float, norm: str = 'var', **kwargs)[source]

Calculate raw psd from a list of light curves.

Parameters:
  • rate (np.ndarray or a list of np.ndarray) – An array or a list of arrays of lcurve rates

  • deltat (float) – Time bin width of the light curve(s).

  • norm (str) – Psd normalization: var|rms|leahy

  • Keywords

  • --------

  • rerr (np.ndarray or a list of np.ndarray) – The measurement error arrays that corresponds to rate. If not given, assume, poisson noise.

  • bgd (np.ndarray or a list of np.ndarray.) – The background rate arrays that corresponds to source rate. In this case, rate above is assumed background subtracted.

  • taper (bool) – Apply Hanning tapering before calculating the psd see p388 Bendat & Piersol; the psd needs to be multiplied by 8/3 to componsate for the reduced variance.

Return type:

freq, rpsd, nois.

static bin_psd(freq: numpy.ndarray, rpsd: numpy.ndarray, fqbin: dict, noise: bool = None, logavg: bool = True)[source]

Bin power spectrum.

Parameters:
  • freq (np.ndarray) – Array of raw frequencies.

  • rpsd (np.ndarray) – Array of raw powers.

  • fqbin (dict) – Binning dict to be passed to @misc.group_array to bin the frequency axis.

  • noise (bool) – Array of noise values or None.

  • logavg (bool) – Do averaging in log-space, and correct for bias. Otherwise it is linear averaging.

Return type:

freq, psd, psde, desc::dict having some useful info

static calculate_lag(xarr: numpy.ndarray | list, yarr: numpy.ndarray | list, deltat: float, fqbin: dict = None, **kwargs)[source]

Calculate and bin lags from two lists of light curves.

Parameters:
  • xarr (np.ndarray or list) – Array or list of arrays of light curve rates.

  • yarr (np.ndarray or list) – Array or list of arrays of reference light curve rates.

  • deltat (float) – Time bin width of the light curve.

  • fqbin (dict) – Binning dict to be passed to @misc.group_array to bin the frequency axis. If None, return raw lag

  • Keywords

  • --------

  • xerr (np.ndarray or a list of np.ndarray) – The measurement error arrays that corresponds to rate. If not given, assume, poisson noise.

  • xbgd (np.ndarray or a list of np.ndarray.) – The background rate arrays that corresponds to source rate. In this case, rate above is assumed background subtracted.

  • yerr (np.ndarray or a list of np.ndarray) – The measurement error arrays that corresponds to yarr. If not given, assume, poisson noise.

  • ybgd (np.ndarray or a list of np.ndarray.) – The background rate arrays that corresponds to ref_rate. In this case, yarr above is assumed background subtracted.

  • phase (bool) – return phase lag instead of time lag

  • taper (bool) – Apply Hanning tapering before calculating the fft see p388 Bendat & Piersol; the fft need to be multiplied by sqrt(8/3) to componsate for the reduced variance. Default: False

  • norm (str) – How to normalize the fft during the calculations. None|rms|leahy|var. Default is None, so the calculations is done with raw numpy fft

Returns:

  • freq, lag, lage, extra

  • extra = {‘fqm’, ‘fql’, ‘xlimit’, ‘ylimit’ ..}

static read_pn_lcurve(fits_file, **kwargs)[source]
Read pn lcurve fits file.

This sets values relevant to PN and calls @misc.read_fits_lcurve

Parameters:
  • fits_file (str) – The name of the files file

  • Keywords

  • --------

  • @misc.read_fits_lcurve (See)

Return type:

LCurve object

static read_pca_lcurve(fits_file, **kwargs)[source]
Read pca lcurve fits file.

This sets values relevant to PCA and calls @misc.read_fits_lcurve

Parameters:
  • fits_file (str) – The name of the files file

  • Keywords

  • --------

  • @misc.read_fits_lcurve (See)

Return type:

LCurve object

static read_nu_lcurve(fits_file, **kwargs)[source]
Read nustar lcurve fits file.

This sets values relevant to NUSTAR and calls @misc.read_fits_lcurve

Parameters:
  • fits_file (str) – The name of the files file.

  • Keywords

  • --------

  • @misc.read_fits_lcurve (See)

Return type:

LCurve object

static read_xis_lcurve(fits_file, **kwargs)[source]
Read suzaku xis lcurve fits file.

This sets values relevant to Suzaku XIS and calls @misc.read_fits_lcurve

Parameters:
  • fits_file (str) – The name of the files file.

  • Keywords

  • --------

  • @misc.read_fits_lcurve (See)

Return type:

LCurve object

static read_ni_lcurve(fits_file, **kwargs)[source]
Read nicer lcurve fits file.

This sets values relevant to NICER and calls @misc.read_fits_lcurve

Parameters:
  • fits_file (str) – The name of the files file.

  • Keywords

  • @misc.read_fits_lcurve (See)

Returns:

LCurve object