sflip -- Flip data and/or dispersion coordinates in spectra
sflip input output
The dispersion coordinate system and/or the data in the spectra specified by the input list of images are flipped and stored in the matching output image given in the output list of images. If the output image list is left blank or an output image name is the same as an input image name then the operation is done so that the flipped spectra in the image replace the original spectra. All of the supported spectrum types are allowed; one dimensional images, collections of spectra in multispec format, and two and three dimensional spatial spectra in which one axis is dispersion. In all cases the flipping affects only the dispersion axis of the image as specified by the DISPAXIS header keyword or the "dispaxis" parameter. The parameters coord_flip and data_flip select whether the coordinate system and data are flipped. If neither operation is selected then the output spectra will simply be copies of the input spectra.
Flipping of the coordinate system means that the relation between "logical" pixel coordinates (the index system of the image array) and the dispersion and physical coordinate systems is reversed. The dispersion coordinate of the first pixel in the flipped spectrum will be the same as the dispersion coordinate of the last pixel in the original spectrum and vice-versa for the other endpoint.
Flipping of the data means that the order in which the pixels are stored in the image file is reversed along the image axis corresponding to the dispersion.
While flipping spectra seems simple there are some subtleties. If both the coordinate system and the data are flipped then plots of the spectra in which the dispersion coordinates are shown will appear the same as in the original spectra. In particular the coordinate of a feature in the spectrum will remain unchanged. In contrast flipping either the coordinate system or the data will cause features in the spectrum to move to opposite ends of the spectrum relative to the dispersion coordinates.
Since plotting programs often plot the dispersion axis in some standard way such as increasing from left to right, flipping both the dispersion coordinates and the data will produce plots that look identical even though the order of the points plotted will be reversed. Only if the spectra are plotted against logical pixel coordinates will a change be evident. Note also that the plotting programs themselves have options to reverse the displayed graph. So if all one wants is to reverse the direction of increasing dispersion in a plot then physically flipping of the spectra is not generally necessary.
Flipping of both the coordinate system and the data is also equivalent to using an image section with a reversed axis. For example a one dimensional spectrum can be flipped in both dispersion coordinates and data pixel order by
cl> imcopy spec1[-*] spec2
Higher dimensional spectra need appropriate dimensions in the image sections. One advantage of sflip is that it will determine the appropriate dispersion axis itself.
In the following the spectra can be one dimensional, multispec, long slit, or spectral data cubes.
cl> sflip spec1 spec1f # Flip data to new image cl> sflip spec1 spec1 # Flip data to same image cl> sflip spec1 spec1f coord+ data- # Flip coordinates and not data cl> sflip spec1 spec1f coord+ # Flip both coordinates and data cl> sflip spec* f//spec* # Flip a list of images
imcopy, scopy, dispcor, sapertures