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: object

Combine IFU data onto a regular grid.

Parameters:
pipelineint

Integer that indicates which pipeline is being run:

input_modelsModelContainer

Container of multiple IFUImageModel

output_name_basestr

String defining the name of the output product. Unlike other steps, cube_build determines 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.

build_ifucube()

Create an IFU cube.

build_ifucube_single()

Build a set of single mode IFU cubes.

check_ifucube()

Perform some quick checks that the type of cube to be produced conforms to the rules.

define_cubename()

Define the base output name.

determine_cube_parameters()

Determine the spatial and wavelength ROI size if IFU covers more than 1 band of data.

determine_cube_parameters_internal()

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.

find_spaxel_flux()

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 SkyCoord to apply the offsets.

print_cube_geometry()

Print to log the general properties of the size of the IFU cube.

set_final_dq_flags()

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.

setup_ifucube_wcs()

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_cubeIFUCubeModel

IFU cube data model

build_ifucube()[source]

Create an IFU cube.

  1. Loop over every band contained in the IFU cube and read in the data associated with the band.

  2. map_detector_to_outputframe(): Maps the detector data to the cube output coordinate system.

  3. 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:

    1. 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.

    2. src/cube_match_internal.c is 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.

  4. find_spaxel_flux(): find the final flux associated with each spaxel

  5. setup_final_ifucube_model()

Returns:
resultIFUCubeModel

An IFU cube of combined IFU image data.

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_containerIFUCubeModel

A single type IFU cube datamodel

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 to cube_build to 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

rois array read from CUBEPAR reference file.

roiw_tablendarray

roiw array 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

rois array of detector pixel for the associated wavelength of the pixel.

roiw_detndarray

roiw array 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_modelIFUImageModel

Input IFU image model to combine.

Returns:
coord1ndarray

Coordinate for axis1 in output cube for mapped pixel

coord2ndarray

Coordinate for axis2 in 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_modelIFUImageModel

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

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_modelIFUImageModel

Input IFU image model to combine

offsetsndarray

RA and Dec offsets to apply to each file

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 SkyCoord to 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

print_cube_geometry()[source]

Print to log the general properties of the size of the IFU cube.

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_refIFUImageModel

The first IFU image model to use to fill in basic header values.

Returns:
resultIFUCubeModel

IFU cube datamodel with data arrays filled in.

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.