autowisp.database.photref_selection module
Class Inheritance Diagram

Photometric-reference selection helpers shared by the BUI and tests.
This module hosts the non-Django half of what the BUI’s
select_photref_views does:
compute_photref_candidates()walksprocessing.pendingforfit_magnitudesand groups the per-condition batches that still need a single photometric reference.bind_images_to_photref()writes theImageMasterSelectionrows for every batch image withinmax_photref_separationof the chosen photref.
The view module calls these to populate the Django session / handle form submissions; the integration test calls them directly to mimic “user picks a photref” without going through HTTP.
- autowisp.database.photref_selection.bind_images_to_photref(dr_fname, batch)[source]
Write ImageMasterSelection rows for batch images near the photref.
Reads the fit_magnitudes config to get
max_photref_separation(which may be conditional), then for each image inbatchcomputes the angular separation between the image center and the photref center. Images whose separation is withinmax_photref_separation * photref_diagonal_fovare bound to the photref via an upsert intoImageMasterSelection.- Parameters:
dr_fname – Path to the photref DR file that was just registered as a
single_photrefmaster viaImageProcessingManager.add_masters().batch – List of
(calibrated_fname, dr_fname, image_id, channel)tuples – the candidate images from the same condition group. Onlyimage_idandchannelare consumed here; the first two slots exist for parity withcompute_photref_candidates’s return shape.
- autowisp.database.photref_selection.compute_photref_candidates(processing, db_session)[source]
Return the per-condition batches of images missing a photref.
Holds the data-gathering half of what
select_photref_views._get_missing_photrefdoes. The BUI calls this (and then writes the result into the Django session); the integration test calls it directly.Builds
processing.pendingfor thefit_magnitudesstep (optionally falling back to “demo” mode where every candidate is treated as pending), strips images whosesolve_astrometryprerequisite failed, groups the survivors by master-condition values, and for each non-empty group produces a(master_values, calculate_photref_merit_config, batch)tuple wherebatchis the list of(calibrated_fname, dr_fname, image_id, channel)entriesbind_images_to_photref()expects.- Parameters:
processing – A fresh
ImageProcessingManager. Itspendingattribute is populated as a side effect.db_session – Open SQLAlchemy session.
- Returns:
"demo"(bool)True iff no images were actually pending
fit_magnitudes– the caller may then surface every candidate for inspection rather than only the unbound ones."candidates"(list[dict])One entry per
(step_id, image_type_id)inprocessing.pending. Each entry has:"step_id"(int)"image_type_id"(int)"master_expressions"(list[str]) – the condition expressions defining a photref’s identity."groups"(list[tuple]) – a tuple of(list(master_values), config, batch)per group of images sharing the same master-condition values.
- Return type:
dict with keys