Joint Astronomy Centre
Show document only
JAC Home
JCMT
UKIRT
Contact info
JAC Divisions
OMP
Outreach
Seminars
Staff-only Wiki
Weather
Web Cameras
____________________

JCMT home
Observing at JCMT
OMP Observation Manager
Telescope
Spectral Line Observing
Continuum Observing
Schedule
Data Archive
Future Developments
Legacy Surveys
Newsletter & Publications
First Steps

First Steps in Reducing an ACSIS Cube

The routines and methods required to reduce a raw ACSIS data cube are described in this section. Most of these steps are also carried out by the ORAC-DR data reduction pipeline (both the offline and telescope versions). If you do not have ORAC-DR available on your machine then you can download it from the Starlink download page here.

Visualising the time series cube

The GAIA data visualisation package handles 3D cubes. To visualise any image (2D or 3D) place the file name after the gaia command:
> gaia temp.sdf &
The ampersand runs the program in the background allowing you access to the command line. Loading a time-series cube into GAIA will give something like the following:

GAIA window
This example shows a HARP time series giving the response of the receptors (x-axis) as a function of time (y-axis). Note that at the time this cube was taken, 3 of HARPs receptors were not functioning. Simply by clicking onto a pixel on the image, the spectrum recorded at that time for that receptor will pop-up:

GAIA spectrum plot window

The red line running down the window is not an artifact. Grab it with the cursor and move it around - see what happens?

Masking bad receptors

There will be times when you will want to mask out bad receptors from your analysis. This may be due to a poorly performing HARP receptor or because of poor baselines in your data. It is best to remove these bad receptors from the data before you begin your analysis. In the example above, an image of the time series is shown, giving the response of each receptor as a function of time. We can set all data from a particular receptor to be BAD using the chpix command in KAPPA:
> chpix in=file_in out=file_out section="',8:8,'" newval=bad 
or
> chpix in=file_in out=file_out section=\',8:8,\' newval=bad 
Note the use of the \ to prevent the shell from interpreting the quote symbols when entering this in the command line. This command should now have set receptor number 8 (or H07) to be "switched off" and all future data reduction should ignore the information from that receptor. To switch off other receptors, repeat the command with the new receptor number. Of course, if the receptors are contiguous then you can put them into the same command. So, to mask out receptors 7 and 8:
> chpix in=file_in out=file_out section="',7:8,'" newval=bad 

It is also possible to use the chpix command to mask out certain sections of the time series of a certain receptor. Time is stored in the third dimension of the data structure (note that this is only relevant for the time series cubes). Perhaps you notice that something went awry with the receptor 5 for just one jiggle pattern (say, time steps 17 to 32 of a 16-point jiggle). To mask out just this section of the time series the command should be:

> chpix in=file_in out=file_out section="',5:5,17:32'" newval=bad 
Other ways to identify bad receptors are discussed under Advanced Methods.
Combination of several maps with masked pixels (or how to omit unmasked receptors) is discussed at the bottom of the next section.

Making a cube

To convert the information from the time series cube into a 3D cube of spatial and spectral dimensions you need to run the SMURF command makecube. For example:
 > makecube a20070113_00022_00_0001.sdf autogrid=true

   Projection parameters used:
      CRPIX1 = 0
      CRPIX2 = 0
      CRVAL1 = 51.3958333333333 ( RA = 3:25:35.0 )
      CRVAL2 = 30.75 ( Dec = 30:45:00 )
      CDELT1 = -0.00166666666666667 ( -6 arcsec )
      CDELT2 = 0.00166666666666667 ( 6 arcsec )
      CROTA2 = 0

   Output cube pixel bounds: ( -57:60, 4:58, -1024:1023 )

Weights cannot be determined for the input spectra.
Each output spectrum will be an unweighted sum of the input spectra.

   Output cube WCS bounds:
        Right ascension: 3:25:07.3 -> 3:26:02.3
        Declination: 30:45:15 -> 30:50:45
        Radio velocity (USB): -429.1489 -> 437.7256 km/s

OUT - Output NDF data structure > tempcube1
By specifying autogrid=true, the software will attempt to calculate the optimal projection parameters when the image is regridded. This usually works well for grid and jiggle observations but it's a good idea to always check the numbers reported (the CRDELT1 and CRDELT2 values shown above).

For raster maps, the current advice is that this option should be set to false. When doing so then you should provide the pixel scale as a command line argument. For example,

 > makecube a20070113_0022_00_0001.sdf autogrid=false pixsize=7.3 out=tempcube1 
