Skip to content

Code cleanup - #18

Open
wtgee wants to merge 12 commits into
masterfrom
chore/agcc-cleanup
Open

Code cleanup#18
wtgee wants to merge 12 commits into
masterfrom
chore/agcc-cleanup

Conversation

@wtgee

@wtgee wtgee commented Jun 22, 2026

Copy link
Copy Markdown
Member

Walkthrough — Refactoring Cleanup

Changes Made

agccActor

centroid.py

  • Region coordinates loop: Defined a list of tuples half_regions with slices for both halves of the detector and processed them in a single for loop to extract spots and backgrounds.
  • Dynamic slice assignment: Populated the result structured array via dynamic slicing with start_idx and end_idx inside the loop, avoiding hardcoded 0:nSpots1 and nSpots1:nElem indices.
  • Saturation array concatenation: Simplified the initialization of the satValue array using np.concatenate and np.repeat.
  • Background subtraction loop: Rewrote the background subtraction of tempData using a loop over half_regions and the extracted backgrounds.
  • In-place moment update: Modified the iteratively-weighted FWHM updates to edit result in place if the moment converged (conv == 0), eliminating the need for temporary list allocations (m20, m02, m11, flags).
  • Semantic flags check: Changed the bitmask logic from result["flags"][i] & 1 to result["flags"][i] & SourceDetectionFlag.RIGHT for clarity.
  • Informative INFO level logging: Added helpful logger.info statements at the beginning of the centroiding process (indicating the camera, threshold, and min area), per-region spot detection counts including background median and standard deviation, overall spot detection counts, and the number of spots failing FWHM moment convergence.

AgccCmd.py

  • Helper method parseCameras: Created a centralized helper method to parse the optional cameras command keyword. It returns a list of 0-indexed camera indices or defaults to either the running cameras (if defaultToRunning=True is passed) or all cameras.
  • Handler Refactoring: Cleaned up the duplicate parsing logic in 8 command handlers (shutterOps, expose, abort, setframe, resetframe, setmode, getmode, and settemperature) to use parseCameras, removing all redundant if cams is None check blocks.
  • Cleaned Unused Variables: Removed cmdKeys variable assignments that became unused after refactoring.

wtgee added 10 commits June 22, 2026 07:35
* Add the `boxSize` and `halfBox` size to the config defaults.
…getParams()` function in `centroid.py` to reduce code duplication and centralize configuration reading.

- Refactored `AgccCmd.py` to use a single `reloadParams()` method for both `setCentroidParams` and `setImageParams` commands, simplifying the command handler logic.
- Updated all internal callers, test fixtures, and analysis scripts to use the new `getParams()` API.
- Maintained backward compatibility for the `setCentroidParams` and `setImageParams` tron commands.
…e duplication.

* Add logging statements to centroiding.
… line before could probably be eliminated but I'm leaning them now
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Test Coverage

Name Stmts Miss Cover Missing
python/agccActor/Commands/AgccCmd.py 177 177 0% 3-524
python/agccActor/Commands/__init__.py 0 0 100%
python/agccActor/__init__.py 0 0 100%
python/agccActor/camera.py 274 78 72% 43-44, 57-87, 118-119, 172-173, 260, 275, 282-305, 352, 354, 370-383, 395-408, 423-425, 453-455, 476-478, 506-507
python/agccActor/centroid.py 226 44 81% 21-23, 44-65, 85, 202-204, 282, 346-347, 350, 424-429, 472, 487, 494, 500-503, 529-536
python/agccActor/database.py 41 0 100%
python/agccActor/expose.py 143 78 45% 133-186, 210-213, 217-220, 224-227, 233, 240-259, 265-268, 282-285
python/agccActor/fli/__init__.py 0 0 100%
python/agccActor/main.py 24 24 0% 3-87
python/agccActor/photometry.py 31 0 100%
python/agccActor/setmode.py 26 17 35% 34-52
python/agccActor/writeFits.py 69 4 94% 117, 144-146
TOTAL 1011 422 58%

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.

1 participant