Skip to content

Commit 504dd13

Browse files
committed
chain
1 parent 60e5291 commit 504dd13

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

pypeit/spectrographs/mmt_binospec.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,10 +1059,8 @@ def binospec_read_amp(inp, ext):
10591059
String with the bias section in IRAF format, e.g. '[x1:x2,y1:y2]'.
10601060
"""
10611061
# Parse input
1062-
if isinstance(inp, str):
1063-
hdu = io.fits_open(inp)
1064-
else:
1065-
hdu = inp
1062+
hdu = io.fits_open(inp) if isinstance(inp, str) else inp
1063+
10661064
# get entire extension...
10671065
temp = hdu[ext].data.transpose()
10681066
nxt = temp.shape[0]
@@ -1073,30 +1071,29 @@ def binospec_read_amp(inp, ext):
10731071

10741072
# parse the DATASEC keyword to determine the size of the science region (unbinned)
10751073
datasec = header['DATASEC']
1076-
xdata1, xdata2, ydata1, ydata2 = np.asarray(
1077-
parse.load_sections(datasec, fmt_iraf=False)
1078-
).flatten()
1079-
datasec = '[{:}:{:},{:}:{:}]'.format(xdata1 - 1, xdata2, ydata1-1, ydata2)
10801074

1081-
# TODO: Since pypeit can only subtract overscan along one axis, I'm subtract
1075+
x1, x2, y1, y2 = chain.from_iterable(parse.load_sections(datasec, fmt_iraf=False))
1076+
datasec = f'[{x1-1}:{x2},{y1-1}:{y2}]'
1077+
1078+
# NOTE: Since pypeit can only subtract overscan along one axis, I'm subtract
10821079
# the overscan here using median method.
10831080
# Overscan X-axis
1084-
if xdata1 > 1:
1085-
overscanx = temp[2:xdata1-1, :]
1081+
if x1 > 1:
1082+
overscanx = temp[2:x1-1, :]
10861083
overscanx_vec = np.median(overscanx, axis=0)
10871084
temp = temp - overscanx_vec[None,:]
1088-
data = temp[xdata1 - 1:xdata2, ydata1 -1 : ydata2]
1085+
data = temp[x1-1:x2, y1-1:y2]
10891086

10901087
## Overscan Y-axis
1091-
if ydata2<nyt:
1092-
os1, os2 = ydata2+1, nyt-1
1093-
overscany = temp[xdata1 - 1:xdata2, ydata2:os2]
1088+
if y2 < nyt:
1089+
os1, os2 = y2+1, nyt-1
1090+
overscany = temp[x1 - 1:x2, y2:os2]
10941091
overscany_vec = np.median(overscany, axis=1)
10951092
data = data - overscany_vec[:,None]
10961093

10971094
# Overscan
1098-
biassec = '[0:{:},{:}:{:}]'.format(xdata1-1, ydata1-1, ydata2)
1099-
xos1, xos2, yos1, yos2 = np.asarray(parse.load_sections(biassec, fmt_iraf=False)).flatten()
1095+
biassec = f'[0:{x1-1},{y1-1}:{y2}]'
1096+
xos1, xos2, yos1, yos2 = chain.from_iterable(parse.load_sections(biassec, fmt_iraf=False))
11001097
overscan = np.zeros_like(temp[xos1:xos2, yos1:yos2]) # Give a zero fake overscan at the edge of each amplifiers
11011098

11021099
return data, overscan, datasec, biassec

0 commit comments

Comments
 (0)