Converting to CLASS format


To run the GILDAS software (CLASS, GREG, etc) in Hilo or at JCMT first type (or enter this in your .login file):

setenv GAG_ROOT_DIR /jcmt_sw/CLASS/GILDAS

setenv GAG_EXEC_SYSTEM x86_64-redhat6.9-gfortran

source $GAG_ROOT_DIR/etc/login

The latest installed version (February 2018c) can be reached at all 64-bit machines in Hilo and at the JCMT on pueo and ulili.

If you prefer to use CLASS and other Gildas software to reduce your spectra these are the steps to take.

The following assumes that you are using the most recent release of the Starlink and GILDAS software.

If you plan to convert reduced FITS files from the CADC archive, see the bottom of this page.

Converting single spectra

First make cubes of the ACSIS data with makecube or ORAC-DR. Note that in some cases (e.g., comet data) the coordinate system is not standard and it might be necessary to add system=’FK5′ to the end of this command to ensure proper conversion. Also note that the default projection parameters may not be suitable so it might be necessary to add autogrid=true (as below) or specify the parameters CROTA, PIXSIZE, REFLAT and REFLON directly — see the makecube manual for more details of these parameters.

makecube file.sdf file-cube.sdf autogrid=true

Then extract subcubes of dimension 1,1,nspec from the cubes in NDF format and convert these to FITS format.

This can be done with the kappa command ndfcopy and the convert command ndf2fits.

If you have multi-subsystem observations, where the first subband is in LSB (USB) and another is in USB (LSB), you have to change the sideband in the header of the USB (LSB) cube:

kappa

wcsattrib file.sdf set sideband USB (LSB)

The simplest ways to convert .sdf files to FITS format for Namakanui, RxA3 and RxW (single spectra):

convert
ndf2fits file.sdf file.fits encoding=”fits-class”

For certain mapping dataset obtained with RxA3, Namakanui or HARP, in order to retain correct spectral units, one might need to follow these steps to extract one single spectrum. The usage of section might be necessary. For example, to extract a spectrum from position (1,1) in a map:

kappa
ndfcopy in=’file(1,1,)’ out=fileout.sdf exten
./cubecopy fileout.sdf file_cc.sdf

convert
ndf2fits file_cc.sdf file.fits encoding=”fits-class”

The parameter exten in ndfcopy extracts header arrays (e.g. Tsys, Trec, exposure time) correctly when copying the cubes.
Cubecopy copies the cube and updates the median values of the FITS header parameters MEDTSYS, EFF_EXP, and EFF_TIME.

Converting maps

To convert maps one needs to do this for all positions in the map.
At the bottom of this page is an alternative method where however some header information is lost.

This is an example of a csh script that finds the dimensions of a cube and extract all spectra:
fitsfiles (Use: ./fitsfiles ndffilename)

To CLASS

These files can be converted into class format

%class

LAS90>file out jcmtdata mul (or sin)

LAS90>fits read file.fits

(or alternatively)

LAS90>fits read “/dir/subdir/file.fits”

LAS90>write n

(note: if the scannumber is missing in the fits header one needs to give a number when writing to the output file, or it will be put to 1)

If you have large maps it is useful to do the conversion to class format with a commandfile, e.g.

%ls *.fits > files.class

and then edit files.cfits with your favourite editor from

file.fits

to

fits read file.fits

write 1

etc

then

%class

to start CLASS

LAS90>@files.class

Problems

Currently there are some problems with the FITS files converted in this way.
Some header variables don’t have the expected name in the FITS files.
To correct this, enter in CLASS before reading the file:

LAS90> sic\symbol OBSNUM SCAN-NUM
LAS90> sic\symbol NSUBSCAN SUBSCAN
LAS90> sic\symbol MEDTSYS TSYS
LAS90> sic\symbol EXP_TIME OBSTIME
LAS90> sic\symbol LINE NOTAKEY
LAS90> sic\symbol MOLECULE LINE

Note:
The SCAN number is missing (and put to 1 by class) when the ACSIS spectrum is the sum of many spectra; the CLASS parameter NUMBER remains 0.

There is a FITS keyword LINE, but it is empty (CLASS LINE is part of MOLECULE).
The FITS keyword OBSID (present when the spectrum is from a single observation) causes a warning for unknown reasons.
The FITS spectrum may contain an extension image with the variance which causes a warning. If this is a problem it can be removed with a KAPPA command from the sdf file, e.g. erase file_cc.sdf.variance

Other header parameters which are missing are:

tau (not calculated for ACSIS data)
weather parameters
beameff
forweff

All class spectra will have the observed position in the header
(offsets are 0 0 for every position in a map).
So in class one may want to modify the positions:
In order to do that one has to modify the projection to ‘radio’ (7).
set var pos write
let proj 7
modi pos hh:mm:ss.ss dd:mm:ss

Converting cubes

It is possible to convert a FITS format cube to a GDF file and extract CLASS format spectra from the GDF file.
One can use the CLASS commandfile jcmt2class.class after converting the SDF file to FITS format:

convert
ndf2fits cube.sdf cube.fits
%class
LAS90>@jcmt2class cube.fits

This will make a GDF file cube.gdf and a file cube.jcmt with the CLASS format spectra (it uses the CLASS command lmv to extract the spectra from the cube).
However the system temperature and integration time in the CLASS headers are the median values within the cube. If one needs exact values for these parameters the earlier described method has to be followed.

Note

Because of the limitations of the CLASS headers, observations made with very large radial velocities will have incorrect velocities and velocity resolutions in CLASS. It is recommended in such cases to observe with a calculated sky frequency and velocity 0 km/s.

This can also be reached using Starlink Kappa commands (before converting to CLASS):

Kappa
wcsattrib file.sdf set RestFreq frequency
wcsattrib file.sdf set SourceVel 0.0

where frequency is the rest frequency corrected for the assumed radial velocity (default is LSR velocity) of the source.

Reduced archive data

When converting reduced FITS files obtained from the CADC archive first convert the FITS file to NDF format:

Convert
fits2ndf file.fits file.sdf

Then proceed as explained above.

Comments are closed.