7.3. Cubes with an equidistant wavelength grid

Equistant cubes are created with a task that spectrally resamples the flux array of an input cube (and its other data arrays) onto a regular and equidistant wavelength grid. Why do we do this? The wavelength grid created by the pipeline task "wavelengthGrid" and carried from the rebinned cubes to the mosaic cubes (drizzled, projected, and interpolated) is regular but it is not equidistant: the bin sizes scale with the resolution, which in turn scales with the wavelength. This was done so that the spectral sampling was at least Nyquist at all wavelengths in an observation: this is especially important for the long wavelength range observations, although less necessary for short ranges and line scans. Because the mosaic cubes created by the pipeline do not have an equidistant wavelength grid, the third dimension of the WCS is not defined with a set of single values (cdelt3, crpix3, crval3, and ctype3) but are left undefined. Some software has trouble handling this and therefore cannot read PACS cubes directly. For this reason PACS created the "equidistant cubes", which are the three mosaic cubes interpolated on to an equidistant wavelength grid, and these are provided as standalone browse products (see the PPE). These cubes do have the third dimension of the WCS filled in. The equidistant wavelength grid used is based on that of the input cube, but it has smaller bin sizes. In this section we show you how to create equidistant cubes and show plots comparing the equidistant spectra to the standard spectra for a few examples.

7.3.1. Create your own equidistant cubes

Here we show how to create equidistant cubes and compare them to the original cubes. This example follows that given in a HIPE scripts in Scripts→PACS useful scripts→Spectroscopy: Re-create the standalone browse products. We will call the wavelength grid from the first the "equidistant grid" and that from the second the "scaled grid".

Starting from an observation (or the example obsid can be used), extract the Level 2 PacsCubes (HPS3DB), PacsRebinnedCubes (HPS3DRB), and then the cube you want to make equidistant, i.e. the projected, drizzled, or interpolated cube (HPS3D[P|D|I]B; noting that for this example observation there are no interpolated cubes):

obsid=1342187206
obs=getObservation(obsid,useHsa=1)

slicedCubes = obs.level2.blue.cube.product 
slicedRebinnedCubes = obs.level2.blue.rcube.product

slicedProjectedCubes = obs.level2.blue.pcube.product
# Or, to get the drizzled or interpolated cube context
slicedDrizzledCubes = obs.refs["level2"].product.refs["HPS3DDB"].product
slicedInterpolatedCubes = obs.refs["level2"].product.refs["HPS3DIB"].product

To create the equidistant cubes it is necessary to create the wavelength grid using the same task that the original (non-equidistant) wavelength grid of the cubes was created with, some parameters being exactly the same and others being different. This is necessary so that the spectra of the equidistant cube are as much as possible the same as those of the input cube. The parameters for the task wavelengthGrid that need to be the same when creating the equidistant grid are: upsample, oversample, and standardGrid. The former two we get directly from "slicedRebinnedCubes" as shown below, the latter parameter is anyway always True when used in the pipeline (and it is the default value). To learn what these parameters mean, we refer you to the URM entry for "wavelengthGrid" and Section 7.2.

# Query on the meta data to find the values of oversample 
# and upsample used in creation of their the wavelength grid 
slice = 0  # any slice will do
oversample = slicedRebinnedCubes.refs[slice].product.meta["oversample"].double
upsample   = slicedRebinnedCubes.refs[slice].product.meta["upsample"].double

# Set the size of the new bins
frac = 0.5 # let's say you want bins of 50% of the smallest in the input cubes

# Get the calibration tree
calTree = getCalTree()

Create the wavelength grid, and then resample the projected (or drizzled, or interpolated) cube on that grid, e.g.

waveGrid = wavelengthGrid(slicedCubes, oversample=oversample, upsample=upsample,\
 calTree = calTree, regularGrid = True, fracMinBinSize = frac)
slicedProjectedCubes_eq = specRegridWavelength(slicedProjectedCubes,waveGrid) 

The important parameters in the task wavelengthGrid to be used when creating the equidistant grid are the following:

  • fracMinBinSize: this is the fraction by which the smallest bin size of the scaled grid is multiplied to set the bin size of the equidistant grid.

  • fixedBinSizes: to specify fixed bin sizes, enter these with this parameter; since there may be more than one cube in the input sliced cube product, you must specify a line id for each slice using a dictionary, e.g.

    fixedBinSizes={2: 0.02, 3: 0.03}

    sets a bin size of 0.02 micron for lineId=2 and 0.03 micron for lineId=3. The lineId values can be obtained by running the task: slicedSummary(sliced cube product).

  • oversample, upsample: as stated above, their values should be the same as that with which the wavelength grid of the projected (drizzled, interpolated) cubes were created with.

  • regularGrid: should be set to True to have a grid with equidistant bins. If regularGrid is True but neither fracMinBinSize nor fixedBinSizes is specified, then the bin size of the equidistant grid is the minimum bin size of the scaled grid (i.e. fracMinBixSize = 1).

  • standardGrid: set to True to use a scaled grid with standardised starting and ending wavelength points; this parameter is not important for creating a regular grid but the name is similar—do not confuse this with "regularGrid"

Do not be tempted to use the equidistant grid in the pipeline when creating the rebinned cubes, rather than the scaled grid that is the default. Compared to re-sampling cubes at the end of the pipeline, the result is noticeably inferior for all except the narrowest wavelength range observations.

Note that it is not a good idea to apply the task specRegridWavelength to projected cubes created for single pointing observation: these cubes have very many very small spaxels (0.5"), and HIPE can run out of "Java heap space".

7.3.2. Comparison of equidistant with standard cube spectra

Here we show a comparison between a spectrum taken from a projected cube and the spectra from its equidistant counterpart cubes for different values of fracMinPix. In the black curve is the spectrum of the central spaxel from the projected cube with a standard wavelength grid (oversample=2, upsample=4), and in coloured dots are the datapoints from the equidistant version of that same cube with a wavelength grid created with fracMinBinSize of 0.5, 0.35, and 0.25. The top spectrum is an entire range and that below a zoom in on the line. It is clear that all of the equidistant spectra match the shape of the standard spectrum very well.

Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids (fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): a very short rangeScan

Figure 7.5. Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids (fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): a very short rangeScan


Next we show the same plots but for a full SED, using the standard cube (created with oversample=2, upsample=2) and the equidistant cubes with a range of fracMinBinSize values. The plots show parts of the blue, central, and red ranges of the blue camera and red camera data. The largest bin size for the scaled grid for this observation is in the very blue for the blue camera (B2B) and also for the red camera (R1).

Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids (fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): blue part of an SED

Figure 7.6. Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids (fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): blue part of an SED


Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids(fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): red part of an SED

Figure 7.7. Comparison of the spectrum with a scaled grid and the same data interpolated onto different equidistant grids(fracMinBinSize = 0.5: blue; 0.35: red; 0.25: magenta): red part of an SED


It is clear from these plots that even for this SED, the equidistant grid follows the standard grid data very well.

A note of warning, however, about having many, small bins: this can make the data appear to have a resolution greater than it actually has. It must be remembered that these equidistant-grid data are an interpolation of the original data and have a sampling that implies a greater resolution than the data actually have. It is for this reason that the Meta datum "fracMinBinSize" is included with the cubes, so you can work out by how much this is.