Skip to content

Feat/improved autofocuser - #129

Merged
ppp-one merged 16 commits into
ppp-one:mainfrom
dgegen:feat/improved-autofocuser
Aug 6, 2026
Merged

Feat/improved autofocuser#129
ppp-one merged 16 commits into
ppp-one:mainfrom
dgegen:feat/improved-autofocuser

Conversation

@dgegen

@dgegen dgegen commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

name: Pull request
about: Create a pull request


Description
Improves the Autofocuser class with a shared run_timestamp property so all output files from a single autofocus run share a consistent timestamp-based naming scheme. Also simplify the focus record handling to use only the in-memory record, and adds logging for the observatory subclass type at startup.

Changes Made

  • Log name of subclass during observatory startup
  • Add run_timestamp property to Autofocuser that lazily generates a single timestamp (format YYYYMMDD_HHMMSS) shared across all output files of one run
  • Add _output_path() helper that builds consistent output paths using run_timestamp
  • Refactor make_summary_plot() and save_result() to use _output_path() instead of ad-hoc timestamp/CSV-derived filenames
  • Remove fallback CSV-reading logic in make_summary_plot() — the in-memory focus_record is now the only source; failures emit warnings and return early
  • Also save the focus record DataFrame as CSV via make_summary_plot() using the shared timestamp
  • Log observatory subclass name at startup (observatory.py)
  • Fix self.observatory.error(...)self.observatory.logger.error(...) call
  • Bump astrafocus dependency to 0.1.2. This fixes a few small bugs that propagated into Astra, especially when using secondary focus measure operators.

Checklist

  • Code follows project style guidelines
  • Tests added/updated
  • Documentation updated (if needed)
  • All checks pass

Copilot AI review requested due to automatic review settings March 19, 2026 18:23

This comment was marked as resolved.

@dgegen
dgegen force-pushed the feat/improved-autofocuser branch from b70600c to 8069d43 Compare March 24, 2026 10:21
Comment thread src/astra/autofocus.py Outdated
except Exception as e:
field_of_view = np.array([np.nan, np.nan])
self.observatory.error(
self.observatory.logger.error(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

warning, instead?

@dgegen
dgegen force-pushed the feat/improved-autofocuser branch from 1633aa0 to 33ffe60 Compare July 21, 2026 09:09
dgegen added 8 commits July 21, 2026 11:09
Upgrades astrafocus from 0.1.2 to 0.1.3, which fixes autofocus runs
crashing with "Input must be a 2D array" when an exposure fails mid-sweep
(e.g. due to weather); the new version catches focus measure exceptions
and records NaN instead of aborting.

Also adds documentation (docstring and FIELD_DESCRIPTIONS) clarifying when
to prefer non-parametric operators (fft, normalized_variance) for coarse
searches vs. analytic operators (HFR) for fine tuning near the focus peak.
@dgegen
dgegen force-pushed the feat/improved-autofocuser branch from 33ffe60 to 9632c68 Compare July 21, 2026 09:26
@dgegen
dgegen force-pushed the feat/improved-autofocuser branch from 9632c68 to 6bee361 Compare July 21, 2026 09:28
dgegen added 7 commits July 21, 2026 15:25
Break the monolithic utils.py into astra/utils/{time,image,ephemeris,speculoos}.py
grouped by responsibility (JD/time conversions, image cleaning, sun/body
ephemeris, SPECULOOS error handling), and update all call sites and tests
to import from the new submodules.
Adds PairedDevices.calculate_fwhm(), estimating the DAOStarFinder FWHM
from the camera/telescope plate scale assuming ~2" seeing when
AutofocusConfig.fwhm is left unset. Also moves field-of-view
calculation from Autofocuser into PairedDevices.calculate_field_of_view()
for symmetry, reusing the shared math in astra.utils.optics.
…ogic

Break out of the IsMoving poll loop early if observatory conditions
fail during a focuser slew, rather than waiting for timeout. Also
extract the repeated save_path/last_image_path fallback logic in
Autofocuser into a shared _determine_save_dir() helper.
…he redundant prefix on check/ack function names

Reflects that the module handles AsTelOS telescope errors specifically, not SPECULOOS-wide utilities.
@dgegen

dgegen commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

This led me to some cleanup related to, but also going beyond, the autofocuser improvements. With the acceptance of twirl/pull/44, the dependency tension between photutils>3.0.0 and twirl has been resolved. @ppp-one, I think this is ready to merge if you're happy with the changes.

@ppp-one

ppp-one commented Aug 6, 2026

Copy link
Copy Markdown
Owner

<3

@ppp-one
ppp-one merged commit 992b119 into ppp-one:main Aug 6, 2026
2 checks passed
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.

3 participants