IFUCubeData
- class jwst.cube_build.ifu_cube.IFUCubeData(input_models, output_name_base, output_type, linear_wave, instrument, list_par1, list_par2, instrument_info, master_table, **pars_cube)[source]
Bases:
objectCombine IFU data onto a regular grid.
- Parameters:
- input_models
ModelContainer Container of multiple
IFUImageModel- output_name_basestr
String defining the name of the output product. Unlike other steps,
cube_builddetermines the name of the output file because the bands of the data are determined after reading in the data. In addition, the name of the output also depend if calwebb_spec2 or calwebb_spec3 is being run and if the user has selected particular band to use.- output_typestr
The type of cube to created. The possibilities are:
'band''channel''grating''multi'
The default for calwebb_spec2 is to create
'multi'band cubes. In the case of MIRI, the'multi'band cubes from calwebb_spec2 contain the two channels from single calibration FITS file. The default type of cube for calwebb_spec3 is'band'. These cubes will contain a single band of data.- linear_wavebool
If true then create a linear wavelength dimension for output cubes. If false then output cubes have a non-linear wavelength spacing. The non-linear spacing is determined by the cube_pars reference file.
- instrumentstr
Instrument name, either “MIRI” or “NIRSpec”
- list_par1list
For MIRI the list contains the channels used to build the IFU, while for NIRSpec the list contains the grating used.
- list_par2list
For MIRI the list contains the sub-channels uses to build the IFU, while for NIRSpec the list contains the filters used.
- instrument_infodict
Dictionary containing information on the basic instrument parameters.
- master_tabledict
Dictionary of containing the files covering each band.
- **pars_cubedict
Dictionary of parameters controlling how the cube is built.
- input_models
Methods Summary
blend_output_metadata(ifu_cube)Create new output metadata based on blending all input metadata.
build_ifucube(cube_wcs)Create an IFU cube.
Perform some quick checks that the type of cube to be produced conforms to the rules.
Determine the filename suffix consisting of channels/sub channels or gratings/filters.
Determine the spatial and wavelength ROI size if IFU covers more than 1 band of data.
Determine the spatial and spectral IFU size for
coord_system=internal_cal.find_closest_wave(iw, w, wavelength_table, ...)Given a specific wavelength, find the closest value in the
wavelength_table.find_ra_dec_offset(filename)For the given filename find the RA and Dec offset to apply.
map_detector_to_outputframe(this_par1, ...)Map detector pixels to the output cube frame.
map_miri_pixel_to_sky(input_model, ...)Loop over a MIRI model and map the detector pixels to the output cube.
map_nirspec_pixel_to_sky(input_model, offsets)Loop over a NIRSpec model and map the detector pixels to the output cube.
offset_coord(ra, dec, raoffset, decoffset)Given a RA, Dec, RA offset, and Dec offset, use
SkyCoordto apply the offsets.set_wcs_slicer(corner_a, corner_b, ...)Set up the size of the cube in the internal IFU plane.
Set up the WCS of the IFU cube.
Methods Documentation
- blend_output_metadata(ifu_cube)[source]
Create new output metadata based on blending all input metadata.
- Parameters:
- ifu_cube
IFUCubeModel IFU cube data model
- ifu_cube
- build_ifucube(cube_wcs)[source]
Create an IFU cube.
Loop over every band contained in the IFU cube and read in the data associated with the band.
map_detector_to_outputframe(): Maps the detector data to the cube output coordinate system.For each mapped detector pixel, find the IFU cube spaxel located in the region of interest. There are two different routines to do this step, both of which use a C extension to combine the detector fluxes that fall within a region of influence from the spaxel center:
src/cube_match_sky*.c: This routine uses the modified Shepard method to determine the weighting function, which weights the detector fluxes based on the distance between the detector center and spaxel center.src/cube_match_internal.cis only for single exposure, single band cubes, and the IFU cube in created in the detector plane. The weighting function is based on the overlap of between the detector pixel and spaxel. This method is simplified to determine the overlap in the along slice-wavelength plane.
jwst.cube_build.cube_lib.find_spaxel_flux(): find the final flux associated witheach spaxel
- Parameters:
- cube_wcs
CubeWCS Data class containing the wcs information of the IFU cube.
- cube_wcs
- Returns:
- cube_model
IFUCubeModel An IFU cube of combined IFU image data.
- cube_model
- check_ifucube()[source]
Perform some quick checks that the type of cube to be produced conforms to the rules.
- Raises:
- IncorrectInputError
Interpolation = area was selected for when input data is more than one file or model
- define_cubename_suffix()[source]
Determine the filename suffix consisting of channels/sub channels or gratings/filters.
The base name is defined by the pipeline. Cube_build determines which channels, bands, gratings, or filters are used to make the IFU cube, so it appends the appropriate suffix to the base name. This function not used to determine the suffix when cube_build is called from calwebb_spec2. In that case, the pipeline attaches ‘s3d’ onto the filename.
- Returns:
- suffixstr
Output suffix for the IFU cube.
- determine_cube_parameters()[source]
Determine the spatial and wavelength ROI size if IFU covers more than 1 band of data.
If the IFU cube covers more than 1 band, then use the rules to define the spatial and wavelength ROI size to use for the cube.
- determine_cube_parameters_internal()[source]
Determine the spatial and spectral IFU size for
coord_system=internal_cal.
- find_closest_wave(iw, w, wavelength_table, rois_table, roiw_table, softrad_table, weight_power_table, scalerad_table, rois_det, roiw_det, softrad_det, weight_det, scalerad_det)[source]
Given a specific wavelength, find the closest value in the
wavelength_table.- Parameters:
- iwint
Index of wavelength array.
- wfloat
Wavelength array of data.
- wavelength_tablendarray
Wavelength array read from CUBEPAR reference file.
- rois_tablendarray
roisarray read from CUBEPAR reference file.- roiw_tablendarray
roiwarray read from CUBEPAR reference file.- softrad_tablendarray
Softrad array read from CUBEPAR reference file.
- weight_power_tablendarray
Weight power array read from CUBEPAR reference file.
- scalerad_tablendarray
Scalerad array read from CUBEPAR reference file.
- rois_detndarray
roisarray of detector pixel for the associated wavelength of the pixel.- roiw_detndarray
roiwarray of detector pixel for the associated wavelength of the pixel.- softrad_detndarray
Softrad array of detector pixel for the associated wavelength of the pixel.
- weight_detndarray
Weight array of detector pixel for the associated wavelength of the pixel.
- scalerad_detndarray
Scalerad array of detector pixel for the associated wavelength of the pixel.
- find_ra_dec_offset(filename)[source]
For the given filename find the RA and Dec offset to apply.
- Parameters:
- filenamestr
Filename that holds the RA and Dec offset to apply
- Returns:
- raoffsetfloat
Right ascension offset value read in from file
- decoffset ; float
Declination offset valuet read in from file
- map_detector_to_outputframe(this_par1, input_model)[source]
Map detector pixels to the output cube frame.
The output frame is on the sky (RA-Dec). This method determines the coordinates of all detector pixels in the output frame, along with arrays for pixel fluxes, errors, and weighting parameters. These values are used downstream to calculate the final flux of a cube spaxel based on the detector pixels falling within its region of interest (ROI).
- Parameters:
- this_par1str
For MIRI, this is the channel number (1, 2, 3, or 4); needed for MIRI to distinguish which channel on the detector we have. For NIRSPEC, this is the grating name.
- input_model
IFUImageModel Input IFU image model to combine.
- Returns:
- coord1ndarray
Coordinate for
axis1in output cube for mapped pixel- coord2ndarray
Coordinate for
axis2in output cube for mapped pixel- wavendarray
Wavelength associated with
`coord1, coord2- fluxndarray
Flux associated with
coord1, coord2- errndarray
Error associated with
coord1, coord2- dqndarray
DQ associated with
coord1, coord2- readvarndarray
Var_rnoise associated with
coord1 coord2- rois_detfloat
Spatial ROI size to use
- roiw_detndarray
Spectral ROI size associated with
coord1,coord2- weight_detndarray
Weighting parameter associated with
coord1,coord2- softrad_detndarray
Softrad parameter associated with
coord1,coord2
- map_miri_pixel_to_sky(input_model, this_par1, offsets)[source]
Loop over a MIRI model and map the detector pixels to the output cube.
The output frame is on the sky (RA-Dec). Return the coordinates of all the detector pixel in the output frame for every valid input pixel from the IFU image model.
- Parameters:
- input_model
IFUImageModel Input IFU image model to combine
- this_par1str
For MIRI, this is the channel number. needed for MIRI to distinguish which channel on the detector we have. For NIRSpec, this is the grating name.
- offsetsdict
Optional dictionary of RA and Dec offsets to apply
- input_model
- Returns:
- x, yfloat
The pixel values on the detector
- ra, decfloat
Detector values mapped to sky
- wavefloat
Wavelength corresponding to pixel
- slice_noint
Slice number of the pixel
- dwavefloat
Delta wavelength covered by pixel
- corner_coordtuple
The corners of the pixel mapped to
ra,dec
- map_nirspec_pixel_to_sky(input_model, offsets)[source]
Loop over a NIRSpec model and map the detector pixels to the output cube.
The output frame is on the sky (RA-Dec). Return the coordinates of all the detector pixel in the output frame for every valid input pixel from the IFU image model.
- Parameters:
- input_model
IFUImageModel Input IFU image model to combine
- offsetsndarray
RA and Dec offsets to apply to each file
- input_model
- Returns:
- x, yfloat
The pixel values on the detector
- ra, decfloat
Detector values mapped to sky
- wavefloat
Wavelength corresponding to pixel
- slice_noint
Slice number of the pixel
- dwavefloat
Delta wavelength covered by pixel
- corner_coordtuple
Rhe corners of the pixel mapped to
ra,dec`
- offset_coord(ra, dec, raoffset, decoffset)[source]
Given a RA, Dec, RA offset, and Dec offset, use
SkyCoordto apply the offsets.- Parameters:
- rafloat
Right ascension coordinate to offset
- decfloat
Declination coordinate to offset
- raoffsetfloat
Right ascension offset to apply
- decoffsetfloat
Declination offset to apply
- Returns:
- raw_newfloat
Right ascension coordinate with offset applied
- dec_newfloat
Declination coordinate with offset applied
- set_wcs_slicer(corner_a, corner_b, lambda_min, lambda_max, cdelt1, cdelt2, cdelt3, linear_wave)[source]
Set up the size of the cube in the internal IFU plane.
This will be a single exposure cube. The internal IFU Cube is in the slicer plane and is defined by along slice and across slice coordinates.
- Parameters:
- corner_andarray
Array of along slice corners of the footprint of all input data.
- corner_bndarray
Array of across slice corners of the footprint of all input data.
- lambda_minfloat
Minimum wavelength value of the data.
- lambda_maxfloat
Maximum wavelength value of the data.
- linear_wavebool
Boolean that holds if the output wavelength plane is linear (True) or non-linear (False).
- Returns:
- CubeWCS
CubeWCS Data class with all WCS parameters set for the internal IFU slicer plane, containing the following attributes:
- naxis1int
Cube pixel dimension along x (across slice for MIRI, across slice for NIRSpec).
- naxis2int
Cube pixel dimension along y (along slice for MIRI, along slice for NIRSpec).
- naxis3int
Cube pixel dimension along wavelength.
- cdelt1float
Pixel scale along x-axis.
- cdelt2float
Pixel scale along y-axis.
- cdelt3float
Pixel scale along wavelength axis.
- crpix1float
Reference pixel along x-axis (0.5).
- crpix2float
Reference pixel along y-axis (0.5).
- crpix3float
Reference pixel along wavelength axis (1.0).
- crval1float
Reference coordinate along x-axis.
- crval2float
Reference coordinate along y-axis.
- crval3float
Reference coordinate at first wavelength bin center.
- cdelt3_normalNone
Not used in slicer mode.
- xcoordndarray
1D array of spaxel center positions along x.
- ycoordndarray
1D array of spaxel center positions along y.
- zcoordndarray
1D array of spaxel center positions along wavelength.
- a_minfloat
Minimum bound of the along slice coordinate.
- a_maxfloat
Maximum bound of the along slice coordinate.
- b_minfloat
Minimum bound of the across slice coordinate.
- b_maxfloat
Maximum bound of the across slice coordinate.
- lambda_minfloat
Adjusted minimum wavelength bound.
- lambda_maxfloat
Adjusted maximum wavelength bound.
- linear_wavebool
Set to False for slicer mode (non-linear wavelength grid).
- CubeWCS
- setup_ifucube_wcs()[source]
Set up the WCS of the IFU cube.
Loop over every datamodel contained in the cube and find the WCS of the output cube that contains all the data.
Notes
If the coordinate system is
internal_cal, then min and max coordinates of along slice, across slice, and lambda (microns).For MIRI, the units along/across slice dimension are arcseconds. For NIRSPEC the units along/across slice dimension are meters.
If the coordinate system is
skyalign/ifualign, then the min and max of RA (degrees), dec (degrees), and lambda (microns) are returned for internal calculations.