hcam-obsutils 0.0.2__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.
- hcam_obsutils/__init__.py +0 -0
- hcam_obsutils/scripts/__init__.py +0 -0
- hcam_obsutils/scripts/missbias.py +140 -0
- hcam_obsutils-0.0.2.dist-info/METADATA +21 -0
- hcam_obsutils-0.0.2.dist-info/RECORD +8 -0
- hcam_obsutils-0.0.2.dist-info/WHEEL +4 -0
- hcam_obsutils-0.0.2.dist-info/entry_points.txt +2 -0
- hcam_obsutils-0.0.2.dist-info/licenses/LICENSE +19 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Iterable
|
|
4
|
+
|
|
5
|
+
from hipercam.hcam import Rhead as Hhead
|
|
6
|
+
from hipercam.ucam import Rhead as Uhead
|
|
7
|
+
|
|
8
|
+
HELP = """
|
|
9
|
+
missbias reads all the runs in the directories specified and tries to work out if there
|
|
10
|
+
are any non-biases without corresponding biases. This is a crude test and does not verify that
|
|
11
|
+
runs identified as 'Bias' are what they say they are or that they are any good. As well as the
|
|
12
|
+
directories specified, the script also looks for subdirectories called 'data'
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
UCAM_RE = "run[0-9][0-9][0-9].xml"
|
|
16
|
+
HCAM_RE = "run[0-9][0-9][0-9][0-9].fits"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def is_bias(header: Hhead | Uhead) -> bool:
|
|
20
|
+
try:
|
|
21
|
+
# assume ucam first
|
|
22
|
+
target = header.header["TARGET"].lower()
|
|
23
|
+
except KeyError:
|
|
24
|
+
target = header.header["OBJECT"].lower()
|
|
25
|
+
return "bias" in target
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def headers(dirpath: str, hcam: bool = False) -> Iterable[Hhead | Uhead]:
|
|
29
|
+
"""
|
|
30
|
+
Generator yielding header objects from all runs in dirpath.
|
|
31
|
+
|
|
32
|
+
ULTRACAM/ULTRASPEC Power ON/OFF runs are skipped.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
dirpath : str
|
|
37
|
+
Path to directory to search for runs.
|
|
38
|
+
hcam : bool
|
|
39
|
+
If True, process HiPERCAM runs, otherwise ULTRASPEC/ULTRACAM runs.
|
|
40
|
+
|
|
41
|
+
Yields
|
|
42
|
+
------
|
|
43
|
+
header : Hhead or Uhead
|
|
44
|
+
Header object for each run found.
|
|
45
|
+
"""
|
|
46
|
+
dirpath = Path(dirpath)
|
|
47
|
+
if dirpath.is_dir():
|
|
48
|
+
header_files = dirpath.glob(HCAM_RE) if hcam else dirpath.glob(UCAM_RE)
|
|
49
|
+
for fn in header_files:
|
|
50
|
+
fn = fn.with_suffix("")
|
|
51
|
+
header = Hhead(str(fn)) if hcam else Uhead(str(fn))
|
|
52
|
+
if not hcam and header.isPonoff():
|
|
53
|
+
continue
|
|
54
|
+
yield header
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def uhead_equal(h1: Uhead, h2: Uhead, fussy: bool = False) -> bool:
|
|
58
|
+
ok = (
|
|
59
|
+
(h1.xbin == h2.xbin)
|
|
60
|
+
and (h1.instrument == h2.instrument)
|
|
61
|
+
and (h1.ybin == h2.ybin)
|
|
62
|
+
and (len(h1.win) == len(h2.win))
|
|
63
|
+
and (h1.gainSpeed == h2.gainSpeed)
|
|
64
|
+
and (
|
|
65
|
+
h1.header.get("HVGAIN", None) == h2.header.get("HVGAIN", None)
|
|
66
|
+
if fussy
|
|
67
|
+
else True
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
if ok:
|
|
71
|
+
for window in h1.win:
|
|
72
|
+
if not any(w == window for w in h2.win):
|
|
73
|
+
ok = False
|
|
74
|
+
break
|
|
75
|
+
return ok
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def main():
|
|
79
|
+
parser = argparse.ArgumentParser(description=HELP)
|
|
80
|
+
parser.add_argument(
|
|
81
|
+
"-f",
|
|
82
|
+
"--fussy",
|
|
83
|
+
action="store_true",
|
|
84
|
+
default=False,
|
|
85
|
+
help="fussy tests ensure difference in avalanche gains are picked up, only important for ULTRASPEC",
|
|
86
|
+
)
|
|
87
|
+
parser.add_argument(
|
|
88
|
+
"-i",
|
|
89
|
+
"--include-caution",
|
|
90
|
+
default=False,
|
|
91
|
+
action="store_true",
|
|
92
|
+
help="include runs marked 'data caution' when listing runs without biasses",
|
|
93
|
+
)
|
|
94
|
+
parser.add_argument(
|
|
95
|
+
"--hcam",
|
|
96
|
+
action="store_true",
|
|
97
|
+
default=False,
|
|
98
|
+
help="process HiPERCAM runs rather than ULTRASPEC and/or ULTRACAMruns",
|
|
99
|
+
)
|
|
100
|
+
parser.add_argument(
|
|
101
|
+
"dirs",
|
|
102
|
+
nargs="+",
|
|
103
|
+
help="directories to search for runs, subdirectories called 'data' will also be searched",
|
|
104
|
+
)
|
|
105
|
+
args = parser.parse_args()
|
|
106
|
+
|
|
107
|
+
# accumulate a list of unique biases and non-biases
|
|
108
|
+
nonbiases = {}
|
|
109
|
+
biases = {}
|
|
110
|
+
dirs = set(["data"] + args.dirs)
|
|
111
|
+
for dirpath in sorted(dirs):
|
|
112
|
+
# all headers in this directory
|
|
113
|
+
for header in headers(dirpath, hcam=args.hcam):
|
|
114
|
+
# which dictionary to store in?
|
|
115
|
+
if is_bias(header):
|
|
116
|
+
destination = biases
|
|
117
|
+
else:
|
|
118
|
+
destination = nonbiases
|
|
119
|
+
|
|
120
|
+
# compare with already stored formats
|
|
121
|
+
new_format = True
|
|
122
|
+
for _, rold in destination.items():
|
|
123
|
+
if uhead_equal(header, rold, fussy=args.fussy):
|
|
124
|
+
new_format = False
|
|
125
|
+
break
|
|
126
|
+
if new_format:
|
|
127
|
+
destination[header.run] = header
|
|
128
|
+
|
|
129
|
+
# now see if each non-bias has a matching bias
|
|
130
|
+
for run, nhead in nonbiases.items():
|
|
131
|
+
if not args.include_caution and nhead.header["DTYPE"].lower() == "data caution":
|
|
132
|
+
continue
|
|
133
|
+
|
|
134
|
+
has_bias = False
|
|
135
|
+
for _, bhead in biases.items():
|
|
136
|
+
if uhead_equal(nhead, bhead, fussy=args.fussy):
|
|
137
|
+
has_bias = True
|
|
138
|
+
break
|
|
139
|
+
if not has_bias:
|
|
140
|
+
print(f"No bias found for run {run} in format:")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hcam_obsutils
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: A collection of utility scripts for observing with HiPERCAM and ULTRACAM.
|
|
5
|
+
Project-URL: Homepage, https://github.com/hipercam/hcam_obsutils
|
|
6
|
+
Project-URL: Issues, https://github.com/hipercam/hcam_obsutils/issues
|
|
7
|
+
Author-email: Stuart Littlefair <s.littlefair@sheffield.ac.uk>, Martin Dyer <m.j.dyer@sheffield.ac.uk>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Requires-Dist: astropy
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy
|
|
16
|
+
Requires-Dist: trm-cline
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# HCAM Obsutils
|
|
20
|
+
|
|
21
|
+
This is a package containing useful scripts for observing with the instruments HiPERCAM, ULTRACAM and ULTRASPEC.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
hcam_obsutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
hcam_obsutils/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
hcam_obsutils/scripts/missbias.py,sha256=odpTJvF-uGAo9vBKUlz8VVMpVthOXlzwbipU1-kwx4E,4374
|
|
4
|
+
hcam_obsutils-0.0.2.dist-info/METADATA,sha256=6UQH98r2baSYd5t8wZjLjN5m5xAg6fYa6XewuOJedHg,803
|
|
5
|
+
hcam_obsutils-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
hcam_obsutils-0.0.2.dist-info/entry_points.txt,sha256=Eyri_5Qwg0RPWgrgLDal63i0aGP8zfP9xU9szGhOr5Q,65
|
|
7
|
+
hcam_obsutils-0.0.2.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
8
|
+
hcam_obsutils-0.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|