setiastrosuitepro 1.6.10__py3-none-any.whl → 1.7.0.post2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. setiastro/images/colorwheel.svg +97 -0
  2. setiastro/images/narrowbandnormalization.png +0 -0
  3. setiastro/images/planetarystacker.png +0 -0
  4. setiastro/saspro/__main__.py +1 -1
  5. setiastro/saspro/_generated/build_info.py +2 -2
  6. setiastro/saspro/aberration_ai.py +49 -11
  7. setiastro/saspro/aberration_ai_preset.py +29 -3
  8. setiastro/saspro/backgroundneutral.py +73 -33
  9. setiastro/saspro/blink_comparator_pro.py +116 -71
  10. setiastro/saspro/convo.py +9 -6
  11. setiastro/saspro/curve_editor_pro.py +72 -22
  12. setiastro/saspro/curves_preset.py +249 -47
  13. setiastro/saspro/doc_manager.py +178 -11
  14. setiastro/saspro/gui/main_window.py +305 -66
  15. setiastro/saspro/gui/mixins/dock_mixin.py +245 -24
  16. setiastro/saspro/gui/mixins/file_mixin.py +35 -16
  17. setiastro/saspro/gui/mixins/menu_mixin.py +32 -1
  18. setiastro/saspro/gui/mixins/toolbar_mixin.py +135 -11
  19. setiastro/saspro/histogram.py +179 -7
  20. setiastro/saspro/imageops/narrowband_normalization.py +816 -0
  21. setiastro/saspro/imageops/serloader.py +972 -0
  22. setiastro/saspro/imageops/starbasedwhitebalance.py +23 -52
  23. setiastro/saspro/imageops/stretch.py +66 -15
  24. setiastro/saspro/legacy/numba_utils.py +25 -48
  25. setiastro/saspro/live_stacking.py +24 -4
  26. setiastro/saspro/multiscale_decomp.py +30 -17
  27. setiastro/saspro/narrowband_normalization.py +1618 -0
  28. setiastro/saspro/numba_utils.py +0 -55
  29. setiastro/saspro/ops/script_editor.py +5 -0
  30. setiastro/saspro/ops/scripts.py +119 -0
  31. setiastro/saspro/remove_green.py +1 -1
  32. setiastro/saspro/resources.py +4 -0
  33. setiastro/saspro/ser_stack_config.py +74 -0
  34. setiastro/saspro/ser_stacker.py +2310 -0
  35. setiastro/saspro/ser_stacker_dialog.py +1500 -0
  36. setiastro/saspro/ser_tracking.py +206 -0
  37. setiastro/saspro/serviewer.py +1258 -0
  38. setiastro/saspro/sfcc.py +602 -214
  39. setiastro/saspro/shortcuts.py +35 -16
  40. setiastro/saspro/stacking_suite.py +332 -87
  41. setiastro/saspro/star_alignment.py +243 -122
  42. setiastro/saspro/stat_stretch.py +220 -31
  43. setiastro/saspro/subwindow.py +2 -4
  44. setiastro/saspro/whitebalance.py +24 -0
  45. setiastro/saspro/widgets/resource_monitor.py +122 -74
  46. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/METADATA +2 -2
  47. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/RECORD +51 -40
  48. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/WHEEL +0 -0
  49. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/entry_points.txt +0 -0
  50. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/licenses/LICENSE +0 -0
  51. {setiastrosuitepro-1.6.10.dist-info → setiastrosuitepro-1.7.0.post2.dist-info}/licenses/license.txt +0 -0
