IDL Routines

IDL data reduction instructions:

Other tools:


This is a wrapper script for a number of Phil's routines, automating much of the processing that would be carried out if following Chris's “IDL Cheat Sheet”.

Dependencies: Requires AOIDL and (if called) corhann.

Format: onoffred, input, b, ball, bpbl, bpol, bbl, scan=scanno, scljy=scljy, sclcal=sclcal, han=han, deg=deg, smo=smo, box=box, savgol=savgol


A wrapper for mbmeasure for IC and WAPP data files. Only parameters used directly by cormeasure and not passed to mbmeasure are described below.

Dependencies: Requires AOIDL and mbmeasure.

Format: cormeasure, b, board=board, profile=profile, xlabel=xstring, ylabel=ystring, xrange=xrange, hann=hann, niter=niter, file=file, psfile=psfile, velcor=velcor, boxwidth=boxwidth, mask=mask, log=log, eps=eps, hidelines=hidelines, medsub=medsub


A wrapper for mbmeasure for Mock data files. Only parameters used directly by cormeasure and not passed to mbmeasure are described below.

Dependencies: Requires AOIDL and mbmeasure.

Format: masmeasure, b, profile=profile, xlabel=xstring, ylabel=ystring, xrange=xrange, hann=hann, niter=niter, file=file, psfile=psfile, boxwidth=boxwidth, mask=mask, log=log, eps=eps, hidelines=hidelines, restfreq=restfreq, velcrdsys=velcrdsys, medsub=medsub


Measure profiles given variables containing the velocity and flux and a profile window. Based on and IDL implementation of the the MIRIAD MBSPECT routine. Reports errors based on the error equations from Koribalski et al. (2004) - these are dependent on the user supplying the correct factor to convert from channel separation to velocity resolution. It is generally recommended that spectra are baseline-subtracted and polarization-combined prior to analysis, but it is possible to subtract a DC level from the spectrum to allow the program to work on spectra not centred around zero (i.e. ones with continuum).

Dependencies: dohanning (if hann is set), medabsdev.

Format: mbmeasure, allvel, allflux, profile=profile, xlabel=xstring, ylabel=ystring, xrange=xrange, hann=hann, niter=niter, file=file, psfile=psfile, boxwidth=boxwidth, mask=mask, source=source, hidelines=hidelines, medsub=medsub


Large elements copied from Phil's corsmo routine, but setup to do Hanning moothing rather than Boxcar. Also, requires bsmo rather than returning in b if no bsmo given.

Dependencies: Requires AOIDL and dohanning.

Format: corhann, b, bsmo, smo=smo


This is a wrapper for a number of routines: Phil's masposonoff, Phil's masdpsp, and my masbpcal. Many of the parameters are passed to those routines - please see Phil's documentation for details of how these work. The other parameters are mainly concerned with setting up the filenames correctly for input to the called routines. The routine returns a 14-element mas structure that can be displayed using masplotall..

Dependencies: Requires AOIDL, masplotall and (if called) masmakeflist and masbpcal.

Format: masonoffall, flist, projid, date, b, sclcal=sclcal, sclJy=sclJy, avg=avg, median=median, side=side, dateroll=dateroll, verbose=verbose, nonorm=nonorm, dps=dps, flux=flux, board=board


A wrapper for Phil's masplot routine, designed to plot the 14-element mas structures returned by masonoffall and masdpsall. Inputs are as for masplot, except that off is not accepted by masplotall as it would be pointless in this context. Please see Phil's documentation for details. Before plotting, hor and ver should be used to set the axes as usual in AOIDL, otherwise the axes will be taken from the first board plotted.

Dependencies: Requires AOIDL.

Format: masplotall, b, freq=freq, over=over, pollist=pollist, norm=norm, median=median, retvel=retvel, restFreq=restFreq, velCrdsys=velCrdSys, colar=colar


A wrapper for Phil's masdpsp routine for reducing DPS observations. It returns data in b, along with the inidividual parts (as described in masdpsp) in srcOn, srcOff, bpon, bpoff, src_onoff. Parameters that are the s ame as masonoffall or masdpsp are.not repeated here.

