### 2 Rapid Introduction to SPECX

Let’s assume you just got your data from the telescope; now you need to look at the data, but don’t want to read the SPECX manual or this one. Then follow these steps, depending on what you want to do. You can learn about the intricacies later. Occasional margin notes, like the one here(3), indicate sections where additional information can be found in the main part of this ‘Cookbook’.

#### 2.1 Start-up

(3.1)

Starting SPECX is simple. All the necessary environment variables should have been setup correctly as part of your Starlink login. You can start SPECX from any directory in which you have write access but for now it’s easier if you start it up in the directory that contains your data. In order to start SPECX type:

% specx

The % sign represents the shell prompt for input; its actual form may be something Unix-y like 3:45|iiwi~|; in this case giving the time and a reminder of the name of the workstation you are logged into.

SPECX will next dump out part of a long introductory text. You might want to read this; if so use the space bar to jump a page at a time. If not, use Control-c to jump to the end. At the end, the system responds with the SPECX prompt:

$>\phantom{\rule{0.3em}{0ex}}>$

mm]1.0in0.015in An Aside
mm]1.0in0.015in
If SPECX complains that it cannot find your data, this is likely if you started SPECX in a directory that does not contain your data, you should exit SPECX (using the command exit), and before restarting up SPECX type e.g.:

or wherever you happen to have stored your data. SPECX will then look for data first in your current directory but then in your data directory (as defined by the DATADIR environment variable).

#### 2.2 Initialization

(3.3.1)

Check, and perhaps set, terminal device, plot device, and hardcopy device. Generally the defaults will be what you want, but it won’t hurt to go through the motions:

$>\phantom{\rule{0.3em}{0ex}}>$ s-t-d     (system default is xw for a Sun workstation such as IIWI)

$>\phantom{\rule{0.3em}{0ex}}>$ s-p-d t   (set to plot on terminal screen)

$>\phantom{\rule{0.3em}{0ex}}>$ s-h-d     (default is Postscript-landscape – shown as ps_l; but note alternatives)

The default state of SPECX is to look for spectra taken with the DAS; if that’s what you want, there is no need to do anything to get it. However, if you have (old) data taken with the AOSC, say, a number of parameters have to be changed. See Section 3.3.1 for this and other additional information on setting up SPECX.

#### 2.3 Looking at spectra

To read in a spectrum (GSD format)(3.4) type (e.g. spectrum 131):

$>\phantom{\rule{0.3em}{0ex}}>$ r-g-d 131

See Section 3.4 for more information, especially if you want to look at map data.

Plot on screen:

$>\phantom{\rule{0.3em}{0ex}}>$ n

Incidentally, DAS spectra do not look very pretty (cf. Figure 8) in most cases at this point until you have done the step described in section 2.5. SPECX under Unix also has a bad habit of leaving the cursor on the plot window.

Change plot scales(3.4.1) with:

$>\phantom{\rule{0.3em}{0ex}}>$ s-p-sc

The x-axis default is velocity; if you want to change it use(3.16.1):

$>\phantom{\rule{0.3em}{0ex}}>$ set-x

and complete the dialog. The basic options are channels, velocity and frequency scales.

#### 2.4 Averaging spectra

To average(3.11.1) three spectra (131, 132 and 133) type:

$>\phantom{\rule{0.3em}{0ex}}>$ r-g-d 131
$>\phantom{\rule{0.3em}{0ex}}>$ r-g-d 132; ave
$>\phantom{\rule{0.3em}{0ex}}>$ r-g-d 133; ave

Plot result, with

$>\phantom{\rule{0.3em}{0ex}}>$ n

Incidentally, note that two or more commands may be placed on one line, separated by semicolons, as shown in this example.

#### 2.5 Dealing with DAS spectra: basics

As described elsewhere, DAS spectra usually (3.10) consist of several overlapping (in frequency/velocity space) sections (or ‘sub-bands’). Except for single sub-band (125-MHz) spectra it is necessary to combine these sub-bands to produce a nice spectrum. This is done with the command das-merge; e.g.:

$>\phantom{\rule{0.3em}{0ex}}>$ r-g-d 131; das-merge