@@ -129,7 +129,7 @@ from PyQt6.QtGui import (QPixmap, QColor, QIcon, QKeySequence, QShortcut,
129
129
 
130
130
  # ----- QtCore -----
131
131
  from PyQt6.QtCore import (Qt, pyqtSignal, QCoreApplication, QTimer, QSize, QSignalBlocker, QModelIndex, QThread, QUrl, QSettings, QEvent, QByteArray, QObject,
132
- QPropertyAnimation, QEasingCurve, QElapsedTimer
132
+ QPropertyAnimation, QEasingCurve, QElapsedTimer, QPoint
133
133
  )
134
134
 
135
135
  from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
@@ -193,9 +193,9 @@ from setiastro.saspro.resources import (
193
193
  nbtorgb_path, freqsep_path, contsub_path, halo_path, cosmic_path,
194
194
  satellite_path, imagecombine_path, wrench_path, eye_icon_path,multiscale_decomp_path,
195
195
  disk_icon_path, nuke_path, hubble_path, collage_path, annotated_path,
196
- colorwheel_path, font_path, csv_icon_path, spinner_path, wims_path,
196
+ colorwheel_path, font_path, csv_icon_path, spinner_path, wims_path, narrowbandnormalization_path,
197
197
  wimi_path, linearfit_path, debayer_path, aberration_path, acv_icon_path,
198
- functionbundles_path, viewbundles_path, selectivecolor_path, rgbalign_path,
198
+ functionbundles_path, viewbundles_path, selectivecolor_path, rgbalign_path, planetarystacker_path,
199
199
  background_path, script_icon_path
200
200
  )
201
201
 
@@ -604,7 +604,10 @@ class AstroSuiteProMainWindow(
604
604
  self.docman.documentAdded.connect(self._on_document_added)
605
605
  self.mdi.viewStateDropped.connect(self._on_mdi_viewstate_drop)
606
606
  self.mdi.linkViewDropped.connect(self._on_linkview_drop)
607
-
607
+ self._mdi_open_batch = 0
608
+ self._mdi_place_mode = "cascade" # or "tile"
609
+ self._mdi_next_pos = None # QPoint in MDI coords
610
+ self._mdi_cascade_step = 28
608
611
  self.doc_manager.set_mdi_area(self.mdi)
609
612
  # Coalesce undo/redo label refreshes
610
613
  self._undo_redo_refresh_pending = False
@@ -2660,10 +2663,27 @@ class AstroSuiteProMainWindow(
2660
2663
  return f"{name}{dims}"
2661
2664
 
2662
2665
  def _update_explorer_item_for_doc(self, doc):
2663
- for i in range(self.explorer.count()):
2664
- it = self.explorer.item(i)
2665
- if it.data(Qt.ItemDataRole.UserRole) is doc:
2666
- it.setText(self._format_explorer_title(doc))
2666
+ # Delegate to DockMixin implementation if present
2667
+ try:
2668
+ return super()._update_explorer_item_for_doc(doc)
2669
+ except Exception:
2670
+ pass
2671
+
2672
+ # Fallback: tree-safe implementation
2673
+ if not hasattr(self, "explorer") or self.explorer is None:
2674
+ return
2675
+ try:
2676
+ n = self.explorer.topLevelItemCount()
2677
+ except Exception:
2678
+ return
2679
+
2680
+ for i in range(n):
2681
+ it = self.explorer.topLevelItem(i)
2682
+ if it.data(0, Qt.ItemDataRole.UserRole) is doc:
2683
+ try:
2684
+ self._refresh_explorer_row(it, doc)
2685
+ except Exception:
2686
+ pass
2667
2687
  return
2668
2688
  #-----------FUNCTIONS----------------
2669
2689
 
@@ -3888,6 +3908,19 @@ class AstroSuiteProMainWindow(
3888
3908
 
3889
3909
  dlg.show()
3890
3910
 
3911
+ def _open_narrowband_normalization_tool(self):
3912
+ # Correct module import
3913
+ from setiastro.saspro.narrowband_normalization import NarrowbandNormalization
3914
+
3915
+ w = NarrowbandNormalization(doc_manager=self.docman, parent=self)
3916
+ w.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)
3917
+ w.setWindowTitle("Narrowband Normalization")
3918
+ try:
3919
+ w.setWindowIcon(QIcon(narrowbandnormalization_path))
3920
+ except Exception:
3921
+ pass
3922
+ w.show()
3923
+
3891
3924
  def _open_ppp_tool(self):
3892
3925
  from setiastro.saspro.perfect_palette_picker import PerfectPalettePicker
3893
3926
  w = PerfectPalettePicker(doc_manager=self.docman) # parent gives access to _spawn_subwindow_for
@@ -4239,6 +4272,14 @@ class AstroSuiteProMainWindow(
4239
4272
  dlg.setWindowIcon(QIcon(livestacking_path))
4240
4273
  dlg.show()
4241
4274
 
4275
+ def _open_planetary_stacker(self):
4276
+ # import locally to avoid startup cost / circular imports
4277
+ from setiastro.saspro.serviewer import SERViewer
4278
+ dlg = SERViewer(self)
4279
+ dlg.setWindowFlag(Qt.WindowType.Window, True)
4280
+ dlg.setWindowIcon(QIcon(planetarystacker_path))
4281
+ dlg.show()
4282
+
4242
4283
  def _open_stacking_suite(self):
4243
4284
  # Reuse if we already have one
4244
4285
  dlg = getattr(self, "_stacking_suite", None)
@@ -4282,6 +4323,202 @@ class AstroSuiteProMainWindow(
4282
4323
  except Exception:
4283
4324
  pass
4284
4325
 
4326
+ def _convert_mono_to_rgb_active(self):
4327
+ """
4328
+ Convert active mono document to RGB by duplicating the channel.
4329
+ Updates the active document in-place (undoable).
4330
+ """
4331
+ dm = getattr(self, "docman", None)
4332
+ if dm is None:
4333
+ return
4334
+
4335
+ try:
4336
+ doc = dm.get_active_document()
4337
+ except Exception:
4338
+ doc = None
4339
+ if doc is None:
4340
+ return
4341
+
4342
+ img = getattr(doc, "image", None)
4343
+ if img is None:
4344
+ return
4345
+
4346
+ import numpy as np
4347
+
4348
+ x = np.asarray(img)
4349
+
4350
+ # Already RGB?
4351
+ if x.ndim == 3 and x.shape[-1] == 3:
4352
+ try:
4353
+ name = getattr(doc, "display_name", lambda: None)() or getattr(doc, "name", "") or "Active"
4354
+ except Exception:
4355
+ name = "Active"
4356
+ if hasattr(self, "_log"):
4357
+ self._log(f"Mono → RGB: '{name}' is already RGB (shape={getattr(x,'shape',None)}).")
4358
+ return
4359
+
4360
+ # Determine what we're converting FROM
4361
+ src_desc = "unknown"
4362
+ if x.ndim == 2:
4363
+ mono = x
4364
+ src_desc = "mono (H×W)"
4365
+ elif x.ndim == 3 and x.shape[-1] == 1:
4366
+ mono = x[..., 0]
4367
+ src_desc = "mono (H×W×1)"
4368
+ else:
4369
+ # Unknown format (e.g., multi-channel >3)
4370
+ try:
4371
+ name = getattr(doc, "display_name", lambda: None)() or getattr(doc, "name", "") or "Active"
4372
+ except Exception:
4373
+ name = "Active"
4374
+ if hasattr(self, "_log"):
4375
+ self._log(f"Mono → RGB: '{name}' not convertible (shape={getattr(x,'shape',None)}).")
4376
+ return
4377
+
4378
+ before_shape = getattr(x, "shape", None)
4379
+ before_dtype = getattr(x, "dtype", None)
4380
+
4381
+ mono = mono.astype(np.float32, copy=False)
4382
+ rgb = np.stack([mono, mono, mono], axis=-1)
4383
+
4384
+ # metadata: preserve existing, but force "not mono"
4385
+ try:
4386
+ md = dict(getattr(doc, "metadata", None) or {})
4387
+ except Exception:
4388
+ md = {}
4389
+
4390
+ md["is_mono"] = False
4391
+ md["color_model"] = "RGB"
4392
+ md["channels"] = 3
4393
+ md["source"] = (md.get("source") or "Edit")
4394
+
4395
+ # If you track op params for history explorer
4396
+ md["__op_params__"] = {
4397
+ "op": "mono_to_rgb",
4398
+ "mode": "triplicate",
4399
+ "from": str(src_desc),
4400
+ "from_shape": tuple(before_shape) if before_shape is not None else None,
4401
+ "to_shape": tuple(rgb.shape),
4402
+ }
4403
+
4404
+ # name for logging
4405
+ try:
4406
+ name = getattr(doc, "display_name", lambda: None)() or getattr(doc, "name", "") or "Active"
4407
+ except Exception:
4408
+ name = "Active"
4409
+
4410
+ try:
4411
+ dm.update_active_document(
4412
+ rgb,
4413
+ metadata=md,
4414
+ step_name="Mono → RGB",
4415
+ doc=doc, # explicit is safer
4416
+ )
4417
+
4418
+ if hasattr(self, "_log"):
4419
+ self._log(
4420
+ f"Mono → RGB: '{name}' converted {src_desc} "
4421
+ f"(shape={before_shape}, dtype={before_dtype}) → "
4422
+ f"RGB (shape={rgb.shape}, dtype={rgb.dtype})."
4423
+ )
4424
+
4425
+ except Exception:
4426
+ import traceback
4427
+ try:
4428
+ from PyQt6.QtWidgets import QMessageBox
4429
+ QMessageBox.critical(self, "Mono → RGB", traceback.format_exc())
4430
+ except Exception:
4431
+ pass
4432
+
4433
+ def _swap_rb_active(self):
4434
+ """
4435
+ Swap R and B channels in the active RGB document (undoable).
4436
+ Intended for debayer/channel-order mismatches.
4437
+ """
4438
+ dm = getattr(self, "docman", None)
4439
+ if dm is None:
4440
+ return
4441
+
4442
+ try:
4443
+ doc = dm.get_active_document()
4444
+ except Exception:
4445
+ doc = None
4446
+ if doc is None:
4447
+ return
4448
+
4449
+ img = getattr(doc, "image", None)
4450
+ if img is None:
4451
+ return
4452
+
4453
+ import numpy as np
4454
+ x = np.asarray(img)
4455
+
4456
+ # Must be RGB
4457
+ if not (x.ndim == 3 and x.shape[-1] == 3):
4458
+ try:
4459
+ name = getattr(doc, "display_name", lambda: None)() or getattr(doc, "name", "") or "Active"
4460
+ except Exception:
4461
+ name = "Active"
4462
+
4463
+ if hasattr(self, "_log"):
4464
+ self._log(f"Swap R/B: '{name}' is not RGB (shape={getattr(x,'shape',None)}).")
4465
+ return
4466
+
4467
+ before_shape = x.shape
4468
+ before_dtype = x.dtype
4469
+
4470
+ # swap channels without changing dtype
4471
+ # (copy is safest so we don't mutate shared views)
4472
+ out = x.copy()
4473
+ out[..., 0], out[..., 2] = x[..., 2], x[..., 0]
4474
+
4475
+ # metadata: preserve existing, but annotate operation
4476
+ try:
4477
+ md = dict(getattr(doc, "metadata", None) or {})
4478
+ except Exception:
4479
+ md = {}
4480
+
4481
+ md["color_model"] = md.get("color_model", "RGB")
4482
+ md["channels"] = 3
4483
+ md["is_mono"] = False
4484
+ md["source"] = (md.get("source") or "Edit")
4485
+
4486
+ # If you track op params for history explorer
4487
+ md["__op_params__"] = {
4488
+ "op": "swap_rb",
4489
+ "from_shape": tuple(before_shape),
4490
+ "to_shape": tuple(out.shape),
4491
+ "dtype": str(before_dtype),
4492
+ }
4493
+
4494
+ try:
4495
+ name = getattr(doc, "display_name", lambda: None)() or getattr(doc, "name", "") or "Active"
4496
+ except Exception:
4497
+ name = "Active"
4498
+
4499
+ try:
4500
+ dm.update_active_document(
4501
+ out,
4502
+ metadata=md,
4503
+ step_name="Swap R ↔ B",
4504
+ doc=doc,
4505
+ )
4506
+
4507
+ if hasattr(self, "_log"):
4508
+ self._log(
4509
+ f"Swap R/B: '{name}' swapped channels "
4510
+ f"(shape={before_shape}, dtype={before_dtype})."
4511
+ )
4512
+
4513
+ except Exception:
4514
+ import traceback
4515
+ try:
4516
+ from PyQt6.QtWidgets import QMessageBox
4517
+ QMessageBox.critical(self, "Swap R/B", traceback.format_exc())
4518
+ except Exception:
4519
+ pass
4520
+
4521
+
4285
4522
  def _on_stackingsuite_relaunch(self, old_dir: str, new_dir: str):
4286
4523
  # Optional: respond to dialog's relaunch request
4287
4524
  try:
@@ -7871,6 +8108,43 @@ class AstroSuiteProMainWindow(
7871
8108
 
7872
8109
  return t
7873
8110
 
8111
+ def _mdi_begin_open_batch(self, mode: str = "cascade"):
8112
+ self._mdi_open_batch += 1
8113
+ self._mdi_place_mode = mode or "cascade"
8114
+ self._mdi_next_pos = None
8115
+
8116
+ def _mdi_end_open_batch(self):
8117
+ self._mdi_open_batch = max(0, self._mdi_open_batch - 1)
8118
+ if self._mdi_open_batch == 0:
8119
+ self._mdi_next_pos = None
8120
+
8121
+ def _mdi_compute_initial_pos(self) -> QPoint:
8122
+ area = (self.mdi.viewport().geometry() if self.mdi.viewport() else self.mdi.contentsRect())
8123
+ # Put first window a bit inset so titlebars don’t clip
8124
+ return QPoint(area.left() + 18, area.top() + 18)
8125
+
8126
+ def _mdi_place_subwindow(self, sw, target_w: int, target_h: int):
8127
+ """Deterministic placement. Uses a stable cursor during batch opens."""
8128
+ vp = self.mdi.viewport()
8129
+ area = vp.geometry() if vp else self.mdi.contentsRect()
8130
+
8131
+ if self._mdi_next_pos is None:
8132
+ self._mdi_next_pos = self._mdi_compute_initial_pos()
8133
+
8134
+ x = self._mdi_next_pos.x()
8135
+ y = self._mdi_next_pos.y()
8136
+
8137
+ # keep inside viewport; reset when we hit edge
8138
+ if (x + target_w > area.right() - 10) or (y + 40 > area.bottom() - 10):
8139
+ x = area.left() + 18
8140
+ y = area.top() + 18
8141
+
8142
+ sw.move(x, y)
8143
+
8144
+ # advance cursor
8145
+ step = int(self._mdi_cascade_step)
8146
+ self._mdi_next_pos = QPoint(x + step, y + step)
8147
+
7874
8148
  def _spawn_subwindow_for(self, doc, *, force_new: bool = False):
7875
8149
  """
7876
8150
  Open a subwindow for `doc`. If one already exists and force_new=False,
@@ -8044,52 +8318,22 @@ class AstroSuiteProMainWindow(
8044
8318
  target_h = max(200, target_h)
8045
8319
 
8046
8320
  sw.resize(target_w, target_h)
8047
- sw.showNormal() # CRITICAL: clears any "maximized" flag from previous active window
8321
+ sw.showNormal() # clears any "maximized" flag from previous active window
8048
8322
 
8049
- # -------------------------------------------------------------------------
8050
- # Smart Cascade: Position relative to the *currently active* window
8051
- # (before we make the new one active).
8052
- # -------------------------------------------------------------------------
8053
- new_x, new_y = area.left(), area.top()
8054
-
8055
- # Get dominant/active window *before* we activate the new one
8056
- active = self.mdi.activeSubWindow()
8057
- if active and active.isVisible() and not (active.windowState() & Qt.WindowState.WindowMinimized):
8058
- # Cascade from the active window
8059
- geo = active.geometry()
8060
- new_x = geo.x() + 30
8061
- new_y = geo.y() + 30
8062
- else:
8063
- # Fallback: try to find the "last added" visible window to cascade from
8064
- # (useful if active is None but windows exist)
8065
- try:
8066
- subs = [s for s in self.mdi.subWindowList() if s.isVisible() and s is not sw]
8067
- if subs:
8068
- # simplistic "last created" might be at end of list
8069
- last = subs[-1]
8070
- geo = last.geometry()
8071
- new_x = geo.x() + 30
8072
- new_y = geo.y() + 30
8323
+ # Deterministic placement (batch-aware)
8324
+ try:
8325
+ self._mdi_place_subwindow(sw, target_w, target_h)
8326
+ except Exception:
8327
+ # absolute fallback: top-left-ish
8328
+ try:
8329
+ sw.move(area.left() + 18, area.top() + 18)
8073
8330
  except Exception:
8074
8331
  pass
8075
8332
 
8076
- # Bounds check: keep titlebar visible and stay inside viewport
8077
- if (new_x + target_w > area.right() - 10) or (new_y + 40 > area.bottom() - 10):
8078
- new_x = area.left()
8079
- new_y = area.top()
8080
-
8081
- new_x = max(area.left(), new_x)
8082
- new_y = max(area.top(), new_y)
8083
-
8084
- sw.move(new_x, new_y)
8085
-
8086
- # ❌ removed the "fill MDI viewport" block - we *don't* want full-monitor first window
8087
-
8088
8333
  # Show / activate
8089
8334
  sw.show()
8090
8335
  sw.raise_()
8091
8336
  self.mdi.setActiveSubWindow(sw)
8092
- # (no second setWindowTitle() here)
8093
8337
 
8094
8338
  # Optional minimize/restore interceptor
8095
8339
  if hasattr(self, "_minimize_interceptor"):
@@ -8473,26 +8717,21 @@ class AstroSuiteProMainWindow(
8473
8717
 
8474
8718
 
8475
8719
  def _activate_or_open_from_explorer(self, item):
8476
- doc = item.data(Qt.ItemDataRole.UserRole)
8477
- base = self._normalize_base_doc(doc)
8478
-
8479
- # 1) Try to focus an existing view for this base
8480
- for sw in self.mdi.subWindowList():
8481
- w = sw.widget()
8482
- if getattr(w, "base_document", None) is base:
8483
- try:
8484
- sw.show(); w.show()
8485
- st = sw.windowState()
8486
- if st & Qt.WindowState.WindowMinimized:
8487
- sw.setWindowState(st & ~Qt.WindowState.WindowMinimized)
8488
- self.mdi.setActiveSubWindow(sw)
8489
- sw.raise_()
8490
- except Exception:
8491
- pass
8492
- return
8493
-
8494
- # 2) None exists -> open one
8495
- self._open_subwindow_for_added_doc(base)
8720
+ doc = item.data(0, Qt.ItemDataRole.UserRole)
8721
+ if doc is None:
8722
+ return
8723
+ # you already have logic for this; typically:
8724
+ sw = self._find_subwindow_for_doc(doc)
8725
+ if sw:
8726
+ self.mdi.setActiveSubWindow(sw)
8727
+ sw.show()
8728
+ sw.raise_()
8729
+ return
8730
+ # else open it (if your app supports opening closed docs, otherwise no-op)
8731
+ try:
8732
+ self._open_subwindow_for_added_doc(doc)
8733
+ except Exception:
8734
+ pass
8496
8735
 
8497
8736
  def _set_linked_stretch_from_action(self, checked: bool):
8498
8737
  # persist as the default for *new* views