Dependencies: Requires AOIDL, masplotall and (if called) masmakeflist.

Format: masdpsall, flist, projid, date, b, srcOn=srcOn, srcOff=srcOff, bpon=bpon, bpoff=bpoff, src_onoff=src_onoff, side=side, flux=flux, dateroll=dateroll, verbose=verbose


A wrapper for masonoffall, designed to make and accumulate bpcal files for pseudo-DPS observations. It calls masonoffall with the /nonorm switch and returns data both in b and accumulated data in baccum. Most of the parameters are passed to masonoffall and are not repeated here.

Dependencies: Requires AOIDL along with masonoffall and all subsequent dependencies.

Format: masmakebpcal, fnum, projid, date, b, baccum, sclcal=sclcal, sclJy=sclJy, avg=avg, median=median, side=side, dateroll=dateroll, verbose=verbose


Do On - Off reduction without normalising by dividing by the Off scan. This is useful for reducing pseudo-DPS observations where an on-off is taken on both the target and the bandpass calibrator (e.g. a2463 observations). It is normally called from masonoffall and many of the parameters are described there.

Dependencies: Requires AOIDL.

Format: masbpcal, files, bout, sclcal=sclcal,s clJy=sclJy, median=median, avg=avg, verbose=verbose


Form (and optionally accumulate) a DPS reduced mas structure from an on-off and a supplied bandpass calibrator mas structure. Most of the parameters are passed to masonoffall and are not repeated here. It should be noted, however that sclJy and sclcal refer to the calibration of the target on-off, not the DPS reduced data, which is is relative units (unless flux is supplied).. These should be set to match the calibration of the input bandpass calibrator to get meaningful results.

Dependencies: Requires AOIDL along with masonoffall and all subsequent dependencies.

Format: maspseudodps, flist, projid, date, b, bpcal, baccum, sclcal=sclcal, sclJy=sclJy, median=median, side=side, dateroll=dateroll, verbose=verbose, flux=flux, target=target, board=board


Average together the two polarizations of a mas struct and return a single-polarization mas struct. If you put in a mas struct that doesn't have two polarizations, I won't be responsible for the consequences...

Dependencies: Requires AOIDL.

Format: bpolavg = maspolavg(b)


Smooth a mas struct with a tophat (a.k.a. boxcar average) function, using the IDL ‘smooth’ routine, or using a boxcar median or a Hann function.

Dependencies: Required dohanning if /han is used.

Format: bsmo = massmo(b, width, median=median, han=han)