The files produced can be several hundred MB in size (this is especially true for large rasters). To try to minimise disk space usage and, more importantly, processing time, there is an important parameter within makecube which allows you to select just a specific region in velocity space. For instance, if you know that your line will lie close to 0 km/s and will not be exceedingly broad, then you may choose to only process the central 200 km/s, say. You can do this with the specbounds paramter:
> makecube a20070113_00022_00_0001.sdf specbounds=\"-100.0 100.0\" autogrid=false 
out=tempcube1
In the example here, there are 3 subscans from a single raster observations. They can be reduced into a single cube by specifying all three time series cubes. On the command line this can be done with:
> makecube "a20070113_00022_00_000[1-3].sdf" specbounds=\"-100.0 100.0\" autogrid=false
out=tempcube
Note how the various delimeters had to be escaped on the command line with the \. Note also how the construct <filename>_000[1-3] means that the last integer is cycled through the range given within the square backets. This has the effect of sending all three files with suffixes _0001, _0002 and _0003 into the makecube program for processing together. The final result is the complete raster written to the file tempcube.

The output cube can be plotted in GAIA for inspection. Note that the pop-up window has a number of tabs which allow the user to manipulate the data in various ways. Click on the Help button on the top-right corner of this window to get a description of what each does. Most of the functionality is described in this cookbook. Click anywhere on the image to reveal the spectrum at that position.

Coadding a list of maps

One can coadd different maps by editing an ASCII file filelist.txt with a list of filenames and then e.g.
> makecube in=^filelist.txt specbounds=\"-100.0 100.0\" autogrid=false
out=tempcube
The KAPPA command
> provshow tempcube
will give a list of the files which were used to create a particular data cube.

filelist.txt should be of the format:
(path)file1.sdf
(path)file2.sdf
...
(path)lastfile.sdf
where (path) is the location of the files when they are not in the current directory.

Parameter detectors

If one would like to make a cube where a receptor appears to be bad, but without masking it one can use the detectors parameter:
> makecube in=a20070113_00022_00_0001.sdf autogrid=true out=tempcube detectors='"-H04,H10"'
would make a map using all receptors, except H04 and H10.
Similarly,
> makecube in=a20070113_00022_00_0001.sdf autogrid=true out=tempcube detectors='"H10"'
would make a map using only receptor H10.

Parameter badmask

When combining several maps with masked receptors one can use the badmask parameter of makecube. The best is to use 'badmask=AND', but for large datasets the memory requirements will be excessive in this case. Then it is better to use 'badmask=OR' (which is the default). Using 'badmask=FIRST' means that the decisions on which pixels will be flagged as BAD will be made with the first input spectrum (the rest are ignored).

Gridding options in makecube

There are several re-gridding options available to the user through the makecube command. These are specified with the spread parameter on the command line. To see the complete list of regridding options type the following into the command line:
 > smurfhelp makecube para spread 
The default method is Nearest which assigns the input pixel completely to the nearest output pixel. This is the fastest method available. There are a number of other methods available including Gauss and Sinc which spread the emission to neighbouring pixels (you will need to provide the size of the convolution function through the PARAMS parameter). These methods are useful in the case of e.g. HARP raster maps which contain holes because of bad receptors (which are not filled if the method Nearest is used).

Generating variance

There is a genvar parameter within makecube which allows you to generate a variance array for your cube. This array can be displayed with GAIA. There are three options for genvar:

spread - the variance values generated are based on the spread of input data values which contribute to each pixel. Multiple passes over the same region would be required for this to be effective. At least 3 input pixels are required to generate an ouput variance value. If only one pixel contributes to the output then the associated variance will be set to BAD.

Tsys - the output variance is calculated based on the system noise temperature.

None - no variance values are generated.

