Skip to content

Conversation

@TakKanekoGit
Copy link
Contributor

@TakKanekoGit TakKanekoGit commented Aug 20, 2025

Work-in-progress...

Features:

  • IMU dead-reckoning tracking for EQ mounts.
  • PiFinder no longer needs to be placed upright (it can be mounted as any angle as long as the camera points the same way as the scope).
  • For altaz mounts, the charts are displayed in horizontal coordinates (Zenith-up) so that alt/az motion will be left/right and up/down. For EQ mounts, the charts are displayed in equatorial coordinates (NCP up) so that az/dec motion will be left/right and up/down.

Changes:

  • imu_pi.py: IMU data coordinates are no longer altered here depending on the PiFinder type. IMU outputs will be they are from the IMU. This is now done in imu_dead_reckoning.py.
  • integrator.py: Substantial changes. Tracking is done in the equatorial coordinates rather than altaz coordinates. Use quaternion for the IMU dead-reckoning. Sets solver["Roll"] depending on the mount type for chart display.
  • pointing_model\: The new classes and functions are grouped up here. It's possible that we could extend this in the future?
  • requirements_dev.txt: Requires numpy.quaternion.

This PR touches the core of the IMU functionality so it still needs to be tested thoroughly on all PiFinder types and also on altaz and EQ mounts.

Issues:

  • Fix issues after merging with the auto exposure feature
  • Chart rotates 180 degrees to the East of Mirfak (from sky testing): Pointings in RA, Dec were OK but in Chart mode, the chart rotated 180 degrees as I crossed to the East of around Mirfak in Perseus with the result that slewing to the
    East showed up as moving to the right.
  • Southern hemisphere & equator EQ mode: Should it be South Pole up (roll = 180 deg)?
  • Southern hemisphere & equator Alt/az mode: if lat < 0: Display Roll + 180 deg (south up). Use North at equator

Sky test IMU orientations

  • Flat v2
  • Left
  • Right
  • Straight
  • Flat v3
  • as_dream

TakKanekoGit added 30 commits August 8, 2025 22:52
…ternion(0, 0, 0, 0) because it's used in statements like if imu["quat"]...
…-> Now plate solves but chart doesn't move when PiFinder moved
TakKanekoGit and others added 30 commits November 15, 2025 11:56
…nges for Auto Exposure that was lost in merge
…ots#371)

* Add a testing the backlight step and a warning to test the backlight before installing the GPS.

* Add instructions to for testing the keypad
* Adding first version of sqm measurement

* Added UI screen, some refactoring for jupyter debugging

* Fix crash on no solution

* No shared_state crash

* Protect against various crash situations

* Swapping centroid y/x

* Added bortle classes, radius=3

* Now try radius=2

* Raw output for camera in shared state

* Introducing bias image

* feeding linear image through pipeline

* Delete and ignore comets file, sqm fixes

* Fix bias image bug

* Missing bias image arguments

* Another raw_image mention removed

* Add debugging output

* Merged main with the location changes

* Final version of sqm ui

- still has the bias frames, will be removed next commit
- added bortle descriptions in the ui

* Add unit test

* Removed bias, added performance code

* speed up per-star calculations

* Less info logging, translations, fix nox error

* fix messages

* Updated other languages with translation

* Perform SQM every 5 secs, prettify the SQM ui

* Fix linting error

* Some raw and pedestal changes

* Add default dark frames

* Better noise floor

* fix exposure

* leave exposure

* Noise floor fixes

* processed vs raw

* marking menu for pro sqm

* add sqm calibration

* Immediately reload measurements

* improve sweeps and camera type, maybe camera type should be reverted

* Raw pipeline

* Cleanup

* Cleanup after partial PR review

* Refactoring camera handling and sqm calibration

* Do sqm calibration captures in manual mode

* small AE and sqm fixes

* Solve stuck

* show background during sqm

* Fix name error

* another fix

* resize

* Stretch image

* Fix SQM sweep capture for production readiness

- PNG Processing: Changed sweep to save 8-bit processed PNGs using capture() method
- GPS Time Integration: Sweep now uses GPS datetime from shared_state
- Altitude Calculation: Added automatic altitude calculation from RA/Dec
- Metadata Saving: Implemented comprehensive metadata saving with save_sweep_metadata.py
- Progress Bar Fix: Updates progress for every image (not every 10th)
- Background Clamping: Modified SQM calculator to clamp negative backgrounds to 1 ADU
- Type Hints: Added proper Optional[] type hints for mypy compliance

* Fix cedar-detect shared memory crashes and variable shadowing

Cedar-detect shared memory fix:
- Fixed intermittent FileNotFoundError when cedar-detect has shared memory issues
- Client now gracefully handles missing/stale shared memory
- Automatically falls back to non-shmem mode instead of crashing
- Updated tetra3 submodule with robust error handling

Variable shadowing fix:
- Fixed linter error where 'time' variable shadowed 'time' module import
- Renamed to 'obs_time' for clarity in altitude calculation

* Add real-time progress UI for exposure sweep
* fix crash on sweep

* time based progress of sweep

* Fix sweep

* Use GPS time

* Fix json writing

* fix altitude calc

* Improve exposure sweep

* Better counting and solver crah

* more solver indenting

* Improve sweep UI

* Handle daytime calibration

* Add correction ui and help

* Add sqm debugging sweeps

* Adding SNR AE