Transform (and resample) a mas struct between topocentric, barycentric and LSR frequencies in order to allow the accumulation of observations taken without doppler tracking. Note that different transformed observations made at different times without doppler tracking will not have the same barycentric or LSR frequencies, so will need further resampling onto a standard frequency grid prior to accumulation (this can be done with masshiftaccum - but at least the frequencies will refer to the same velocities, unlike topocentric frequencies.

Masveltrans uses header values for the barycentric velocity of the observatory, the LSR velocity of the observatory is calculated from this using Phil's vellsrproj routine with the barycentric velocity, RA and Dec values from the header. Conversion of the values in the file is done using the relativistic equations of Frank Ghigo. Resampling is done using the standard IDL ‘interpol’ routine.

Will recognise specsys = TOPOCENT, BARYCENT and LSRK from the header and use these as the starting frame for the conversion. All mas structs produced by the telescope should have specsys = TOPOCENT. Masveltrans will write specsys = BARYCENT or specsys = LSRK (as appropriate) into the header of the output struct.

Use of the /rest switch (either on its own, or associated with redshift and possibly the /vel switch) will transform the spectrum into rest frequency using the header information or supplied redshifts. This should be used with the appropriate /bary or /lsr switch, depending on the velocity frame of the redshift, e.g.:
will transform the spectrum in the mas structure ic860_3500_b2aps into rest frequency using a supplied barycentric redshift of z = 0.0129089 (overriding the redshift in the header) and write the result into the mas structure test.

Dependencies: Requires AOIDL.

Format: masveltrans, b, bout,bary=bary, lsr=lsr, resamp=resamp, spline=spline, lsquadratic=lsquadratic, quadratic=quadratic, errcode=errcode, rest=rest, redshift=redshift, vel=vel


Find Mock spectrometer fits files meeting certain parameters, uses Phil's masfilelistp and masfilesum. The output of masfilesum is then processed with the selection criteria given and the results are returned. A number of the parameters are passed to massfilelistp for file selection, please see Phil's documentation for details of how these work.

Dependencies: Requires AOIDL.

Format: masfindfiles, projid, filesum, srcname=srcname, obsmode=obsmode, scantype=scantype, band=band, num=num, freqrange=freqrange, rarange=rarange, decrange=decrange, year=year, month=month, day=day, beam=beam, side=side, group=group, onoff=onoff, dps=dps, alfa=alfa, zoa=zoa, allbm=allbm


Accumulates mas structs, shifting them first so that the frequencies agree. Uses Phil's masaccum for the actual accumulation. Resampling can be nearest neighbour (if the grids are compatible) or interpolated. If the baccum does not exist, it is created (masaccum is called with /new) and no shifting is done. If the spectra do not have the same frequency spacing (CRVAL1), then nearest-neighbour will refuse to work but the spectra can be accumulated using interpolation.

Dependencies: Requires AOIDL.

Format: masshiftaccum, bIn, baccum, interp=interp, spline=spline, lsquadratic=lsquadratic, quadratic=quadratic, nonan=nonan


This weights mas structs by changing the value of ACCUM. This is particularly useful where ACCUM has been set to zero during the reduction process. Whether ACCUM is zeroed is not consistent: masgetfile with /avg, for instance, will set ACCUM correctly, while masdpsp and masgetfile with /median will not. Setting ACCUM to correctly reflect the number of records that were reduced into the struct will allow the strcut to be correctly accumulated using masaccum and procedures that call masaccum, such as masshiftaccum.

Dependencies: None.

Format: masaddwgt, b, weight


This is a modification of Phil's masmon routine to monitor all 14 boards in use during a Mock single-pixel observation. It is normally called with simply the project id, and will then find and display the most recent files. If not scaling is given, masmonall will autoscale the x-axos tp cover the full frequency range of the observation and the y-axis to go from median/3 to median×3 (where ‘median’ is the median of the data, normally a good approximation to Tsys). If the observation includes both radar-like shifted boards and noise-like shifted boards, then a logarithmic y-scale can be applied to help to see all the data at once.

As with Phil's masmon routine, a menu inside the program (called by hitting any key) allows further control of the scaling and a number of other functions. This menu also allows the user to quit the program or to interrupt it for debugging. The menu appears in the IDL terminal window (not the graphics window) and focus must be on the IDl terminal window to interrupt plotting and bring up the menu.

Cmd CurVal    function

 p       -1       pol to use (1..4,-1=all)
 h    low high   set horizontal plot range args --> autoscale
 v    low high   set vertical   plot range args --> autoscale
 delay  0.25  plot delay secs
 l      0       logarithmic y-axis. 1-on,0-off

 d    20121217       move to first file of date
 dn   20121217 00000 move to date and filenum
 num  00000          number of file to use
 r      11           row of file to position. maxRows:  60
 f    ('all'/date)   list project files for this date
                     ('all' --> all dates, date --> that date)

-->  MISC:
 cur            track cursor position
 hdr            print current header
 s      0       step mode. 1-on,0-off
 z              stop in procedure (for debugging)
 q              to quit

otherKeys       continue plotting

The menu prompts the user for input, then carries out the operation requested and returns to the display of the spectra. If an invalid input is given, it returns to the spectra without carrying out an operation. Note that keys will not register until the menu appears - this can take a short while, depending on when in the program cycle a key is pressed to interrupt plotting. Polarisations should be supplied as p 1234, etc., not p 0123.

Known issues: There may be a lun leak somewhere in the program. If it crashes, try masclose,/all and then restart (after retall of course).

Dependencies: Requires AOIDL, and masplotall2.

Format: masmonall, projid, num=num, date=date, noavg=noavg, pollist=pollist, dirI=dirI, col=col, auto=auto, ylog=ylog