wfc3tools 1.5.0__py3-none-any.whl → 1.6.1__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.
wfc3tools/calwf3.py CHANGED
@@ -29,11 +29,13 @@ import subprocess
29
29
 
30
30
  # STSCI
31
31
  from stsci.tools import parseinput
32
+
32
33
  from .util import error_code
33
34
 
34
35
 
35
- def calwf3(input=None, printtime=False, save_tmp=False,
36
- verbose=False, debug=False, parallel=True, version=False, log_func=print):
36
+ def calwf3(
37
+ input=None, printtime=False, save_tmp=False, verbose=False, debug=False, parallel=True, version=False, log_func=print
38
+ ):
37
39
  """
38
40
  Run the calwf3.e executable as from the shell.
39
41
 
@@ -137,33 +139,32 @@ def calwf3(input=None, printtime=False, save_tmp=False,
137
139
 
138
140
  """
139
141
 
140
- call_list = ['calwf3.e']
142
+ call_list = ["calwf3.e"]
141
143
  return_code = None
142
144
 
143
145
  if printtime:
144
- call_list.append('-t')
146
+ call_list.append("-t")
145
147
 
146
148
  if save_tmp:
147
- call_list.append('-s')
149
+ call_list.append("-s")
148
150
 
149
151
  if verbose:
150
- call_list.append('-v')
152
+ call_list.append("-v")
151
153
 
152
154
  if version:
153
- call_list.append('--version')
155
+ call_list.append("--version")
154
156
 
155
157
  if debug:
156
- call_list.append('-d')
158
+ call_list.append("-d")
157
159
 
158
160
  if not parallel:
159
- call_list.append('-1')
161
+ call_list.append("-1")
160
162
 
161
163
  infiles, dummy = parseinput.parseinput(input)
162
164
  if (len(parseinput.irafglob(input)) == 0) and not version:
163
165
  raise IOError("No valid image specified")
164
166
  if len(parseinput.irafglob(input)) > 1:
165
- raise IOError("calwf3 can only accept 1 file for"
166
- "input at a time: {0}".format(infiles))
167
+ raise IOError("calwf3 can only accept 1 file forinput at a time: {0}".format(infiles))
167
168
 
168
169
  for image in infiles:
169
170
  if not os.path.exists(image):
@@ -180,7 +181,7 @@ def calwf3(input=None, printtime=False, save_tmp=False,
180
181
 
181
182
  if log_func is not None:
182
183
  for line in proc.stdout:
183
- log_func(line.decode('utf8'))
184
+ log_func(line.decode("utf8"))
184
185
 
185
186
  return_code = proc.wait()
186
187
  ec = error_code(return_code)
wfc3tools/embedsub.py CHANGED
@@ -1,13 +1,13 @@
1
- from .sub2full import sub2full
1
+ import numpy
2
2
 
3
3
  # STDLIB
4
4
  from astropy.io import fits
5
- import os
6
- import numpy
7
5
 
8
6
  # STSCI
9
7
  from stsci.tools import parseinput
10
8
 
9
+ from .sub2full import sub2full
10
+
11
11
  __taskname__ = "embedsub"
12
12
 
13
13
 
@@ -36,14 +36,13 @@ def embedsub(files):
36
36
 
37
37
  # process all the input subarrays
38
38
  for filename in infiles:
39
-
40
39
  # Make sure the input name conforms to normal style
41
- if '_flt' not in filename:
40
+ if "_flt" not in filename:
42
41
  print("Warning: Can't properly parse '%s'; Skipping" % files)
43
42
 
44
43
  # Extract the root name and build SPT and output file names
45
- root = filename[0:filename.find('_flt')]
46
- full = root[0:len(root)-1] + 'f_flt.fits'
44
+ root = filename[0 : filename.find("_flt")]
45
+ full = root[0 : len(root) - 1] + "f_flt.fits"
47
46
 
48
47
  try:
49
48
  # open input file read-only
@@ -51,14 +50,13 @@ def embedsub(files):
51
50
  except EnvironmentError:
52
51
  print("Problem opening fits file %s" % (filename))
53
52
 
54
- detector = flt[0].header['DETECTOR']
55
- if 'UVIS' in detector:
53
+ detector = flt[0].header["DETECTOR"]
54
+ if "UVIS" in detector:
56
55
  uvis = True
57
56
 
58
57
  # compute subarray corners assuming the raw image location
59
58
  x1, x2, y1, y2 = sub2full(filename, fullExtent=True)[0]
60
- print("Subarray image section [x1,x2,y1,y2] = [%d:%d,%d:%d]" % (x1, x2,
61
- y1, y2))
59
+ print("Subarray image section [x1,x2,y1,y2] = [%d:%d,%d:%d]" % (x1, x2, y1, y2))
62
60
 
63
61
  if uvis:
64
62
  xaxis = uvis_full_x
@@ -74,44 +72,44 @@ def embedsub(files):
74
72
  err = numpy.zeros([xaxis, yaxis], dtype=numpy.float32)
75
73
  dq = numpy.zeros([xaxis, yaxis], dtype=numpy.int16) + 4
76
74
 
77
- sci[y1-1:y2, x1-1:x2] = flt[1].data
78
- err[y1-1:y2, x1-1:x2] = flt[2].data
79
- dq[y1-1:y2, x1-1:x2] = flt[3].data
75
+ sci[y1 - 1 : y2, x1 - 1 : x2] = flt[1].data
76
+ err[y1 - 1 : y2, x1 - 1 : x2] = flt[2].data
77
+ dq[y1 - 1 : y2, x1 - 1 : x2] = flt[3].data
80
78
 
81
79
  if not uvis:
82
80
  samp = numpy.zeros([xaxis, yaxis], dtype=numpy.int16)
83
81
  time = numpy.zeros([xaxis, yaxis], dtype=numpy.float32)
84
- samp[y1-1:y2, x1-1:x2] = flt[4].data
85
- time[y1-1:y2, x1-1:x2] = flt[5].data
82
+ samp[y1 - 1 : y2, x1 - 1 : x2] = flt[4].data
83
+ time[y1 - 1 : y2, x1 - 1 : x2] = flt[5].data
86
84
 
87
85
  # Reset a few WCS values to make them appropriate for a
88
86
  # full-chip image
89
- crpix1 = flt[1].header['CRPIX1']
90
- crpix2 = flt[1].header['CRPIX2']
87
+ crpix1 = flt[1].header["CRPIX1"]
88
+ crpix2 = flt[1].header["CRPIX2"]
91
89
 
92
- flt[1].header['sizaxis1'] = yaxis
93
- flt[1].header['sizaxis2'] = xaxis
90
+ flt[1].header["sizaxis1"] = yaxis
91
+ flt[1].header["sizaxis2"] = xaxis
94
92
 
95
93
  for i in range(1, 4):
96
- if 'CRPIX1' in flt[i].header:
97
- flt[i].header['crpix1'] = crpix1 + x1 - 1
98
- flt[i].header['crpix2'] = crpix2 + y1 - 1
99
- if 'LTV1' in flt[i].header:
100
- flt[i].header['ltv1'] = 0.0
101
- flt[i].header['ltv2'] = 0.0
94
+ if "CRPIX1" in flt[i].header:
95
+ flt[i].header["crpix1"] = crpix1 + x1 - 1
96
+ flt[i].header["crpix2"] = crpix2 + y1 - 1
97
+ if "LTV1" in flt[i].header:
98
+ flt[i].header["ltv1"] = 0.0
99
+ flt[i].header["ltv2"] = 0.0
102
100
 
103
101
  # set the header value of SUBARRAY to False since it's now
104
102
  # regular size image
105
- flt[0].header['SUBARRAY'] = False
106
-
103
+ flt[0].header["SUBARRAY"] = False
104
+
107
105
  # Now write out the SCI, ERR, DQ extensions to the full-chip file
108
- flt[1].data = sci
106
+ flt[1].data = sci
109
107
  flt[2].data = err
110
108
  flt[3].data = dq
111
-
109
+
112
110
  if not uvis:
113
111
  flt[4].data = samp
114
- flt[5].data = time
112
+ flt[5].data = time
115
113
 
116
114
  flt.writeto(full, overwrite=False)
117
115
 
wfc3tools/pstack.py CHANGED
@@ -42,16 +42,14 @@ Usage:
42
42
  """
43
43
 
44
44
  # STDLIB
45
- import os
46
- from astropy.io import fits
47
45
  import numpy as np
46
+ from astropy.io import fits
48
47
  from matplotlib import pyplot as plt
49
48
 
50
49
  plt.ion()
51
50
 
52
51
 
53
- def pstack(filename, column=0, row=0, extname="sci", units="counts",
54
- title=None, xlabel=None, ylabel=None, plot=True):
52
+ def pstack(filename, column=0, row=0, extname="sci", units="counts", title=None, xlabel=None, ylabel=None, plot=True):
55
53
  """
56
54
  A function to plot the statistics of one pixels up the IR ramp image.
57
55
  Original implementation in the iraf nicmos package. Pixel values here are
@@ -139,28 +137,28 @@ def pstack(filename, column=0, row=0, extname="sci", units="counts",
139
137
 
140
138
  for i in range(1, nsamp, 1):
141
139
  if time:
142
- yaxis[i-1] = myfile["SCI", i].header['SAMPTIME']
140
+ yaxis[i - 1] = myfile["SCI", i].header["SAMPTIME"]
143
141
  else:
144
142
  # Numpy is row-major with array indices written row-first
145
143
  # (lexicographical access order)
146
- yaxis[i-1] = myfile[extname.upper(), i].data[row, column]
147
- xaxis[i-1] = myfile["SCI", i].header['SAMPTIME']
144
+ yaxis[i - 1] = myfile[extname.upper(), i].data[row, column]
145
+ xaxis[i - 1] = myfile["SCI", i].header["SAMPTIME"]
148
146
 
149
147
  # convert to countrate
150
148
  if "rate" in units.lower() and "/" not in bunit.lower():
151
- exptime = myfile["SCI", i].header['SAMPTIME']
152
- yaxis[i-1] /= exptime
149
+ exptime = myfile["SCI", i].header["SAMPTIME"]
150
+ yaxis[i - 1] /= exptime
153
151
  # convert to counts
154
152
  if "counts" in units.lower() and "/" in bunit.lower():
155
- exptime = myfile["SCI", i].header['SAMPTIME']
156
- yaxis[i-1] *= exptime
153
+ exptime = myfile["SCI", i].header["SAMPTIME"]
154
+ yaxis[i - 1] *= exptime
157
155
 
158
156
  if not ylabel:
159
157
  if "rate" in units.lower():
160
158
  if "/" in bunit.lower():
161
159
  ylabel = bunit
162
160
  else:
163
- ylabel = bunit+" per second"
161
+ ylabel = bunit + " per second"
164
162
  else:
165
163
  if "/" in bunit:
166
164
  stop_index = bunit.find("/")
@@ -177,8 +175,7 @@ def pstack(filename, column=0, row=0, extname="sci", units="counts",
177
175
  plt.xlabel("Sample time")
178
176
 
179
177
  if not title:
180
- title = "%s Pixel stack for col=%d, row=%d" % (filename, column,
181
- row)
178
+ title = "%s Pixel stack for col=%d, row=%d" % (filename, column, row)
182
179
  plt.title(title)
183
180
 
184
181
  if time:
wfc3tools/pstat.py CHANGED
@@ -37,7 +37,7 @@ Usage:
37
37
  Note that the arrays are structured in SCI order, so the final exposure is the first element in the array.
38
38
 
39
39
  .. Warning::
40
- The interface to this utility has been updated from previous versions and
40
+ The interface to this utility has been updated from previous versions and
41
41
  is **not backwards compatible.** Here is an example to illustrate the "original"
42
42
  syntax, the "original syntax corrected for row/column order", and finally the
43
43
  "new" syntax which requires column and row sections to be specified as tuples.
@@ -56,17 +56,27 @@ Usage:
56
56
  """
57
57
 
58
58
  # STDLIB
59
- import os
60
- from astropy.io import fits
61
59
  import numpy as np
60
+ from astropy.io import fits
62
61
  from matplotlib import pyplot as plt
63
62
  from scipy.stats import mode as mode
64
63
 
65
64
  plt.ion()
66
65
 
67
66
 
68
- def pstat(filename, col_slice=None, row_slice=None, extname="sci", units="counts",
69
- stat="midpt", title=None, xlabel=None, ylabel=None, plot=True, overplot=False):
67
+ def pstat(
68
+ filename,
69
+ col_slice=None,
70
+ row_slice=None,
71
+ extname="sci",
72
+ units="counts",
73
+ stat="midpt",
74
+ title=None,
75
+ xlabel=None,
76
+ ylabel=None,
77
+ plot=True,
78
+ overplot=False,
79
+ ):
70
80
  """
71
81
  A function to plot the statistics of one or more pixels up an IR ramp.
72
82
 
@@ -147,9 +157,9 @@ def pstat(filename, col_slice=None, row_slice=None, extname="sci", units="counts
147
157
  bracket_loc = filename.find("[")
148
158
 
149
159
  # get the base filename and strip off any extra information as necessary
150
- if (bracket_loc < 0):
160
+ if bracket_loc < 0:
151
161
  imagename = filename
152
- elif (bracket_loc > 0):
162
+ elif bracket_loc > 0:
153
163
  imagename = filename[:bracket_loc]
154
164
  print("Any extension name or image section must be specified via parameters.")
155
165
  print("Input filename has been stripped of data in brackets, %s" % (imagename))
@@ -169,14 +179,14 @@ def pstat(filename, col_slice=None, row_slice=None, extname="sci", units="counts
169
179
  all_cols = False
170
180
  if not col_slice:
171
181
  all_cols = True
172
- elif not(isinstance(col_slice, tuple) and len(col_slice) == 2 and all(isinstance(val, int) for val in col_slice)):
182
+ elif not (isinstance(col_slice, tuple) and len(col_slice) == 2 and all(isinstance(val, int) for val in col_slice)):
173
183
  print("Invalid specification for col_slice which must be a tuple of two integer values.")
174
184
  return 0, 0
175
185
 
176
186
  all_rows = False
177
187
  if not row_slice:
178
188
  all_rows = True
179
- elif not(isinstance(row_slice, tuple) and len(row_slice) == 2 and all(isinstance(val, int) for val in row_slice)):
189
+ elif not (isinstance(row_slice, tuple) and len(row_slice) == 2 and all(isinstance(val, int) for val in row_slice)):
180
190
  print("Invalid specification for row_slice which must be a tuple of two integer values.")
181
191
  return 0, 0
182
192
 
@@ -207,33 +217,32 @@ def pstat(filename, col_slice=None, row_slice=None, extname="sci", units="counts
207
217
 
208
218
  for i in range(1, nsamp, 1):
209
219
  if "midpt" in stat:
210
- yaxis[i-1] = np.median(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
220
+ yaxis[i - 1] = np.median(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
211
221
 
212
222
  if "mean" in stat:
213
- yaxis[i-1] = np.mean(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
223
+ yaxis[i - 1] = np.mean(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
214
224
 
215
225
  if "mode" in stat:
216
- yaxis[i-1] = mode(myfile[extname.upper(), i].data[ystart:yend, xstart:xend],
217
- axis=None)[0]
226
+ yaxis[i - 1] = mode(myfile[extname.upper(), i].data[ystart:yend, xstart:xend], axis=None)[0]
218
227
 
219
228
  if "min" in stat:
220
- yaxis[i-1] = np.min(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
229
+ yaxis[i - 1] = np.min(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
221
230
 
222
231
  if "max" in stat:
223
- yaxis[i-1] = np.max(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
232
+ yaxis[i - 1] = np.max(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
224
233
 
225
234
  if "stddev" in stat:
226
- yaxis[i-1] = np.std(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
235
+ yaxis[i - 1] = np.std(myfile[extname.upper(), i].data[ystart:yend, xstart:xend])
227
236
 
228
- exptime = myfile["SCI", i].header['SAMPTIME']
229
- xaxis[i-1] = exptime
237
+ exptime = myfile["SCI", i].header["SAMPTIME"]
238
+ xaxis[i - 1] = exptime
230
239
 
231
240
  # convert to countrate
232
241
  if "rate" in units.lower() and "/" not in bunit.lower():
233
- yaxis[i-1] /= exptime
242
+ yaxis[i - 1] /= exptime
234
243
  # convert to counts
235
244
  if "counts" in units.lower() and "/" in bunit.lower():
236
- yaxis[i-1] *= exptime
245
+ yaxis[i - 1] *= exptime
237
246
 
238
247
  if plot:
239
248
  if not overplot:
@@ -251,15 +260,14 @@ def pstat(filename, col_slice=None, row_slice=None, extname="sci", units="counts
251
260
  else:
252
261
  ylabel = bunit
253
262
 
254
- ylabel += (" %s" % (stat))
263
+ ylabel += " %s" % (stat)
255
264
  plt.ylabel(ylabel)
256
265
 
257
266
  if not xlabel:
258
267
  plt.xlabel("Sample time (s)")
259
268
 
260
269
  if not title:
261
- title = "%s Pixel stats for [%d:%d,%d:%d]" % (imagename, xstart,
262
- xend, ystart, yend)
270
+ title = "%s Pixel stats for [%d:%d,%d:%d]" % (imagename, xstart, xend, ystart, yend)
263
271
  plt.title(title)
264
272
  plt.plot(xaxis, yaxis, "+")
265
273
  plt.draw()
wfc3tools/sampinfo.py CHANGED
@@ -26,57 +26,57 @@ Usage:
26
26
 
27
27
  >>> from wfc3tools import sampinfo
28
28
  >>> sampinfo('ibcf02faq_raw.fits')
29
- >>> IMAGE NEXTEND SAMP_SEQ NSAMP EXPTIME
30
- ibcf02faq_raw.fits 80 STEP50 16 499.234009
31
-
32
- IMSET SAMPNUM SAMPTIME DELTATIM
33
- 1 15 499.234009 50.000412
34
- 2 14 449.233582 50.000412
35
- 3 13 399.233154 50.000412
36
- 4 12 349.232727 50.000412
37
- 5 11 299.2323 50.000412
38
- 6 10 249.231873 50.000412
39
- 7 9 199.231461 50.000412
40
- 8 8 149.231049 50.000412
41
- 9 7 99.230637 50.000412
42
- 10 6 49.230225 25.000511
43
- 11 5 24.229715 12.500551
44
- 12 4 11.729164 2.932291
45
- 13 3 8.796873 2.932291
46
- 14 2 5.864582 2.932291
47
- 15 1 2.932291 2.932291
48
- 16 0 0.0 0.0
29
+ >>> IMAGE NEXTEND SAMP_SEQ NSAMP EXPTIME
30
+ ibcf02faq_raw.fits 80 STEP50 16 499.234009
31
+
32
+ IMSET SAMPNUM SAMPTIME DELTATIM
33
+ 1 15 499.234009 50.000412
34
+ 2 14 449.233582 50.000412
35
+ 3 13 399.233154 50.000412
36
+ 4 12 349.232727 50.000412
37
+ 5 11 299.2323 50.000412
38
+ 6 10 249.231873 50.000412
39
+ 7 9 199.231461 50.000412
40
+ 8 8 149.231049 50.000412
41
+ 9 7 99.230637 50.000412
42
+ 10 6 49.230225 25.000511
43
+ 11 5 24.229715 12.500551
44
+ 12 4 11.729164 2.932291
45
+ 13 3 8.796873 2.932291
46
+ 14 2 5.864582 2.932291
47
+ 15 1 2.932291 2.932291
48
+ 16 0 0.0 0.0
49
49
 
50
50
  Include median:
51
51
 
52
52
  >>> sampinfo('ibcf02faq_raw.fits',median=True)
53
- >>> IMAGE NEXTEND SAMP_SEQ NSAMP EXPTIME
54
- ibcf02faq_raw.fits 80 STEP50 16 499.234009
55
-
56
- IMSET SAMPNUM SAMPTIME DELTATIM
57
- 1 15 499.234009 50.000412 MedPixel: 11384.0
58
- 2 14 449.233582 50.000412 MedPixel: 11360.0
59
- 3 13 399.233154 50.000412 MedPixel: 11335.0
60
- 4 12 349.232727 50.000412 MedPixel: 11309.0
61
- 5 11 299.2323 50.000412 MedPixel: 11283.0
62
- 6 10 249.231873 50.000412 MedPixel: 11256.0
63
- 7 9 199.231461 50.000412 MedPixel: 11228.0
64
- 8 8 149.231049 50.000412 MedPixel: 11198.0
65
- 9 7 99.230637 50.000412 MedPixel: 11166.0
66
- 10 6 49.230225 25.000511 MedPixel: 11131.0
67
- 11 5 24.229715 12.500551 MedPixel: 11111.0
68
- 12 4 11.729164 2.932291 MedPixel: 11099.0
69
- 13 3 8.796873 2.932291 MedPixel: 11097.0
70
- 14 2 5.864582 2.932291 MedPixel: 11093.0
71
- 15 1 2.932291 2.932291 MedPixel: 11090.0
72
- 16 0 0.0 0.0 MedPixel: 11087.0
53
+ >>> IMAGE NEXTEND SAMP_SEQ NSAMP EXPTIME
54
+ ibcf02faq_raw.fits 80 STEP50 16 499.234009
55
+
56
+ IMSET SAMPNUM SAMPTIME DELTATIM
57
+ 1 15 499.234009 50.000412 MedPixel: 11384.0
58
+ 2 14 449.233582 50.000412 MedPixel: 11360.0
59
+ 3 13 399.233154 50.000412 MedPixel: 11335.0
60
+ 4 12 349.232727 50.000412 MedPixel: 11309.0
61
+ 5 11 299.2323 50.000412 MedPixel: 11283.0
62
+ 6 10 249.231873 50.000412 MedPixel: 11256.0
63
+ 7 9 199.231461 50.000412 MedPixel: 11228.0
64
+ 8 8 149.231049 50.000412 MedPixel: 11198.0
65
+ 9 7 99.230637 50.000412 MedPixel: 11166.0
66
+ 10 6 49.230225 25.000511 MedPixel: 11131.0
67
+ 11 5 24.229715 12.500551 MedPixel: 11111.0
68
+ 12 4 11.729164 2.932291 MedPixel: 11099.0
69
+ 13 3 8.796873 2.932291 MedPixel: 11097.0
70
+ 14 2 5.864582 2.932291 MedPixel: 11093.0
71
+ 15 1 2.932291 2.932291 MedPixel: 11090.0
72
+ 16 0 0.0 0.0 MedPixel: 11087.0
73
73
 
74
74
  """
75
75
 
76
76
  # STDLIB
77
- from astropy.io import fits
78
- import os
77
+
79
78
  import numpy as np
79
+ from astropy.io import fits
80
80
 
81
81
  # STSCI
82
82
  from stsci.tools import parseinput
@@ -132,11 +132,11 @@ def sampinfo(imagelist, add_keys=None, mean=False, median=False):
132
132
  ir_list += add_keys
133
133
 
134
134
  # measure the min and max data
135
- if (mean):
136
- if (add_keys):
137
- if ("DATAMIN" not in add_keys):
135
+ if mean:
136
+ if add_keys:
137
+ if "DATAMIN" not in add_keys:
138
138
  ir_list += ["DATAMIN"]
139
- if ("DATAMAX" not in add_keys):
139
+ if "DATAMAX" not in add_keys:
140
140
  ir_list += ["DATAMAX"]
141
141
  else:
142
142
  ir_list += ["DATAMIN", "DATAMAX"]
@@ -155,37 +155,35 @@ def sampinfo(imagelist, add_keys=None, mean=False, median=False):
155
155
  samp_seq = header0["SAMP_SEQ"]
156
156
 
157
157
  print("IMAGE\t\t\tNEXTEND\tSAMP_SEQ\tNSAMP\tEXPTIME")
158
- print("%s\t%d\t%s\t\t%d\t%f\n" % (image, nextend, samp_seq,
159
- nsamp, exptime))
158
+ print("%s\t%d\t%s\t\t%d\t%f\n" % (image, nextend, samp_seq, nsamp, exptime))
160
159
  printline = "IMSET\tSAMPNUM"
161
160
 
162
161
  for key in ir_list:
163
- printline += ("\t"+key)
162
+ printline += "\t" + key
164
163
  print(printline)
165
164
 
166
165
  # loop through all the samples for the image and print stuff as we go
167
- for samp in range(1, nsamp+1, 1):
166
+ for samp in range(1, nsamp + 1, 1):
168
167
  printline = ""
169
168
  printline += str(samp)
170
- printline += ("\t"+str(nsamp-samp))
169
+ printline += "\t" + str(nsamp - samp)
171
170
  for key in ir_list:
172
171
  if "DATAMIN" in key:
173
172
  datamin = True
174
173
  dataminval = np.min(current["SCI", samp].data)
175
174
  if "DATAMAX" in key:
176
175
  datamax = True
177
- datamaxval = np.min(current["SCI", samp].data)
176
+ datamaxval = np.max(current["SCI", samp].data)
178
177
  try:
179
- printline += ("\t"+str(current["SCI", samp].header[key]))
178
+ printline += "\t" + str(current["SCI", samp].header[key])
180
179
  except KeyError:
181
180
  try:
182
- printline += ("\t"+str(current[0].header[key]))
181
+ printline += "\t" + str(current[0].header[key])
183
182
  except KeyError as e:
184
- printline += ("\tNA")
185
- if (datamin and datamax):
186
- printline += ("\tAvgPixel: "+str((dataminval+datamaxval)/2.))
187
- if (median):
188
- printline += ("\tMedPixel: "+str(np.median(current["SCI",
189
- samp].data)))
183
+ printline += "\tNA"
184
+ if datamin and datamax:
185
+ printline += "\tAvgPixel: " + str((dataminval + datamaxval) / 2.0)
186
+ if median:
187
+ printline += "\tMedPixel: " + str(np.median(current["SCI", samp].data))
190
188
  print(printline)
191
189
  current.close()
wfc3tools/sub2full.py CHANGED
@@ -36,8 +36,9 @@ Usage:
36
36
  """
37
37
 
38
38
  # STDLIB
39
- from astropy.io import fits
40
39
  import os
40
+
41
+ from astropy.io import fits
41
42
  from stsci.tools import parseinput
42
43
 
43
44
 
@@ -85,13 +86,12 @@ def sub2full(filename, x=None, y=None, fullExtent=False):
85
86
 
86
87
  infiles, dummy_out = parseinput.parseinput(filename)
87
88
  if len(infiles) < 1:
88
- return ValueError("Please input a valid HST filename")
89
+ raise ValueError("Please input a valid HST filename")
89
90
 
90
91
  coords = list()
91
92
 
92
93
  for f in infiles:
93
- spt = os.path.join(os.path.dirname(f), os.path.basename(f)[0:9] +
94
- '_spt.fits')
94
+ spt = os.path.join(os.path.dirname(f), os.path.basename(f)[0:9] + "_spt.fits")
95
95
  uvis_x_size = 2051
96
96
  serial_over = 25.0
97
97
  ir_overscan = 5.0
@@ -100,27 +100,27 @@ def sub2full(filename, x=None, y=None, fullExtent=False):
100
100
  try:
101
101
  fd2 = fits.open(spt)
102
102
  except (ValueError, IOError) as e:
103
- raise ValueError('%s ' % (e))
103
+ raise ValueError("%s " % (e))
104
104
 
105
105
  # check for required keywords and close the images
106
106
  try:
107
- detector = fd2[0].header['SS_DTCTR']
108
- subarray = fd2[0].header['SS_SUBAR']
109
- xcorner = int(fd2[1].header['XCORNER'])
110
- ycorner = int(fd2[1].header['YCORNER'])
111
- numrows = int(fd2[1].header['NUMROWS'])
112
- numcols = int(fd2[1].header['NUMCOLS'])
107
+ detector = fd2[0].header["SS_DTCTR"]
108
+ subarray = fd2[0].header["SS_SUBAR"]
109
+ xcorner = int(fd2[1].header["XCORNER"])
110
+ ycorner = int(fd2[1].header["YCORNER"])
111
+ numrows = int(fd2[1].header["NUMROWS"])
112
+ numcols = int(fd2[1].header["NUMCOLS"])
113
113
  fd2.close()
114
114
  except KeyError as e:
115
- raise KeyError("Required header keyword missing; %s" % (e))
115
+ raise KeyError(f"Required header keyword missing: {e}")
116
116
 
117
117
  if "NO" in subarray:
118
- raise ValueError("Image is not a subarray: %s" % (f))
118
+ raise ValueError(f"Image is not a subarray: {f}")
119
119
 
120
120
  sizaxis1 = numcols
121
121
  sizaxis2 = numrows
122
122
 
123
- if (xcorner == 0 and ycorner == 0):
123
+ if xcorner == 0 and ycorner == 0:
124
124
  cornera1 = 0
125
125
  cornera2 = 0
126
126
  cornera1a = cornera1 + 1
@@ -128,7 +128,7 @@ def sub2full(filename, x=None, y=None, fullExtent=False):
128
128
  cornera2a = cornera2 + 1
129
129
  cornera2b = cornera2a + sizaxis2 - 1
130
130
  else:
131
- if 'UVIS' in detector:
131
+ if "UVIS" in detector:
132
132
  cornera1 = ycorner
133
133
  cornera2 = uvis_x_size - xcorner - sizaxis2
134
134
  if xcorner >= uvis_x_size:
@@ -152,17 +152,16 @@ def sub2full(filename, x=None, y=None, fullExtent=False):
152
152
  cornera2a = cornera2 + 1
153
153
  cornera2b = cornera2a + sizaxis2 - 11
154
154
 
155
- if (x or y):
156
- if ((not isinstance(x, int) or (not isinstance(y, int)))):
155
+ if x or y:
156
+ if not isinstance(x, int) or (not isinstance(y, int)):
157
157
  raise ValueError("Must input integer value for x and y ")
158
158
  else:
159
159
  cornera1a = cornera1a + x
160
160
  cornera2a = cornera2a + y
161
161
  fullExtent = False
162
162
 
163
- if (fullExtent):
164
- coords.append((int(cornera1a), int(cornera1b), int(cornera2a),
165
- int(cornera2b)))
163
+ if fullExtent:
164
+ coords.append((int(cornera1a), int(cornera1b), int(cornera2a), int(cornera2b)))
166
165
  else:
167
166
  coords.append((int(cornera1a), int(cornera2a)))
168
167