pyreduce-astro 0.6.0b1__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.
- pyreduce/__init__.py +58 -0
- pyreduce/__main__.py +106 -0
- pyreduce/clib/__init__.py +0 -0
- pyreduce/clib/_slitfunc_2d.cpython-313-darwin.so +0 -0
- pyreduce/clib/_slitfunc_bd.cpython-313-darwin.so +0 -0
- pyreduce/clib/build_extract.py +75 -0
- pyreduce/clib/slit_func_2d_xi_zeta_bd.c +1313 -0
- pyreduce/clib/slit_func_2d_xi_zeta_bd.h +55 -0
- pyreduce/clib/slit_func_bd.c +362 -0
- pyreduce/clib/slit_func_bd.h +17 -0
- pyreduce/clipnflip.py +147 -0
- pyreduce/combine_frames.py +855 -0
- pyreduce/configuration.py +186 -0
- pyreduce/continuum_normalization.py +329 -0
- pyreduce/cwrappers.py +404 -0
- pyreduce/datasets.py +231 -0
- pyreduce/echelle.py +413 -0
- pyreduce/estimate_background_scatter.py +129 -0
- pyreduce/extract.py +1359 -0
- pyreduce/extraction_width.py +77 -0
- pyreduce/instruments/__init__.py +0 -0
- pyreduce/instruments/andes.json +59 -0
- pyreduce/instruments/andes.py +100 -0
- pyreduce/instruments/common.json +46 -0
- pyreduce/instruments/common.py +675 -0
- pyreduce/instruments/crires_plus.json +63 -0
- pyreduce/instruments/crires_plus.py +103 -0
- pyreduce/instruments/filters.py +195 -0
- pyreduce/instruments/harpn.json +136 -0
- pyreduce/instruments/harpn.py +201 -0
- pyreduce/instruments/harps.json +155 -0
- pyreduce/instruments/harps.py +310 -0
- pyreduce/instruments/instrument_info.py +140 -0
- pyreduce/instruments/instrument_schema.json +221 -0
- pyreduce/instruments/jwst_miri.json +53 -0
- pyreduce/instruments/jwst_miri.py +29 -0
- pyreduce/instruments/jwst_niriss.json +52 -0
- pyreduce/instruments/jwst_niriss.py +98 -0
- pyreduce/instruments/lick_apf.json +53 -0
- pyreduce/instruments/lick_apf.py +35 -0
- pyreduce/instruments/mcdonald.json +59 -0
- pyreduce/instruments/mcdonald.py +123 -0
- pyreduce/instruments/metis_ifu.json +63 -0
- pyreduce/instruments/metis_ifu.py +45 -0
- pyreduce/instruments/metis_lss.json +65 -0
- pyreduce/instruments/metis_lss.py +45 -0
- pyreduce/instruments/micado.json +53 -0
- pyreduce/instruments/micado.py +45 -0
- pyreduce/instruments/neid.json +51 -0
- pyreduce/instruments/neid.py +154 -0
- pyreduce/instruments/nirspec.json +56 -0
- pyreduce/instruments/nirspec.py +215 -0
- pyreduce/instruments/nte.json +47 -0
- pyreduce/instruments/nte.py +42 -0
- pyreduce/instruments/uves.json +59 -0
- pyreduce/instruments/uves.py +46 -0
- pyreduce/instruments/xshooter.json +66 -0
- pyreduce/instruments/xshooter.py +39 -0
- pyreduce/make_shear.py +606 -0
- pyreduce/masks/mask_crires_plus_det1.fits.gz +0 -0
- pyreduce/masks/mask_crires_plus_det2.fits.gz +0 -0
- pyreduce/masks/mask_crires_plus_det3.fits.gz +0 -0
- pyreduce/masks/mask_ctio_chiron.fits.gz +0 -0
- pyreduce/masks/mask_elodie.fits.gz +0 -0
- pyreduce/masks/mask_feros3.fits.gz +0 -0
- pyreduce/masks/mask_flames_giraffe.fits.gz +0 -0
- pyreduce/masks/mask_harps_blue.fits.gz +0 -0
- pyreduce/masks/mask_harps_red.fits.gz +0 -0
- pyreduce/masks/mask_hds_blue.fits.gz +0 -0
- pyreduce/masks/mask_hds_red.fits.gz +0 -0
- pyreduce/masks/mask_het_hrs_2x5.fits.gz +0 -0
- pyreduce/masks/mask_jwst_miri_lrs_slitless.fits.gz +0 -0
- pyreduce/masks/mask_jwst_niriss_gr700xd.fits.gz +0 -0
- pyreduce/masks/mask_lick_apf_.fits.gz +0 -0
- pyreduce/masks/mask_mcdonald.fits.gz +0 -0
- pyreduce/masks/mask_nes.fits.gz +0 -0
- pyreduce/masks/mask_nirspec_nirspec.fits.gz +0 -0
- pyreduce/masks/mask_sarg.fits.gz +0 -0
- pyreduce/masks/mask_sarg_2x2a.fits.gz +0 -0
- pyreduce/masks/mask_sarg_2x2b.fits.gz +0 -0
- pyreduce/masks/mask_subaru_hds_red.fits.gz +0 -0
- pyreduce/masks/mask_uves_blue.fits.gz +0 -0
- pyreduce/masks/mask_uves_blue_binned_2_2.fits.gz +0 -0
- pyreduce/masks/mask_uves_middle.fits.gz +0 -0
- pyreduce/masks/mask_uves_middle_2x2_split.fits.gz +0 -0
- pyreduce/masks/mask_uves_middle_binned_2_2.fits.gz +0 -0
- pyreduce/masks/mask_uves_red.fits.gz +0 -0
- pyreduce/masks/mask_uves_red_2x2.fits.gz +0 -0
- pyreduce/masks/mask_uves_red_2x2_split.fits.gz +0 -0
- pyreduce/masks/mask_uves_red_binned_2_2.fits.gz +0 -0
- pyreduce/masks/mask_xshooter_nir.fits.gz +0 -0
- pyreduce/rectify.py +138 -0
- pyreduce/reduce.py +2205 -0
- pyreduce/settings/settings_CRIRES_PLUS.json +89 -0
- pyreduce/settings/settings_HARPN.json +73 -0
- pyreduce/settings/settings_HARPS.json +69 -0
- pyreduce/settings/settings_JWST_MIRI.json +55 -0
- pyreduce/settings/settings_JWST_NIRISS.json +55 -0
- pyreduce/settings/settings_LICK_APF.json +62 -0
- pyreduce/settings/settings_MCDONALD.json +58 -0
- pyreduce/settings/settings_METIS_IFU.json +77 -0
- pyreduce/settings/settings_METIS_LSS.json +77 -0
- pyreduce/settings/settings_MICADO.json +78 -0
- pyreduce/settings/settings_NEID.json +73 -0
- pyreduce/settings/settings_NIRSPEC.json +58 -0
- pyreduce/settings/settings_NTE.json +60 -0
- pyreduce/settings/settings_UVES.json +54 -0
- pyreduce/settings/settings_XSHOOTER.json +78 -0
- pyreduce/settings/settings_pyreduce.json +178 -0
- pyreduce/settings/settings_schema.json +827 -0
- pyreduce/tools/__init__.py +0 -0
- pyreduce/tools/combine.py +117 -0
- pyreduce/trace_orders.py +645 -0
- pyreduce/util.py +1288 -0
- pyreduce/wavecal/MICADO_HK_3arcsec_chip5.npz +0 -0
- pyreduce/wavecal/atlas/thar.fits +4946 -13
- pyreduce/wavecal/atlas/thar_list.txt +4172 -0
- pyreduce/wavecal/atlas/une.fits +0 -0
- pyreduce/wavecal/convert.py +38 -0
- pyreduce/wavecal/crires_plus_J1228_Open_det1.npz +0 -0
- pyreduce/wavecal/crires_plus_J1228_Open_det2.npz +0 -0
- pyreduce/wavecal/crires_plus_J1228_Open_det3.npz +0 -0
- pyreduce/wavecal/harpn_harpn_2D.npz +0 -0
- pyreduce/wavecal/harps_blue_2D.npz +0 -0
- pyreduce/wavecal/harps_blue_pol_2D.npz +0 -0
- pyreduce/wavecal/harps_red_2D.npz +0 -0
- pyreduce/wavecal/harps_red_pol_2D.npz +0 -0
- pyreduce/wavecal/mcdonald.npz +0 -0
- pyreduce/wavecal/metis_lss_l_2D.npz +0 -0
- pyreduce/wavecal/metis_lss_m_2D.npz +0 -0
- pyreduce/wavecal/nirspec_K2.npz +0 -0
- pyreduce/wavecal/uves_blue_360nm_2D.npz +0 -0
- pyreduce/wavecal/uves_blue_390nm_2D.npz +0 -0
- pyreduce/wavecal/uves_blue_437nm_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_2x2_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_565nm_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_580nm_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_600nm_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_665nm_2D.npz +0 -0
- pyreduce/wavecal/uves_middle_860nm_2D.npz +0 -0
- pyreduce/wavecal/uves_red_580nm_2D.npz +0 -0
- pyreduce/wavecal/uves_red_600nm_2D.npz +0 -0
- pyreduce/wavecal/uves_red_665nm_2D.npz +0 -0
- pyreduce/wavecal/uves_red_760nm_2D.npz +0 -0
- pyreduce/wavecal/uves_red_860nm_2D.npz +0 -0
- pyreduce/wavecal/xshooter_nir.npz +0 -0
- pyreduce/wavelength_calibration.py +1873 -0
- pyreduce_astro-0.6.0b1.dist-info/METADATA +112 -0
- pyreduce_astro-0.6.0b1.dist-info/RECORD +151 -0
- pyreduce_astro-0.6.0b1.dist-info/WHEEL +4 -0
- pyreduce_astro-0.6.0b1.dist-info/licenses/LICENSE +674 -0
pyreduce/__init__.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
3
|
+
except ImportError: # for Python<3.8
|
|
4
|
+
from importlib_metadata import PackageNotFoundError, version
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
__version__ = version(__name__)
|
|
8
|
+
except PackageNotFoundError:
|
|
9
|
+
__version__ = "unknown"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# add logger to console
|
|
13
|
+
import logging
|
|
14
|
+
|
|
15
|
+
import tqdm
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# We need to use this to have logging messages handle properly with the progressbar
|
|
19
|
+
class TqdmLoggingHandler(logging.Handler):
|
|
20
|
+
def __init__(self, level=logging.NOTSET):
|
|
21
|
+
super().__init__(level)
|
|
22
|
+
|
|
23
|
+
def emit(self, record):
|
|
24
|
+
try:
|
|
25
|
+
msg = self.format(record)
|
|
26
|
+
tqdm.tqdm.write(msg)
|
|
27
|
+
self.flush()
|
|
28
|
+
except (KeyboardInterrupt, SystemExit):
|
|
29
|
+
raise
|
|
30
|
+
except:
|
|
31
|
+
self.handleError(record)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
logger = logging.getLogger(__name__)
|
|
35
|
+
logger.setLevel(logging.DEBUG)
|
|
36
|
+
logging.captureWarnings(True)
|
|
37
|
+
|
|
38
|
+
console = TqdmLoggingHandler()
|
|
39
|
+
console.setLevel(logging.INFO)
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
import colorlog
|
|
43
|
+
|
|
44
|
+
console.setFormatter(
|
|
45
|
+
colorlog.ColoredFormatter("%(log_color)s%(levelname)s - %(message)s")
|
|
46
|
+
)
|
|
47
|
+
del colorlog
|
|
48
|
+
except ImportError:
|
|
49
|
+
console.setFormatter("%(levelname)s - %(message)s")
|
|
50
|
+
print("Install colorlog for colored logging output")
|
|
51
|
+
|
|
52
|
+
logger.addHandler(console)
|
|
53
|
+
|
|
54
|
+
del logging
|
|
55
|
+
# do not del tqdm, it is needed in the Log Handler
|
|
56
|
+
|
|
57
|
+
# Load externally available modules
|
|
58
|
+
from . import configuration, datasets, reduce, util
|
pyreduce/__main__.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is used when pyreduce is used as a script
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from .reduce import main
|
|
9
|
+
from .tools.combine import combine as tools_combine
|
|
10
|
+
|
|
11
|
+
scripts = ["reduce", "combine"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def help():
|
|
15
|
+
parser = argparse.ArgumentParser(
|
|
16
|
+
description="PyReduce script tools interface", prog="python -m pyreduce"
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument("script", help="which script to execute", choices=scripts)
|
|
19
|
+
parser.print_help()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def reduce():
|
|
23
|
+
parser = argparse.ArgumentParser(
|
|
24
|
+
description="PyReduce script tools interface", prog="python -m pyreduce"
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument("script", help="which script to execute", choices=["reduce"])
|
|
27
|
+
|
|
28
|
+
parser.add_argument("-b", "--bias", action="store_true", help="Create master bias")
|
|
29
|
+
parser.add_argument("-f", "--flat", action="store_true", help="Create master flat")
|
|
30
|
+
parser.add_argument("-o", "--orders", action="store_true", help="Trace orders")
|
|
31
|
+
parser.add_argument("-n", "--norm_flat", action="store_true", help="Normalize flat")
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"-w", "--wavecal", action="store_true", help="Prepare wavelength calibration"
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"-s", "--science", action="store_true", help="Extract science spectrum"
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
"-c", "--continuum", action="store_true", help="Normalize continuum"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
parser.add_argument("instrument", type=str, help="instrument used")
|
|
43
|
+
parser.add_argument("target", type=str, help="target star")
|
|
44
|
+
|
|
45
|
+
args = parser.parse_args()
|
|
46
|
+
instrument = args.instrument.upper()
|
|
47
|
+
target = args.target.upper()
|
|
48
|
+
|
|
49
|
+
steps_to_take = {
|
|
50
|
+
"bias": args.bias,
|
|
51
|
+
"flat": args.flat,
|
|
52
|
+
"orders": args.orders,
|
|
53
|
+
"norm_flat": args.norm_flat,
|
|
54
|
+
"wavecal": args.wavecal,
|
|
55
|
+
"science": args.science,
|
|
56
|
+
"continuum": args.continuum,
|
|
57
|
+
}
|
|
58
|
+
steps_to_take = [k for k, v in steps_to_take.items() if v]
|
|
59
|
+
|
|
60
|
+
# if no steps are specified use all
|
|
61
|
+
if len(steps_to_take) == 0:
|
|
62
|
+
steps_to_take = "all"
|
|
63
|
+
|
|
64
|
+
main(instrument=instrument, target=target, steps=steps_to_take)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def combine():
|
|
68
|
+
parser = argparse.ArgumentParser(
|
|
69
|
+
description="PyReduce script tools interface", prog="python -m pyreduce"
|
|
70
|
+
)
|
|
71
|
+
parser.add_argument("script", help="which script to execute", choices=["combine"])
|
|
72
|
+
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
"--output", help="destination of the combined file", default="./combined.ech"
|
|
75
|
+
)
|
|
76
|
+
parser.add_argument(
|
|
77
|
+
"--plot", type=int, help="plot the results of the desired order"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
parser.add_argument(
|
|
81
|
+
"input", nargs="+", help="input files to use", default="./*.final.ech"
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
args = parser.parse_args()
|
|
85
|
+
|
|
86
|
+
files = args.input
|
|
87
|
+
output = args.output
|
|
88
|
+
plot = args.plot
|
|
89
|
+
|
|
90
|
+
tools_combine(files, output, plot=plot)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if __name__ == "__main__":
|
|
94
|
+
# Determine which script to run
|
|
95
|
+
if len(sys.argv) == 1:
|
|
96
|
+
script = "help"
|
|
97
|
+
else:
|
|
98
|
+
script = sys.argv[1]
|
|
99
|
+
|
|
100
|
+
# Run the chosen script
|
|
101
|
+
if script == "reduce":
|
|
102
|
+
reduce()
|
|
103
|
+
elif script == "combine":
|
|
104
|
+
combine()
|
|
105
|
+
else:
|
|
106
|
+
help()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Builds the C library that contains the extraction algorithm
|
|
3
|
+
|
|
4
|
+
This module prepares and builds the C libary containing the curved
|
|
5
|
+
(and vertical) extraction algorithm using CFFI.
|
|
6
|
+
It also prepares the ffibuilder objects for setup.py,
|
|
7
|
+
so that the library is compiled on installation.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
The user can also call the Module as a script to compile the
|
|
11
|
+
C libraries again.
|
|
12
|
+
|
|
13
|
+
Attributes
|
|
14
|
+
----------
|
|
15
|
+
ffi_builder_vertical : FFI
|
|
16
|
+
CFFI Builder for the vertical extraction algorithm
|
|
17
|
+
ffi_builder_curved : FFI
|
|
18
|
+
CFFI Builder for the curved extraction algorithm
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import logging
|
|
22
|
+
import os
|
|
23
|
+
|
|
24
|
+
from cffi import FFI
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
CWD = os.path.dirname(__file__)
|
|
30
|
+
CWD = os.path.abspath(CWD)
|
|
31
|
+
release_path = os.path.join(CWD, "Release")
|
|
32
|
+
|
|
33
|
+
print("Include dir: ", CWD)
|
|
34
|
+
print("Release dir: ", release_path)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
ffibuilder_vertical = FFI()
|
|
38
|
+
with open(os.path.join(CWD, "slit_func_bd.h")) as f:
|
|
39
|
+
ffibuilder_vertical.cdef(f.read())
|
|
40
|
+
with open(os.path.join(CWD, "slit_func_bd.c")) as f:
|
|
41
|
+
ffibuilder_vertical.set_source(
|
|
42
|
+
"_slitfunc_bd",
|
|
43
|
+
f.read(),
|
|
44
|
+
include_dirs=[CWD, release_path],
|
|
45
|
+
depends=["slit_func_bd.h"],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
ffibuilder_curved = FFI()
|
|
49
|
+
with open(os.path.join(CWD, "slit_func_2d_xi_zeta_bd.h")) as f:
|
|
50
|
+
ffibuilder_curved.cdef(f.read())
|
|
51
|
+
with open(os.path.join(CWD, "slit_func_2d_xi_zeta_bd.c")) as f:
|
|
52
|
+
ffibuilder_curved.set_source(
|
|
53
|
+
"_slitfunc_2d",
|
|
54
|
+
f.read(),
|
|
55
|
+
include_dirs=[CWD, release_path],
|
|
56
|
+
depends=["slit_func_2d_xi_zeta_bd.h"],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def build():
|
|
61
|
+
"""Builds the C slitfunc library"""
|
|
62
|
+
logger.info("Building required C libraries, this might take a few seconds")
|
|
63
|
+
|
|
64
|
+
old_cwd = os.getcwd()
|
|
65
|
+
path = os.path.abspath(CWD)
|
|
66
|
+
os.chdir(path)
|
|
67
|
+
|
|
68
|
+
ffibuilder_vertical.compile(verbose=True, debug=False)
|
|
69
|
+
ffibuilder_curved.compile(verbose=True, debug=False)
|
|
70
|
+
|
|
71
|
+
os.chdir(old_cwd)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__": # pragma: no cover
|
|
75
|
+
build()
|