starbash 0.3.7__tar.gz → 0.3.9__tar.gz
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.
- {starbash-0.3.7 → starbash-0.3.9}/PKG-INFO +1 -1
- {starbash-0.3.7 → starbash-0.3.9}/pyproject.toml +3 -3
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/analytics.py +16 -1
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/publish.py +6 -1
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/doit.py +71 -7
- starbash-0.3.9/src/starbash/fits.py +160 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/processing.py +208 -25
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/publish/github_publish.py +14 -2
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/publish/github_service.py +9 -1
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/recipes/crop.py +90 -4
- starbash-0.3.9/src/starbash/recipes/osc.py +568 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/run_state.py +15 -2
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/context.py +24 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/graxpert.py +59 -4
- starbash-0.3.9/src/starbash/tool/ranges.py +52 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/rcastro.py +77 -12
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/siril.py +20 -1
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/publish.py +46 -10
- starbash-0.3.7/src/starbash/fits.py +0 -59
- starbash-0.3.7/src/starbash/recipes/osc.py +0 -260
- {starbash-0.3.7 → starbash-0.3.9}/LICENSE +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/README.md +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/aliases.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/app.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/check.png +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/favicon.ico +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/icon.png +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/icon.svg +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/assets/starbash.desktop.in +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/check_version.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/gui.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/info.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/process.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/repo.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/select.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/commands/user.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/database.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/defaults/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/defaults/starbash.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/doit_types.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/dwarf3.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/events.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/exception.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/filtering.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/interaction.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/linux.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/main.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/os.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/parameters.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/paths.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/preferences.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/processed_target.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/processing_like.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/publish/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/publish/credentials.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/publish/github.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/recipes/README.md +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/recipes/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/recipes/report_registration.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/report.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/rich.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/safety.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/score.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/selection.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/sim_siril/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/sim_siril/connection.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/sim_siril/enums.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/sim_siril/utility.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/siril/import_registration.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/stage_utils.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/stages.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/repo/master.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/repo/processed.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/Gemfile +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/README.md.jinja +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/_config.yml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/default.html +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/index.md.jinja +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/report/target.md.jinja +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/target/master.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/target/processed/about.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/target/processed/main.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/target/processed/sessions.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/templates/userconfig.toml +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/toml.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/base.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/python.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/tool/starnet.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/cli.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/cli_events.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/app.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/bridge.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/desktop.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/interaction.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/jobs.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/launcher.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/main_window.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/models.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/base.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/dashboard.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/masters.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/processing.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/repositories.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/sessions.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/settings.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/targets.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/pages/wizard.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/services.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/theme.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/__init__.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/busy_indicator.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/file_links.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/github_login.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/hover_preview.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/image_viewer.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/log_view.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/master_picker.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/selection_panel.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/stat_card.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/widgets/tool_warning.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/ui/qt/workers.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/url.py +0 -0
- {starbash-0.3.7 → starbash-0.3.9}/src/starbash/windows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "starbash"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.9"
|
|
4
4
|
description = "A tool for automating/standardizing/sharing astrophotography workflows."
|
|
5
5
|
authors = ["Kevin Hester <kevinh@geeksville.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,6 @@ toml-repo = "^0.1.7"
|
|
|
32
32
|
|
|
33
33
|
# Note: to use graxpert from the local tree rather than pypi use:
|
|
34
34
|
# graxpert = {path = "GraXpert", extras = ["cpuonly"], develop = true}
|
|
35
|
-
graxpert = {version = "^3.2.0a3", extras = ["cpuonly"]}
|
|
36
35
|
|
|
37
36
|
# The following two libs are only needed for the (temporary) experiment of running siril scripts directly...
|
|
38
37
|
# experimenting with siril-scripts/processing/VeraLux_HyperMetric_Stretch.py
|
|
@@ -43,6 +42,7 @@ pyqt6 = "^6.10.1"
|
|
|
43
42
|
# The desktop GUI (`sb gui`) binding. A normal dependency: the GUI is a first-class
|
|
44
43
|
# way to drive Starbash. "Optional" only means users may keep using the CLI instead.
|
|
45
44
|
pyside6 = "^6.11.2"
|
|
45
|
+
graxpert = {version = "^3.2.0a3", extras = ["cpuonly"]}
|
|
46
46
|
|
|
47
47
|
[tool.poetry.group.dev.dependencies]
|
|
48
48
|
pytest = ">=8.4.2,<10.0.0"
|
|
@@ -72,7 +72,7 @@ sb = "starbash.main:app" # std alias for convenience
|
|
|
72
72
|
|
|
73
73
|
[tool.pytest.ini_options]
|
|
74
74
|
markers = [
|
|
75
|
-
"slow: marks tests
|
|
75
|
+
"slow: marks tests that take >10s in the default '-n auto' run (deselect with '-m \"not slow\"')",
|
|
76
76
|
"integration: marks tests as integration tests requiring /test-data (deselect with '-m \"not integration\"')",
|
|
77
77
|
"gui: marks tests that build real Qt widgets (offscreen; deselect with '-m \"not gui\"')",
|
|
78
78
|
"gui_integration: marks the scripted gui_integration movie runs (needs ffmpeg + /test-data; deselect with '-m \"not gui_integration\"')",
|
|
@@ -2,6 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
import platform
|
|
4
4
|
import types
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
5
6
|
from typing import Any
|
|
6
7
|
|
|
7
8
|
from sentry_sdk.integrations.excepthook import ExcepthookIntegration
|
|
@@ -56,6 +57,19 @@ def analytics_include_user(repo: Any) -> bool:
|
|
|
56
57
|
return bool(repo.get("analytics.include_user", DEFAULT_ANALYTICS_INCLUDE_USER))
|
|
57
58
|
|
|
58
59
|
|
|
60
|
+
def _starbash_version() -> str | None:
|
|
61
|
+
"""Return the installed starbash version, or None if it isn't installed.
|
|
62
|
+
|
|
63
|
+
Mirrors the lookup used in ``app.py`` / ``check_version.py``. It can fail
|
|
64
|
+
when running from an uninstalled source checkout or a bare source bundle, so
|
|
65
|
+
we never let a missing distribution stop analytics from initialising.
|
|
66
|
+
"""
|
|
67
|
+
try:
|
|
68
|
+
return version("starbash")
|
|
69
|
+
except PackageNotFoundError:
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
|
|
59
73
|
def analytics_setup(allowed: bool = False, user_email: str | None = None) -> None:
|
|
60
74
|
global analytics_allowed
|
|
61
75
|
analytics_allowed = allowed
|
|
@@ -72,7 +86,8 @@ def analytics_setup(allowed: bool = False, user_email: str | None = None) -> Non
|
|
|
72
86
|
)
|
|
73
87
|
sentry_sdk.init(
|
|
74
88
|
dsn="https://e9496a4ea8b37a053203a2cbc10d64e6@o209837.ingest.us.sentry.io/4510264204132352",
|
|
75
|
-
|
|
89
|
+
release=_starbash_version(),
|
|
90
|
+
data_collection={},
|
|
76
91
|
enable_logs=True,
|
|
77
92
|
traces_sample_rate=1.0,
|
|
78
93
|
disabled_integrations=[
|
|
@@ -212,8 +212,13 @@ def _publish_github(dry_run: bool, login: bool) -> None:
|
|
|
212
212
|
if not dry_run:
|
|
213
213
|
assert credential is not None
|
|
214
214
|
service = _credential_service(credential)
|
|
215
|
-
|
|
215
|
+
# Rotate an expired token *before* the first API call. Asking GitHub for
|
|
216
|
+
# the account first would 401 an expired token, make the service
|
|
217
|
+
# auto-refresh - consuming the stored refresh token - and then leave
|
|
218
|
+
# refresh_if_needed below to reuse the now-dead token, which GitHub
|
|
219
|
+
# rejects as incorrect_client_credentials.
|
|
216
220
|
refresh_if_needed(service, credential, client_id=CLIENT_ID)
|
|
221
|
+
owner = str(service.user()["login"])
|
|
217
222
|
|
|
218
223
|
site = _rewrite(owner) if owner else _rewrite()
|
|
219
224
|
files = collect_site_files(site)
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
import shutil
|
|
7
7
|
from collections import OrderedDict
|
|
8
8
|
from collections.abc import Callable
|
|
9
|
-
from dataclasses import dataclass
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from typing import TYPE_CHECKING, Any
|
|
12
12
|
|
|
@@ -22,6 +22,7 @@ from starbash import InputDef, events
|
|
|
22
22
|
from starbash.database import ImageRow
|
|
23
23
|
from starbash.doit_types import TaskDict
|
|
24
24
|
from starbash.exception import FilesystemUnavailableError, UserHandledError
|
|
25
|
+
from starbash.fits import resolve_fits_variant
|
|
25
26
|
from starbash.os import symlink_or_copy
|
|
26
27
|
from starbash.paths import get_user_cache_dir
|
|
27
28
|
from starbash.tool.base import Tool
|
|
@@ -59,6 +60,7 @@ class FileInfo:
|
|
|
59
60
|
image_rows: list[ImageRow] | None = None # List of individual files (if applicable)
|
|
60
61
|
provenance: dict[str, int] | None = None # Generated basename -> source image ID
|
|
61
62
|
sequence_provenance: dict[str, list[int]] | None = None # Sequence -> source IDs in order
|
|
63
|
+
producers: dict[str, str] = field(default_factory=dict) # output path -> producing task
|
|
62
64
|
definition: InputDef | None = (
|
|
63
65
|
None # The input (or output) definition that produced this FileInfo
|
|
64
66
|
)
|
|
@@ -171,6 +173,34 @@ def cleanup_temporaries(stage: Any, context: dict[str, Any]) -> None:
|
|
|
171
173
|
logging.warning(f"Failed to remove temporary {match_path}: {e}")
|
|
172
174
|
|
|
173
175
|
|
|
176
|
+
def _normalize_declared_outputs(task_dict: TaskDict) -> None:
|
|
177
|
+
"""Record declared outputs under the FITS spelling that actually exists.
|
|
178
|
+
|
|
179
|
+
Siril appends its *saved* extension (``.fit``/``.fits``) to an
|
|
180
|
+
extension-less ``-out`` path, so a recipe declaring ``master.fit`` gets
|
|
181
|
+
``master.fits`` on machines whose preference is ``.fits``. Doit checks its
|
|
182
|
+
``targets`` by exact path, and downstream lookups key on the recorded
|
|
183
|
+
abspath; both must point at the file that really exists. We deliberately
|
|
184
|
+
do *not* rename the on-disk file to the declared spelling: other tools and
|
|
185
|
+
workflows may reference either suffix (they are sometimes mixed), so
|
|
186
|
+
starbash accepts whichever Siril wrote and just re-points its own records
|
|
187
|
+
at it.
|
|
188
|
+
|
|
189
|
+
Accepts either a full task dict (with a ``meta`` key) or the meta dict
|
|
190
|
+
itself -- the shape ``ToolAction`` holds (``self.task.meta``) -- so the
|
|
191
|
+
production call site and the unit tests both work.
|
|
192
|
+
"""
|
|
193
|
+
meta = task_dict.get("meta")
|
|
194
|
+
if not isinstance(meta, dict):
|
|
195
|
+
meta = task_dict
|
|
196
|
+
output = (meta.get("context") or {}).get("output")
|
|
197
|
+
if isinstance(output, FileInfo) and output.image_rows:
|
|
198
|
+
for img in output.image_rows:
|
|
199
|
+
resolved = resolve_fits_variant(img.get("abspath", ""))
|
|
200
|
+
if str(resolved) != img.get("abspath"):
|
|
201
|
+
img["abspath"] = str(resolved)
|
|
202
|
+
|
|
203
|
+
|
|
174
204
|
def doit_post_process(task_dict: TaskDict) -> None:
|
|
175
205
|
"""Do after execution processing
|
|
176
206
|
|
|
@@ -197,9 +227,12 @@ def doit_post_process(task_dict: TaskDict) -> None:
|
|
|
197
227
|
|
|
198
228
|
# The generated files might not have propagated all of the metadata (because we added it after FITS import)
|
|
199
229
|
extra_metadata = context.get("metadata", {})
|
|
230
|
+
# Siril appends its *saved* extension (.fit/.fits) to an
|
|
231
|
+
# extension-less -out path, so the declared output may name a
|
|
232
|
+
# sibling of the file Siril actually wrote.
|
|
200
233
|
sb.add_image(
|
|
201
234
|
output.repo,
|
|
202
|
-
output.full,
|
|
235
|
+
resolve_fits_variant(output.full),
|
|
203
236
|
force=True,
|
|
204
237
|
extra_metadata=extra_metadata,
|
|
205
238
|
)
|
|
@@ -207,6 +240,33 @@ def doit_post_process(task_dict: TaskDict) -> None:
|
|
|
207
240
|
add_action(task_dict, closure)
|
|
208
241
|
|
|
209
242
|
|
|
243
|
+
def _sequence_member_files(base_dir: Path, sequence_file: Path) -> list[Path]:
|
|
244
|
+
"""The FITS files a Siril sequence names, in member order.
|
|
245
|
+
|
|
246
|
+
Members are ``<stem>_<index>.fit`` (or ``.fits``). A glob of ``<stem>*``
|
|
247
|
+
also matches a later stage that reused the stem: the broadband convert
|
|
248
|
+
wrote 4832 ``bkg_pp_light_s233_*.fits`` beside the 89 ``.fit`` members, and
|
|
249
|
+
rewrote the ``.seq`` to claim those 4832. The header is therefore not the
|
|
250
|
+
membership. One extension is the sequence; when both exist the smaller set
|
|
251
|
+
is the original and the larger one is the rewrite.
|
|
252
|
+
"""
|
|
253
|
+
stem = sequence_file.stem
|
|
254
|
+
by_extension: dict[str, list[Path]] = {}
|
|
255
|
+
for extension in (".fit", ".fits"):
|
|
256
|
+
numbered = []
|
|
257
|
+
for path in base_dir.glob(f"{stem}*{extension}"):
|
|
258
|
+
match = re.fullmatch(rf"{re.escape(stem)}(\d+){extension}", path.name)
|
|
259
|
+
if match:
|
|
260
|
+
numbered.append((int(match.group(1)), path))
|
|
261
|
+
if numbered:
|
|
262
|
+
by_extension[extension] = [path for _, path in sorted(numbered)]
|
|
263
|
+
if not by_extension:
|
|
264
|
+
return []
|
|
265
|
+
if len(by_extension) == 1:
|
|
266
|
+
return next(iter(by_extension.values()))
|
|
267
|
+
return min(by_extension.values(), key=len)
|
|
268
|
+
|
|
269
|
+
|
|
210
270
|
def merge_to(base_name: str, fi: FileInfo) -> None:
|
|
211
271
|
"""Merge all input files in fi into a single sequence named base_name.
|
|
212
272
|
|
|
@@ -232,12 +292,13 @@ def merge_to(base_name: str, fi: FileInfo) -> None:
|
|
|
232
292
|
for short_path in fi.short_paths:
|
|
233
293
|
path = Path(short_path)
|
|
234
294
|
|
|
235
|
-
# If it's a .seq file,
|
|
295
|
+
# If it's a .seq file, collect the members it declares. A prefix glob
|
|
296
|
+
# also matches frames a later stage wrote with the same stem.
|
|
236
297
|
if path.suffix == ".seq":
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
298
|
+
sequence_file = base_dir / path.name
|
|
299
|
+
matching_files = [
|
|
300
|
+
str(member) for member in _sequence_member_files(base_dir, sequence_file)
|
|
301
|
+
]
|
|
241
302
|
source_ids = (fi.sequence_provenance or {}).get(path.name)
|
|
242
303
|
if source_ids is None and path.name.endswith("_.seq"):
|
|
243
304
|
source_ids = (fi.sequence_provenance or {}).get(f"{path.stem}.seq")
|
|
@@ -376,6 +437,9 @@ class ToolAction(BaseAction):
|
|
|
376
437
|
self.result = self.tool.run(
|
|
377
438
|
self.commands, context=context, cwd=self.cwd, log_out=logfile, **self.parameters
|
|
378
439
|
)
|
|
440
|
+
# Siril may have written a FITS sibling (.fits for a declared .fit);
|
|
441
|
+
# bring it to the declared spelling before doit checks its targets.
|
|
442
|
+
_normalize_declared_outputs(self.task.meta)
|
|
379
443
|
except OSError as e:
|
|
380
444
|
error = FilesystemUnavailableError(
|
|
381
445
|
f"running {self.tool.name} for task '{self.task.name}'", e
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Helpers for reading FITS metadata."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
from astropy.io import fits
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"canonical_fits_path",
|
|
11
|
+
"read_dimensions",
|
|
12
|
+
"read_fits_header",
|
|
13
|
+
"resolve_declared_outputs",
|
|
14
|
+
"resolve_fits_variant",
|
|
15
|
+
"signal_scale",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
#: Siril appends its *saved* extension (``.fit`` or ``.fits``, per the user's
|
|
19
|
+
#: ``config.1.4.ini``) to an extension-less ``-out`` path. A recipe that names
|
|
20
|
+
#: ``master_bias_gain100.fit`` therefore gets ``...gain100.fits`` on a machine
|
|
21
|
+
#: whose preference is ``.fits`` -- and recording the declared path would point
|
|
22
|
+
#: doit and the DB at a file that was never created. We deliberately do *not*
|
|
23
|
+
#: pin this with ``setext``: it calls ``writeinitfile()``, persisting the
|
|
24
|
+
#: preference into Siril's shared user config, so parallel runs race on that
|
|
25
|
+
#: file (Windows CI: ``save`` failing with "already exists?"). Instead every
|
|
26
|
+
#: lookup treats the two spellings as the same file.
|
|
27
|
+
FITS_VARIANT_SUFFIXES = (".fit", ".fits")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def resolve_fits_variant(path: str | Path) -> Path:
|
|
31
|
+
"""Return the on-disk spelling of a FITS path, trying ``.fit``/``.fits``.
|
|
32
|
+
|
|
33
|
+
Returns ``path`` itself when it exists (or has no FITS suffix); otherwise
|
|
34
|
+
returns the existing sibling with the other spelling, or ``path`` unchanged
|
|
35
|
+
when neither exists.
|
|
36
|
+
"""
|
|
37
|
+
candidate = Path(path)
|
|
38
|
+
if candidate.exists() or candidate.suffix.lower() not in FITS_VARIANT_SUFFIXES:
|
|
39
|
+
return candidate
|
|
40
|
+
sibling = candidate.with_suffix(".fits" if candidate.suffix.lower() == ".fit" else ".fit")
|
|
41
|
+
return sibling if sibling.exists() else candidate
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def canonical_fits_path(path: str | Path) -> str:
|
|
45
|
+
"""Canonical key for comparing FITS paths: collapses ``.fit``/``.fits``.
|
|
46
|
+
|
|
47
|
+
Dict lookups keyed on ``abspath`` (producers, image_rows, doit
|
|
48
|
+
file_dep/target matching) must agree whether Siril wrote ``.fit`` or
|
|
49
|
+
``.fits``. Non-FITS paths pass through unchanged.
|
|
50
|
+
"""
|
|
51
|
+
text = str(path)
|
|
52
|
+
lower = text.lower()
|
|
53
|
+
for suffix in FITS_VARIANT_SUFFIXES:
|
|
54
|
+
if lower.endswith(suffix):
|
|
55
|
+
return text[: -len(suffix)] + ".fit"
|
|
56
|
+
return text
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def resolve_declared_outputs(paths: list[str]) -> list[str]:
|
|
60
|
+
"""Map declared output paths onto whichever FITS spelling exists on disk.
|
|
61
|
+
|
|
62
|
+
Siril appends its *saved* extension (``.fit`` or ``.fits``, per its
|
|
63
|
+
config) to extension-less ``-out`` paths, so a repo/recipe that declares
|
|
64
|
+
``...master_flat_None_gain100.fit`` may find Siril wrote
|
|
65
|
+
``...master_flat_None_gain100.fits``. Doit checks its ``targets`` by exact
|
|
66
|
+
path, so a spelling mismatch makes every run look out-of-date -- and, for
|
|
67
|
+
a master flat, the flat (then light calibration, then stacking) is
|
|
68
|
+
regenerated with each run. Resolving each declared target to the spelling
|
|
69
|
+
that actually exists lets doit treat either suffix as the output being
|
|
70
|
+
present; when neither exists (a genuine first generation) the declared
|
|
71
|
+
path is kept so the task still runs.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
paths: Declared (already context-expanded) output paths.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
The declared paths, each replaced by its on-disk variant when the
|
|
78
|
+
other spelling of the file exists. Non-FITS paths pass through.
|
|
79
|
+
"""
|
|
80
|
+
return [str(resolve_fits_variant(p)) for p in paths]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _json_safe(value: Any) -> Any:
|
|
84
|
+
"""Convert an astropy header value into a plain JSON-serializable Python value.
|
|
85
|
+
|
|
86
|
+
Commentary cards (COMMENT/HISTORY/blank keyword) come back as
|
|
87
|
+
``_HeaderCommentaryCards`` (a list-like of strings) and other cards can be
|
|
88
|
+
``bool``, numpy scalars etc. None of those serialize via ``json.dumps``.
|
|
89
|
+
"""
|
|
90
|
+
# Commentary cards: list-like container of strings; join into one string
|
|
91
|
+
if isinstance(value, fits.header._HeaderCommentaryCards):
|
|
92
|
+
return "\n".join(value)
|
|
93
|
+
if isinstance(value, (list, tuple)):
|
|
94
|
+
return [_json_safe(v) for v in value]
|
|
95
|
+
if isinstance(value, bool): # must precede int check (bool is an int subclass)
|
|
96
|
+
return value
|
|
97
|
+
if isinstance(value, (int, float, str)) or value is None:
|
|
98
|
+
return value
|
|
99
|
+
# numpy scalars and anything else: fall back to str()
|
|
100
|
+
return str(value)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def read_fits_header(file_path: str | Path) -> dict[str, Any]:
|
|
104
|
+
"""Read and return the primary FITS header from ``file_path``.
|
|
105
|
+
|
|
106
|
+
All values are converted to plain JSON-serializable Python types.
|
|
107
|
+
"""
|
|
108
|
+
with fits.open(str(file_path), memmap=False) as hdul:
|
|
109
|
+
hdu0: Any = hdul[0]
|
|
110
|
+
return {key: _json_safe(value) for key, value in hdu0.header.items()}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def read_dimensions(file_path: str | Path) -> tuple[int, int]:
|
|
114
|
+
"""Return the primary FITS image dimensions as ``(width, height)``.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ValueError: If the primary header has missing or invalid dimensions.
|
|
118
|
+
"""
|
|
119
|
+
header = read_fits_header(file_path)
|
|
120
|
+
try:
|
|
121
|
+
width = int(header["NAXIS1"])
|
|
122
|
+
height = int(header["NAXIS2"])
|
|
123
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
124
|
+
raise ValueError(
|
|
125
|
+
f"FITS image '{file_path}' is missing valid NAXIS1/NAXIS2 dimensions"
|
|
126
|
+
) from exc
|
|
127
|
+
|
|
128
|
+
if width <= 0 or height <= 0:
|
|
129
|
+
raise ValueError(f"FITS image '{file_path}' has invalid dimensions: {width}x{height}")
|
|
130
|
+
|
|
131
|
+
return width, height
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def signal_scale(file_path: str | Path, q: float = 99) -> float:
|
|
135
|
+
"""Return ``1 / (Pq - median)`` for a palette channel, its bright reference.
|
|
136
|
+
|
|
137
|
+
The SHO/HOO palettes rescale each channel by this inverse span so that a
|
|
138
|
+
duo-stack OIII/Sii channel's nebulosity is not crushed by a star-pinned
|
|
139
|
+
global max: ``(x - median) * scale`` maps the channel's own Pq onto 1 while
|
|
140
|
+
leaving the sky (at/below the median) at zero. ``q`` is the percentile of
|
|
141
|
+
the reference (default 99), which lands above the nebula but below the few
|
|
142
|
+
saturated star cores (see doc/plans/duo-palette-orange.md).
|
|
143
|
+
|
|
144
|
+
Raises:
|
|
145
|
+
ValueError: If the image is not a finite float FITS, or has no signal
|
|
146
|
+
above its median (everything within [median, median]).
|
|
147
|
+
"""
|
|
148
|
+
with fits.open(str(file_path), memmap=True) as hdul:
|
|
149
|
+
primary: Any = hdul[0]
|
|
150
|
+
data = primary.data
|
|
151
|
+
if data is None or data.dtype.kind != "f":
|
|
152
|
+
raise ValueError(f"Palette channel must be a floating-point FITS image: {file_path}")
|
|
153
|
+
if not np.isfinite(data).all():
|
|
154
|
+
raise ValueError(f"Palette channel contains non-finite pixels: {file_path}")
|
|
155
|
+
median = float(np.median(data))
|
|
156
|
+
reference = float(np.percentile(data, q))
|
|
157
|
+
span = reference - median
|
|
158
|
+
if span <= 0:
|
|
159
|
+
raise ValueError(f"Palette channel has no above-median signal: {file_path}")
|
|
160
|
+
return 1.0 / span
|