Baseline subtraction of Effelsberg HI-Spektra for beginners


Generally the baselines of HI-Spektra are not flat at the beginning. A baseline subtraction can be done within CLASS, a continuum and line analysis single-dish software from IRAM. This simple tutorial brievly tells you how to subtract a baseline from an Effelsberg HI-Spectrum.




Step 1: Converting the data into the CLASS format

First you have to convert the data into the CLASS format. Therefore you need the command drawclass. The program drawclass works only on alpha workstations in Bonn.

> drawclass

Input file name: Filename.tb
Output file name: Filename.eff

The default extension .eff of the output file is not obligatory. You can choose whatever you want, but usually one takes .eff for Effelsberg spectra.


Step 2: Open a file in CLASS

CLASS is started by typing CLASS after the prompt:

> class

You can go back to the UNIX shell without exiting CLASS by typing sys and return to CLASS by typing exit.

LAS> sys
aibn22:/aibn22_1/csteidel/effdaten> exit
LAS>

It is also possible to directly execute a UNIX command within CLASS.
Examples:

LAS> sys ls
LAS> sys "ls -al *.eff"

To open a file within CLASS there is the "file in Filename.eff" command:

LAS> file in Filename.eff

Now you have opened a file, but CLASS doesn't know its content. The command find finds the spectra in the file.

LAS> find
I-FIND, 400 observations found

There are a number of possibilities to limit the number of spectra that are found.
For example: find /number number1 number2

LAS> FIND/NUMBER 1 10
I-FIND, 10 observations found

To get more detailed information type list to list all the individual spectra.

LAS> list


Step 3: Plotting a spectrum with GreG

Plotting your spectrum is done by GreG. GreG is a graphic utility package and the GreG commands can be used within CLASS. In order to plot your spectrum you have to open a display first.
Use the device xa to open a display:

LAS> device xa

A display will be opened in the foreground.

To work with one of the spectra you have to get it. This is done by the get command:

LAS> get spectrum number

Now you can display the spectrum with the plot command:

LAS> plot



As you can see from the picture above there are some artefacts at the edges of the plot. You can confine the plotting range by the "set mode x lower_limit upper_limit" command. CLASS works only on the part of spectrum that is displayed.
In our example this would be:

LAS> set mode x -400 200

The same is possible for the y-axis, but affects only the display of the spectrum. After plotting it again the spectrum will look like:




Step 4: Baseline subtraction of a HI spectrum

Now we are ready for the baseline subtraction. To exclude the emission lines we have to define windows around them. This is done by the command "set window". The coordinates of the windows may be entered numerically as arguments or graphically with the crosshair cursor if "set cursor on" has been selected.
Numerically this is done with the command "set window value_left value_right". Graphically it looks like:

LAS> set cursor on
LAS> set window

After you have typed these two commands you place the cursor on the left side of the signal and press space and repeat this procedure on the right side. A window will be placed around the signal (but you cannot see that window right now!). This procedure may be done several times until all lines are excluded from the spectrum and it will be terminated by typing e (The plotwindow must be active! Not the Xterm!). One can define up to 20 windows.
To see if the windows are placed correctly draw them with the "draw window" command.

LAS> draw window




The "BASE degree of the polynomial" command fits a polynomial to the emission-free parts of the spectrum. In our example we chose a degree of 3 and also plotted the polynomial by attaching "/plot" to our command.

LAS> base 3 /plot





To get the baseline reduced spectrum use the plot command again and you'll get a very nice spectrum :-)



If you do not like the result use the swap command to return to the previous spectrum and repeat the baseline subtraction again.

LAS> swap

CLASS can only keep 2 observations in memory and the swap command swaps them.


Step 5: How to save the baseline reduced spectrum

Till now you have not done any permanent changes to your spectrum. To save your spectrum you have to create an output file first. This is done with the "file out New_Filename.eff new" command:

LAS> file out New_Filename.eff new

The file is created by means of the last argument new. If you want to open an existing file, omit it.
The spectrum can be saved with the write command:

LAS> write

Repeat steps 3-5 with the other spectra. Use the "get next" command to load in the next spectrum:

LAS> get next

or alternatively

LAS> get 2

for the second spectrum, "get 3" for the third spectrum etc. You can also automatize this procedure. To do so open a text editor, for example nedit and write down all the necessary commands:

find /number 1 20
for i 1 to found
get next
base 3
write
next

Save the file and integrate it into CLASS by typing:
LAS> @filename

Of course this only works if the emission lines occur at the same position. You can roughly check this by the stamp command. The stamp command allows you to have a quick look at all the observations. In my case I confined the number of spectra to 20.

LAS> stamp



or by writing another little script:

find /number 1 20
clear plot
box
draw window
for i 1 to found
get next
spectrum 0.2*i
next







Some remarks:

1.
To get a brief description of the CLASS commands type help.

LAS> help command

If this is not sufficient look into the official CLASS Tutorial for some more detailed information.

2.
If you do not want to write the same command over and over again there is a useful command named recall, which brings back the last command you have typed. If you are interested in a specific command you can also use "recall command" to get the last entry where you used that command.

3.
In most cases you don't have to write out the full names of the commands. For example pl instead of plot will be sufficient. If there are any ambiguities CLASS will ask for some more letters:

LAS> set c on
W-SET, Ambiguous keyword, choices are :
CURSOR CHARACTER CALIBRATION

In this case it is sufficient to write only one more letter:

LAS> set cu on

This will give the same result as

LAS> set cursor on




Last modified July 29th, 2002