7 Environment variables

 7.1 Surf environment variables
 7.2 Other useful environment variables

The behaviour of Surf can be modified by the use of environment variables.

7.1 Surf environment variables

This section describes environment variables that are spcific to Surf. Surf has variables for determining the location of the data (DATADIR and SCUBA_PREFIX)6 and the behaviour of the automatic filenaming system (SCUBA_SUFFIX).

7.1.1 DATADIR

DATADIR can be used to specify an alternative location for the raw data. This means that users do not need to make multiple copies of the demodulated data files (for example, at the JAC support scientists access the data archive directly and never take their own copies) and saves disk space.

As an example, at the JAC, to access demodulated data taken on the 30th October 1997 all that is needed is

  % setenv DATADIR /scuba/observe/19971030/dem

$DATADIR is supported by all routines that access demodulated data (reduce_switch, sdip, skydip, sculog etc.) but is not recognised by routines that deal with partly processed data.

Note that use of DATADIR is equivalent to setting a unix-style path of: .:$DATADIR (i.e. the current working directory is always chosen in preference to DATADIR).

7.1.2 SCUBA_PREFIX

In general, the initial stages of data reduction involve data taken on the same night. Typing in the full name of demodulated data files every time an observation is to be analysed is somewhat tedious and it would be much simpler if only the observation number was required.

Two pieces of information are required to spcify the file associated with a particular observation:

(1)
The observation number
(2)
The constant prefix of the data file

The SCUBA_PREFIX environment variable can be used to inform Surf of the form of the fixed prefix. Data files of the form prefix_dem_nnnn can be accessed by observation number (nnnn) so long as SCUBA_PREFIX is set to prefix (the _dem_ is added automatically).

Also, if the full path name is specified for SCUBA_PREFIX, DATADIR is not required. As an example, data in /scuba/observe/19971015/dem can be accessed by number either by setting

  % setenv DATADIR /scuba/observe/19971015/dem
  % setenv SCUBA_PREFIX 19971015

or by just setting SCUBA_PREFIX:

  % setenv SCUBA_PREFIX /scuba/observe/19971015/dem/19971015

Note that the current directory is not searched in the second case (since the software adds the prefix before trying to load the file). The scusetenv command can be used to set this variable (this command is especially useful when reducing data at the Joint Astronomy Centre as DATADIR is also set correctly).

7.1.3 SCUBA_SUFFIX

Most Surf tasks automatically constructs a default output filename based on the input filename (rebin bases the output filename on the object name). In this way it is possible for the filename to reflect the data reduction history.7 The SCUBA_SUFFIX environment variable can be used to select the preferred method to use for constructing the output name.



Table 2: Output file suffices for each task.






Task
Suffix


SHORT LONG/VERBOSE



reduce_switch onna onn
flatfield f _flat
restore r _res
extinction _???_xb _???_ext
remip i _ip
remsky s _sky
despike d _dsp
despike2 d _des
scuclip c _clip
scan_rlb b _rlb
scuphot p _pht
change_data a _cdata
add_dbm 2_thr_pac _dbm_thr_pa







Three modes are available:

SHORT

In this mode, the output filename is constructed by appending the short suffix related to the current task to the input filename.

LONG

In this mode, the output filename is constructed as follows:

(1)
Remove everything from the last underscore to the end of the input string.
(2)
Append the long task suffix

For example, for scuclip an input string of o15_lon_ext would become an output string of o15_lon_clip (i.e. the trailing _ext has been replaced with _clip. This method ensures that the length of the filename does not grow out of control during the data reduction. Additionally, if the suggested output filename would be the same as the input (e.g. by running scuclip successively), a ‘-’ is appended to the string so that the two can be distinguished.

This is the default method (and is used by scuquick).

VERBOSE

In this mode, the output filename is constructed by appending the long suffix related to the current task to the input filename. This means that the filename becomes longer and longer as the reduction proceeds.

The method of choice can be selected by setting SCUBA_SUFFIX to one of the above values (case independent) e.g.:

  % setenv SCUBA_SUFFIX verbose

The suffix strings related to each task and mode are detailed in table 2 and typical examples from a data reduction are shown in table 3. Currently modes LONG and VERBOSE share the same suffices but use them in different ways.


Table 3: Filenames generated from a typical data reduction. Each row demonstrates how the filename is constructed from the previous row. An observation number of 15 is used in this example.








Task Short Long Verbose




reduce_switch o15 o15 o15
flatfield o15f o15_flat o15_flat
extinction o15f_lon_x o15_lon_ext o15_flat_lon_ext
scuclip o15f_lon_xc o15_lon_clip o15_flat_lon_ext_clip
remsky o15f_lon_xcs o15_lon_sky o15_flat_lon_ext_clip_sky
despike o15f_lon_xcsd o15_lon_dsp o15_flat_lon_ext_clip_sky_dsp
despike o15f_lon_xcsdd o15_lon_dsp- o15_flat_lon_ext_clip_sky_dsp_dsp
rebin 3c279 3c279 3c279









7.2 Other useful environment variables

Three non-Surf environment variables can be used to affect the behaviour of Surf.

HDS_SCRATCH

As described in (SUN/92), this variable defines the directory in which HDS will create temporary files. This variable must sometimes be set when you are accessing data from directories in which you do not have write permission.

Usually, this variable should be set to a local scratch disk:

  % setenv HDS_SCRATCH /tmp

This has the additional advantage that NFS traffic can be reduced when accessing data on remote disks as the scratch files can be written locally.

ADAM_ABBRV

Another useful environment variable is ADAM_ABBRV. If this envrionment variable is set, parameter abbreviation is turned on (e.g., PIXSIZE_OUT can be referenced as PIX).

ADAM_EXIT

If this environment variable is set when an ADAM task terminates, the calling process will exit with system status set to 1 if the ADAM status was set, or 0 if the ADAM status was okay. This is useful when writing shell scripts.

All the ADAM environment variables are listed in SUN/144 [15].

6These variables are directly comparable with the Specx [14] use of the DATADIR environment variable and the set-gsd-filename command.

7The Kappa command hislist provides an explicit data reduction history for a file.

ann = observation number

b??? = first three letters of the selected sub-instrument (e.g. lon, sho, p20, p11, p13)

cThese include the throw and position angle of the chop to be added to the data.