-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakemask.py
More file actions
52 lines (42 loc) · 1.36 KB
/
makemask.py
File metadata and controls
52 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""This script makes a mask file."""
import sys
from datetime import UTC, datetime
import asdf
import numpy as np
outfile = sys.argv[1]
sca = int(sys.argv[2])
dq = np.zeros((4096, 4096), dtype=np.uint32)
# Reference pixels
dq[:4, :] |= 2**31
dq[-4:, :] |= 2**31
dq[:, :4] |= 2**31
dq[:, -4:] |= 2**31
# Low QE pixels
with asdf.open(outfile.replace("_mask_", "_linearitylegendre_")) as f:
pflat = f["roman"]["pflat"][0, :, :]
print(np.median(pflat))
pflat = pflat / np.median(pflat)
dq |= f["roman"]["dq"]
dq |= np.where(pflat < 0.5, 2**13, 0).astype(np.uint32)
# Hot pixels - right now 12.5 DN/s
# Warm pixels - right now 0.25 DN/s
with asdf.open(outfile.replace("_mask_", "_dark_")) as f:
darkslope = f["roman"]["dark_slope"]
dq |= np.where(darkslope > 0.25, np.where(darkslope > 12.5, 2**11, 2**12), 0).astype(np.uint32)
tree = {
"roman": {
"meta": {
"author": "makemask.py",
"description": "makemask.py",
"instrument": {"detector": f"WFI{sca:02d}", "name": "WFI"},
"origin": "PIT - romanimpreprocess",
"date": datetime.now(UTC).isoformat(),
"pedigree": "DUMMY",
"reftype": "PFLAT",
"telescope": "ROMAN",
"useafter": "!time/time-1.2.0 2020-01-01T00:00:00.000",
},
"dq": dq,
},
}
asdf.AsdfFile(tree).write_to(outfile)