Reducing Mock Pseudo-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.

Mock Pseudo-DPS observing follows a similar idea, but instead of observing the bandpass calibrator each time the target is observed and using this to reduce that observation of the target, separate on-off observations are made of the target and the bandpass calibrator and the observations of the bandpass calibrator are then reduced and accumulated before they are used to reduce the observations of the target. This has advantages where the target is much stronger than the bandpass calibrator, where observing the calibrator for long enough to bring down the noise would be prohibitive if this were done on every observation of the target.

Observations should be made at a set frequency and without any doppler correction (e.g. Frame: Topocentric in CIMA) as the bandpass calibrator and the target source need to be observed with exactly the same IF setup in order to be useful. Reduced data will need to be shifted to a dynamical frame (normally LSR or Barycentric) prior to accumulation.

The basic Mock routines for reducing pseudo-DPS observations are masmakebpcal and maspseudodps. The former creates and accumulates a bandpass by doing a simple ON - OFF reduction (without dividing by the OFF), while the latter does an ON - OFF on the target and divides it by an input bandpass.

Calibration of the spectrum: Both masmakebpcal and maspseudodps take the /sclcal or /sclJy switches. These refer to the calibration applied to the part-reduced ON - OFF spectrum, not to the output spectrum. It is important that one of these switches is set and that the same switch is set for both maspbcal and maspseudodps, otherwise the ratio spectrum will not reflect the true ratio of the target and the calibrator. To get an absolute calibration of the output ratio spectrum, flux = Scal should be used to provide the flux of the calibrator (Scal), as with standard DPS observing. It is also important that a calibration switch is set if the bandpass calibrator is to be accumulated.

IDL commands to reduce Mock pseudo-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 bandpass calibrators

Next, do the reduction of the bandpass calibrators:

IDL> masmakebpcal, fnum, projid, date, b, baccum, /sclcal, /scljy - this reduces (and accumulates, if request), the bandpass calibrator data. 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; baccum - (optional) the mas struct into which the reduced data will be accumulated, this will be created if it does not alread exist, /sclcal or /scljy - the calibration setting: one of these should always be chosen (see above).

For example:


which will return data in b and accumulated into baccum, scaled into Jy.

Accumulating the bandpass calibrator: It is possible to accumulate the bandpass calibrator using just masmakebpcal. However, it may be preferable to simply recover the reduced calbrator in b and examine it prior to deciding whether to accumulate it or not. As all the data should have been taken with the same frequency setting, this data can be accumulated as normal using Phil's masaccum routine.

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,/mb) - after the first time, do not give the /new switch, as this will reset the accumulation!

Single-board reduction: It might sometimes be desirable to accumulate the bandpass calibrator on a board-by-board basis rather, for example if some of the boards are affected by RFI and others are not. It is possible to accumulate just a single board of the bandpass calibrator by using:

naccum = masaccu(bIn[N],baccum,/new) - where N is the board number (0 - 13). As with multi-board accumulations, after the first time, the /new switch should not be used.

Reducing the target sources

Next, do the reduction of the target sources:

IDL> maspseudodps, fnum, projid, date, b, bpcal, /sclcal, /scljy, flux=flux - this reduces a target spectrum by taking ON - OFF and dividing by the reduced bandpass calibrator data (from masmakebpcal). 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; bpcal - the mas struct with the accumulated bandpass calibrator data, /sclcal or /scljy - the calibration setting: this should have the same setting as used for masmakebpcal, flux = Scal - the flux of the bandpass calibrator (Scal), used to provide an absolute calibration to the data.

For example:


which will return data in b reduced using the accumulated bandpass calibrator in bpaccum, scaled relative to the flux of the bandpass calibrator

Single-board reduction: If using a single-board accumulation of the bandpass calibrator, then only a single-board of the target can be reduced at a time. To do this use the board=N switch to maspseudodps, where N is the same board number (0 - 13) as was used for the accumulation of the bandpass calibrator, e.g.:


Accumulating the reduced target data: The target data provides more of a challenge for accumulation than the bandpass calibrator data, due to the need to do doppler correction prior to accumulating.

The data should have been taken in topocentric mode (i.e. with no doppler tracking), otherwise the bandpass calibration will not work. However, this leaves astronomical sources open to velocity shifts of ± 30 km/s due to the Earth's motion around the Sun. It is therefore necessary to shift the data into an astronomical velocity frame – either LSR or barycentric – before it is accumulated. Once shifted into different a different velocity frame, the data need to be shifted again to ensure they are on the same frequency grid prior to being accumulated. These two operations are carried out by masveltrans and masshiftaccum.

masveltrans, b, bout, /bary, /lsr, resamp=0, /rest, redshift=redshift, /vel where b is in input mas struct, holding the reduced target spectrum in the topocentric velocity frame, bout is the output spectrum shifted into the new velocity frame, /bary or /lsr are the velocity frame you choose to shift into – one of these should always be chosed, resampe=0 will not do any resampling but will simply shift the entire grid – this is recommended here as resampling the grid could leave it incompatible with other grids – setting /resamp or omitting this option will resample the data using (by default) linear interpolation (other inputs such as /spline, /lsquadratic or quadratic can be used to tell interpol what sort of interpolation to use), /rest returns the spectrum shifted to rest frequencies, by default this is calculated using the req_vel header item, but this can be overridden by setting the redshift using redshift = z, if /vel is also set then redshift is in km/s rather than redshift.

masshiftaccum, b, baccum, /interp, /nonan were b is the input spectrum, shifted into the correct velocity frame (i.e. bout from masveltrans), baccum is the struct that will hold the accumulation (if it does not exist, this will be created), /interp sets whether the data is to be interpolated (using interpol) or simply shifted prior to accumulation, if resamp=0 was not used with masveltrans then it will probably be necessary to interpolate the data as the grids will not be consistent, /nonan says to set frequency pixels left blank by shifting the data to the value of the last valid pixel, rather than to NaN, if the data are interpolated this option will not do anything as these points will be extrapolated by the interpolation routine.

Single-board reduction: It should be possible to accumulate a single board reduction in exactly the same manner as a multi-board reduction by following the steps above for masveltrans and masshiftaccum.

Coping with month roll-overs

It should be noted that while masmakebpcal and maspseudodps 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, Cal-ON, Cal-OFF (this should be the order of the files on the disk, assuming observing was done in standard On-Off mode) and give the respective dates separetely for each file, for example:


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. If a single-board reduction has been done, then the output is a standard 1-element mas structure that can be viewed normally with masplot.

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.

Data-reduction flowchart

data reduction flowchart