The default behaviour is to use Tsys.
When using spread, one also must use badmask=and and use not spread=nearest (but instead e.g. spread=linear .
Note that in older data (before early 2007) the off exposure time is missing in the header and makecube cannot (yet) generate variance from Tsys. In those cases there will be a message
 Weights cannot be determined for the input spectra.
Each output spectrum will be an unweighted sum of the input spectra.

Sparse array

If one has observed a number of offset positions which are not on a regular grid or are widely spaced, it is of little use to make a normal cube with makecube, which then would have a large size and which would be mostly empty. Then one can use the makecube parameter Sparse, which will make a sparse array (when set to true). See
 > smurfhelp makecube para sparse 
This is a one dimensional array where spectra are displayed by GAIA in the order where they were observed (from left to right).
Positional information of all spectra is in the WCS header, and an sdf file with a sparse array can be combined with a normal cube using wcsmosaic - one of its uses is to fill holes in maps.
At the moment (20071121) spectra in sparse arrays are not yet coadded by makecube, so it contains all e.g. 1 second spectra of e.g. 30 seconds integrations. Hopefully this will be changed soon.

Compressing the data

As well as carefully selecting the spectral range for producing cubes, another method for saving on processing power is to bin up the data before running makecube. This can be done using the KAPPA command, compave, which will bin up data along a given axis.
For example, to bin up the spectral axis by a factor of 3 you would type into the command line:
> compave a20070113_00022_00_0001.sdf compress=\[3,1,1\] out=test
Note that the first dimension is the spectral axis in the time-series cube. It becomes the third axis after the makecube command re-grids the time-series data into a spatial grid.
A cube which has been both compressed and had spectral bounds truncated will occupy much less disk space and memory. Of course, if you are looking for small discrete lines or require the highest spectral resolution, compressing the spectral dimension may not be appropriate for your needs.
The image below shows the result of compressing and truncating the spectral axis of a cube observed as part of a raster map.
Compressed & truncated cube in GAIA

The spectrum in the cube now spans from -100 to +100 km/s. Note that the blue cross on the image indicates the location of the spectrum shown in the pop-up window. Grab that cross with the mouse and see what happens!

Rebinning the spectrum

There is a KAPPA command, sqorst, which will allow you to rebin a spectrum (whether a 1-D spectrum or 3-D spectral cube) to a specific resolution.
 > sqorst in=tempcube mode=pixelscale axis=3 pixscale=5 out=tempcube_sqorst5 
This will rebin a 3-D cube along its spectral axis (axis=3). In the example shown above the input spectrum is rebinned so that it's resolution element is 5 km/s (pixelscale=5). The figure below shows a before and after comparison. A comparison of the spectral binning feature of the SQORST command

Removing the baseline

Noise on images may be due to varying or bad baselines. The baselines in a cube can be fitted to and removed using the mfittrend command in KAPPA. Note that it is also possible to do this within GAIA, in an interactive manner, by selecting the Baseline tab in the Image sections window.

The mfittrend routine will fit a polynomial (up to 15th order) to all lines of data along a chosen axis. The fits can be restricted to selected regions so that lines of emission (or absorption) can be avoided. Fits are then extrapolated and interpolated across the whole spectral region in the cube. The resultant baselines can be removed from the input cube, or stored as a seperate cube and removed later. The default behaviour is for the baseline cube to be written to disk and not subtracted (which will give you the freedom to undo your actions if necessary).
> mfittrend test2.sdf ranges=\"-90 -30 30 90\" order=1 axis=3 out=baseline
 Fitting NDF axis 3, using pixel ranges:
-72 : -24
22 : 70

> sub test2 baseline test3
In this example, a straight line was used to perform the baseline fits along the spectral dimension (axis=3), fitting to the velocity range given in the ranges parameter. The resultant basline cube is written out and in the next line is subtracted from the input cube.

The image below shows a before-after comparison of baseline removal for a single plane within an ACSIS cube. The top image is that before baseline removal and the image below is after the baselines have been removed.

Example of baseline removal

Note on 1x1 "cubes"

If your data was collected with either RxA or RxW, then it is likely that you do not have real cubes but just single, pointed observations of spectra. Up to this point the data reduction has still been appropriate for such so-called 1x1 "cubes". The rest of this section will now be more specific for properly 3D cubes. Going ahead to the section on SPLAT and GAIA is likely to be more appropriate for those with single spectra.

Mosaicing cubes

If more than one time series cube is passed to makecube, then those cubes will be mosaiced together. This has the advantage of not generating many intermediate cubes, but has the disadvantage of using up lots of your computer's processing power. In the example given above for making a cube , three subscans were passed to makecube to create a single cube. The principle is the same for passing different raster maps of neighbouring fields. As the next step, you should remove the baselines from this cube following the procedure above.

The alternative is to use wcsmosaic for putting cubes together,
> wcsmosaic 'tempcube_base*' 
REF - The reference image /!/ >
LBND - Lower pixel index bounds for output image /[-118,-57,-237]/ >
UBND - Upper pixel index bounds for output image /[61,57,236]/ >
  Using sincsinc binning kernel.
OUT - Output image > tempcube_base
The resultant image when viewed in GAIA is shown below. LBND and UBND are pixel bounds for the resultant image which the software will calculate itself. Just accept these to get back all the data. If you wish to make further truncations to the output mosaic you can do so here by adjusting these bounds.

wcsmosaic result
Whichever method you use, you should now be in a position to create data cubes from your ACSIS data.

<Back to Contents>

Contact: Per Friberg. Updated: Thu Feb 14 15:33:16 HST 2008

Return to top ^