rretc 0.1.0__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.
rretc-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 galtavilla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rretc-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: rretc
3
+ Version: 0.1.0
4
+ Summary: LBT/LBC point-source exposure-time calculator
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Provides-Extra: cli
9
+ Requires-Dist: click>=8.4.2; extra == 'cli'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # rretc
13
+
14
+ The _Rapid Response Exposure Time Calculator_ is an exposure-time calculator for point sources observed with LBT/LBC.
15
+
16
+ ## Installation
17
+
18
+ Install (no dependencies) with:
19
+
20
+ ```bash
21
+ pip install .
22
+ ```
23
+
24
+ Install the optional command-line interface with:
25
+
26
+ ```bash
27
+ pip install ".[cli]"
28
+ ```
29
+
30
+ ## Python API
31
+
32
+ The package exposes five functions:
33
+
34
+ ```python
35
+ from rretc import msat, nexp, snr, texp, tsat
36
+
37
+ conditions = {
38
+ "magnitude": 22.0,
39
+ "band": "g",
40
+ "moon_zd": 60.0,
41
+ "moon_phase": 0.0,
42
+ "moon_elongation": 90.0,
43
+ "aperture": 2.25,
44
+ "airmass": 1.3,
45
+ "site_quality": "ultra-clean",
46
+ "seeing": 0.75,
47
+ }
48
+
49
+ count = nexp(100.0, 60.0, **conditions)
50
+ seconds = texp(10, 100.0, **conditions)
51
+ achieved = snr(60.0, 10, **conditions)
52
+
53
+ saturation_conditions = {
54
+ key: value
55
+ for key, value in conditions.items()
56
+ if key not in {"magnitude", "aperture"}
57
+ }
58
+ saturation_time = tsat(18.0, **saturation_conditions)
59
+ saturation_magnitude = msat(10.0, **saturation_conditions)
60
+ ```
61
+
62
+ `nexp` returns the minimum exposure count for a target SNR and exposure duration;
63
+ `texp` returns the minimum exposure duration for a target SNR and exposure count;
64
+ and `snr` computes the SNR for an exposure stack. `texp` returns `math.inf` if
65
+ the requested SNR is above the systematic-noise limit for the specified number
66
+ of exposures.
67
+ `tsat` returns the exposure time at which the peak pixel saturates; `msat`
68
+ returns the corresponding saturation magnitude for a proposed exposure time.
69
+ Both use 90% of the detector full-well capacity. `msat` returns `math.nan`
70
+ when sky and dark current alone saturate the pixel.
71
+
72
+ ## Command line
73
+
74
+ The CLI requires [click](https://click.palletsprojects.com/en/stable/) or the `cli` installation extra (`pip install ".[cli]"`). It provides one subcommand for each API operation and prints one numeric value:
75
+
76
+ ```bash
77
+ rretc nexp --snr 100 --texp 60 \
78
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
79
+ --moon-elongation 90 --aperture 2.25
80
+
81
+ rretc texp --nexp 10 --snr 100 \
82
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
83
+ --moon-elongation 90 --aperture 2.25
84
+
85
+ rretc snr --texp 60 --nexp 10 \
86
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
87
+ --moon-elongation 90 --aperture 2.25
88
+
89
+ rretc tsat --magnitude 18 --band V --moon-zd 70 --moon-phase 0.75 \
90
+ --moon-elongation 90
91
+
92
+ rretc msat --texp 10 --band V --moon-zd 70 --moon-phase 0.75 \
93
+ --moon-elongation 90
94
+ ```
95
+
96
+ Run `rretc COMMAND --help` for all options.
97
+
98
+ ## Inputs and assumptions
99
+
100
+ - Supported bands are `U`, `B`, `V_B`, `V`, `R`, `I`, `u`, `g`, `r_B`, `r`, `i`, and `z`.
101
+ - Magnitudes are finite values, Vega for Johnson-Cousins bands and AB for Sloan bands.
102
+ - Exposure times are seconds. Lunar angles are degrees. Seeing and aperture are arcseconds.
103
+ - Saturation calculations use the central pixel, so `tsat` and `msat` do not
104
+ take an aperture.
105
+ - `moon_phase` ranges from 0 for new Moon to 1 for full Moon.
106
+ - `moon_zd >= 90` places the Moon below the horizon.
107
+ - Site profiles are `standard`, `dry`, and `ultra-clean`.
108
+ - Default airmass is 1.3, default site quality is `ultra-clean`, and default seeing is 0.75 arcseconds.
109
+
110
+ The lunar sky model follows Krisciunas & Schaefer, *PASP* 103, 1033 (1991). The lunar airmass approximation follows Young, *Applied Optics* 33, 1108 (1994).
111
+
112
+
113
+ ## Testing and development
114
+
115
+ Install with:
116
+
117
+ ```shell
118
+ pip install . --group dev
119
+ ```
120
+
121
+ Run tests with:
122
+
123
+ ```shell
124
+ python -m pytest
125
+ ```
rretc-0.1.0/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # rretc
2
+
3
+ The _Rapid Response Exposure Time Calculator_ is an exposure-time calculator for point sources observed with LBT/LBC.
4
+
5
+ ## Installation
6
+
7
+ Install (no dependencies) with:
8
+
9
+ ```bash
10
+ pip install .
11
+ ```
12
+
13
+ Install the optional command-line interface with:
14
+
15
+ ```bash
16
+ pip install ".[cli]"
17
+ ```
18
+
19
+ ## Python API
20
+
21
+ The package exposes five functions:
22
+
23
+ ```python
24
+ from rretc import msat, nexp, snr, texp, tsat
25
+
26
+ conditions = {
27
+ "magnitude": 22.0,
28
+ "band": "g",
29
+ "moon_zd": 60.0,
30
+ "moon_phase": 0.0,
31
+ "moon_elongation": 90.0,
32
+ "aperture": 2.25,
33
+ "airmass": 1.3,
34
+ "site_quality": "ultra-clean",
35
+ "seeing": 0.75,
36
+ }
37
+
38
+ count = nexp(100.0, 60.0, **conditions)
39
+ seconds = texp(10, 100.0, **conditions)
40
+ achieved = snr(60.0, 10, **conditions)
41
+
42
+ saturation_conditions = {
43
+ key: value
44
+ for key, value in conditions.items()
45
+ if key not in {"magnitude", "aperture"}
46
+ }
47
+ saturation_time = tsat(18.0, **saturation_conditions)
48
+ saturation_magnitude = msat(10.0, **saturation_conditions)
49
+ ```
50
+
51
+ `nexp` returns the minimum exposure count for a target SNR and exposure duration;
52
+ `texp` returns the minimum exposure duration for a target SNR and exposure count;
53
+ and `snr` computes the SNR for an exposure stack. `texp` returns `math.inf` if
54
+ the requested SNR is above the systematic-noise limit for the specified number
55
+ of exposures.
56
+ `tsat` returns the exposure time at which the peak pixel saturates; `msat`
57
+ returns the corresponding saturation magnitude for a proposed exposure time.
58
+ Both use 90% of the detector full-well capacity. `msat` returns `math.nan`
59
+ when sky and dark current alone saturate the pixel.
60
+
61
+ ## Command line
62
+
63
+ The CLI requires [click](https://click.palletsprojects.com/en/stable/) or the `cli` installation extra (`pip install ".[cli]"`). It provides one subcommand for each API operation and prints one numeric value:
64
+
65
+ ```bash
66
+ rretc nexp --snr 100 --texp 60 \
67
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
68
+ --moon-elongation 90 --aperture 2.25
69
+
70
+ rretc texp --nexp 10 --snr 100 \
71
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
72
+ --moon-elongation 90 --aperture 2.25
73
+
74
+ rretc snr --texp 60 --nexp 10 \
75
+ --magnitude 22 --band g --moon-zd 60 --moon-phase 0 \
76
+ --moon-elongation 90 --aperture 2.25
77
+
78
+ rretc tsat --magnitude 18 --band V --moon-zd 70 --moon-phase 0.75 \
79
+ --moon-elongation 90
80
+
81
+ rretc msat --texp 10 --band V --moon-zd 70 --moon-phase 0.75 \
82
+ --moon-elongation 90
83
+ ```
84
+
85
+ Run `rretc COMMAND --help` for all options.
86
+
87
+ ## Inputs and assumptions
88
+
89
+ - Supported bands are `U`, `B`, `V_B`, `V`, `R`, `I`, `u`, `g`, `r_B`, `r`, `i`, and `z`.
90
+ - Magnitudes are finite values, Vega for Johnson-Cousins bands and AB for Sloan bands.
91
+ - Exposure times are seconds. Lunar angles are degrees. Seeing and aperture are arcseconds.
92
+ - Saturation calculations use the central pixel, so `tsat` and `msat` do not
93
+ take an aperture.
94
+ - `moon_phase` ranges from 0 for new Moon to 1 for full Moon.
95
+ - `moon_zd >= 90` places the Moon below the horizon.
96
+ - Site profiles are `standard`, `dry`, and `ultra-clean`.
97
+ - Default airmass is 1.3, default site quality is `ultra-clean`, and default seeing is 0.75 arcseconds.
98
+
99
+ The lunar sky model follows Krisciunas & Schaefer, *PASP* 103, 1033 (1991). The lunar airmass approximation follows Young, *Applied Optics* 33, 1108 (1994).
100
+
101
+
102
+ ## Testing and development
103
+
104
+ Install with:
105
+
106
+ ```shell
107
+ pip install . --group dev
108
+ ```
109
+
110
+ Run tests with:
111
+
112
+ ```shell
113
+ python -m pytest
114
+ ```
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "rretc"
7
+ version = "0.1.0"
8
+ description = "LBT/LBC point-source exposure-time calculator"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = []
13
+
14
+ [project.optional-dependencies]
15
+ cli = [
16
+ "click>=8.4.2",
17
+ ]
18
+
19
+ [project.scripts]
20
+ rretc = "rretc._entrypoint:main"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "black>=26.5.1",
25
+ "click>=8.4.2",
26
+ "isort>=8.0.1",
27
+ "pytest>=9.1.1",
28
+ ]
29
+
30
+ [tool.black]
31
+ target-version = ["py311"]
32
+
33
+ [tool.isort]
34
+ profile = "black"
@@ -0,0 +1,11 @@
1
+ """LBT/LBC point-source exposure-time calculator."""
2
+
3
+ from .core import msat, nexp, snr, texp, tsat
4
+
5
+ __all__ = [
6
+ "msat",
7
+ "nexp",
8
+ "snr",
9
+ "texp",
10
+ "tsat",
11
+ ]
@@ -0,0 +1,18 @@
1
+ """Launcher for the optional command-line interface."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ def main() -> None:
7
+ """Run the CLI or explain how to install its optional dependency."""
8
+ try:
9
+ from .cli import main as cli_main
10
+ except ModuleNotFoundError as error:
11
+ if error.name == "click":
12
+ raise SystemExit(
13
+ "The rretc CLI requires `click` as an optional dependency: "
14
+ 'pip install "rretc[cli]"'
15
+ ) from None
16
+ raise
17
+
18
+ cli_main()
@@ -0,0 +1,186 @@
1
+ """Command-line interface for :mod:`rretc`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable
6
+ import math
7
+ from typing import Any, TypeVar
8
+
9
+ import click
10
+
11
+ from .core import (
12
+ BANDS,
13
+ SITE_QUALITIES,
14
+ msat,
15
+ nexp,
16
+ snr,
17
+ texp,
18
+ tsat,
19
+ )
20
+
21
+ _Command = TypeVar("_Command", bound=Callable[..., Any])
22
+ _POSITIVE_FLOAT = click.FloatRange(min=0.0, min_open=True)
23
+
24
+
25
+ def _finite_float(
26
+ _: click.Context, param: click.Parameter, value: float
27
+ ) -> float:
28
+ """Reject non-finite floating-point command-line values."""
29
+ if not math.isfinite(value):
30
+ raise click.BadParameter("must be a finite number", param=param)
31
+ return value
32
+
33
+
34
+ def _observing_options(
35
+ *, include_magnitude: bool = True, include_aperture: bool = True
36
+ ) -> Callable[[_Command], _Command]:
37
+ """Return the observing-condition options needed by a CLI command."""
38
+ options = [
39
+ click.option(
40
+ "--seeing",
41
+ type=_POSITIVE_FLOAT,
42
+ default=0.75,
43
+ show_default=True,
44
+ help="Seeing FWHM in arcseconds.",
45
+ ),
46
+ click.option(
47
+ "--site-quality",
48
+ type=click.Choice(SITE_QUALITIES, case_sensitive=True),
49
+ default="ultra-clean",
50
+ show_default=True,
51
+ help="Atmospheric aerosol profile.",
52
+ ),
53
+ click.option(
54
+ "--airmass",
55
+ type=_POSITIVE_FLOAT,
56
+ default=1.3,
57
+ show_default=True,
58
+ help="Target airmass.",
59
+ ),
60
+ click.option(
61
+ "--moon-elongation",
62
+ type=click.FloatRange(0.0, 180.0),
63
+ required=True,
64
+ help="Target-Moon angular separation in degrees.",
65
+ ),
66
+ click.option(
67
+ "--moon-phase",
68
+ type=click.FloatRange(0.0, 1.0),
69
+ required=True,
70
+ help="Lunar phase: 0 is new Moon and 1 is full Moon.",
71
+ ),
72
+ click.option(
73
+ "--moon-zd",
74
+ type=click.FloatRange(0.0, 180.0),
75
+ required=True,
76
+ help="Lunar zenith distance in degrees; >=90 is below the horizon.",
77
+ ),
78
+ click.option(
79
+ "--band",
80
+ type=click.Choice(BANDS, case_sensitive=True),
81
+ required=True,
82
+ help="LBT/LBC photometric band.",
83
+ ),
84
+ ]
85
+ if include_aperture:
86
+ options.append(
87
+ click.option(
88
+ "--aperture",
89
+ type=_POSITIVE_FLOAT,
90
+ required=True,
91
+ help="Photometric aperture diameter in arcseconds.",
92
+ )
93
+ )
94
+ if include_magnitude:
95
+ options.append(
96
+ click.option(
97
+ "--magnitude",
98
+ type=click.FLOAT,
99
+ callback=_finite_float,
100
+ required=True,
101
+ help="Source magnitude, Vega for UBVRI and AB for ugriz.",
102
+ )
103
+ )
104
+
105
+ def decorator(command: _Command) -> _Command:
106
+ for option in options:
107
+ command = option(command)
108
+ return command
109
+
110
+ return decorator
111
+
112
+
113
+ @click.group()
114
+ def main() -> None:
115
+ """Calculate LBT/LBC point-source exposure times and SNR."""
116
+
117
+
118
+ @main.command("nexp")
119
+ @click.option("--snr", type=_POSITIVE_FLOAT, required=True, help="Target SNR.")
120
+ @click.option(
121
+ "--texp",
122
+ type=_POSITIVE_FLOAT,
123
+ required=True,
124
+ help="Duration of each exposure in seconds.",
125
+ )
126
+ @_observing_options()
127
+ def nexp_command(snr: float, texp: float, **conditions: Any) -> None:
128
+ """Calculate the minimum exposure count for a target SNR and exposure duration."""
129
+ click.echo(nexp(snr, texp, **conditions))
130
+
131
+
132
+ @main.command("texp")
133
+ @click.option(
134
+ "--nexp",
135
+ type=click.IntRange(min=1),
136
+ required=True,
137
+ help="Number of individual exposures.",
138
+ )
139
+ @click.option("--snr", type=_POSITIVE_FLOAT, required=True, help="Target SNR.")
140
+ @_observing_options()
141
+ def texp_command(nexp: int, snr: float, **conditions: Any) -> None:
142
+ """Calculate the minimum exposure duration for a target SNR and exposure count."""
143
+ click.echo(texp(nexp, snr, **conditions))
144
+
145
+
146
+ @main.command("snr")
147
+ @click.option(
148
+ "--texp",
149
+ type=_POSITIVE_FLOAT,
150
+ required=True,
151
+ help="Duration of each exposure in seconds.",
152
+ )
153
+ @click.option(
154
+ "--nexp",
155
+ type=click.IntRange(min=1),
156
+ required=True,
157
+ help="Number of individual exposures.",
158
+ )
159
+ @_observing_options()
160
+ def snr_command(texp: float, nexp: int, **conditions: Any) -> None:
161
+ """Calculate the SNR for a single-exposure duration and exposure count."""
162
+ click.echo(snr(texp, nexp, **conditions))
163
+
164
+
165
+ @main.command("tsat")
166
+ @_observing_options(include_aperture=False)
167
+ def tsat_command(**conditions: Any) -> None:
168
+ """Calculate the duration at which a source saturates the peak pixel."""
169
+ click.echo(tsat(**conditions))
170
+
171
+
172
+ @main.command("msat")
173
+ @click.option(
174
+ "--texp",
175
+ type=_POSITIVE_FLOAT,
176
+ required=True,
177
+ help="Duration of one exposure in seconds.",
178
+ )
179
+ @_observing_options(include_magnitude=False, include_aperture=False)
180
+ def msat_command(texp: float, **conditions: Any) -> None:
181
+ """Calculate the magnitude at which a source saturates the peak pixel."""
182
+ click.echo(msat(texp, **conditions))
183
+
184
+
185
+ if __name__ == "__main__":
186
+ main()