autowisp.light_curves.tfa_correction module
Class Inheritance Diagram

Define aclass for applying TFA corrections to lightcurves.
- class autowisp.light_curves.tfa_correction.TFACorrection(epd_statistics, configuration, verify_template_data=False, **iterative_fit_config)[source]
Bases:
Correction
Class for performing TFA corrections to a set of lightcurves.
- _configuration
An object with attributes configuring how TFA is to be done (see configuration argument to __init__()).
- _template_qr
The QR decomposition of the template lightcurves. Each entry is the value returned by scipy.linalg.qr for one of the fit datasets.
- Type:
[]
- __call__(lc_fname, get_fit_dataset=<function HDF5File.get_dataset>, extra_predictors=None, save=True)[source]
Apply TFA to the given LC, optionally protecting an expected signal.
- __init__(epd_statistics, configuration, verify_template_data=False, **iterative_fit_config)[source]
Get ready to apply TFA corrections.
- Parameters:
epd_statistics (scipy structured array) –
An array containing information about the input sources and summary statistics for their EPD fit. The array must contain the following fields:
- ID ((numpy.uint, #)):
Array if integers uniquely identifying the source (see DataReductionFile.get_source_data for more info.
- mag (numpy.float64):
The magnitude of the source per the catalogue in the band most approximating the observations.
- xi(numpy.float64):
The pre-projected xi coordinate of the source from the catalogue.
- eta(numpy.float64):
The pre-projected eta coordinate of the source from the catalogue.
- rms ((numpy.float64, #)):
Array of the RMS residuals of the EPD fit for each source for each photometry method.
- num_finite((numpy.uint, #)):
Array of the number of finite observations with EPD corrections.
configuration (dict) –
Configuration specifying how TFA should be done. At least the following keys must be defined (extra ones are ignored):
- saturation_magnitude
The magnitude at which sources start to saturate. See _select_template_stars()
- allow_saturated_templates
Whether saturated stars should be represented in the templates.
- mag_rms_dependence_order
The maximum order of magnitude to include in the fit for typical rms vs magnitude.
- mag_rms_outlier_threshold
Stars are not allowed to be in the template if their RMS is more than this many sigma away from the mag-rms fit. This is also the threshold used for rejecting outliers when doing the iterative fit for the rms as a function of magnutude.
- mag_rms_max_rej_iter
The maximum number of rejection fit iterations to do when deriving the rms(mag) dependence.
- max_rms
Stars are allowed to be in the template only if their RMS is no larger than this.
- faint_mag_limit
Stars fainter than this cannot be template stars.
- min_observations_quantile, min_observations_fraction
The minimum number of observations required of template stars is the smaller of:
this quantile among the input collection of stars
this fraction of the star with most observations
- sqrt_num_templates
The number of template stars is the square of this number.
- observation_id
The datasets to use for matching observations across light curves. For example, the following works for HAT:
( 'fitseader.cfg.stid', 'fitsheader.cfg.cmpos', 'fitsheader.fnum' )
- lc_fname
A format string that expands to the filename of a lightcurve given a source ID.
- fit_datasets
See same name argument to EPDCorrection.__init__().
- fit_points_filter_varibales
See used_variables argument to EPDCorrection.__init__(). In this case only required to evaluate fit_points_filter_expression.
- fit_points_filter_expression
See same name argument to EPDCorrection.__init__().
- [selected_plots] (str): Optional template for naming plots
showing the template selection in action. If not specified, no such plots are generated. Should include %(plot_id)s and %(phot_index)d substitutions.
verify_template_data (bool) – If True a series of assert statements are issued to check that the photometry data is correctly matched to observation IDs. Only useful for debugging.
iterative_fit_config – Any other arguments to pass directly to iterative_fit_qr().
- Returns:
None
- _get_io_configurations()[source]
Return properly formatted configuration to pass to
_save_result()
.
- _get_observation_ids(light_curve, substitutions)[source]
Return the observation IDs from the given light curve.
- _plot_template_selection(epd_statistics, template_indices, allowed_stars, plot_fname_pattern)[source]
Create plots showing the stars selected as template (1 plot/phot).
- Parameters:
epd_statistics – See __init__().
template_indices – The return value of _select_template_stars().
plot_fname_pattern (str) – A %(phot_index)??d and %(plot_id)??s substitutions expanding to a unique filename to save the collection of plots for each given photometry index. The plot_id substitution will be one of: ‘xi_eta’, ‘mag_rms’, and ‘mag_nobs’ each containing a plot of the associated quantities as x and y coordinates respectively.
- Returns:
None
- _prepare_template_data(epd_statistics, max_padding_factor=1.1)[source]
Organize the template star data into predictors and observation IDs.
- Parameters:
epd_statistics – See __init__().
max_padding_factor (float) – Because light curves are read sequentially, at early times the ultimate number of observations is unknown. Any time observations exceed the size of the currently allocated array for the result, the result is resized to to accomodate this factor times the newly required length of observations, hopefully avoiding too many resize operations.
- Returns:
- The source IDs of the stars selected to serve as templates for
each photometry method.
- [numpy.array]:
The brightness measurements from all the templates for all the photometry methods at all observation points where at least one template has a measurement. Entries at observation points not represented in a template are zero. The shape of each array is:
(number template stars, number observations)
, and there are number of photemetry methods arrays in the list.- [numpy.array]:
The sorted observation IDs for which at least one template has a measurement for each photometry method.
- Return type:
[numpy.array]
- _select_template_stars(epd_statistics)[source]
Select the stars tha will be used as TFA templates.
The algorithm is as follows:
Select all stars that are either saturated (see saturation_magnitude configuration) or are close to the typical RMS vs magnitude dependence (see mag_rms_outlier_threshold configuration).
Remove all stars with RMS exceeding a specified values (see max_rms configuration) or fanter than a specified magnitude (see faint_mag_limit configuration) or do not containing sufficient number of data points in their LC (see min_observation_factor configuration).
Create a uniform grid of points spanning the xi and eta region covered by the stars selected by steps 1 and 2 above and select the closest star to each point (see sqrt_num_templates configuration).
- The HATSouth TFA uses the following values:
saturation_magnitude: 8 mag_rms_outlier_threshold: 6 max_rms: 0.15 faint_mag_limit: 11.5 min_observations: median of the number of observations for all LCs
- Parameters:
epd_statistics – See __init__().
- Returns:
A list of sorted 1-D arrays of indices within epd_statistics identifying stars selected to serve as templates for each photometry method.
- Return type:
[numpy.array(shape=(num_template_stars,), dtype=numpy.uint)]