Skip to content

Only use the enabled cameras for offset calculations - tickets/INSTRM-2919#104

Open
wtgee wants to merge 10 commits intomainfrom
tickets/INSTRM-2917
Open

Only use the enabled cameras for offset calculations - tickets/INSTRM-2919#104
wtgee wants to merge 10 commits intomainfrom
tickets/INSTRM-2917

Conversation

@wtgee
Copy link
Copy Markdown
Member

@wtgee wtgee commented May 6, 2026

This gets a list of enabled cameras from pfs_instdata (https://github.com/Subaru-PFS/pfs_instdata/pull/51/changes) and uses that to filter the detected data so that it is not used in any offset or focus caluclations.

The camera will still expose and populate agc_data.

⚠️ Note that the branch is incorrectly named 2917 instead of 2919.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for restricting guiding offset and focus calculations to a configured subset of “enabled” AG cameras, while still allowing all cameras to expose and populate agc_data.

Changes:

  • Plumbs a one-indexed camera allowlist through acquisition/autoguide flows into get_detected_objects() and query_agc_data().
  • Adds camera filtering to the agc_data query (and to focus calculations when operating on an in-memory detected_objects DataFrame).
  • Stores enabled camera configuration on AgCmd and passes it into field acquisition, autoguide, and focus.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/agActor/utils/focus.py Adds optional enabled-camera filtering for focus calculations and DB queries.
python/agActor/utils/data.py Adds camera filtering support to detected-object retrieval and AGC DB querying.
python/agActor/field_acquisition.py Adds a cameras parameter and passes it into detected-object retrieval for offset calculations.
python/agActor/Controllers/ag.py Threads camera selection through the autoguide control loop parameters into offset/focus computations.
python/agActor/Commands/AgCmd.py Reads enabled cameras from actor config and forwards them to acquisition/autoguide/focus.
python/agActor/autoguide.py Accepts a camera allowlist and passes it into detected-object retrieval for offset calculations.
Comments suppressed due to low confidence (1)

python/agActor/field_acquisition.py:82

  • The new cameras parameter changes which detected objects feed into offset calculations, but the existing notebook-based tests for acquire_field() don't exercise passing a camera subset. Please add/update tests to cover that cameras=[...] restricts the queried detected objects (and that results are consistent when some cameras are disabled).
def acquire_field(
    *,
    design_id: int,
    frame_id: int,
    visit0: int | None = None,
    cameras: list[int] | None = None,
    obswl: float = 0.62,
    altazimuth: bool = True,
    is_guide: bool = False,
    **kwargs: Any,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/agActor/field_acquisition.py
Comment thread python/agActor/utils/data.py Outdated
Comment thread python/agActor/Controllers/ag.py
@wtgee wtgee changed the title Only use the enabled cameras for offset calculations - tickets/INSTRM-2917 Only use the enabled cameras for offset calculations - tickets/INSTRM-2919 May 6, 2026
wtgee added 5 commits May 5, 2026 23:49
* Accept a list of enabled cam_id integers from `pfs_instdata`.
* Use list to query the valid agc_data.
Add two new optional parameters to RADECInRShiftA:
- obj_camera_id: per-detection camera ID array (1-based)
- enabled_camera_ids: list of camera IDs allowed to contribute to the fit
Only detections from enabled cameras enter the least-squares solve
(Phases 5–6 and iterative outlier rejection).  All detections are still
matched and included in the returned match_result, so predicted positions
for disabled cameras are preserved in the output.
Thread enabled_camera_ids through calculate_offsets in
FieldAcquisitionAndFocusing.py, passing filtered_detected_array[:, 0]
as obj_camera_id.  Defaults (None) preserve the original behaviour.
…ffsets

Remove the cameras parameter from get_detected_objects so all detections
are always fetched from the DB.  The camera-based restriction is now
applied at the fitting level via the enabled_camera_ids parameter added
to calculate_offsets in the previous commit.
Thread the change through the call chain:
- get_detected_objects: drop cameras param and query_agc_data cameras arg
- acquire_field: stop passing cameras to get_detected_objects; pass it
  to get_guide_offsets as enabled_camera_ids
- get_guide_offsets: add enabled_camera_ids param; pass to calculate_offsets
- autoguide.get_exposure_offsets: stop passing cameras to
  get_detected_objects; pass to get_guide_offsets as enabled_camera_ids
@wtgee wtgee force-pushed the tickets/INSTRM-2917 branch from 2d6b863 to e818ef3 Compare May 6, 2026 10:21
wtgee added 5 commits May 6, 2026 00:25
All detections are now always fetched for the full exposure. Camera-based
restriction on the astrometric fit is handled downstream via
enabled_camera_ids in calculate_offsets / RADECInRShiftA.
query_agc_data no longer accepts a cameras argument. Fetch all detections
unconditionally and apply the enabledCameras filter on the DataFrame
afterwards, unifying the two previously-separate code paths.
…of corrections. More safety checks for fail conditions.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants