wx2d¶
- stistools.wx2d.apply_trace(image, a2center, a2displ, subdiv, offset=0.0, shifta2=0.0, extname='SCI')¶
Add together 'subdiv' rows of 'image', following the trace.
- Parameters:
- imagendarray
input 2-D image array, oversampled by 'subdiv' in axis 0
- a2centerndarray
1-D array of Y locations
- a2displndarray
array of traces, one for each a2center; the length of each trace must be the same as the number of columns in the input image
- subdivint
number of rows to add together
- offsetfloat
offset of the first row in 'image' from the beginning of the data block in the original file, needed for trace
- shifta2float
offset of the row from nominal (from shifta2 keyword)
- extnamestring
which type of extension (SCI, ERR, DQ)?
- Returns:
- x2dndarray
resampled 2-D image array
Notes
The function value is a 2-D array containing the resampled image. This is binned by subdiv in Y (axis 0), after shifting by trace (multiplied by subdiv).
For extname = "ERR" the result differs in these ways:
fractions of pixels at the endpoints of the extraction region are not included
the values are combined as the average of the sum of the squares
For extname = "DQ" the result differs in these ways:
the output is type int16
the output values are nominally the same as the input, while for SCI the output are subdiv times larger than the input
fractions of pixels at the endpoints of the extraction region are not included
the values are combined via bitwise OR rather than an average or sum
- stistools.wx2d.bin_traces(a2displ, binaxis1, ltv)¶
bin the traces by the factor binaxis1
- Parameters:
- a2displndarray
an array of one or more arrays of Y displacements (traces)
- binaxis1int
binning factor in the dispersion axis
- ltvfloat
offset in the dispersion axis (one indexing)
- Returns:
- a2displndarray
an array of traces (a2displ), but with the trace arrays binned and shorter by the factor binaxis1
- stistools.wx2d.extract(image, locn, subdiv)¶
Add together 'subdiv' rows of 'image', centered on 'locn'.
- Parameters:
- imagendarray
input array, oversampled by 'subdiv' in axis 0
- locnndarray
a 1-D array giving the location at which to extract; an integer value corresponds to the center of the pixel. The length must be the same as the number of columns in the input image.
- subdivint
number of rows to add together
- Returns:
- specndarray
a 1-D array containing the extracted row
- stistools.wx2d.extract_err(image, locn, subdiv)¶
Average 'subdiv' rows of 'image', centered on 'locn'.
- Parameters:
- imagendarray
input array, oversampled by 'subdiv' in axis 0
- locnndarray
a 1-D array giving the location at which to extract; an integer value corresponds to the center of the pixel
- subdivint
number of rows to add together
- Returns:
- specndarray
a 1-D array containing the extracted row
Notes
This takes the square root of the average of the squares, intended to be used for interpolating the ERR array. Fractions of pixels at the upper and lower edges are excluded.
- stistools.wx2d.extract_i16(image, locn, subdiv)¶
Bitwise OR 'subdiv' rows of 'image', centered on 'locn'.
- Parameters:
- imagendarray
input array, oversampled by 'subdiv' in axis 0
- locnndarray
a 1-D array giving the location at which to extract; an integer value corresponds to the center of the pixel
- subdivint
number of rows to add together
- Returns:
- specndarray
a 1-D array containing the extracted row
- stistools.wx2d.get_trace(tracefile, phdr, hdr)¶
Read 1-D traces from the 1dt table (sptrctab).
- Parameters:
- tracefilestring or array
either a trace array or the name of a FITS 1dt table
- phdrfits Header object
primary header of input file
- hdrfits Header object
extension header of input image (for binning info and time of exposure)
- Returns:
- trace_arraystuple of 2 arrays
a pair of arrays, one is the Y location at the middle column, and the other is an array of trace arrays
Notes
If 'tracefile' is already a trace array, it will just be returned, together with an arbitrary Y location of 0 (because that will always be within the image).
opt_elem and cenwave are criteria for selecting the relevant rows from the 1dt table. There will normally be several rows that match, and they should have different values of the Y location; the output list will be sorted on Y location.
- stistools.wx2d.interpolate_trace(a2center, a2displ, y, length)¶
Interpolate within the array of traces, and return a trace.
- Parameters:
- a2centerndarray
array of Y locations
- a2displndarray
array of traces, one trace for each element of a2center
- yfloat
Y location on the detector
- lengthint
length of a trace; needed only if traces is empty
- stistools.wx2d.inv_avg_interp(order, image)¶
- stistools.wx2d.inv_haar(image)¶
- stistools.wx2d.kd_apply_trace(image, a2center, a2displ, offset=0.0, shifta2=0.0)¶
Kris Davidson's resampling algorithm, following the trace.
- Parameters:
- imagendarray
input 2-D image array
- a2centerndarray
array of Y locations
- a2displndarray
array of traces, one for each a2center; the length of each trace must be the same as the number of columns in 'image'
- offsetfloat
offset of the first row in 'image' from the beginning of the data block in the original file, needed for trace
- shifta2float
offset of the row from nominal (from shifta2 keyword)
- Returns:
- x2dndarray
2-D array containing the resampled image
- stistools.wx2d.kd_resampling(img, errimg, original_nrows, nrows, ncols, rows, a2center, a2displ, offset, shifta2)¶
Apply Kris Davidson's resampling method.
- Parameters:
- imgndarray
SCI image array (could be a subset of full image)
- errimgndarray
ERR image array (could be a subset of full image)
- original_nrowsint
number of image lines (NAXIS2) in input image
- nrowsint
number of image lines in subset
- ncolsint
number of image columns (NAXIS1)
- rowstuple
tuple giving the slice of rows to process
- a2centerndarray
1-D array of Y locations
- a2displndarray
array of traces, one for each a2center; the length of each trace must be the same as the number of columns in the input image
- offsetfloat
offset of the first row in 'image' from the beginning of the data block in the original file, needed for trace
- shifta2float
offset of the row from nominal (from shifta2 keyword)
- Returns:
- img_arrtuple
the image and error arrays (to replace the input img and errimg)
- stistools.wx2d.polynomial(x, y, z, n)¶
used for interpolation
- Parameters:
- xndarray
the integer values from 0 through n-1 inclusive (but float64)
- yndarray
a 2-D array, axis 0 of length n
- zfloat
n / 2.
- nint
1 + order of polynomial fit
- stistools.wx2d.stis_psf(x, a)¶
Evaluate the cross-dispersion PSF at x.
- Parameters:
- xfloat
offset in pixels from the center of the profile
- afloat
a measure of the width of the PSF
- Returns:
- valfloat
the PSF evaluated at x
- stistools.wx2d.trace_name(trace, phdr)¶
Return the 1dt table name or array.
- Parameters:
- tracestring or array or None
if trace is None the header keyword SPTRCTAB will be gotten from phdr; else if this is a string it should be the name of a trace file (possibly using an environment variable); otherwise, it should be a trace, in which case it will be returned unchanged
- phdrfits Header object
primary header, used only if trace is None
- Returns:
- tracefilestring or array
name of a trace file (with environment variable expanded), or an actual trace array
- stistools.wx2d.wavelet_resampling(hdu, img, errimg, original_nrows, nrows, ncols, rows, a2center, a2displ, offset, shifta2, imset, order, subdiv, psf_width, subsampled, convolved)¶
Resample img and errimg using wavelets.
- Parameters:
- hdufits header/data unit object
header/data unit for a SCI extension
- imgndarray
SCI image array (could be a subset of full image)
- errimgndarray
ERR image array (could be a subset of full image)
- original_nrowsint
number of image lines (NAXIS2) in input image
- nrowsint
number of image lines in subset
- ncolsint
number of image columns (NAXIS1)
- rowstuple
tuple giving the slice of rows to process
- a2centerndarray
1-D array of Y locations
- a2displndarray
array of traces, one for each a2center; the length of each trace must be the same as the number of columns in the input image
- offsetfloat
offset of the first row in 'image' from the beginning of the data block in the original file, needed for trace
- shifta2float
offset of the row from nominal (from shifta2 keyword)
- imsetint
number of the current image set (keyword EXTVER)
- orderint
polynomial order
- subdivint
number of subpixels per input pixel
- psf_widthfloat
width of PSF for convolution (e.g. 1.3);
- subsampledstring or None
name of the output file with the subsampled image
- convolvedstring or None
name of the output file with the convolved image
- Returns:
- img_arr: tuple of ndarrays
the image and error arrays (to replace the input img and errimg)
- stistools.wx2d.wx2d(input, output, wavelengths=None, helcorr='', algorithm='wavelet', trace=None, order=7, subdiv=8, psf_width=0.0, rows=None, subsampled=None, convolved=None)¶
Resample the input, correcting for geometric distortion.
- Parameters:
- inputstring
name of input file containing an image set
- outputstring
name of the output file
- wavelengthsstring, optional [Default: None]
name of the output file for wavelengths
- helcorrstring
specify "perform" or "omit" to override header keyword
- algorithm{'wavelet', 'kd'}
algorithm to use in resampling the input
- tracestring or array, or None
trace array, or name of FITS table containing trace(s)
- orderint [Default: 7]
polynomial order (an odd number, e.g. 5 or 7)
- subdivint [Default: 8]
number of subpixels (a power of 2, e.g. 8 or 16)
- psf_widthfloat [Default: 0.]
width of PSF for convolution (e.g. 1.3); 0 means no convolution
- rowstuple, optional [Default: None]
a tuple giving the slice of rows to process; output values in all other rows will be set to zero. The default of None means all rows, same as (0, 1024)
- subsampledstring, optional [Default: None]
name of the output file with the subsampled image
- convolvedstring, optional [Default: None]
name of the output file with the convolved image
- stistools.wx2d.wx2d_imset(ft, imset, output, wavelengths, helcorr, algorithm, tracefile, order, subdiv, psf_width, rows, subsampled, convolved)¶
Resample one image set, and append to output file(s).
- Parameters:
- ftHDUList
Fits HDUList object for the input file.
- imsetint
one-indexed image set number
- outputstring
name of the output file
- wavelengthsstring or None
name of the output file for wavelengths
- helcorr{'perform', 'omit'}
specify "perform" or "omit" to override header keyword
- algorithm{"wavelet","kd"}
algorithm to use to process input
- tracefilestring or array
trace array, or name of FITS table containing trace(s)
- orderint
polynomial order
- subdivint
number of subpixels
- psf_widthfloat
width of PSF for convolution
- rowstuple
a tuple giving the slice of rows to process
- subsampledstring, or None
name of the output file with the subsampled image
- convolvedstring, or None
name of the output file with the convolved image