Reducing Mock DPS Observations in IDL


DPS (or double position-switched) observations use a bandpass calibrator to remove baseline ripples from observations of sources with significant continuum, giving better baselines and allowing for spectral line observations. The technique is described in detail in Ghosh & Salter (2001) and in the New User's Guide. The basic principle is that rather than the standard on/off reduction of (ON - OFF)/OFF (also written as (ON/OFF) - 1), a modified reduction of (T-ON - T-OFF)/(B-ON - B-OFF) is used. Here T-ON and T-OFF are On and Off scans on the target source and B-ON and B-OFF are On and Off scans on a bandpass calibrator. This gives a result scaled relative to the flux of the bandpass calibrator, and so the cal signal is not normally used in the analysis of DPS observations.

The basic Mock routine for analysing DPS observations is Phil's masdpsp. This takes in a list of filenames in the order T-ON, T-OFF, B-ON, B-OFF and returns the reduced spectrum. From the user's perspective, this presents a couple of problems. Firstly, data from each Mock spectrometer board is contained in an individual file, so it is necessary to run masdpsp 14 times to reduce a single observation. Secondly, the order of observations for the DPS routine does not necessarily (or even often) follow the pattern T-ON, T-OFF, B-ON, B-OFF but is adjusted to give the most efficient observing. A wrapper routine to masdpsp, masdpsall, addresses both of these to give single-command reduction of all 14 Mock boards.

IDL commands to reduce Mock DPS observations

Setting up IDL for the reduction

First, start IDL and make the analysis routines available:

observer% idl - start IDL
IDL> @phil - make Phil's basic routines available
IDL> @masinit - make Phil's Mock apsectrometer analysis routines available
IDl> addpath,'~rminchin/alfa_idl' - make Robert's analysis routines available

Reducing the observations

Next, do the reduction of the observations:

IDL> masdpsall, fnum, projid, date, b, flux=flux - this does the actual data reduction. The parameters are: fnum - the start file number; projid - the project ID for the osbervations; date - the date of the start file (YYYYMMDD); b - the mas structure into which the reduced data will be returned; flux - an optional parameter to give the flux of the bandpass calibrator, in order to return data with an absolute calibration. For example:


which will return data in b scaled relative to the flux of the bandpass calibrator, or:


which will return the same as above multiplied by 3.2. If the flux of the bandpass calibrator is 3.2 Jy, the returned data will now by scaled in Jy.

Coping with month roll-overs

It should be noted that while masdpsall will cope with an ordinary date roll-over at midnight, it will not cope if the month also changes. In this case, it is necessary to specify the file numbers in the order T-ON, T-OFF, B-ON, B-OFF and give the respective dates separetely for each file, for example:


It should be emphasised again that both the file numbers and the dates should be in the order T-ON, T-OFF, B-ON, B-OFF. This will normally mean that the files are not in the order in which they were observed. You will normally have to get this order from the observing notes made at the time, although it is possible to find it by inspecting the header of each file individually.

Displaying the data

The returned data will be in a 14-element mas structure, with each element being from a different board. To display this, use:

hor, hmin, hmax - set the horizontal range to cover hmin to hmax. If this is not done, the scaling will be taken from the first board and will probably not cover all the boards.
ver, vmin, vmax - set the vertical range to cover vmin to vmax. Again, if this is not set auto-scaling will be done using the first board.
masplotall, b - plot all 14 boards.

This will, by default, plot by frequency. To plot by velocity use:

masplotall,b,/retvel,restFreq=restFreq,velCrdSys=velCrdSys - where restFreq should be set to the rest frequency to be used in calculating the velocity. If this is omitted, then the reference frequency of each board will be used, resulting in the boards being plotted on top of each other. You can set velCrdSys to 'T', 'G', 'B' or 'L' to plot velocities in topocentric, geocentric, barycentric or LSR. Note that this applies a shift (or not) on the basis that the spectrum is in topocentric coordinates - if it has been shifted (e.g. when accumulating non doppler-tracked data, see below) then it will be shifted again if velCrdSys is set.

Looking at single boards

To look at a single board, use masplot. This will normally be called (if b is the output from masdpsall) with masplot,b[N]. Here, N is the number of the board to be displayed (0 - 13, not 1 - 14). The full list of switches can be seen at the link above.

Smoothing data

Mock spectra can be smoothed using massmo. This simply does a boxcar (tophat) smooth with the format bsmo = massmo(b,width). Note that for the same velocity resolution, different smoothing widths will be required at different frequencies so it may be best to do this on a board-by-board basis, e.g. bsmoN = massmo(b[N],width). As above, n is the number of the board to be smoothed from 0 - 13.

Accumulating the Data

In order to build up integration time, and thus increase the sensitivity of the observations, it is normally necessary to accumulate the data. If the observations were made with doppler tracking, then this is simple, as the data will already have the same doppler-tracked frequency (normally LSR for Galactic objects or barycentric for extragalactic), even though they will not have the same topocentric frequency (the frequency actually recorded). These data can simply be accumulated without any worries using Phil's masaccum routine.

If, however, the observations have been made without doppler tracking, it will be necessary to shift the data to LSR or barycentric prior to accumulation and to ensure that they are accummulated on a common frequency grid. This has been provided for with masveltrans and masshiftaccum.

To use masaccum, do:

naccum = masaccum(bIn,baccum,/mb,/new - when calling for the first time, it is necessary to give the /mb and /new switches in order to set up a new accummulation and let masaccum know this is a multi-board accumulation. The number of records accumulated is returned in naccum (0 means no accumulation was done!)

naccum = masaccu(bIn,baccum) - after the first time, it is only necessary to give the input struct and the struct to hold the accumulation.

To accumulate data taken without doppler tracking use masveltrans and masshiftaccum:

masveltrans,b,bout,/bary,/lsr,/topo,resamp=resamp - this does the velocity transformation. b is the input strcut; bout is the output struct. Set one of /bary, /lsr or /topo to define the frame into which the struct will be transformed. Set resamp = 0 to do a simple shift without resampling onto the new frequency grid, otherwise the IDL interpol routine is used to resample the data. Masveltrans also takes the /spline, /lsquadratic, and /quadratic switches, which are passed to interpol. Interpolation has the effect of smoothing the data - reducing noise and spectral resolution, but gives a more accurate matching of the data to the new frequency grid than a simple shift. Do not use /spline unless you are absolutely sure you know what you are doing - it tends to mess up your data!

masshiftaccum,bIn,baccum,/interp,/nonan - this shifts the mas structs onto a common frequency grid (taken from the existing grid in the accumulation). It will automatically identify if baccum exists, and if not will call masaccum with /new. If /interp is given, it will interpolate using IDL's interpol routine when shifting the data, taking the same interpol switches as masveltrans. Otherwise it will take the nearest-neighbour when shifting, which maintains noise and frequency resolution. Normally when doing a nearest-neighbour shift, elements off the end of one frequency grid that would require extrapolation are marked as NaN, which will blank them in the accumulation. To instead enter the value of the last element use /nonan. If /interp is called, then the interpol routine will handle extrapolation - which can give some ‘interesting’ results.

Whichever technique is used, the resulting accumulation can be viewed using masplotall. Note that if viewing by velocity, velCrdSys should not be used if the data has been shifted by masveltrans as this will introduce another shift in the data, giving the wrong result.