-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathOrder.py
196 lines (138 loc) · 5.45 KB
/
Order.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# import numpy as np
class Order:
def __init__(self, frames, baseNames, flatOrder):
"""
Attributes:
baseName:
flatOrder:
frames:
"""
self.frames = frames
self.baseNames = baseNames
self.flatOrder = flatOrder
self.integrationTime = 0.0
"""
Attributes:
topCalc: Pixel row of top left (x = 0) corner of order predicted by grating equation.
topMean: Pixel row of top left corder as determined by edge detection.
botCalc: Pixel row of bottom left corner of order predicted by grating equation.
botMeas: Pixel row of bottom left corner of order determined by edge detection.
"""
self.topCalc = 0.0
self.topMeas = 0.0
self.botCalc = 0.0
self.spectralTrace = []
self.objCutout = {}
for frame in self.frames:
self.objCutout[frame] = []
self.onOrderMask = []
self.offOrderMask = []
#
# fields pertaining to wavelength calibration
#
self.lines = []
self.waveShift = None
self.waveScale = []
self.calMethod = 'unknown'
self.orderCal = False # true if per-order fit computed
self.orderCalWaveScale = [] # wavelength scale based on per-order fit
self.orderCalSlope = 0.0 # slope of linear per-order fit
self.orderCalIncpt = 0.0 # y-intercept of linear per-order fit
self.orderCalCorrCoeff = 0.0 # per-order linear fit r^2
self.orderCalNLines = 0 # number of lines used in per-order fit
self.orderCalRMSRes = 0.0 # RMS fit residual for per-order fit
self.frameCalWaveScale = [] # wavelength scale based on per-frame fit
self.mfCalScale = []
# self.topEdgeProfiles = None
# self.botEdgeProfiles = None
self.flatNormalized = False
self.flattened = False
self.spatialRectified = False
self.spectralRectified = False
self.flatMean = 0.0
"""
"""
self.flatImg = []
self.normalizedFlatImg = []
self.objImg = {}
self.ffObjImg = {}
for frame in self.frames:
self.objImg[frame] = []
self.ffObjImg[frame] = []
self.noiseImg = []
"""
These attributes are used for storing order images after spatial
rectification but before spectral rectification for diagnostic purposes.
Attribute:
srNormFlatImg: Normalized flat order image before spectral rectification.
srFlatObjAImg: Flat-fielded object A order image before spectral rectification.
srFlatObjBImg: Flat-fielded object B order image before spectral rectification.
srFlatObjABImg: Flat-fielded object A - B order image before spectral rectification.
"""
self.srNormFlatImg = []
self.srFfObjImg = {}
for frame in self.frames:
self.srFfObjImg[frame] = []
"""
These attributes are used to store spatial profiles and spatial peak locations.
In pair subtraction mode profiles and peaks of A and B images are used to
extract sky spectra for sky line calibration. In single object frame mode,
only the profile and peak for frame A are used.
Attributes:
spatialProfileA, B, AB:
spatialPeakA, B, AB:
centroid:
gaussianParams:
"""
self.spatialProfile = {}
self.peakLocation = {}
self.centroid = {}
self.gaussianParams = {}
for frame in frames:
self.spatialProfile[frame] = []
self.peakLocation[frame] = 0
self.centroid[frame] = None
self.gaussianParams[frame] = None
"""
These attributes define the extraction windows as lists of pixel row numbers
Attributes:
objWindow: Window for extracting object flux spectrum. In the AB pair
subtraction case, this is centered on the positive peak in the
subtracted frame. In the single frame case, this is centered on the
spatial peak in the single frame A.
topSkyWindow: Window for extracting top (higher row numbers) sky window.
This is always on frame A in pair or single frame cases.
botSkyWindow: Window for extracting bottom (lower row numbers) sky window.
Always refers to frame A.
"""
self.objWindow = {}
self.topSkyWindow = {}
self.botSkyWindow = {}
self.topBgMean = {}
self.botBgMean = {}
self.snr = {}
self.objSpec = {}
self.skySpec = {}
for frame in frames:
self.objWindow[frame] = []
if frame == 'AB':
self.topSkyWindow[frame] = None
self.botSkyWindow[frame] = None
self.skySpec[frame] = None
else:
self.topSkyWindow[frame] = []
self.botSkyWindow[frame] = []
self.skySpec[frame] = []
self.topBgMean[frame] = None
self.botBgMean[frame] = None
self.snr[frame] = None
self.objSpec[frame] = []
"""
"""
"""
"""
self.flatSpec = []
self.noiseSpec = {}
for frame in frames:
self.noiseSpec[frame] = []
self.synthesizedSkySpec = []