* Add rotating constellation/SQM display to title bar

Adds a rotating info display that alternates between constellation name
and SQM value every 3 seconds with a smooth cross-fade animation.

* Add exposure time display to SQM view

Shows current camera exposure time (e.g., "400ms" or "0.40s") in the
top right of the SQM view for diagnostic purposes.

Cherry-picked from test-upstream branch.

* Simplify Bortle class display on SQM view

- Remove redundant title text display
- Add guard for missing details
- Use base font for consistency

* Remove dual pipeline references from SQM code

- Remove unused value_raw from SQMState
- Rename update_sqm_single_pipeline to update_sqm
- Rename sqm_raw to sqm_uncorrected (more accurate name)
- Remove raw SQM display from UI
- Clean up outdated comments

* Refactor rotating display into compact helper class

Extract RotatingInfoDisplay class to encapsulate state and animation logic.
Reduces code by ~100 lines while preserving cross-fade animation behavior.

* Derive SNR controller thresholds from camera profile

- Add from_camera_profile() factory method to ExposureSNRController
- Calculate min/target/max background from bit_depth and bias_offset
- Target background just above min (no benefit to higher values)
- Remove arbitrary 400ms min_exposure floor (now 10ms)
- Remove 5-second rate limiting (averaging handled in SQM code)

* Update tetra3 submodule to match main

* Fix KeyError on T_solve when solver fails

Check if T_solve exists in solved dict before accessing it.
Previously checked wrong dict (solution vs solved) or didn't check at all.

* Fix update_sqm parameter name mismatch after merge

* Fix KeyError when deleting optional solution fields

* Fix camera type detection for SNR controller

* Remove duplicate solver code block from bad merge

* Add saturation detection to SNR controller

* Exclude saturated stars from SQM instead of reducing exposure

Move saturation handling from auto-exposure to SQM calculation:
- SQM: detect saturated stars (max aperture pixel >= 250) and exclude
  from mzero calculation by setting flux to -1
- Auto-exposure: remove saturation detection, just target background level

This allows longer exposures for better background SNR while ignoring
bright saturated stars that would corrupt the photometric calibration.

* Fix TypeError in SQM correction UI

colors.get() only takes intensity, not red=True keyword argument.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix SQM correction: value_raw attribute does not exist

SQM state only has value, source, last_update - not value_raw.
Store source in metadata instead.

* Target minimum background for shorter exposures

Change target_background from min*1.25 to min+2 for more linear
camera response and less saturation risk.

* Use adaptive noise floor for SNR auto-exposure

- Add noise_floor to shared state (solver writes, camera reads)
- SNR controller uses adaptive noise floor + 2 as min_background
- Falls back to static camera profile if noise floor not yet available

* UX: Show 'Saving...' during correction save, target exact noise floor

- Show 'Saving...' message immediately before creating zip
- Remove +2 margin from noise floor - target exact value for shortest exposure

* Add noise_floor and imu_delta to correction metadata

* Add full SQM calculation details to shared state and correction metadata

Includes: mzero, mzero_std, background, pedestal, extinction, star counts,
saturation info, etc. - everything needed for calibration validation.
* Show star count in SQM view
* Move star count to top line in SQM view

* Add bracketed exposures to correction package

Captures 3 exposures: base, +1 stop, -1 stop (or base, -1, -2 if at max).
Shows progress for each bracket. Re-enables auto-exposure when done.

* Reduce exposure sweep from 100 to 20 images

Faster sweep (~1 min vs ~4 min) while still sampling exposure space.
Launch from SQM view → hold square → DEBUG.

* Use flux-weighted mean for mzero calculation

Brighter stars have higher SNR so their mzero estimates are more reliable.
Weight each star's contribution by its flux.

* Restore +2 margin above noise floor

Without margin, background_corrected ≈ 0 when at noise floor,
causing log10(~0) = very negative, making SQM too high.

* Fix SQM calculation: use bias_offset only as pedestal, disable extinction

Two fixes for SQM being ~0.4 mag too high:

1. Use only bias_offset (6.0 ADU) as pedestal instead of full noise_floor
   (7.46 ADU). Read noise and dark current are random fluctuations, not
   systematic offsets that should be subtracted.

2. Disable atmospheric extinction correction. When comparing to ground-based
   SQM meters, both measurements are through the same atmosphere, so no
   correction is needed.

* Re-enable extinction correction with 0.1 mag/airmass coefficient

* Add dual extinction correction: fixed 0.1 for meter match, altitude-based for science

- Main SQM value uses fixed 0.1 mag extinction (matches consumer SQM meters)

* Use ASTAP extinction convention: 0.28*(airmass-1), no fixed baseline

* better default for camera

* small corrections to sqm calculation and athmospheric correcitons

* Simplify SQM API, fix read noise calculation, add Cedar fallback

* Set SNR as default for testing

* Fix PID auto-exposure crash and improve sweep recovery

- Fix PID integral crash: Reset integral when error changes sign
  (prevents -487,500µs crash when going from too many → too few stars)
- Start sweep at 400ms instead of 25ms for faster recovery
- Add sleep mode logging to diagnose camera blocking issues
- Revert default to PID (SNR exposures too long on clear nights)

* Update tests for sweep starting at 400ms

Tests now reflect the new sweep pattern that starts at 400ms
instead of 25ms for faster recovery.
# Conflicts:
#	python/PiFinder/camera_interface.py
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.

4 participants