pyreduce-astro 0.7a2__cp313-cp313-win_amd64.whl → 0.7a3__cp313-cp313-win_amd64.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.
pyreduce/__main__.py CHANGED
@@ -11,11 +11,6 @@ Usage:
11
11
 
12
12
  import click
13
13
 
14
- from . import datasets
15
- from .configuration import get_configuration_for_instrument
16
- from .reduce import main as reduce_main
17
- from .tools.combine import combine as tools_combine
18
-
19
14
  ALL_STEPS = (
20
15
  "bias",
21
16
  "flat",
@@ -89,6 +84,9 @@ def run(
89
84
  INSTRUMENT: Name of the instrument (e.g., UVES, HARPS, XSHOOTER)
90
85
  TARGET: Target star name or regex pattern
91
86
  """
87
+ from .configuration import get_configuration_for_instrument
88
+ from .reduce import main as reduce_main
89
+
92
90
  # Parse steps
93
91
  if steps:
94
92
  steps = tuple(s.strip() for s in steps.split(","))
@@ -128,6 +126,8 @@ def combine(files, output, plot):
128
126
 
129
127
  FILES: Input .final.fits files to combine
130
128
  """
129
+ from .tools.combine import combine as tools_combine
130
+
131
131
  tools_combine(list(files), output, plot=plot)
132
132
 
133
133
 
@@ -138,6 +138,8 @@ def download(instrument):
138
138
 
139
139
  INSTRUMENT: Name of the instrument (e.g., UVES, HARPS)
140
140
  """
141
+ from . import datasets
142
+
141
143
  instrument = instrument.upper()
142
144
  dataset_func = getattr(datasets, instrument, None)
143
145
  if dataset_func is None:
@@ -153,6 +155,86 @@ def download(instrument):
153
155
  click.echo(f"Dataset downloaded to: {path}")
154
156
 
155
157
 
158
+ @cli.command()
159
+ @click.argument("filename", required=False)
160
+ @click.option(
161
+ "--list", "-l", "list_examples", is_flag=True, help="List available examples"
162
+ )
163
+ @click.option("--all", "-a", "download_all", is_flag=True, help="Download all examples")
164
+ @click.option("--output", "-o", default=".", help="Output directory")
165
+ def examples(filename, list_examples, download_all, output):
166
+ """List or download example scripts from GitHub.
167
+
168
+ Downloads examples matching your installed PyReduce version.
169
+
170
+ \b
171
+ Examples:
172
+ reduce examples # List available examples
173
+ reduce examples uves_example.py # Download to current dir
174
+ reduce examples --all -o ~/scripts # Download all to ~/scripts
175
+ """
176
+ import json
177
+ import os
178
+ import urllib.request
179
+ from urllib.error import HTTPError
180
+
181
+ from pyreduce import __version__
182
+
183
+ version = __version__.split("+")[0]
184
+ if version == "unknown":
185
+ raise click.ClickException(
186
+ "Cannot determine package version. Install from PyPI or a tagged release."
187
+ )
188
+
189
+ github_api = (
190
+ f"https://api.github.com/repos/ivh/PyReduce/contents/examples?ref=v{version}"
191
+ )
192
+ github_raw = f"https://raw.githubusercontent.com/ivh/PyReduce/v{version}/examples"
193
+
194
+ # Fetch list of examples from GitHub API
195
+ try:
196
+ with urllib.request.urlopen(github_api) as resp:
197
+ contents = json.loads(resp.read().decode())
198
+ except HTTPError as e:
199
+ if e.code == 404:
200
+ raise click.ClickException(
201
+ f"Tag v{version} not found on GitHub. "
202
+ "Try installing a released version."
203
+ ) from None
204
+ raise click.ClickException(f"GitHub API error: {e}") from None
205
+
206
+ example_files = sorted(f["name"] for f in contents if f["name"].endswith(".py"))
207
+
208
+ # List mode
209
+ if list_examples or (not filename and not download_all):
210
+ click.echo(f"Available examples for v{version}:")
211
+ for name in example_files:
212
+ click.echo(f" {name}")
213
+ return
214
+
215
+ # Ensure output directory exists
216
+ os.makedirs(output, exist_ok=True)
217
+
218
+ def download_file(name):
219
+ url = f"{github_raw}/{name}"
220
+ dest = os.path.join(output, name)
221
+ try:
222
+ urllib.request.urlretrieve(url, dest)
223
+ click.echo(f"Downloaded: {dest}")
224
+ except HTTPError as e:
225
+ click.echo(f"Failed to download {name}: {e}", err=True)
226
+
227
+ if download_all:
228
+ for name in example_files:
229
+ download_file(name)
230
+ else:
231
+ if filename not in example_files:
232
+ raise click.ClickException(
233
+ f"Unknown example '{filename}'. Use 'reduce examples --list' to see available."
234
+ )
235
+ download_file(filename)
236
+
237
+
156
238
  @cli.command("list-steps")
157
239
  def list_steps():
158
240
  """List all available reduction steps."""
@@ -174,6 +256,9 @@ def make_step_command(step_name):
174
256
  @click.option("--output-dir", "-o", default="reduced", help="Output directory")
175
257
  @click.option("--plot", "-p", default=0, help="Plot level")
176
258
  def cmd(instrument, target, night, arm, base_dir, input_dir, output_dir, plot):
259
+ from .configuration import get_configuration_for_instrument
260
+ from .reduce import main as reduce_main
261
+
177
262
  config = get_configuration_for_instrument(instrument)
178
263
  reduce_main(
179
264
  instrument=instrument,
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyreduce-astro
3
- Version: 0.7a2
3
+ Version: 0.7a3
4
4
  Summary: A data reduction package for echelle spectrographs
5
5
  Project-URL: Homepage, https://github.com/ivh/PyReduce
6
6
  Project-URL: Documentation, https://pyreduce-astro.readthedocs.io
@@ -1,5 +1,5 @@
1
1
  pyreduce/__init__.py,sha256=e_576KbKh0jALuzvpI-VLeILhtQYJAPTDD0XMb189gM,1797
2
- pyreduce/__main__.py,sha256=z7iW2lyo5HOp-r7GyIiwBksRCVdO2UHDMDVEdNuHQgY,5625
2
+ pyreduce/__main__.py,sha256=Vn0dZBuFwNF-DISyt1lvs0R41PSUgZeAdXzdVnnc25E,8602
3
3
  pyreduce/cli.py,sha256=w8k5OticZ8rzh5JshYv3MBp_Sx0PtECiSOdR3VboNB0,10937
4
4
  pyreduce/clipnflip.py,sha256=S-9CaTfRwPHWJUq92Iv2K1T-4Oe6MmROJQpzv2cMaOI,5704
5
5
  pyreduce/combine_frames.py,sha256=VnvLXexXisunuZ05whbhzSemoahQ6pd7cOoz8Uz_fWU,30407
@@ -19,12 +19,12 @@ pyreduce/trace.py,sha256=VAl6sgjmfYmfNLsddzwx_f4x-oT3KsGiUfhHMoHNGxM,33667
19
19
  pyreduce/util.py,sha256=MpyEpjOzvINBx1ixMWaF7huYZ7GylDOXMdR0Va6ljUI,40870
20
20
  pyreduce/wavelength_calibration.py,sha256=1BT6KfAd7sIabQEb2D0n3511p3IY03G5pvGiB3j9e1E,70592
21
21
  pyreduce/clib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- pyreduce/clib/_slitfunc_2d.cp311-win_amd64.pyd,sha256=-h4Z4Atluvem7d6Pv0DrfrXg2kXy65gNqJt5fEejcKk,35328
23
- pyreduce/clib/_slitfunc_2d.cp312-win_amd64.pyd,sha256=1fIf9DxkbV4vHRS85VUB-WxNtYUkBS4YHdxDRAv0W00,35328
24
- pyreduce/clib/_slitfunc_2d.cp313-win_amd64.pyd,sha256=KJeGQ0LX3iq7ji_Cf96UP_hfsua1Ff1bVE29Qr6fask,35328
25
- pyreduce/clib/_slitfunc_bd.cp311-win_amd64.pyd,sha256=iHJ6rD9rRzlQpX9LtvVLF2Ge3jINTImLlI_iEAsy32U,25600
26
- pyreduce/clib/_slitfunc_bd.cp312-win_amd64.pyd,sha256=RXwz73aVSoxmf7VS8nVwzEhaVY23DVMGF8Kf2Kvksdg,25600
27
- pyreduce/clib/_slitfunc_bd.cp313-win_amd64.pyd,sha256=-TtXOvH7t8ps4bHQRv7-XK_PoXFuKBYgcS5hcplcpnU,25600
22
+ pyreduce/clib/_slitfunc_2d.cp311-win_amd64.pyd,sha256=SIsaqblhKZp4XDpgrM3JmqJiu8SeMggLRkk1h8GTZBA,35328
23
+ pyreduce/clib/_slitfunc_2d.cp312-win_amd64.pyd,sha256=QuTBupPQD0xL1dL_ENQly4rUBzW56YJmZk_GgskNdEs,35328
24
+ pyreduce/clib/_slitfunc_2d.cp313-win_amd64.pyd,sha256=dA6pIPa7qA0VeX2Dt5xdLe0H5PXyP8_gEjxTTZHUwLA,35328
25
+ pyreduce/clib/_slitfunc_bd.cp311-win_amd64.pyd,sha256=bJUsdLDA8-UNx9QeV6rZrj2XZVtkZ1t_xaPq7SyB0UM,25600
26
+ pyreduce/clib/_slitfunc_bd.cp312-win_amd64.pyd,sha256=H02ZpIESyOg2Ldh-GSDup8Cygo4Ch-fixBCMeV-5Hvs,25600
27
+ pyreduce/clib/_slitfunc_bd.cp313-win_amd64.pyd,sha256=oJweCBrur3FxQ7-fLMvBJu7G5WVaVEBRSWJh7rCWw9w,25600
28
28
  pyreduce/clib/build_extract.py,sha256=WTEpyRZWDR4AUkT1mkxmsWbXuRLG2jrRbJC5M8MKi3M,2020
29
29
  pyreduce/clib/slit_func_2d_xi_zeta_bd.c,sha256=o_R_3hq0tX2ZdaCRxJjY2mXQf4RaYENcVKVn2OZR_Rk,51279
30
30
  pyreduce/clib/slit_func_2d_xi_zeta_bd.h,sha256=ezWP3JXfbviCN5FAbB9AJYB1YnAGFhsO5N3wCt-rbmU,1567
@@ -36,14 +36,14 @@ pyreduce/clib/Release/_slitfunc_2d.cp312-win_amd64.exp,sha256=ap2hnA20RvdJAV-jrp
36
36
  pyreduce/clib/Release/_slitfunc_2d.cp312-win_amd64.lib,sha256=cD10d0NBKuPxsmHfYZ17F9O6tt2X3vwfHv49fx7i7mg,2104
37
37
  pyreduce/clib/Release/_slitfunc_2d.cp313-win_amd64.exp,sha256=xgcXydyjVF48BY3DHEU9l-3BIMHBtYVXENVCXG6mpHg,763
38
38
  pyreduce/clib/Release/_slitfunc_2d.cp313-win_amd64.lib,sha256=HtsGowOnstUvTx3wEiX3JcFgOzCsrie-6B5pdb69EVc,2104
39
- pyreduce/clib/Release/_slitfunc_2d.obj,sha256=pZqO9n3WDBfT6_gQFyJWt3zrDFwgDcIxd-kMGI0Tawo,225492
39
+ pyreduce/clib/Release/_slitfunc_2d.obj,sha256=IMWNUnmPWiQZVpayfgqOq8OPnYRAVp8qxjrrNNRu1dw,225492
40
40
  pyreduce/clib/Release/_slitfunc_bd.cp311-win_amd64.exp,sha256=vHZNO5hq4YBqgpgWXOW7wELiB-Pex2QFRvKbLH-vIYY,763
41
41
  pyreduce/clib/Release/_slitfunc_bd.cp311-win_amd64.lib,sha256=hcG-cWafgtz6nNO12lFFtkVLhVAsQyuCpPD78rfPQzs,2104
42
42
  pyreduce/clib/Release/_slitfunc_bd.cp312-win_amd64.exp,sha256=BWCVspYP1T2q5yNWlVpCfK6JWR44RuNiFhWW3H6kNLc,763
43
43
  pyreduce/clib/Release/_slitfunc_bd.cp312-win_amd64.lib,sha256=tJ-lz6MJn-UOdBfx7yFQqrNw4NEmKinrbm8vx2PSkzE,2104
44
44
  pyreduce/clib/Release/_slitfunc_bd.cp313-win_amd64.exp,sha256=v6YBEY_vzeHqhCMqQ7-ISyMP3m07qeSL4yA-Lq27vP8,763
45
45
  pyreduce/clib/Release/_slitfunc_bd.cp313-win_amd64.lib,sha256=R3sT-Vy8AWGitwFDqYI3ipcc86PVkyMgACcDMXMkA1U,2104
46
- pyreduce/clib/Release/_slitfunc_bd.obj,sha256=Y2BGH1xNSeftQXQr11ky8H7MHK_YIGNvwaU3pAo6uCM,175839
46
+ pyreduce/clib/Release/_slitfunc_bd.obj,sha256=UOgxyxn2gASiSCyYeTy19yYpmMMDsjcuW1rmn5l91Wk,175839
47
47
  pyreduce/instruments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  pyreduce/instruments/aj.py,sha256=QSKo2IUvBugBRJF0Qr6T9GueBzeDrA4yGu-qAe7TZwg,155
49
49
  pyreduce/instruments/aj.yaml,sha256=peeQ2ZqvqemHWpNZoiXEscU6ZIzAImbhN_8D0XTeeME,904
@@ -169,8 +169,8 @@ pyreduce/wavecal/xshooter_nir.npz,sha256=0Fu5wxWutc8072n8Hk2AZAWSlyT4WdhJuhh0OzU
169
169
  pyreduce/wavecal/atlas/thar.fits,sha256=nPPNStZ281iPUNsOXu3YJfHNlnHBd1CWMLwTuZL8vvo,1529218
170
170
  pyreduce/wavecal/atlas/thar_list.txt,sha256=saK3YW1slxlXGeulZDdILWf952XOWToJcUULVSHMe6k,63515
171
171
  pyreduce/wavecal/atlas/une.fits,sha256=egHlchdM4AN9MSksEI5MlHkmB3g1G1VhEdzhUG3XU8I,2949057
172
- pyreduce_astro-0.7a2.dist-info/METADATA,sha256=MxuR7E_uOtsoXRY5jKe-nCwYPrhZflmbr7lKxul4_lc,3488
173
- pyreduce_astro-0.7a2.dist-info/WHEEL,sha256=PCIhMO61Z-RaGBFeYB07NemkwSKK2UsOquwuNeClEpE,97
174
- pyreduce_astro-0.7a2.dist-info/entry_points.txt,sha256=n045jK9XZFfdmasTNhriefYyJoY77JKm-RpRD1zgHZo,50
175
- pyreduce_astro-0.7a2.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
176
- pyreduce_astro-0.7a2.dist-info/RECORD,,
172
+ pyreduce_astro-0.7a3.dist-info/METADATA,sha256=nqkw5qkGzEPJNV3SS0_9aJWbBmZZy6yn_Kq6cXgA9ro,3488
173
+ pyreduce_astro-0.7a3.dist-info/WHEEL,sha256=PCIhMO61Z-RaGBFeYB07NemkwSKK2UsOquwuNeClEpE,97
174
+ pyreduce_astro-0.7a3.dist-info/entry_points.txt,sha256=n045jK9XZFfdmasTNhriefYyJoY77JKm-RpRD1zgHZo,50
175
+ pyreduce_astro-0.7a3.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
176
+ pyreduce_astro-0.7a3.dist-info/RECORD,,