reconstruct_ifu – Reconstruct the IFU image¶
Reconstruct the IFU
-
exception
pyhetdex.het.reconstruct_ifu.ReconstructError[source]¶ Bases:
ExceptionGeneric reconstruction error
-
exception
pyhetdex.het.reconstruct_ifu.ReconstructIOError[source]¶ Bases:
pyhetdex.het.reconstruct_ifu.ReconstructError,OSErrorError when the name and/or number fiber extracted file names is not correct
-
exception
pyhetdex.het.reconstruct_ifu.ReconstructIndexError[source]¶ Bases:
pyhetdex.het.reconstruct_ifu.ReconstructError,IndexErrorError for miss-matching the number of fibers in the ifu center files and the fiber extracted ones
-
exception
pyhetdex.het.reconstruct_ifu.ReconstructValueError[source]¶ Bases:
pyhetdex.het.reconstruct_ifu.ReconstructError,ValueErrorErrors for wrong combinations of input parameters in
ReconstructedIFUorfrom_files()
-
class
pyhetdex.het.reconstruct_ifu.QuickReconstructedIFU(ifu_center, dist_l=None, dist_r=None, pixscale=0.25)[source]¶ Bases:
objectQuick reconstructed IFU head image from a set of frames given the
ifu_centerand some reference distortion files.Parameters: - ifu_center : instance of
IFUCenter fiber number to fiber position mapping
- files : string
Basefilename of the image to be reconstructed, or a tuple of three images to reconstruct a complete dither.
- dist_l, dist_r : string
Distortion file for the left and right spectrograph; at least one of them must be provided
- pixscale : float, optional
pixel scale
Raises: - ReconstructValueError
if an empty dither is passed and
fextractisNone- ReconstructIOError
if the number and/or number of fiber extracted frames is not correct; raised by
_fedict()- ReconstructIndexError
if the number of fibers from the fiber extracted files and from the ifu center files do not match; raised by
_reconstruct()
Attributes: -
_get_overscan(img, biassec)[source]¶ Extract the sigma clipped mean of the overscan region
Parameters: - img : instance of
numpy.array Input image data
- biassec : list
List or tuple with the ranges of the bias section. Use :func:_section_to_list to convert the header BIASSEC keyword to a python list
- img : instance of
-
_load_dists(dist_l, dist_r)[source]¶ Load the distortion files into
distsParameters: - dist_l, dist_r : string
Distortion file for the left and right spectrograph; at least one of them must be provided
-
_load_ifu_center(ifu_center)[source]¶ Load the IFUcen file
Parameters: - ifu_center : instance of
IFUCenter fiber number to fiber position mapping
- ifu_center : instance of
-
_min_max()[source]¶ Compute the minimum and max x and y positions from the ifu center file and save them in
maxx,minx,maxy,miny.
-
_section_to_list(sec)[source]¶ Convert a header section string of the form [x1:x2,y1:y2] to a list of integers
Parameters: - sec : str
The header section string
-
reconstruct(files, subtract_overscan=True, do_not_scale_image_data=False)[source]¶ Read the files and create a reconstructed image.
Parameters: - files : list
name of the files to use
- subtract_overscan : bool
If the overscan region is still present in the image, subtract the bias level, calculated from the overscan region of the image.
- do_not_scale_image_data : bool
If True, image data is not scaled using BSCALE/BZERO values when read.
Returns: - img : nd-array
reconstructed image; it is also stored in the
imgattribute
-
write(filename)[source]¶ Write the reconstructed image to file
filenameas using the fits formatParameters: - filename : string
name of the output fits file
-
pscale¶ Pixel scale
Warning
changing the pixel scale with invalidate the reconstructed image
- ifu_center : instance of
-
class
pyhetdex.het.reconstruct_ifu.ReconstructedIFU(ifu_center, dither, fextract=None, fe_prefix='')[source]¶ Bases:
objectReconstructed IFU head image from the fiber extracted frames given the
ifu_centerand thedither.Parameters: - ifu_center : instance of
IFUCenter fiber number to fiber position mapping
- dither : instance child of
_BaseDither dither relative position, illumination, image quality
- fextract : None or list of fits files, optional
- if None the list of files is inferred from
dither.basename; - if not None must have
nditherxnchannelselements. The channel name and dither number are extracted from theCCDPOSand theDITHERheader keywords
- if None the list of files is inferred from
- fe_prefix : string, optional
when getting the names from the dither file, prepend
fe_prefixto thebasename
Raises: - ReconstructValueError
if an empty dither is passed and
fextractisNone- ReconstructIOError
if the number and/or number of fiber extracted frames is not correct; raised by
_fedict()- ReconstructIndexError
if the number of fibers from the fiber extracted files and from the ifu center files do not match; raised by
_reconstruct()
Attributes: - ifu_center
- dither
- x, y : 1-dimensional arrays
x and y position of the fibers
- flux : list of 2-dimensional arrays
each element is the content of one fiber extracted file
- header : list of dictionaries
each element contains the
CRVAL1andCDELT1keywords :value pairs from the headers of the fiber extracted files; used to determine the wavelength range inreconstruct()
-
_fedict(fextract)[source]¶ Organize the fiber extracted file names into a dictionary
Parameters: - fextract : None or list of string
If None get the file names from the dither, otherwise from the fextract list
Returns: - dfextract : dict
dictionary of fiber extracted frames
-
_reconstruct(dfextract)[source]¶ Read the fiber extracted files and creates a set of three lists for x, y and flux.
Parameters: - dfextract : dictionary
name of the fiber extracted file
-
classmethod
from_files(ifu_center_file, dither_file=None, fextract=None, fe_prefix='')[source]¶ Read and parse the file
Parameters: - ifu_center_file : string
file containing the fiber number to fiber position mapping
- dither_file : string, optional
file containing the dither relative position. If not given, a singe dither is assumed
- fextract : None or list of fits files, optional
if None the list of files is inferred from the second column of the
dither_file; if not None must havenditherxnchannelselements. The channel name and dither number are extracted from theCCDPOSand theDITHERheader keywords- fe_prefix : string, optional
when getting the names from the dither file, prepend
fe_prefixto thebasename
Raises: - ReconstructValueError
if both
dither_fileandfextractareNone- ReconstructValueError, ReconstructIOError
as in
ReconstructedIFU
Notes
if
dither_fileis None,fextractmust contain a number of files equal to the number of channels (2)
-
reconstruct(wmin=None, wmax=None)[source]¶ Returns the reconstructed IFU with the flux computed between [
wmin,wmax]Parameters: - wmin, wmax : float, optional
min and max wavelength to use. If
None: use the min and/or max from the file
Returns: - x, y : 1d arrays
x and y position of the fibers
- flux : 1d array
flux of the fibers within
wminandwmax
- ifu_center : instance of