astrobase.varbase.autocorr module

Calculates the autocorrelation for magnitude time series.

astrobase.varbase.autocorr._autocorr_func1(mags, lag, maglen, magmed, magstd)[source]

Calculates the autocorr of mag series for specific lag.

This version of the function is taken from: Kim et al. (2011)

Parameters:
  • mags (np.array) – This is the magnitudes array. MUST NOT have any nans.
  • lag (float) – The specific lag value to calculate the auto-correlation for. This MUST be less than total number of observations in mags.
  • maglen (int) – The number of elements in the mags array.
  • magmed (float) – The median of the mags array.
  • magstd (float) – The standard deviation of the mags array.
Returns:

The auto-correlation at this specific lag value.

Return type:

float

astrobase.varbase.autocorr._autocorr_func2(mags, lag, maglen, magmed, magstd)[source]

This is an alternative function to calculate the autocorrelation.

This version is from (first definition):

https://en.wikipedia.org/wiki/Correlogram#Estimation_of_autocorrelations

Parameters:
  • mags (np.array) – This is the magnitudes array. MUST NOT have any nans.
  • lag (float) – The specific lag value to calculate the auto-correlation for. This MUST be less than total number of observations in mags.
  • maglen (int) – The number of elements in the mags array.
  • magmed (float) – The median of the mags array.
  • magstd (float) – The standard deviation of the mags array.
Returns:

The auto-correlation at this specific lag value.

Return type:

float

astrobase.varbase.autocorr._autocorr_func3(mags, lag, maglen, magmed, magstd)[source]

This is yet another alternative to calculate the autocorrelation.

Taken from: Bayesian Methods for Hackers by Cameron Pilon

(This should be the fastest method to calculate ACFs.)

Parameters:
  • mags (np.array) – This is the magnitudes array. MUST NOT have any nans.
  • lag (float) – The specific lag value to calculate the auto-correlation for. This MUST be less than total number of observations in mags.
  • maglen (int) – The number of elements in the mags array.
  • magmed (float) – The median of the mags array.
  • magstd (float) – The standard deviation of the mags array.
Returns:

The auto-correlation at this specific lag value.

Return type:

float

astrobase.varbase.autocorr.autocorr_magseries(times, mags, errs, maxlags=1000, func=<function _autocorr_func3>, fillgaps=0.0, filterwindow=11, forcetimebin=None, sigclip=3.0, magsarefluxes=False, verbose=True)[source]

This calculates the ACF of a light curve.

This will pre-process the light curve to fill in all the gaps and normalize everything to zero. If fillgaps = ‘noiselevel’, fills the gaps with the noise level obtained via the procedure above. If fillgaps = ‘nan’, fills the gaps with np.nan.

Parameters:
  • times,mags,errs (np.array) – The measurement time-series and associated errors.
  • maxlags (int) – The maximum number of lags to calculate.
  • func (Python function) – This is a function to calculate the lags.
  • fillgaps ('noiselevel' or float) – This sets what to use to fill in gaps in the time series. If this is ‘noiselevel’, will smooth the light curve using a point window size of filterwindow (this should be an odd integer), subtract the smoothed LC from the actual LC and estimate the RMS. This RMS will be used to fill in the gaps. Other useful values here are 0.0, and npnan.
  • filterwindow (int) – The light curve’s smoothing filter window size to use if fillgaps=’noiselevel’.
  • forcetimebin (None or float) – This is used to force a particular cadence in the light curve other than the automatically determined cadence. This effectively rebins the light curve to this cadence. This should be in the same time units as times.
  • sigclip (float or int or sequence of two floats/ints or None) –

    If a single float or int, a symmetric sigma-clip will be performed using the number provided as the sigma-multiplier to cut out from the input time-series.

    If a list of two ints/floats is provided, the function will perform an ‘asymmetric’ sigma-clip. The first element in this list is the sigma value to use for fainter flux/mag values; the second element in this list is the sigma value to use for brighter flux/mag values. For example, sigclip=[10., 3.], will sigclip out greater than 10-sigma dimmings and greater than 3-sigma brightenings. Here the meaning of “dimming” and “brightening” is set by physics (not the magnitude system), which is why the magsarefluxes kwarg must be correctly set.

    If sigclip is None, no sigma-clipping will be performed, and the time-series (with non-finite elems removed) will be passed through to the output.

  • magsarefluxes (bool) – If your input measurements in mags are actually fluxes instead of mags, set this is True.
  • verbose (bool) – If True, will indicate progress and report errors.
Returns:

A dict of the following form is returned:

{'itimes': the interpolated time values after gap-filling,
 'imags': the interpolated mag/flux values after gap-filling,
 'ierrs': the interpolated mag/flux values after gap-filling,
 'cadence': the cadence of the output mag/flux time-series,
 'minitime': the minimum value of the interpolated times array,
 'lags': the lags used to calculate the auto-correlation function,
 'acf': the value of the ACF at each lag used}

Return type:

dict