autowisp.magnitude_fitting.master_photref_collector_zarr module
Class Inheritance Diagram

Define class for collecting statistics and making a master photref.
- class autowisp.magnitude_fitting.master_photref_collector_zarr.MasterPhotrefCollector(statistics_fname, num_photometries, num_frames, temp_directory, **config)[source]
Bases:
object
Class collecting magfit output to generate a master photometric reference.
- _statistics_fname
The file name to save the collected statistics under.
- _grcollect
The running
grcollect
process responsible for generating the statistics.
- _dimensions
How many photometry measurements are being fit based on how many images, and what is the total number of coluns included in the statistics (usually twice the number of photometries).
- _source_name_format
A %-substitution string for turning a source ID tuple to as string in the statistics file.
- _stat_quantities
The quantities that
grcollect
is told to calculate for each input magnitude and error estimate.
- __init__(statistics_fname, num_photometries, num_frames, temp_directory, **config)[source]
Prepare for collecting magfit results for master photref creation.
- Parameters:
statistics_fname (str) – The filename where to save the statistics relevant for creating a master photometric reference.
num_photometries (int) – The number of photometric measurements available for each star (e.g. number of apertures + 1 if psf fitting + …).
outlier_threshold (float) – A threshold value for outlier rejection. The units of this are determined by the
rejection_units
argument.max_rejection_iterations (int) – The maximum number of iterations between rejecting outliers and re-deriving the statistics to allow.
temp_directory (str) – A location in the file system to use for storing temporary files during statistics colletion.
rejection_center (str) – Outliers are define around some central value, either
'mean'
, or'median'
.rejection_units (str) – The units of the outlier rejection threshold. One of
'stddev'
,'meddev'
, or'absolute'
.max_memory (str) – The maximum amount of RAM the statistics process is allowed to use (if exceeded intermediate results are dumped to files in
temp_dir
).
- Returns:
None
- _add_catalog_info(catalog, statistics, catalog_columns)[source]
Add the catalog data for each source to the statistics.
- _calculate_statistics(statistics)[source]
Calculate and fill in the statics from all input collected so far.
- _create_reference(statistics, residual_scatter, *, enough_counts_flags, outlier_average, outlier_threshold, reference_fname, primary_header)[source]
Create the master photometric reference.
- Parameters:
statistics – The return value of _read_statistics().
residual_scatter – The return value of _fit_scatter().
enough_counts_flags (bool array) – Flag for each photometry for each star indicating whether sufficient number of points remained after rejection to use in the master.
outlier_average – See
fit_outlier_average
argument to generate_master().outlier_threshold – See
fit_outlier_threshold
argument to generate_master().reference_fname (str) – The name to use for the generated master photometric reference file.
primary_header (fits.Header) – The header to use for the primary (non-table) HDU of the resulting master FITS file.
- Returns:
None
- _fit_scatter(statistics, fit_terms_expression, *, enough_counts_flags, outlier_average, outlier_threshold, max_rej_iter, scatter_quantity='medianmeddev')[source]
Fit for the dependence of scatter on source properties.
- Parameters:
statistics – The return value of _read_statistics().
fit_terms_expression (str) – A fitting terms expression to use to generate the terms to include in the fit of the scatter.
min_counts (int) – The smallest number of observations to require for a source to participate in the fit.
outlier_average – See
fit_outlier_average
argument to generate_master().outlier_threshold – See
fit_outlier_threshold
argument to generate_master().max_rej_iter – See
fit_max_rej_iter
argument to generate_master().scatter_quantity (str) – The name of the field in
statistics
which contains the estimated scatter to fit.
- Returns:
The residuals of the scatter from
statistics
from the best-fit values found.- Return type:
numpy array
- _get_enough_count_flags(statistics, min_nobs_median_fraction)[source]
Return median number of observations per source in the stat. file.
- generate_master(*, master_reference_fname, catalog, fit_terms_expression, parse_source_id, min_nobs_median_fraction=0.5, fit_outlier_average='median', fit_outlier_threshold=3.0, fit_max_rej_iter=20, extra_header=None)[source]
Finish the work of the object and generate a master.
- Parameters:
master_reference_fname (str) – The file name to use for the newly created master photometric reference.
catalog – See
master_catalog
argument to MagnitudeFit.__init__().fit_terms_expression (str) – An expression expanding to the terms to include in the scatter fit. May use any catalog column.
parse_source_id (callable) – Should convert a string source ID into the source ID format expected by the catalog.
min_nobs_median_fraction (float) – The minimum fraction of the median number of observations a source must have to be inclruded in the master.
fit_outlier_average (str) – The averaging method to use for scaling averaging residuals from scatter fit. The result is used as the unit for
fit_outlier_threshold
.fit_outlier_threshold (float) – A factor to multiply the
fit_outlier_average
averaged residual from scatter fit in order to get the threshold to consider a scatter point an outlier, and hence discard from cantributing to the reference.fit_max_rej_iter (int) – The maximum number of iterations to allow for fitting/rejecting outliers. If this number is reached, the last result is accepted.
extra_header (None or dict-like) – Header keywords to add to the generated FITS header in addition to the ones describing the master fit.
- Returns:
None