IFUCubeData
- class jwst.cube_build.ifu_cube.IFUCubeData(pipeline, 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:
- pipelineint
Integer that indicates which pipeline is being run:
2 = calwebb_spec2
3 = calwebb_spec3
- 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.
Methods Summary
blend_output_metadata(ifu_cube)Create new output metadata based on blending all input metadata.
Create an IFU cube.
Build a set of single mode IFU cubes.
Perform some quick checks that the type of cube to be produced conforms to the rules.
Define the base output name.
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.
Depending on the interpolation method, find the flux for each spaxel value.
map_detector_to_outputframe(this_par1, ...)Loop over a file and map the detector pixels to the output cube.
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.Print to log the general properties of the size of the IFU cube.
Set up the final DQ flags.
set_geometry(corner_a, corner_b, lambda_min, ...)Set up the WCS of the cube in the tangent plane.
set_geometry_slicer(corner_a, corner_b, ...)Set up the size of the cube in the internal IFU plane.
setup_final_ifucube_model(model_ref)Set up the final meta WCS info of IFU cube along with other FITS keywords.
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()[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.
find_spaxel_flux(): find the final flux associated with each spaxel
- Returns:
- result
IFUCubeModel An IFU cube of combined IFU image data.
- result
- build_ifucube_single()[source]
Build a set of single mode IFU cubes.
Loop over every band contained in the IFU cube and read in the data associated with the band. Map each band to the output cube coordinate system.
- Returns:
- single_ifucube_container
IFUCubeModel A single type IFU cube datamodel
- single_ifucube_container
- 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()[source]
Define the base output name.
Usually the output name is defined by the association table. However in the case of
cube_build, several cubes can be created from a single call. The user can override the type of data to combine to make a cube. It is left tocube_buildto determine which channels, bands, gratings, or filters are used to make the IFU cube. The final name includes the channel/band (MIRI) or grating/filter (NIRSpec).- Returns:
- newnamestr
Output name of 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
- find_spaxel_flux()[source]
Depending on the interpolation method, find the flux for each spaxel value.
- map_detector_to_outputframe(this_par1, input_model)[source]
Loop over a file 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. In addition, an array of pixel fluxes and weighing parameters are determined. The pixel flux and weighing parameters are used later in the process to find the final flux of a cube spaxel based on the pixel fluxes and pixel weighing parameters that fall within the ROI of spaxel center
- 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- 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_final_dq_flags()[source]
Set up the final DQ flags.
These flags include:
Good data (0)
NON_SCIENCE
DO_NOT_USE.
- set_geometry(corner_a, corner_b, lambda_min, lambda_max)[source]
Set up the WCS of the cube in the tangent plane.
- Parameters:
- corner_andarray
Array of RA corners of the footprint of all input data.
- corner_bndarray
Array of Dec corners of the footprint of all input data.
- lambda_minfloat
Minimum wavelength value of the data.
- lambda_maxfloat
Maximum wavelength value of the data.
- set_geometry_slicer(corner_a, corner_b, lambda_min, lambda_max)[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.
- setup_final_ifucube_model(model_ref)[source]
Set up the final meta WCS info of IFU cube along with other FITS keywords.
- Parameters:
- model_ref
IFUImageModel The first IFU image model to use to fill in basic header values.
- model_ref
- Returns:
- result
IFUCubeModel IFU cube datamodel with data arrays filled in.
- result
- 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.