autowisp.light_curves.epd_correction module — AutoWISP documentation

# autowisp.light_curves.epd_correction module

## Class Inheritance Diagram

Define class for performing EPD correction on lightcurves.

class autowisp.light_curves.epd_correction.EPDCorrection(*, used_variables, fit_points_filter_expression, fit_terms_expression, fit_datasets, fit_weights=None, **iterative_fit_config)

  Bases: `Correction`

  Class for deriving and applying EPD corrections to lightcurves.

  used_variables

    See __init__.

  fit_points_filter_expression

    See __init__.

  fit_terms

    Instance set-up to generate the independent variables matrix needed for the fits.

    Type:

      FitTermsInterface

  fit_weights

    See __init__.

  _io_fit_config

    A list storing the configuration used for the fitting. Formatted properly for passing as the only entry directly to LightCurveFile.add_configurations().

    Type:

      []

  __call__(lc_fname, get_fit_dataset=<function HDF5File.get_dataset>, extra_predictors=None, save=True)

    Fit and correct the given lightcurve.

    Parameters:

      - lc_fname (str) – The filename of the light curve to fit.

      - get_fit_dataset (callable) – A function that takes a LightCurveFile instance, dataset key and substitutions and returns either a single array which is the dataset to calculate and apply EPD correction to, or a 2-tuple of arrays, the first of which is what the calculated correction is applied to, and the second one is used to calculate the EPD correction. The intention is to allow for protecting a signal from being modified by the fit, in which case the second dataset should have the protected signal removed from it, and the first dataset should be the original datasets stored in the lightcurve.

      - extra_predictors (None, dict, or numpy structured array) – Additional predictor datasets to add to the ones configured through __init__, for this lightcurve only. The intent is to allow for reconstructive EPD, by passing an expected signal or a set of signals which are fit simultaneously to the EPD corrections. The derived corrections for these components are not applied when calculating the corrected dataset, but the best fit amplitudes are added to the result.

      - save (bool) – Should the result be saved to the lightcurve. Can be used to disable saving if the current EPD evaluation is not the final one during reconstructive EPD.

    Returns:

      The RMS of the corrected values and the number of finite points

        for each corrected dataset in the order in which the datasets were supplied to __init__().

      numpy.array(dtype=[(extra predictor 1, numpy.float64), …]):

        The best-fit amplitudes for the extra_predictors.

    Return type:

      numpy.array(dtype=[(‘rms’, float64), (‘num_finite’, uint)])

  __init__(*, used_variables, fit_points_filter_expression, fit_terms_expression, fit_datasets, fit_weights=None, **iterative_fit_config)

    Configure the fitting.

    Parameters:

      - used_variables (dict) – Keys are variables used in fit_points_filter_expression and fit_terms_expression and the corresponding values are 2-tuples of pipeline keys corresponding to each variable and an associated dictionary of path substitutions. Each entry defines a unique independent variable to use in the fit or based on which to select points to fit.

      - fit_points_filter_expression (str) – An expression using used_variables which evalutes to either True or False indicating if a given point in the lightcurve should be fit and corrected.

      - fit_terms_expression (str) – A fitting terms expression involving only variables from used_variables which expands to the various terms to use in a linear least squares EPD correction.

      - fit_datasets – See Correction.__init__().

      - fit_weights (str or [str]) – Weights to use when fitting each fit_dataset. Follows the same format as fit_points_filter_expression. Can be either a single expression, which is applied to all datasets or a list of expressions, one for each entry in fit_datasets.

      - iterative_fit_config – Any other arguments to pass directly to iterative_fit().

    Returns:

      None

  _get_fit_configurations(fit_terms_expression)

    Return the current fitting configurations (see self._fit_config).