autowisp.magnitude_fitting.master_photref_collector_grcollect module — AutoWISP documentation

# autowisp.magnitude_fitting.master_photref_collector_grcollect module

## Class Inheritance Diagram

Define class for collecting statistics and making a master photref.

class autowisp.magnitude_fitting.master_photref_collector_grcollect.MasterPhotrefCollector(statistics_fname, num_photometries, temp_directory, *, outlier_threshold=5.0, max_rejection_iterations=10, rejection_center='median', rejection_units='meddev', max_memory='2g', source_name_format='{0:d}')

  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.

  _num_photometries

    How many photometry measurements being fit.

  _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, temp_directory, *, outlier_threshold=5.0, max_rejection_iterations=10, rejection_center='median', rejection_units='meddev', max_memory='2g', source_name_format='{0:d}')

    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

  _calculate_statistics()

    Creating the statics file from all input collected so far.

  _create_reference(statistics, residual_scatter, *, min_counts, outlier_average, outlier_threshold, reference_fname, primary_header)

    Create the master photometric reference.

    Parameters:

      - statistics – The return value of _read_statistics().

      - residual_scatter – The return value of _fit_scatter().

      - min_counts (int) – The smallest number of observations to require for a source to be included in the refreence.

      - 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

  static _fit_scatter(statistics, fit_terms_expression, *, min_counts, outlier_average, outlier_threshold, max_rej_iter, scatter_quantity='medianmeddev')

    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_med_count()

    Return median number of observations per source in the stat. file.

  _read_statistics(catalog, parse_source_id)

    Read the magnitude & scatter for each source for each photometry.

    Parameters:

      - catalog (dict) – See `master_catalog` argument to MagnitudeFit.__init__().

      - parse_source_id (callable) – See same name argument to generate_master().

    Returns:

      The fields are as follows:

      > source_id: The ID of the source.

      > xi, eta: The projected angular coordinates of the source

      >   from the catalog.

      > full_count: The full number of measurements available for

      >   the sources

      > rejected_count: The number of measurements of the source

      >   after outlier rejection during statistics collection.

      > mediandev: An estimate of the scatter for the source,

      >   as the deviation around the median, calculated during statistics collection.

      > medianmeddev: An estimate of the scatter for the source as

      >   the median deviation around the median, calculated during statistics collection.

    Return type:

      numpy structured array

  _report_grcollect_crash(grcollect_outerr=None)

    Raise an error providing information on why grcollect crashed.

  add_input(fit_results)

    Ingest a fitted frame’s photometry into the statistics.

  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)

    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