Automatically processing and fitting CDS data

The routines described below will automatically process CDS data by removing cosmic rays and calibrating, and then allow automatic Gaussian fitting of line profiles. A futher, widget-based routine allows browsing of the fitted data.

WARNING: currently this software is not compatible with sit-and-stare data, or complete NIS spectral data (e.g., NISAT).

The routines described below are available in a tar file.


This routine is called as

IDL> a=readcdsfits('s1000r00')
IDL> auto_process, a, data

the standard CDS calibration routines are applied, leading to 3D arrays for each wavelength window containing intensities and intensity errors, but not wavelengths (see below for more discussion). 

WARNING: if you want to re-process a data-set, you must reload the CDS FITS file with readcdsfits before running auto_process.

The arrays are stored in a structure with the following tags (file s3075r00 is used as an example).

IDL> help,data,/str
** Structure <8503284>, 6 tags, length=1022428, data length=1022428, refs=1:
   PIX             FLOAT     Array[20, 60, 71]
   ERR             FLOAT     Array[20, 60, 71]
   INT             FLOAT     Array[20, 60, 71]
   LBL             STRING    'O_4_553_69'
   BAND            STRING    'NIS2'
   MISS            FLOAT          -100.000

The PIX array stores the X-pixel numbers for each point in the 3D array. These have been corrected for the CDS spectral tilt, and the scan mirror position, and are suitable to be converted to wavelengths by pix2wave. Although these wavelengths represent the absolute wavelengths, one should be careful about using them for velocity analysis - a better method is to set the zero point velocity from averaged spectra.

The INT array has units of erg cm-2 s-1 sr-1 pixel-1, while the ERR array gives the error on the intensity value. ERR has been derived by assuming photon statistics (see CDS Software Note #49).

Pixel binning

For weak lines it is often useful to bin several spatial pixels to improve the S/N. This can be achieved in auto_process as follows:

IDL> auto_process, a ,data, xbin=4, ybin=4

where groups of 4x4 spatial pixels are binned into 1 pixel. Thus for the example above, the spatial dimensions of 60 x 71 are changed to 15 x  17. The error bars on the binned pixels are correctly dealt with,  as are missing pixels.

Automatic line fitting - AUTO_FIT.PRO

After the processing, the fits for a single emission line across the spatial image can be obtained by doing:

IDL> auto_fit, data, output, wind=4, refwvl=629.732

where WIND=4 selects the O V 629.7 window. A reference wavelength is required to convert the line centroid into a velocity. The CHIANTI database has reference wavelengths for virtually all CDS emission lines. Try, e.g.,

IDL> which_line,'o_5', 629

NOTE: by default the routine uses every pixel in the wavelength window for the fit (although missing data such as cosmic rays are automatically discarded). This is OK for an unblended line centred in its wavelength window, e.g., O V 629.7, but not for other lines. See below for information on dealing with more difficult cases.

OUTPUT is a structure with the following tags:

IDL> help,output,/str
** Structure <8524d5c>, 9 tags, length=664568, data length=664566, refs=1:
   INT             FLOAT     Array[60, 71]
   WID             FLOAT     Array[60, 71]
   VEL             FLOAT     Array[60, 71]
   CHI             FLOAT     Array[60, 71]
   WIND            INT              4
   REFWVL          FLOAT           629.732
   LAMBARR         FLOAT     Array[20, 60, 71]
   PIX_MIN1        INT       Array[20, 60, 71]
   AA              FLOAT     Array[5, 60, 71]

The INT, WID, VEL and CHI arrays give the intensity, line width (FWHM), velocity and Chi^2 value at each spatial pixel. LAMBARR gives the wavelength vector at each spatial pixel, while PIX_MIN1 indicates which wavelength pixels were used for the fit at each spatial pixel. AA contains the fit parameters at each spatial pixel.

Case 1: a line lying in two windows

Sometimes observers choose wavelength windows that are directly adjacent to each other in order to get a contiguous piece of spectrum that will aid in line fitting. A line could thus be partly in both windows, or a piece of "good" background needed to fit the line may lie in the neighbouring window.

To combine two windows when using AUTO_FIT, simply do, e.g.,

IDL> auto_fit, data, output, wind=[4,5], refwvl=629.732

where 4 and 5 are the indices for the windows.

Case 2: selecting a sub-region of the wavelength window

Large wavelength windows can contain two or more emission lines, thus you only want to fit the part of the spectrum containing the line you're interested in. This can be done by giving the /CHOOSE keyword. A graphics window will then appear showing the average profile for the specified wavelength window. Click twice with the mouse to select the sub-region that you want to fit.

Case 3: precise selection of pixels for fitting

To precisely specify which pixels are to be included in the fit, one can use the PIXMAP input. For example, if a wavelength window is 40 pixels wide, then one can do

IDL> pixmap=[indgen(5),indgen(12)+15,indgen(6)+32]
IDL> auto_fit, data, output, wind=4, refwvl=629.732, pixmap=pixmap

where only pixels 0:4, 15:26 and 32:37 will be used in the fit.

Viewing the fit parameters - FIT_VIEWER.PRO

A widget-based routine is available to view the results from the fitting, and is called as

IDL> fit_viewer, data, output

The top 3 graphics windows give intensity, velocity and line width maps. They are all clickable with the mouse. The button widget on left-hand side gives the 'mouse mode'. When set to ZOOM, clicking-and-dragging the mouse across the image opens a rubber-band box for zooming into the images. When set to PIXEL, clicking on individual pixels in the images, brings up the line profile in the graphic window in the bottom left corner.

The graphic window in the bottom right shows an intensity histogram for the whole image.

WARNING: Currently the button widgets in the bottom half of the GUI do not work!