This command removes the large data values at the ends of the subbands, and combines the subbands into one continuous spectum. It is sufficient to take the defaults for most purposes; however, see Section 3.10 for caveats etc. The final spectrum should be free of evidence of sub-band edges, except in pathological cases.

Note that:

• It is not necessary to do the das-merge operation on individual spectra before averaging; the average can be formed first and das-merge applied to the result.
• If you have modified the centre frequency of the previous spectrum (3.16.2) using the s-l-r-f command3 it is necessary to reset the defaults using

$>\phantom{\rule{0.3em}{0ex}}>$ s-l-r-f 0.0

before attempting the das-merge command.

#### 2.6 Sending plots to laser printer

The (3.18) simplest way is to type

$>\phantom{\rule{0.3em}{0ex}}>$ laser

to send the last plot you made on the screen. The Unix version of SPECX creates a plot file called specx_pgplot.ps if you have asked for Postscript files to be made (these are the required type for our normal printer). This plot file will be overwritten every time you issue a new plot command.

To send any other plot directly to the (laser) printer, first change plot device to hardcopy:

$>\phantom{\rule{0.3em}{0ex}}>$ s-p-d h

then open a new plotfile:

$>\phantom{\rule{0.3em}{0ex}}>$ n

and either close the plotfile;

$>\phantom{\rule{0.3em}{0ex}}>$ cl-pl

or open a new plotfile;

$>\phantom{\rule{0.3em}{0ex}}>$ n

or reset the plot device:

$>\phantom{\rule{0.3em}{0ex}}>$ s-p-d t

all of which create the plotfile specx_pgplot.ps. To plot it on the default (local) printer use

$>\phantom{\rule{0.3em}{0ex}}>$ $lp specx_pgplot.ps and if you like this plot enough you can save the Postscript file with $>\phantom{\rule{0.3em}{0ex}}>$$ mv specx_pgplot.ps yourplotfilename.ps

#### 2.7 Saving the results

Data may be written to files, which can contain many spectra, or saved temporarily in storage registers, each of which contains only one spectrum.

To write data to a file, first open one(3.9.1):

$>\phantom{\rule{0.3em}{0ex}}>$ o-fil

and tell SPECX the file name etc4. Each file can be addressed by its name, or a number. A file name has by default the filetype .sdf, which will be added to whatever name you give. Several files may be open at once. To discover a file’s number (you will need this) type:

$>\phantom{\rule{0.3em}{0ex}}>$ l-o-f

Then, to write the current data (that seen with the n command) to (say) file 2 type:

$>\phantom{\rule{0.3em}{0ex}}>$ wr-sp 2

The data are stored in the next available space.

To list the contents of a file type:

$>\phantom{\rule{0.3em}{0ex}}>$ ind-fil

To save the current data in a temporary storage register(3.9.2), type, e.g.:

$>\phantom{\rule{0.3em}{0ex}}>$ st-sp 3

#### 2.8 Retrieving data

To read data from file you must have read (R), or read-write (RW), access. The default state of newly-created files is write-only. l-o-f will tell you the current access. To change the latter enter(3.9.1):

$>\phantom{\rule{0.3em}{0ex}}>$ s-f-a

To read a spectrum (say, number 16, from file 2):

$>\phantom{\rule{0.3em}{0ex}}>$ rea-s 2 16

This places the result in the x-register, from where it is immediately available for plotting or whatever you might have in mind.

To get data from a temporary storage area(3.9.2) (say, 3):

$>\phantom{\rule{0.3em}{0ex}}>$ reca-sp 3

#### 2.9 Fitting and removing baselines

One usually finds that one’s spectral line lies atop some kind of baseline curvature; to display the line to better advantage one fits a linear, polynomial or other function to the line-free regions of the spectrum. It is possible to specify the “fit regions” either by typing in the numbers, or by using the cursor with the plot. The latter is where the interactive mode comes in handy. First type:

$>\phantom{\rule{0.3em}{0ex}}>$ set-int y

Then use(3.7.1)

$>\phantom{\rule{0.3em}{0ex}}>$ r-l-b

to remove a linear baseline from the current spectrum. Define two fitting regions by placing the cursor in the respective positions, and typing l, r, and a (left, right, accept, region) for each. The x-register will contain the result.

