autowisp.light_curves.apply_correction module

Class Inheritance Diagram

Inheritance diagram of DataReductionFile, EPDCorrection, FileKind, LightCurveFile, ReconstructiveCorrectionTransit, RelatedFile, partial

Unified interface to the detrending algorithms.

Related files for a detrending work item: the LC + its photref.

Module-level (so a partial of it is picklable to the workers) and passed as the run_pool related_files classifier, so any error – a config-vs-LC mismatch or a silent crash – carries both the light curve being corrected and the single photometric reference the whole batch is detrended against.

Parameters:
  • lc_fname (str) – The light curve work item.

  • single_photref_dr_fname (str or None) – The batch’s single photometric reference DR file, if configured.

Returns:

The RelatedFile entries for this item.

Return type:

list

autowisp.light_curves.apply_correction.apply_parallel_correction(lc_fnames, correct, num_parallel_processes, **config)[source]

Correct LCs running one of the detrending algorithms in parallel.

Parameters:
  • lc_fnames ([str]) – The filenames of the light curves to correct.

  • correct (Correction) – The underlying correction to apply in parallel.

  • num_parallel_processes (int) – The maximum number of parallel processes to use.

  • statistics_fname (str) – Filename to use for saving the statistics.

Returns:

The return values of correct.__call__() in the same order as lc_fnames.

Return type:

numpy.array

autowisp.light_curves.apply_correction.apply_reconstructive_correction_transit(lc_fname, correct, *, transit_model, transit_parameters, fit_parameter_flags, num_limbdark_coef)[source]

Perform a reconstructive correction on a LC assuming it contains a transit.

The corrected lightcurve, preserving the best-fit transit is saved in the lightcurve just like for non-reconstructive corrections.

Parameters:
  • transit_model – Object which supports the transit model intefrace of pytransit.

  • transit_parameters (scipy float array) – The full array of parameters required by the transit model’s evaluate() method.

  • fit_parameter_flags (scipy bool array) – Flags indicating parameters whose values should be fit for (by having a corresponding entry of True). Must match exactly the shape of transit_parameters.

  • num_limbdark_coef (int) – How many of the transit parameters are limb darkening coefficinets? Those need to be passed to the model separately.

  • correct (Correction) – Instance of one of the correction algarithms to make adaptive.

Returns:

  • The best fit transit parameters

  • The return value of ReconstructiveCorrectionTransit.__call__() for the best-fit transit parameters.

Return type:

(scipy array, scipy array)

autowisp.light_curves.apply_correction.calculate_iterative_rejection_scatter(values, calculate_average, calculate_scatter, outlier_threshold, max_outlier_rejections, *, return_average=False)[source]

Calculate the scatter for a dataset, with outlier rejectio iterations.

Parameters:
  • values (numpy array like) – The data to calculate the scatter of.

  • calculate_average (callable) – A callable that returns the average of the data aroung which the scatter will be calculated.

  • calculate_scatter (callable) – The scatter is defined as the square root of whatever get_scatter calculates from the square deviations of the data from the average.

  • outlier_threshold (float) – In units of the scatter, how far away should a point be from the average to be considered an outlier.

  • max_outlier_rejections (int) – The maximum number of iterations between outlier rejection and re-calculating the scatter to perform.

  • return_average (bool) – Should the average of the poinst also be returned?

Returns:

The scatter in values and the number of non-rejected points in the last scatter calculation.

Return type:

float, int

autowisp.light_curves.apply_correction.load_correction_statistics(filename, add_catalog=False)[source]

Read a previously stored statistics from a file.

The returned array is sorted by ID regardless of the row order on disk; see save_correction_statistics() for the motivation.

autowisp.light_curves.apply_correction.recalculate_correction_statistics(lc_fnames, fit_datasets, variables, lc_points_filter_expression, **calculate_scatter_config)[source]

Extract the performance metrics for a de-trending step directly from LCs.

Parameters:
  • lc_fnames ([str]) – The filenames of the light curves that were corrected.

  • fit_datasets – See Correction.__init__().

  • extra_predictors – See EPDCorrection.__init__().

  • calculate__scatter_config – Arguments passed directly to calculate_iterative_rejection_scatter().

Returns:

See apply_parallel_correction’s return value.

autowisp.light_curves.apply_correction.save_correction_statistics(correction_statistics, filename)[source]

Save the given statistics (result of apply_parallel_correction).

Rows are written sorted by ID so the on-disk order is independent of the order in which the parallel correction returned the lightcurves. Downstream consumers (notably TFA template selection) therefore see the same source ordering regardless of whether the upstream EPD ran via wisp-epd or run_pipeline, which keeps the QR decomposition of the template matrix bit-for-bit identical between the two paths.