To remove a polynomial baseline, type(3.7.2)

$>\phantom{\rule{0.3em}{0ex}}>$ f-p-b

and define a number of regions to which the baseline is to be fitted. If you use the cursor as before, exit the plot screen with an ‘e’ (for ‘exit’). If you supply the fit ranges in non-interactive mode terminate the entries with Control-d.5 Next you will be prompted for the order of polynomial to be fitted. The model fit curve is in the x-register and the original data in the y-register.6

Then to display the fit superposed on the original before subtraction, type, say

$>\phantom{\rule{0.3em}{0ex}}>$ over 1 5

The overlay function expects two numbers – the line width and colour.

Generally you will be confident of the results of your fit, so you can skip the above step. To see the final baseline-subtracted result type

$>\phantom{\rule{0.3em}{0ex}}>$ sub; n

#### 2.10 Making maps

Map files(3.19) (‘datacubes’ to the initiated) consist of a potentially large number of related spectra in one place under a common header. The spectra are taken on a regular spatial grid of points. This, and a few other things, you must tell SPECX before anything else. First create a map file with

$>\phantom{\rule{0.3em}{0ex}}>$ o-map

Give it a name (whatever name you give is automatically appended with the string _map.sdf), tell the system the grid spacing of the observations, and a few other things (answer the questions). Be sure to set the map size to be adequate for your needs, or else you will have to recreate it later. Only one map file may be open at one time.

To place the current spectrum in the map file, use the add-to-map command(3.19.2):

$>\phantom{\rule{0.3em}{0ex}}>$ a-t-m

To overwrite an existing spectrum in the map, first use

$>\phantom{\rule{0.3em}{0ex}}>$ s-m-a

to set map access (or not, as the case may be).

#### 2.11 Displaying Map Data

Several techniques are useful. First, typing(3.19.5)

$>\phantom{\rule{0.3em}{0ex}}>$ gr-sp

will display a set of postage-stamp spectra on the page. You provide a number of parameters defining the plot.

Second, use(3.19.6)

$>\phantom{\rule{0.3em}{0ex}}>$ cont

to obtain a contour plot.

Or, better yet (provided you are working on a Sun workstation or something similar), type(3.19.7)

$>\phantom{\rule{0.3em}{0ex}}>$ gray

to obtain a gray-scale plot. This can be turned into various colour schemes, with a number of options. I suggest you experiment; using the interactive mode is a good way to do this – type ‘h’ within the plot to see the options available – or in non-interactive mode use the command

$>\phantom{\rule{0.3em}{0ex}}>$ set-gray

Finally, either using s-p-d h and sending one of the above commands, or typing see-map, will save the image to a file (e.g. specx_pgplot.ps) suitable for output to the printer.

#### 2.12 Some other things

Any command may be aborted while it awaits input by typing Control-c.

Data may be ‘binned’ (averaged) over n channels by typing

$>\phantom{\rule{0.3em}{0ex}}>$ bin n

and smoothed using

$>\phantom{\rule{0.3em}{0ex}}>$ hann

Several spectra may be plotted on the same frame to good effect by offsetting vertically with respect to one another using

$>\phantom{\rule{0.3em}{0ex}}>$ off-sp

and then using the over command.

One spectrum may be subtracted from another by using

$>\phantom{\rule{0.3em}{0ex}}>$ sub

or divided by another (channel-by-channel) by typing:

$>\phantom{\rule{0.3em}{0ex}}>$ f-q-s

#### 2.13 And now…

This just gets you started. By now you should have learned enough for simple operations. However, like as not you will want more, such as how to build procedures for repetitive operations. So, you will have to read the full introduction to SPECX in this cookbook, or Rachael Padman’s full SPECX manual. Also, experimentation is a good thing; the worst that can happen is a core dump (a large file called core will be created in your directory). You should delete this file if this happens.

3More on this in Section 3.16.2.

4The VMS version of SPECX requires the number of spectra expected in addition; Unix allows the files to be expanded indefinitely.

5SPECX prompts you for an ‘EOF’ (end-of-file); what the Unix-types don’t tell you is that this is a Control-d; it is Control-z under VMS.

6SPECX uses an HP calculator-like stack; the x-register is on the top, and is the one which is always plotted.