NRAO Home  >  Green Bank  |  Wiki Topic:    GB > Data > DishUsersGuideForGBT
   Changes | Index | Contents | Search | Statistics | Jump to Topic

DISH User's Guide for GBT Observations

J. Braatz, G. Langston, J. Lockman, J. McMullin, and R.Garwood

Introduction to dish

dish is a fully capable tool for reducing Single Dish Radio Astronomy Data efficiently. dish builds on the AIPS++ capacities with tools specifically designed to meet the needs of astronomers when interpreting spectra and images from observations with single dish radio telescopes. dish provides all the capabilities of the UniPOPS? package used to reduce 140ft data. In addition, it has capabilities to optimally reduce different types of observations, having special functions for Beam Switched and Frequency Switched observing modes. Important new capabilities to flag selected ranges of spectra and produce spectral images are illustrated.

Additional documentation is available at the AIPS++ site: http://aips2.nrao.edu/docs/user/documentation.html

The best way to learn is by doing. The aips++ recipies page: http://aips2.nrao.edu/docs/recipes/Recipes/index.html has simple, step by step, guides for standard data reduction scenarios.

Starting up dish

The AIPS++ dish package is started under Unix by first setting up the unix shell environment. This is accomplished by running a shell script. It is recommended that the user work in an empty subdirectory, since many files will be created. Also, if you run from a disk mounted on the local machine, dish will run more responsively. See the OptimizingAIPSppInGB note for more details on this and other ways to help aips++ run faster in Green Bank.

In the first example, OH megamaser data will be reduced in the directory named "OH". It isn't required that a new empty directory be created, but doing so will isolated related aips++ files and directories in one location.

% mdkir OH                                    # Create an empty work directory
% cd OH                                       # Go to it
% gbdish                                      # Start up AIPS++ and dish

The gbdish command is specific to Green Bank. For installations away from Green Bank, you will need to follow these steps to start up dish:

% . /home/aips++/stable/aipsinint.sh             # Setup in the BASH shell
OR
% source /home/aips++/stable/aipsinit.csh       # Setup in the T/CSH shell
% dish                                          # Start up AIPS++ and dish

Note: The path to your aips++ installation may be different from /home/aips++/stable (the recommended installation in Green Bank).

Note: Chose one of the aipsinit lines shown above, appropriate for your shell.

After starting dish a number of messages are printed in the window. Three new Graphical User Interfaces appear;

  1. message log
  2. PGplotter
  3. dish results manager.
The AIPS++ prompt is "-". Most commands return T (the glish True) if the command is successful. The prompts and Ts are dropped in the examples in this note.

A few comments on dish philosophy

In general, dish assumes that observations are organized into scans. A scan may contain a number of integrations. The concept of a globalscan is used in dish. The globalscan is essentially a single spectrum which many dish functions operate on, by default. The globalscan can be a single scan's spectrum, the spectrum from a single integration from within that scan, or the spectrum from an averaged group of scans. Its use will become evident as we proceed with the example. You can always see the contents of the globalscan spectrum by typing d.show().

An example dish session

This example session shows how GBT data are loaded into dish followed by a first examination of the observing parameters, calibration of some of the data, displaying the calibrated data, and averaging the data. In later examples more data will be averaged and fit.

The data used in this section are from a GBT OH megamaser survey by Jim Braatz of NRAO. The survey uses the GBT L-band receiver as the frontend and the Spectral Processor as the backend. (See http://www.gb.nrao.edu/GBT for a complete description of the GBT electronics). Two polarizations were observed over a 50 MHz bandwidth, using 1024 channels. The goal of the exercise is to determine whether redshifted OH maser emission is present in the 1665.4018 and 1667.359 MHz lines.

The following steps are taken:

The dish commands to complete these steps are shown below.

# Load survey scans 17, 18, 19, 20
d.import('/home/archive/early-data/tape-1/OHsurvey',,,17,20)  
d.lscans()                                      # List the scans
# AIPS++ output == [17,18,19,20]         
d.gms()                                         # Show scan relationships
d.plotr(17,1)                                   # Plot raw reference scan 17
                                                # Cal-On Spectra for 2 pol. (figure 2)
d.calib(18)                                     # Sig-Ref/Ref calibrate the Signal Scan
d.plotc(18)                                     # Plot the calibrated data,
                                                # also prepares data for averaging
d.accum()                                       # Transfer for averaging with other scan
d.calib(20)                                     # Sig-Ref/Ref calibrate the Signal Scan
d.plotc(20)                                     # Show the spectra and 
                                                # Transfer data for averaging
d.accum()                                       # Add the scan to the accumulation
d.ave()                                         # Average all accumulated scans
d.show()                                        # Look at the Average

fig1.1718rawcal.gif

Figure 1: Left: Raw reference spectra (scan 17) of an OFF-ON pair of scans (17 and 18) towards IRAS09539+0857. The dual polarization plots of the data in counts are presented. The spectral shape is due to the variation in IF gain across the band. Right: Calibrated spectra from the same OFF-ON pair of scans.

Next a baseline can be fit to the two polarization spectra and subtracted to show the detected OH emission.

                                                # Fit, remove a spectral baseline

d.nfit(3)                                       # Set third order polynomial
d.nregion(80,270,650,960)                       # Select channels 80-270 and 650-960 
d.bshape()                                      # Fit and show the baseline shape 
d.baseline()                                    # Subtract the baseline 
d.show()                                        # Show the baseline subtracted 
                                                # There is the 1667 OH line!
d.fileout('averageSpectra')                     # Name the output file 
d.keep()                                        # Save visible spectra; given number 18
exit                                            # We're done!

fig2.1718avesub.gif

Figure 2: Left: Dual polarization spectra of IRAS09539+0857 with the results of the third order baseline fit shown. Right: Dual polarization observation of IRAS09539+0857, with baseline fit subtracted.

Reload Saved Spectra; Fit components

Now we reopen the previously imported measurement set and restore the saved average spectra. In this step the spectra are fit with two Gaussian components, and displayed.

d.open('averageSpectra')                        # Re-open the previously averaged data
firstScan := d.lscans()[1]                      # Get the number of the ave scan
aveSD := d.getscan(firstScan)                   # Fetch the previously averaged scan
d.plotscan( aveSD)                              # plot the average scan
d.hanning()                                     # Hanning smooth the spectra
d.show()                                        # View the smoothed data
d.gauss(2)                                      # Fit 2 gaussians; X axis in GHz 
#Gauss:  1                                      AIPS++ output (see figure 4) 
#Center:  1.47757e+00   Height: 2.01256e-02    Width: 8.06329e-04
#Cerr:    3.12915e-05   Herr:   1.59137e-03    Werr:  7.41239e-05
#Gauss:  2                                      AIPS++ output
#Center:  1.47605e+00   Height: 8.07131e-03    Width: 6.44905e-04
#Cerr:    6.65425e-05   Herr:   1.82314e-03    Werr:  1.57421e-04
C := 2.99792E5                                  # Velocity of light in km/sec  
ohFreqB := 1665.400; ohFreqC := 1667.358        # Set OH constants 
C * (ohFreqB - 1476.05) / ohFreqB               # Calculate velocities 
34085.2739                                      # AIPS++ output in km/sec
C * (ohFreqC - 1477.57) / ohFreqC               # Calculate velocities 
34123.9998                                      # AIPS++ output in km/sec

The OH survey observations towards IRAS09539+0857 were made to confirm the observing setup for weak sources. These GBT observations show a peak of emission at 1.47757 GHz. The Arecibo survey of Darling and Giovanelli (2001, AJ, 121: 1278) had previously detected IRAS09539+0857 and measured a velocity of 38,673 km/sec (optical heliocentric), consistent with the observations presented here. (Note that  v_{opt} = 38673 km/sec [optical definition] corresponds to  v_{rad} = 34270 km/sec [radio definition]).

fig3.1718fitvel.gif

Figure 3: Left: Gaussian fits to the baseline subtracted and calibrated spectra from the average spectra towards IRAS09539+0857, X axis units are GHz. Right: Same as Left, except that X axis units are km/sec.

                                                                 # Use PG Plotter GUI; Set X
                                                                 # to Barycentric Radio km/sec
d.gauss(2,bchan=100, echan=400)                                  # Fit 2 gaussians; X axis in km/sec
Gauss:  1                                                        # AIPS++ output (see figure 4)
Center:     34397.004568   Height:         0.008296    Width:       111.158507
C-err :        12.172717   H-err :         0.001747    W-err:        28.826383
Gauss:  2
Center:     34124.739777   Height:         0.020254    Width:       144.852889
C-err :         5.465173   H-err :         0.001561    W-err:        12.959182

# the above Center values are in barycentric radio km/s

Data Path

The following lists the most often used utilities. There are many more available functions in dish. Type "help('Refman:dish')" at the command line prompt to redirect your browser to the dish command line documentation; 'd.info()' will also provide an alphabetical, table of all available dish functions); typing d.help('function_name') will provide information on the function (d.help('function_name',T) will also automatically drive your web browser to the AIPS++ User Reference Manual entry on this function).

File Access Scan Access Editing Calibration Analysis Display
import getr msplot calib (all operations) plotr
open getc viewer TPcal e.g., aver plotc
filein getscan autoflag FScal base plotscan
fileout   flag SRcal    
    clip      

Data and File Access

File Access

GBT data must be converted from their raw GbtFits files to an AIPS++ MeasurementSet before being accessed with dish functions. The command to fill raw GBT data is import. Once data have been filled, they can be accessed with the open function. Two additional file access functions, filein and fileout, are used to specify where data is read from and written to.

1. import - Fills an AIPS++ MeasurementSet from raw GBT FITS files and makes the data accessible from dish via the open command. The MeasurementSet created on disk will default to the input project name with an appended '_' followed by a backend specifier. If an 'outms' argument is supplied, the name on disk will be this string with the appended underscore and backend specified. import always follows the fill step with a call to open that sets this newly filled MS as the current input data source (filein=T). If a MeasurementSet having that name already exists, it will be appended to. In that case, only scans which start after the last time already filled to the existing MS will be added to that MS.

Example:

d.import(projdir='/home/mirror/gbtdata/OHsurvey',outms='oh',startscan=100,stopscan=105)

This creates a file 'oh_SP' on disk for spectral processor data, or 'oh_ACS' for the spectrometer.

Parameters:

'SPECTROMETER' is synonymous with 'ACS'. 'ACS' is used to shorten the amount of typing at the command line.

2. open - This function will load an existing data set (MeasurementSet or the type of table used by save and keep) on disk into dish memory. That is, it can be used on datasets which have already been filled using import. This places a tool attached to the data on disk into the Results Manager, making the data globally accessible in the Glish session (it can be manipulated from the command line, etc.). This may also performs a filein on the MeasurementSet (when filein is T) that indicates that subsequent commands/functions will use this MeasurementSet. It can also be used to create a new data set which can be used to save processed data using save and keep. Such a newly created data set is not a MeasurementSet, but instead is a simple aips++ table that resembles an SDFITS table.

Example:

d.open('oh_SP');

Parameters:

3. filein - This function sets the data set that will be examined and displayed. The files function indicates the current settings for the selected filein and fileout. This allows the user to switch between several already open data sets without having to re-enter the open command each time.

Example:

d.filein('ohSP')

Parameters:

4. fileout - This function sets the data set that will be written to. The files function will indicate the current settings for the selected filein and fileout. This allows the user to select between several already open data sets without having to re-enter the open command each time. fileout assumes that the data set has write permission (e.g., you should have already created the file with open).

Example:

d.fileout('avg_spectra')

Parameters:

Scan (Data) Access

Data in the MeasurementSet contains both the uncalibrated (raw or observed data) and the calibrated data. Initially, the calibrated data is simply a copy of the uncalibrated data. As the data is manipulated through the calibration routines (calib, TPcal, FScal, SRcal), the calibrated data becomes distinct.

The SdRecord (single dish record) is the data structure returned by the data access commands. It is a Glish record containing astronomical information (data, header, history, etc). In dish, an SdRecord is essentially synonymous with "spectrum" plus associated descriptive (header) information.

Several dish functions operate on a globally accessible SdRecord to help simplify the interface. In general, these functions will operate on the currently displayed spectrum or the contents of this globally accessible record (called globalscan1). Functions which take no arguments will, in general, access this spectrum and perform the operation on it.

1. getr - Retrieve uncalibrated (raw) data. This function returns an SdRecord. Specifying only the scan and phase will yield an average over all available integrations. getr accesses the FLOAT_DATA column of the MeasurementSet (the raw data) which is never modified. This function only works on a MeasurementSet (not on data sets created using open containing data stored using keep or save).

Example:

- s35_1 := d.getr(35,1,1,1) #retrieve scan 35, phase 1, integration 1,
                            #polarization 1 from the opened MS and
                            #store in variable s35_1
- s35_1 := d.getr(35,1)     #retrieve scan 35, phase 1, average all 
                            #integrations, show all polarizations

Parameters:

2. getc - Retrieve calibrated data. This function returns an SdRecord. Specifying only the scan will yield an average over all available integrations. The function accesses the CORRECTED_DATA column of the MeasurementSet (the calibrated/corrected data). This function only works on a MeasurementSet (not on data sets created using open containing data stored using keep or save).

Example:

- s35_c1 := d.getc(35,1,1)  #retrieve scan 35, integration 1,
                            #polarization 1 from the opened MS and
                            #store in variable s35_c1
- s35_c1 := d.getc(35)      #retrieve scan 35, average all integrations, 
                            #show all polarizations

Parameters:

3. getscan - Retrieve an individual row (phase, integration) from a scan. This functions returns an SdRecord. This function works on all types of data sets but is most useful in retrieving data previously saved using keep or save.

Example:

- s35_c1 := d.getscan(35,3) #retrieve scan 35, subscan 1

Parameters:

Data Inspection and Display

Flagging

Flagging data is done in two basic modes: 1) command line and 2) GUI. There are two basic command line flagging utilities, clip and flag.

clip is a simple function which will allow you to flag a currently viewed spectrum. It sets the flag sub-record in the SdRecord being viewed.

Example:

d.clip(0.4);    #clip all above 0.4
d.clip(0.4,[100:500]);  #clip above 0.4 in the channel range 100-500
d.clip(-0.3,clipdir='low'); #clip below -0.3

Parameters:

flag is a more complete flagging utility allowing versatile flagging of data. Automated flagging based on data statistics is under development for single dish data. flag sets the FLAG column in the main table of the MeasurementSet.

Example:

d.open('stjul13SP');
d.gms();
d.plotc(36)
d.flag(36,channel=100:120)      #flag all subscans, polarizations of scan
                                #36 in the channel range of 100:120
d.plotc(36)                     #you should see the range masked
d.flag(36,flag=F);              #unset all flagging
d.plotc(36)                     #it's back!
d.flag(36,channel=500:550,polarization=1)
d.plotc(36)                     #you should see a gap just in the first
                                #polarization

d.flag(36,flag=F);
d.flag(36,1)                    #flag just the first integration
d.plotc(36)                     #should look okay though it doesn't
                                #include the first integration
d.plotc(36,1)                   #masked
d.plotc(36,2)                   #okay

Parameters:

autoflag

autoflag is a tool within AIPS++ which allows automated (based on statistics, etc) flagging of data without direct examination of each flagged row/scan. A few specific examples are provided below.

Flag based on statistics

include 'autoflag.g'
af:=autoflag('stjul13SP')       #Specify the MeasurementSet to operate on
af.setfreqmed();                #Use a sliding median filter in frequency
                                # default threshold is 5
af.run(plotscr=F);
af.done();                      #important to release the MeasurementSet

img48.gif

Figure 4: Left: the unflagged data. Right: the flagged data. This is being viewed with the viewer as discussed below.

Clip data using autoflag

include 'autoflag.g'
af:=autoflag('stjul13SP')   # Specify the MeasurementSet to operate on

cliprec:=[=]                # set up a record to contain the clipping info
cliprec[1]:=[expr='ABS XX',min=0,max=200]
                            #clip the XX correlation above 200 and below 0
af.setselect(clip=cliprec)  #specify the clip record as the selection
af.run(plotscr=F)           #execute (disable intermediate displays)

Interactive (using a GUI) modes of flagging are also enabled through the viewer and msplot tools.

For the viewer:

include 'viewer.g'
dv.gui();

This will bring up two GUIs. The first is for selecting what to display. You select the MeasurementSet and choose the type of display (only 'Raster' is available for MeasurementSets). This will then be displayed in the other display panel.

fig2.5.gif

Figure 5: Display of the Adjust panel for the viewer with the flagging tab open alongside a viewer display. Some of the data on the right has been flagged as bad. The selection will mark all times for the selected channels and all polarizations and spectral windows (from the Adjust panel selection).

For msplot:

include 'msplot.g'
mp := msplot('your_measurementset_name');

This brings up a GUI which will allow you to select the type of display ("X vs. Y" or "Display data as image") and optionally select a subset of the data.

Display

1. plotr - Display uncalibrated (raw) data using the dish plotter. Specifying only the scan and phase will yield an average over all available integrations. plotr accesses the FLOAT_DATA column of the MeasurementSet (the raw data) which is never modified. This function only works on a MeasurementSet (not on data sets created using open containing data stored using keep or save).

Parameters:

2. plotc - Display calibrated data using the dish plotter. Specifying only the scan will yield an average over all available integrations. plotc accesses the CORRECTED_DATA column of the MeasurementSet (the calibrated/corrected data). This function only works on a MeasurementSet (not on data sets created using open containing data stored using keep or save).

Parameters:

3. plotscan - Plots an SdRecord to the dish plotter (as returned from functions like getr, getc, and getscan).

Parameters:

The dish plotter

The dish plotter is the standard dish display for spectral line data. It is built on the existing AIPS++ pgplotter tool and so has all of the basic PGPLOT functionality. In addition, the plotter features tools for:

  1. changing the X-axis units
  2. changing the reference frame for the X-axis
  3. toggling header information display
  4. toggling the overlay of subsequent plots
  5. options for a) reversing the color scheme and b) providing a chalkboard draw facility
  6. toggling the X-axis autoscale
  7. unzoom (incrementally unzooms any zooms)
  8. line identification (marks any molecular lines within the frequency ranges of the displayed plot

Calibration

Calibration is applied to the data based on information in the STATE table of the MS, in particular, these functions utilize the OBSMODE column to determine a procedure type, switching signal, and switching state. In addition, information on the procedure size and procedure sequence number are used. That information in turn comes from the GO FITS file associated with that scan. Indexing from within the MeasurementSet is done using the scan number. There have historically been times when the GO FITS information was either missing completely or had the wrong scan number. In such cases, the calibration function described here may not work correctly and you may need to work directly with the data using getr and other, more primative dish and Glish capabilities.

dish attempts to implement the SpecLineCalibration draft memo.

A scale factor may be applied (multiplied) to the data as part of the calibration depending on the requested units. That scale factor is given here:

 factor = \frac{e^{\tau (1/sin(elev))}}{\eta_x}

where \eta_x is the efficiency factor determined by the user selected units (1 for TA', \eta_l for TA*, \eta_M for TMB, or \frac{\eta_A}{0.351582} for Jy). If the requested units are TA, no scale factor is applied.

The efficiencies are

  1. \eta_l is the rear spillover, ohmic loss, and blockage efficiency. dish currently assumes that this is 0.99 in all cases.
  2. \eta_A is the aperture efficiency.
  3. \eta_M is the main beam efficiency. dish assumes that \eta_M = 1.4 \eta_A

The default efficiencies as well as opacity at zenith (\tau) used by dish in the default case are returned by the eff function.

eff - return a Glish record containing the default efficiencies and opacity

Parameters:

eff stores these values in a public place in dish. They can be modified and the calibration routines can be told to use already set values. In this way, you can supply your own values for the efficiencies and opacity.

uniget returns a named variable known to dish. In this context the relevent named variables are "tau", "etal", "eta", and "etabeam".

Example:

- print d.uniget("etal")
0.99

uniput sets a named variable inside of dish. In this context the relevent named variables are "tau", "etal", "eta", and "etabeam".

Example:

- d.uniput("etal",0.90")
- print d.uniget("etal")
0.9

geteff returns a Glish record containing all these efficiencies and the opactity and the scale factor to be used for a given scan and units.

Parameters:

Based on the observation procedure, the calibration functions will attempt to calibrate data. Typically, this entails calibrating "cal on" and "cal off" switching phases of signal (on source) and reference (off source) observations, where the "cal" is a known noise diode. e.g.,

 V_{sig}(\nu) = \frac{(V_{sig,on}(\nu) w_{sig,on} + V_{sig,off}(\nu) w_{sig,off})}{w_{sig,on} + w_{sig,off}}

Similarly for the reference observation,  V_{ref} is also calculated.

These then lead to the difference spectrum:

 T_{diff}(\nu) = <T_{sys,ref}> \frac{V_{sig}(\nu) - V_{ref}(\nu)}{V_{ref}(\nu)} where, T_{sys,ref} is:

 < T_{sys,ref}(\nu) > = < \frac{T_{cal}(\nu) V_{ref}(\nu)}{V_{ref,on}(\nu) - V_{ref,off}(\nu)} > 1. calib - Function to attempt to calibrate data taking using any known procedure type. It determines the procedure sequence number and looks in the MeasurementSet for the other scans in the procedure. It then does the appropriate thing (e.g., if it is a map, it will calibrate all of the scans in the map, if it is a OnOff scan sequence (or OffOn) it will calibrate both scans and then perform the (sig-ref)/ref calcilation. See the calib function documentation in the User Reference Manual for dish for more details on this.

Parameters:

2. TPcal - Function to calibrate any TPwCAL scans. Unlike calib, it will only calibrate the specified scan(s).

Parameters:

3. FScal - Function to calibrate any FSWITCH scans. Unlike calib, it will only calibrate the specified scan(s).

Parameters:

4. SRcal - Function to perform a (SIG-REF)/REF calibration. Unlike the other calibration routines, SRcal uses the CORRECTED_DATA column (remember this is identical to the observed data in FLOAT_DATA if no calibration has been performed); this allows a layered approach to TPwCAL scans which can be noise diode calibrated and then subsequently calibrated with SRcal. SRcal is ideally suited for situations with many SIGs per REF. Unlike calib, it will only calibrate the specified scan(s).

Parameters:

Analysis

Each of the following operations has a GUI counterpart in dish. We describe only the command line interface.

Averaging

The functionality for averaging is provided in the aver function.

aver - Average a group of scans and subscans.

Example:

- myavg := d.aver([303,305:308])   #average scans 303,305,306,307,308
- myavg := d.aver([159:165],'1/4') #average every fourth subscan in 
-                                  #scans 159-165

Generally, you need to understand how the data was taken to effectively use aver.

Parameters:

There is also a means of averaging individual scans using an accumulator. Three functions are relevant: sclear, accum, and ave.

Example:

  d.sclear()    # clear the accumulator
  d.getc(35)    # retrieve calibrated scan 35
  d.accum()     # add the scan to the accumulator
  d.getc(36)    # retrieve calibrated scan 36
  d.accum()     # add the scan to the accumulator
  d.ave()       # average scans in the accumulator
  d.show()      # display the result on the plotter

sclear takes no parameters, and clears the accumulator.

accum adds a scan into the accumulator

Parameter:

ave averages the contents of the accumulator, and the average is returned to the globalscan1 spectrum for further processing.

An equivalent alternative to the previous example:

  d.sclear()       # clear the accumulator
  d.accum([35,36]) # add the scans to the accumulator
  d.ave()          # average scans in the accumulator
  d.show()         # display the result on the plotter

A UniPOPS-like stack is also available. The stack is simply a vector of scan numbers which are intended to be averaged, or operated on in some other manner. It is possible to use Glish methods to accomplish the formation and manipulation of a vector of scan numbers; nevertheless, these stack techniques provide another path for those familiar with the UniPOPS syntax.

Four functions are used to manipulate the stack: empty, addstack, delete and tellstack.

Example:

  d.empty()                 # clear the stack
  d.addstack(10,50,2)       # add even scans from 10 through 50 to the stack
  d.delete(24)              # remove scan 24
  d.delete(28)              # remove scan 28
  d.tellstack()             # show the contents of the stack
  d.aver(d.tellstack())     # average the scans listed in the stack

Function empty takes no parameters, and simply clears the stack.

Function addstack is used to append new entries to the stack.

Parameters:

So, addstack(10) appends scan 10 to the stack; addstack(15,18) appends scans 15, 16, 17 and 18 to the stack, and addstack(21,28,3) appends scans 21, 24 and 27 to the stack. If these three commands were executed on an empty stack, the result would be [10, 15, 16, 17, 18, 21, 24, 27].

delete removes a given scan by scan number from the stack. It takes a single argument, the scan number to remove. So to remove scan 16 from the stack constructed above, type d.delete(16).

tellstack takes no parameters, and is used to list the entries in the stack, and also to pass the stack to other functions in AIPS++. For example, to average the entries in the stack, type d.aver(d.tellstack()).

Fitting Baselines

Baselines can be removed during the calibration step; this is the most efficient means if the baseline regions are constant and there are many scans to operate on. Additional functions for baselining are also provided using base.

base - Perform a polynomial or sinusoidal baseline fit to a scan, optionally subtracting it.

Example:

mybl := d.base(order=2,action='subtract',range='[50:400],[1500:2000]')
                                        # This will perform a 2nd order poly.
                                        # fit to the currently displayed scan.

Parameters:

One can also fit a baseline with these UniPOPS-like functions.

d.nregion(50,100,900,1000)# Provide pairs of numbers as the channel range for the
                          # baseline region.  Any number of pairs defining separate regions
                          # to include in the fit can be given here.
d.setregion()             # This will prompt the user to set the baseline regions
                          # with a cursor
d.nfit(1)                 # Fit a first order polynomial
d.bshape()                # Show the baseline fit superposed on the spectrum
d.baseline()              # Subtract the baseline; this also calls the 
                          # d.rms() function displaying the baseline region stats
d.show()                  # Show the result

Fitting Gaussians

The dish function used to fit gaussian profiles is gauss. This function can fit multiple gaussians simultanously. The range of data used in the fit can be restricted if necessary. It can also be used interactively so set the initial guesses.

A typical sequence of events is:

  1. Plot a spectrum using, e.g., plotc
  2. Subtract a baseline, if this has not already been done.
  3. Fit the gaussian using, typically, d.gauss(1,prompt=T)

gauss - Fit one or more gaussian profiles to a spectrum

Example 1: This example fits a single gaussian to the displayed spectrum. The function makes a guess at the component to be fit. The function can be used this way when there is a single, unambiguous component to be fit.

- d.gauss(1)          
Gauss:  1
Center: 1.280574e+01   Height: 2.124378e-02    Width: 8.603278e-05
C-err : 1.807589e-05   H-err : 8.627218e-03    W-err: 3.990019e-05

Example 2: This example shows how the user can use the mouse cursor to specify initial guesses to the gaussian fit. This is useful when your spectrum has many components and you want to specify which ones to fit. After calling the d.gauss function, check the message window in the plotter and follow the instructions given there. The user will first click on the plot to specify the range of values used for the fit, and then will click on the approximate peak and half-width of the spectral components. The half-width click should be roughly on the edge of the spectral line, halfway down from the peak. The fitting routine is robust enough that, for lines with good signal, the initial guesses do not have to be perfectly placed.

- d.gauss(2,prompt=T) 
NORMAL: Follow instructions on the plotter's message line for entering
NORMAL: restrictions and initial guesses for the fits.
Gauss:  1
Center: 1.280523e+01   Height: 1.121331e-02    Width: 3.324110e-04
C-err : 4.848294e-05   H-err : 3.218354e-03    W-err: 1.141686e-04
Gauss:  2
Center: 1.281269e+01   Height: 1.322893e-02    Width: 1.396933e-04
C-err : 2.543723e-05   H-err : 5.079551e-03    W-err: 5.988269e-05

Parameters:

Moments and Statistics

There are several functions for obtaining statistical information on a given spectrum.

1. stat - Provide statistics on an SdRecord

Example:

- d.stat()            # stats of the last viewed spectrum (full range)
[peak=68.9537735, area=0.00448239934, min=-0.303991884, rms=5.74451895,
scan=35, centroid=1.42037562, vpeak=1.4203805, startint=1.41901819,
stopint=1.42400843] 
- d.stat(range='[700:800]');      # stats over a limited range of channels
[peak=68.9537735, area=914.18058, min=0.242817193, rms=16.1565856,
scan=35, centroid=745, vpeak=744, startint=700, stopint=800] 
- d.stat(range='[550:650]')      # stats over a different range of channels
[peak=0.180041969, area=-1.33219323, min=-0.202106252, rms=0.0901912276,
scan=35, centroid=0, vpeak=554, startint=550, stopint=650]

Parameters:

2. rms - Display statistics on a region of the globalscan

This function will calculate statistics on the regions set via setregion or nregion.

Example:

- d.rms()
Using 1023 for calculating baseline stats.
== Feed  1  ===
RMS   =  3.24550665    Mean =  0.000737983237    Num points =  1023
max   =  48.9361229   min =  -12.9025164
nregion =  [1 1023] 
== Feed  2  ===
RMS   =  3.29074012    Mean =  0.351124813    Num points =  1023
max   =  50.4430733   min =  -14.0051394
nregion =  [1 1023] 

3. stats - Display statistics over a region.

This function will calculate statistics of the globalscan. It will use the global echan and bchan parameters for the region if available; these can also be set within the function.

Example:

- d.stats()
Feed : 1       bchan: 1        rms  : 5.744519       min  : -0.303992   
Npts : 1023    echan: 1023     mean : 0.898234       max  : 68.953773   

Feed : 2       bchan: 1        rms  : 6.180395       min  : -0.329462   
Npts : 1023    echan: 1023     mean : 0.912738       max  : 73.913177   

Parameters:

4. moment - Display statistics over a region.

This function will calculate statistics of the globalscan. It will use the global emoment and bmoment parameters for the region if available; these can be set with the bmoment and emoment.

Example:

- d.bmoment(700)
T
- d.emoment(800)
T
- d.moment()     
[peak=68.9537735, area=914.18058, min=0.242817193, rms=16.1565856,
scan=35, centroid=745, vpeak=744, startint=700, stopint=800]

Regridding

smooth - Smooth the resolution of the last viewed spectrum

Example:

- smooth_spc:=d.smooth(type='HANNING',decimate=T);
- d.plotscan(smooth_spc)

Parameters:

boxcar, hanning, and chngres are streamlined cases of smooth using type BOXCAR, HANNING, or GAUSSIAN respectively, and with decimation=T.

boxcar - Perform a boxcar smooth on the last viewed spectrum

Example:

d.show()
d.boxcar(5)
d.show()

Parameters:

hanning - Perform a hanning smooth on the last viewed spectrum

Example:

d.show()
d.hanning()
d.show()

chngres - Perform a gaussian smooth on a spectrum

Example:

d.show()
d.chngres(5)
d.show()

Parameters:

Saving Spectra

Saving spectra to into a new or existing output file is done using fileout, lsoutfile, save, and keep. fileout was described in the section on file access.

save - Save a spectrum to the output data set.

Example:

d.files()
Current filein is  :  N1SP
Current fileout is :  exampleout
d.save()                           #save currently viewed spectrum to output file.

Parameters:

keep does the same thing as save in the default case; it takes no arguments

lsoutfile - List the scan numbers in the specified output file.

Example:

- d.fileout('exampleout')
New file  exampleout  is created
- d.save()
- d.lsoutfile()
159

Writing Spectra

writetofile - Write ASCII columned data of x and y to a disk file.

Example:

- d.writetofile('final.spc'); #default is to write currently viewed spectrum.

The columns that are written out are: the x-axis in the currently displayed units and the data arrays for each polarization.

Parameters:

Imaging

Imaging in dish is done with the imager tool in AIPS++. Currently, there are two functions (makeim and imagems) in dish to achieve this. makeim will operate on a mapping procedure within a MS. imagems will operate on all of the scans within a MS; this is particularly useful for imaging several pieces of maps over the same region. Once an image is made, it can be examined by constructing an image tool as in this example.

include 'image.g'          # need only be done once
myim := image('scanimage') # insert the name of your image here
myim.view()                # launch the viewer - many other functions are available

makeim - Make a spectral line data cube.

Example:

- d.makeim(345,600,900,imname='g29.im');

This function selects the appropriate data from the MeasurementSet, regrids the data and constructs the image. The data are converted into the coordinate system of the image and then added to the image using a gridding function (boxcar [BOX], prolate spheroidal [SF], or primary beam [PB]). The size of the convolving function can be controlled for BOX and SF gridding. The PB gridding is not recommended since the primary beam model currently known to the imager is a poor approximation to the GBT beam. The default size of the convolving function (convsupport) seems to produce the most satisfying images although there is no right answer. For BOX convolving, the default is 0. That is equivalent to nearest-pixel gridding. Data values are simply averaged in with whatever has previously contributed to the cell in the image nearest to the actual pointing direction for that data value. For SF gridding,the convsupport defaults to a value of 1. This means that the convolving function falls to a value of 0 at a radius of 1 image pixel from the pointing direction of each data point. There is no convolution along the frequency axis. Data values are simply averaged at the frequency value in the image nearest to their observed value.

Parameters:

imagems - Make a spectral line data cube from scans in a MeasurementSet.

Example:

- d.imagems('cloud_SP',520,1000,imname='cloud.im');

This function selects the appropriate data from the MeasurementSet, regrids the data and constructs the image. The data are converted into the coordinate system of the image and then added to the image using a gridding function (boxcar [BOX], prolate spheroidal [SF] or primary beam [PB]). The PB gridding is not recommended since the primary beam model currently known to the imager is a poor approximation to the GBT beam. The default size of the convolving function (convsupport) seems to produce the most satisfying images although there is no right answer. For BOX convolving, the default is 0. That is equivalent to nearest-pixel gridding. Data values are simply averaged in with whatever has previously contributed to the cell in the image nearest to the actual pointing direction for that data value. For SF gridding,the convsupport defaults to a value of 1. This means that the convolving function falls to a value of 0 at a radius of 1 image pixel from the pointing direction of each data point. There is no convolution along the frequency axis. Data values are simply averaged at the frequency value in the image nearest to their observed value.

Parameters:

Image Moments

The image tool function moments offers traditional moment analysis (weighted sums of profiles) of images. It offers a wide range of moments and a wide range of methods with which to calculate them. The word `moment' is used loosely here. It refers to collapsing an axis (the moment axis) to one pixel and setting the value of that pixel (for all of the other non-collapsed axes) to something computed from the data values along the moment axis. For example, take an RA-DEC-Velocity cube, collapse the velocity axis by computing the mean intensity at each RA-DEC pixel. This function offers many different moments and a variety of interactive and automatic methods to compute them. A quick summay of the available moments:

- im:=image('g29im')       #g29im is the data cube
- im.moments(moments=[-1,0])    #get the average and integrated moments
Moment axis type is Frequency

***********************************************************************
You have selected the following methods
The basic method
Created /home/despina2/scratch/jmcmulli/g29im.average
Created /home/despina2/scratch/jmcmulli/g29im.integrated
Begin computation of moments
Finished image::moments
       0.48 real        0.08 user        0.02 system
T 
- im2:=image('g29im_integrated')
- im2.view()
- im.summary();
- r:=drm.box(blc='1 1 1 5', trc='20 20 1 100') # create a region
- #using the channels 5 to 100; the first 2 coordinates are ra, dec,
- #the 3rd is stokes, and the 4th is the channel axis.
- im.moments(moments=0,region=r,outfile='g29im_lowvel') #create the
- #integrated intensity over channels 5-100

You can also use the GUI interface via:

- im:=image('g29im')            #g29im is the data cube
- im.momentsgui();      #use GUI to derive moments

See the User Reference Manual on the moments function of the image tool for the most details moments and moment methods.

Image Source Fitting

Source fitting is achieved through the imagefitter tool. From the example above:

- imfit:=imagefitter('g29im_integrated')
- #Use the GUI to select a region (double click to derive source characteristics,
- #statistics, residuals, etc. The 'show' button will display the fit value.

Image math

Manipulation of images is done with the imagecalc tool. With this you can construct an image from expressions involving other images. For example,

im1 := imagecalc(outfile='x3', pixels='sin(x1) + min(x2) ')

where the image disk files x1 and x2 must pre-exist and the result is the image disk file called x3.

You can also construct a read-only image from expressions involving other images. The output image is never created, it is just evaluated each time you use it.

im2 := imagecalc(pixels='pi() - min(x2) + sqrt(x1)')

where the image disk files x1 and x2 must pre-exist. Note that by simply excluding the output file name (argment outfile) you have created the read-only image.

With the image calc function, you can change the pixel values of an image by replacing them with the result of the expression:

im1 := image('x2')
im2 := im1.calc('abs(x2) / min(x2)')

where the image disk file x2 must pre-exist. Because the scalar expression is evaluated first, the images in the expression can be the same as the image which is being overwritten.

Note that for image file names with special characters in them (like for example), you should (double) escape those characters or put the file name in double quotes. E.g.

- im1 := imagecalc(pixels='test\\-im')            # Note double escape
- im2 := imagecalc(pixels='"test-im"')

When using imagecalc, you can use either image disk file names, or an associated image tool name in the expression. For example,

im1 := image('im1')
im2a := imagecalc('im2a', '2*im1')     # Use disk file names
im2b := imagecalc('im2b', '2*$im1')    # Use tool name

For information on image manipulation (concatenation, addition, etc), see the aips++ cookbook.

Exiting dish

To exit dish, type 'exit' at the Glish command line. If you have enabled the "Save state when done" option (in the GUI), the state of dish will be preserved for your next session (it will be loaded automatically). You can also manually save the state of dish using the File menu options of the main dish GUI.

Spectral Line Observing Recipes

In the following, the > designates a UNIX prompt, and a '-' designates the glish prompt.

Frequency Switched data: Pointed observations

This section details calibration of data taken in the following modes:

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish tool
...
- d.open('exampleSP')
T
- d.files()               #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T 
- d.gms()                                       #provide brief summary
Scan     Object                       Obs_mode   Procseqn   Procsize
  35         S8            Track:FSWITCH:FSW01          1          1
  36         S8            Track:FSWITCH:FSW12          1          1
  37         S8            Track:FSWITCH:FSW12          1          1
  38         S8      OffOn:PSWITCHOFF:TPWCALSP          1          2
  40         S8       OnOff:PSWITCHON:TPWCALSP          1          2
  42         S8            Track:NONE:TPWCALSP          1          1
T 
- #Note: This only lists the first scan in a procedural sequence of scans
- d.lscans()                                    #shows all scans present
[35 36 37 38 39 40 41 42]  
- d.plotr(35,1)                                 #plot the raw(observed) data
                                                #for the first phase of scan
                                                #35. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case
                                                #this is all data with CAL ON.
-
- d.calib(35)                                   #this will calibrate scan 35
                                                #according to the way the
                                                #the data were taken (i.e., the
                                                #observing procedure
- d.plotc(35)                                   #plot the calibrated data for
                                                #scan 35. Since no integration
                                                #was specified, all data is
                                                #averaged.
- d.plotc(35,1)                                 #plots the first integration of
                                                #the calibrated data for 35.
- d.plotc(35,3,2)                               #plots the third integration of
                                                #the second polarization for 
                                                #scan 35.
- d.plotc(scan=35,int=3,pol=2)                  #same using the explicit names
                                                #for the arguments.
-
- #HINT: if you are uncertain as to the arguments for a function, simply type
- #      the function name.
- d.plotc
function (val scan, val int = F, val pol = F) {
(ok := public.plotscan(public.getc(scan, int, pol)));
return T}
- #NOTE: if you are unhappy with the calibration, you can simply reapply it
- #      using different attributes.  d.calib always starts from the raw,
- #      uncalibrated data.
- d.calib(35,baseline=T,range=[300:600,800:1000]);
                                                #Apply calibration but also
                                                #baseline the data using the
                                                #specified range (defaults
                                                #to first order but this can
                                                #also be specified.
- #This will over-write the calibration data with the new calibration data.
- d.plotc(35)                                  #re-examine the data

Total Power observations

This section details calibration of data taken in the following modes:

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish tool
...
- d.open('exampleSP')
T
- d.files()                                     #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T
- d.gms()                                       #provide brief summary
Scan     Object                       Obs_mode   Procseqn   Procsize
  35         S8            Track:FSWITCH:FSW01          1          1
  36         S8            Track:FSWITCH:FSW12          1          1
  37         S8            Track:FSWITCH:FSW12          1          1
  38         S8      OffOn:PSWITCHOFF:TPWCALSP          1          2
  40         S8       OnOff:PSWITCHON:TPWCALSP          1          2
  42         S8            Track:NONE:TPWCALSP          1          1
T
- #Note: This only lists the first scan in a procedural sequence of scans
- d.lscans()                                    #shows all scans present
[35 36 37 38 39 40 41 42] 
- d.plotr(42,1)                                 #plot the raw(observed) data
                                                #for the first phase of scan
                                                #42. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case
                                                #this is all data with CAL ON.
-
- d.calib(42)                                   #this will calibrate scan 42
                                                #according to the way the
                                                #the data were taken (i.e., the
                                                #observing procedure
- d.plotc(42)                                   #plot the calibrated data for
                                                #scan 42. Since no integration
                                                #was specified, all data is
                                                #averaged.
- d.plotc(42,1)                                 #plots the first integration of
                                                #the calibrated data for 42.
- d.plotc(42,3,2)                               #plots the third integration of
                                                #the second polarization for
                                                #scan 42.
- d.plotc(scan=42,int=3,pol=2)                  #same using the explicit names
                                                #for the arguments.
-
- #HINT: if you are uncertain as to the arguments for a function, simply type
- #      the function name.
- d.plotc
function (val scan, val int = F, val pol = F) {
(ok := public.plotscan(public.getc(scan, int, pol)));
return T}
- #NOTE: if you are unhappy with the calibration, you can simply reapply it
- #      using different attributes.  d.calib always starts from the raw,
- #      uncalibrated data.
- d.calib(42,baseline=T,range=[300:600,800:1000]);
                                                #Apply calibration but also
                                                #baseline the data using the
                                                #specified range (defaults
                                                #to first order but this can
                                                #also be specified.
- #This will over-write the calibration data with the new calibration data.
- d.plotc(42)                                   #re-examine the data
- #NOTE: You can also individually calibrate each scan in the sequence with
- #      'd.TPcal(scan)'. There are numerous dish functions for 
- #       manipulating SDRecords (e.g., scanscale (multiplies a scan
- #       by a factor, scandiv (divides two scans), etc.

Position Switched Observations

This section details calibration of data taken in the following modes:

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish tool
...
- d.open('exampleSP')
T
- d.files()                                     #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T
- d.gms()                                       #provide brief summary
Scan     Object                       Obs_mode   Procseqn   Procsize
  35         S8            Track:FSWITCH:FSW01          1          1
  36         S8            Track:FSWITCH:FSW12          1          1
  37         S8            Track:FSWITCH:FSW12          1          1
  38         S8      OffOn:PSWITCHOFF:TPWCALSP          1          2
  40         S8       OnOff:PSWITCHON:TPWCALSP          1          2
  42         S8            Track:NONE:TPWCALSP          1          1
T
- #Note: This only lists the first scan in a procedural sequence of scans
- d.lscans()                                    #shows all scans present
[35 36 37 38 39 40 41 42] 
- d.plotr(39,1)                                 #plot the raw(observed) data
                                                #for the first phase of scan
                                                #38. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case

                                                #this is all data with CAL ON.
-
- d.calib(39)                                   #this will calibrate scan 38/39
                                                #(since both compose the 
                                                #the OffOn procedure), 
                                                #according to the way the
                                                #the data were taken (i.e., the
                                                #observing procedure
- d.plotc(39)                                   #plot the calibrated data for
                                                #scan 39. Since no integration
                                                #was specified, all data is
                                                #averaged.
                                                #The (sig-ref)/ref data is 
                                                #only stored in the 'On' scans
                                                #data record; the 'Off' scan
                                                #contains only the calibrated
                                                #TPwCal data.
- d.plotc(39,1)                                 #plots the first integration of
                                                #the calibrated data for 39.
- d.plotc(39,3,2)                               #plots the third integration of
                                                #the second polarization for
                                                #scan 39.
- d.plotc(scan=39,int=3,pol=2)                  #same using the explicit names
                                                #for the arguments.
-
- #HINT: if you are uncertain as to the arguments for a function, simply type
- #      the function name.
- d.plotc
function (val scan, val int = F, val pol = F) {
(ok := public.plotscan(public.getc(scan, int, pol)));
return T}
- #NOTE: if you are unhappy with the calibration, you can simply reapply it
- #      using different attributes.  d.calib always starts from the raw,
- #      uncalibrated data.
- d.calib(38,baseline=T,range=[300:600,800:1000]);
                                                #Apply calibration but also
                                                #baseline the data using the
                                                #specified range (defaults
                                                #to first order but this can
                                                #also be specified.
- #This will over-write the calibration data with the new calibration data.
- d.plotc(38)                                  #re-examine the data

Position Switched Observations - Many SIGs per REF

This section details calibration of data taken in the following modes:

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish
tool
...
- d.open('exampleSP')
T
- d.files()                                     #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T
- d.gms()                                       #provide brief summary
Scan     Object                       Obs_mode   Procseqn   Procsize
  35         S8            Track:FSWITCH:FSW01          1          1
  36         S8            Track:FSWITCH:FSW12          1          1
  37         S8            Track:FSWITCH:FSW12          1          1
  38         S8      OffOn:PSWITCHOFF:TPWCALSP          1          2
  40         S8       OnOff:PSWITCHON:TPWCALSP          1          2
  42         S8            Track:NONE:TPWCALSP          1          1
T
- #Note: This only lists the first scan in a procedural sequence of scans
- d.lscans()                                    #shows all scans present
[35 36 37 38 39 40 41 42]
- d.plotr(39,1)                                 #plot the raw(observed) data
                                                #for the first phase of scan
                                                #38. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case
                                                #this is all data with CAL ON.
-
- d.calib(39)                                   #this will calibrate scan 38/39
                                                #(since both compose the 
                                                #the OffOn procedure), 
                                                #according to the way the
                                                #the data were taken (i.e., the
                                                #observing procedure
- d.plotc(39)                                   #plot the calibrated data for
                                                #scan 39. Since no integration
                                                #was specified, all data is
                                                #averaged.
                                                #The (sig-ref)/ref data is 
                                                #only stored in the 'On' scans
                                                #data record; the 'Off' scan
                                                #contains only the calibrated
                                                #TPwCal data.
- d.plotc(39,1)                                 #plots the first integration of
                                                #the calibrated data for 39.
- d.plotc(39,3,2)                               #plots the third integration of
                                                #the second polarization for
                                                #scan 39.
- d.plotc(scan=39,int=3,pol=2)                  #same using the explicit names
                                                #for the arguments.

- #Now, if you wanted to use a different reference scan for this on, you could
- #do the following:
- d.TPcal(41)                                   #calibrate 'Off' scan 41.
- d.SRcal(39,41)                                #perform (sig-ref)/ref with
                                                #signal=39, reference=41
- d.SRcal(39,[38,41]);                          #perform (sig-ref)/ref with
                                                #signal scan=39, reference=
                                                #the average of 38 and 41.
                                                #in general:
-d.SRcal([vector of signal scans],
         [vector of reference scans])           #all reference scans will be
                                                #averaged and that average will be 
                                                #subtracted from each signal scan in turn.

---++++ Frequency Switched Observations - Mapping
This section details calibration of data taken in the following modes:

    * <nop>RALongMap:FSWITCH:FSW01
    * <nop>RALongMap:FSWITCH:FSW12
    * <nop>DECLatMap:FSWITCH:FSW01
    * <nop>DECLatMap:FSWITCH:FSW12 

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish tool
...
- d.open('exampleSP')
T
- d.files()                                     #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T
- d.gms()                                       #provide brief summary
Scan     Object                       Obs_mode   Procseqn   Procsize
 303         S6      T      rack:FSWITCH:FSW01          1          1
 304     G250p8        RALongMap:FSWITCH:FSW01          1         41
T
- #Note: This only lists the first scan in a procedural sequence of scans
- d.lscans()                                    #shows all scans present
[303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
341 342 343 344]
- d.plotr(304,1)                                #plot the raw(observed) data
                                                #for the first phase of scan
                                                #303. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case
                                                #this is all data with CAL ON.
-
- d.calib(304)                                  #this will calibrate scan 304
                                                #according to the way the
                                                #the data were taken (i.e., the
                                                #observing procedure
- d.plotc(303)                                  #plot the calibrated data for
                                                #scan 303. Since no integration
                                                #was specified, all data is
                                                #averaged.
- d.plotc(303,1)                                #plots the first integration of
                                                #the calibrated data for 303.
- d.plotc(303,3,2)                              #plots the third integration of

                                                #the second polarization for
                                                #scan 303.
- d.plotc(scan=303,int=3,pol=2);                #same using the explicit names
                                                #for the arguments.
-
- #HINT: if you are uncertain as to the arguments for a function, simply type
- #      the function name.
- d.plotc
function (val scan, val int = F, val pol = F) {
(ok := public.plotscan(public.getc(scan, int, pol)));
return T}
- #NOTE: if you are unhappy with the calibration, you can simply reapply it
- #      using different attributes
- d.calib(303,baseline=T,range=[300:600,800:1000]);
                                                #Apply calibration but also
                                                #baseline the data using the
                                                #specified range (defaults
                                                #to first order but this can
                                                #also be specified.
- #This will over-write the calibration data with the new calibration data.
- d.plotc(303)                                  #re-examine the data
- #NOTE:In addition, if the SIG/REF signals are mixed (there was a temporary
- #     problem with the SPECTRAL PROCESSOR which caused some fraction of the
- #     scans to be flipped), you can reverse the sense of SIG and REF by
- #     doing:
- d.FScal(304,flipsr=T)                         #flips what is SIG and REF
-
- #NOTE:You can write a procedure to interactively view and flip your data.
- 
- sns:=seq(304,344)                             #make a vector from 304-344
- for (i in sns) {                              #loop over these scans
+ d.plotc(i)                                    #plot scan
+ ans:=readline()                               #pause and prompt user for input
+ if (ans=='y') {                               #if 'y' typed, then 
+    d.FScal(i,flipsr=T)                        #  flip SIG and REF sense
+ }
+ }
- 
- d.makeim(304,600,900,imname='ralong')         #Make an image. This needs the
                                                #  first scan in the map
                                                #  the beginning (600) and end
                                                #  (900) channels to include.
                                                #  step determines the 
                                                #  averaging over channel 
                                                #  (none here) and imname
                                                #  specifies the output image
# NOTE: This actually creates three images on disk: 1) the original image, 
#       a weights image, and an image corrected (divided) by the weights.
#       These are imname, imname_weight and imname_corr.
- im:=image('ralong_corr')                      #Make an image tool - lots of
                                                #functions here!
- im.view()                                     #View the image

Total Power Observations - Mapping

This section details calibration of data taken in the following modes:

> source /home/aips++/gbt/aipsinit.sh           #load environment
> dish                                          #start AIPS++ dish tool
...
- d.open('exampleSP')
T
- d.files()                                     #show active files
Current filein is  :  exampleSP
Current fileout is :  not set
T
- d.gms()
successful readonly open of default-locked table ./specLine_M33c_SP/NRAO_GBT_GLISH: 23 columns, 94 rows
Scan     Object                       Obs_mode   Procseqn   Procsize
   6        M33          RALongMap:NONE:TPWCAL          1         91
  10        M33          RALongMap:NONE:TPWCAL          1         91
T 
- d.lscans()
[6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99]  

- d.plotr(10,1)                                 #plot the raw(observed) data
                                                #for the first phase of scan
                                                #10. Since no integration
                                                #value is specified, it averages
                                                #all phase 1 data (in this case
                                                #this is all data with CAL ON.
- #Since there is no TP mapping procedure that will take offs, we must use
- #some of the map as the reference data.
- #First calibrate all scans in the completed map (beginning scan 10)
- for (i in 10:99) { d.TPcal(i);}               #Total power calibrate all scans
-                                               #in the map
- d.SRcal([10:99],[10,99],T,[50:350,725:1000]); #Sig/Ref calibrate the scans
-                                               #using the average of the first
- #and last scans in the map (10,99) as the reference
- d.makeim(10,350,625,imname='m33.im');         #make a data cube using the map
-                                               #beginning on scan 10, using
-                                               #channels 350-625 (default is
-                                               #step=1 which is no averaging)
- im:=image('m33.im');                          #create an image tool
- im.view();                                    #view the tool
- im.summary();                                 #see image summary
-
- r := drm.box(blc='1 1 1 x', trc='x x 1 y');   #just want planes x to y of cube
- im.moment(moments=0,region=r,outfile='m33int')#create integrated
- im.moments(moments=0,outfile='m33int');       #use all planes for integrated
-                   #view m33int!

OTF Mapping

This section details calibration of data taken in the following modes:

Currently, the DCR tool is in a separate utility and must be included.

include 'gbtcalutils.g';

This creates a gc tool which four associated functions:

  1. setdata takes the file name of a MeasurementSet on disk.
  2. contcal calibrates the data
  3. makeimage makes an image
  4. covercorr corrects the image to the proper scale

See the Getting Results chapter on Continuum Single Dish Imaging for more details: docs/gettingresults/grvol3/node4.html.

- gc.setdata('cassaDCR');
successful readonly open of default-locked table cassaDCR/NRAO_GBT_GLISH: 21 col
umns, 120 rows
successful readonly open of default-locked table cassaDCR/NRAO_GBT_IF: 22 column
s, 240 rows
successful read/write open of default-locked table cassaDCR/FEED: 12 columns, 2 
rows
successful read/write open of default-locked table cassaDCR/POLARIZATION: 4 colu
mns, 2 rows
successful read/write open of default-locked table cassaDCR/SPECTRAL_WINDOW: 14 
columns, 1 rows
successful readonly open of default-locked table cassaDCR/POINTING: 15 columns, 
48000 rows
T 
- gc.contcal() 
successful read/write open of default-locked table cassaDCR: 28 columns, 192000 
rows
T 
- gc.makeimage()
successful readonly open of default-locked table cassaDCR: 28 columns, 192000 ro
ws
Starting server imager
Server started: /export/home/guthwine/aips++/linux_gnu/bin/imager (AIPS++ versio
n: 1.7 (build #405))
Opening MeasurementSet cassaDCR
defaultcatalog (dc) ready
Starting imager::setdata
Selecting data
Performing selection on MeasurementSet
Selecting on field and spectral window ids
By selection 192000 rows are reduced to 48000
Finished imager::setdata
       0.96 real        0.69 user        0.19 system
successful readonly open of default-locked table cassaDCR/NRAO_GBT_GLISH: 21 col
umns, 120 rows
Cell size is  0.289495253arcmin
Map size is  117.705376  by  59.9669179
Grid sizes are  406   208
Defining image properties
nx = 406 is not composite; nx = 432 or 400 will be more efficient
ny = 208 is not composite; ny = 216 or 200 will be more efficient
Setting processing options
Starting imager::weight
Weighting MS: IMAGING_WEIGHT column will be changed
Natural weighting
Sum of weights = 48000
Finished imager::weight
       32.6 real       23.58 user        6.11 system
Starting imager::makeimage
Calculating image (without full skyequation)
Making single dish image from corrected data
Image is : scanimage
Frequency = 8.9 GHz, synthesized continuum bandwidth = 0.08 GHz
Image polarization = Stokes I
Frequency = 8.9 GHz, synthesized continuum bandwidth = 0.08 GHz
Image polarization = Stokes I
Performing Single Dish gridding with convolution function SF
Gridding will use specified common tangent point:
     23:21:00.00         +58.32.00.00             B1950
Using prolate spheriodal wave function as the convolution function
Finished imager::makeimage
      10.25 real        6.77 user        0.49 system
Starting imager::makeimage
Calculating image (without full skyequation)
Making single dish coverage function 
Image is : scanimage_weight
Frequency = 8.9 GHz, synthesized continuum bandwidth = 0.08 GHz
Image polarization = Stokes I
Frequency = 8.9 GHz, synthesized continuum bandwidth = 0.08 GHz
Image polarization = Stokes I
Using prolate spheriodal wave function as the convolution function
Finished imager::makeimage
       8.12 real        6.58 user        0.52 system
Successfully closed empty server: imager
T 
- gc.covercorr()
Starting server app_image
Server started: /export/home/guthwine/aips++/linux_gnu/bin/app_image (AIPS++ ver
sion: 1.7 (build #405))
Selected bounding box : 
    [1, 1, 1, 1] to [406, 208, 1, 1]  (23:28:23.897, +58.01.04.977, I, 8.900000e
+09Hz to 23:13:25.534, +59.00.59.643, I, 8.900000e+09Hz)
Creating new statistics storage lattice of shape [9]

Number points =   8.444800e+04       Sum      =   8.444801e+04
Mean          =   1.000000e+00
Variance      =   1.026810e+00       Std dev   =   1.013316e+00
Rms           =   1.423657e+00

Minimum value   0.000000e+00 at [1, 1, 1, 1] (23:28:23.897, +58.01.04.977, I, 8.
900000e+09Hz)
Maximum value   4.499732e+00 at [105, 182, 1, 1] (23:24:41.961, +58.54.05.639, I
, 8.900000e+09Hz)

Creating image `scanimage_corr' of shape [406, 208, 1, 1]
Created mask `mask0'
T 
- #Scale images to Jy (e.g., 1.76 K/Jy)
- im:=imagecalc(outfile='scanimage_tmb',pixels='(scanimage_corr)/1.76');
- im.view();    #note the higher amplitudes

Index of dish commands

BScal
calibrate beam switched data.
FScal
calibrate frequency switched data.
SRcal
calibrate signal/reference scans.
TPcal
calibrate total power data.
accum
add a scan (or scans) to an ongoing accumulation (average).
addstack
add a scan number to the stack.
ave
get the average from the onling accumulation.
aver
Average a group of scans,subscans.
avgpols
Averages all polarizations in the globalscan.
base
Perform a polynomial baseline fit to a scan.
baseline
Perform a polynomial baseline fit to spectrum in globalscan1.
bdrop
Set value for dropping beginning channels of a spectrum in display.
bgauss
Set the value of the bgauss parameter.
bias
Add an offset to the globalscan data.
bmoment
Sets the bmoment parameter.
boxcar
Perform a boxcar smoothing
bshape
Show the baseline fit of order nfit to globalscan1
cal
Calibrate data (this is the workhorse behind calib)
calib
Apply calibration to a scan (GBT only currently).
center
Sets the center parameter.
chngres
Perform a gaussian smooth on a spectrum.
clearrm
Clear all variables from results manager, etc.
clip
Clip/Edit data (set flags).
close
Close a previously opened data set.
copy
Copies a value to another name using uniput/uniget.
dcbase
Removes a zero-order baseline using nregion.
dhistory
Append a history message to the hist field of an SdRecord.
divide
Divides globalscan1 by offscan1.
done
Exits and destroys the current dish tool.
edrop
Set value for dropping end channels of a spectrum in display.
eff
Get the default efficiences for a given frequency and elevation.
egauss
Set the value of the egauss parameter.
emoment
Set the value of the emoment parameter.
empty
Empty the stack.
filein
Sets the scan group that will be manipulated.
fileout
Sets the scan group that can be written to.
files
Prints the currently set values for filein/out.
find
Do a grep on a string to find glish variables.
flag
Flag some data.
fold
Fold frequency switched data.
fullrange
Toggles out of a restricted viewing range on plotter (see range).
galactic
Provide the coordinates in the Galactic reference frame.
gauss
Fit gaussian profiles.
gbtsum
Summarize a GBT project directory.
getc
Retrieve calibrated data (from the CORRECTED_DATA column).
geteff
Get the efficiences, opacity, and scale factor for a given scan.
getpol
Get an SdRecord containing only one polarization from the globalscan.
getr
Retrieve raw data (from the FLOAT_DATA column)
getscan
Retrieve a scan (SdRecord) from a scan group.
getvf
Return the velocity and frequency for a specified channel. getvfarray:Return the velocities and frequences for the currently viewed spectrum.
gms
Print MeasurementSet summary to screen.
gridmap
Print spectra on the plotter according to their locations.
gui
Toggles mapping of dish main gui (results manager).
hanning
Perform a hanning smooth.
header
Print formatted header information to the command line window.
height
Sets the height parameter.
help
Provide simple help on dish functions
history
Add a string or vector of strings to the history of a current SdRecord
hwidth
Sets the hwidth parameter.
imagems
Make a data cube from scans in a MS.
imcal
Calibrate an imaging/mapping procedure
import
Import GBT data into an AIPS++ MeasurementSet
info
Lists the available dish functions.
keep
Saves the current globalscan1 SdRecord to the designated fileout.
klscans
Lists the scans in fileout (the "keep" file).
listscans
List the scan numbers from the active scan group.
lkmap
Map scans on the plotter. logcommand:Writes command to scripter.
ls
Lists files in a directory.
lscans
Synonymous with listscans.
lsoutfile
Lists scans in the fileout scangroup
makeim
Make an image from scans in a MeasurementSet.
message
Writes a command to the dish GUI message entry.
minus
Subtracts offscan1 from globalscan1.
moment
Statistics using bmoment and emoment.
mscal
Calibrate a MeasurementSet.
msr
Implementation of Arecibo galaxy profile charactizing tool.
mult
Scales (multiplies) a scan by a value.
multiply
Mutiply globalscan1 by offscan1.
nfit
Set the order of the polynomial for baseline subtraction.
nsubscans
How many subscans are associated with a particular scan number.
nogui
Unmaps frame to dish main GUI.
nregion
Set the channel ranges for baseline subtraction.
open
Load a scan group from disk into dish and perform a fil ein on it.
page
Clears the dish plotter display.
peak
Obtain the peak amplitude, half-width and center in the displayed spectrum
plotc
Plot calibrated data (from the CORRECTED_DATA column)
plotcom
Direct access to the plotter_command method of the dish plotter.
plotr
Plot raw data (from the FLOAT_DATA column)
plotscan
Plot an SdRecord.
plotter
Return a reference to the dish plotter so that it can be interacted with from the command line.
plotxy
Plot two vectors in the dish plotter.
plus
Add offscan1 to globalscan1.
qdumps
Returns nsubscans, nphases, nspwin, nfield, and (nsubscans/nphases) for a given scan.
qscan
Query characteristics of a scan.
qsp
Query characteristics of a scan - more detail than qscan.
range
Restrict the displayed plotter range (xmin, xmax, ymin, ymax).
reference
See TPcal
restore
Retrieve the contents of the uni Record from disk.
restorestate
Restore the state of *dish*'s GUIs.
rmadd
Add an SdRecord to the results manager.
rms
Display statistics on baseline regions.
save
Save an SdRecord to file.
savestate
Save the current state of dish.
saxis
Set the units of the plotters displayed x axis
scale
Multiply the array in an SdRecord by a value.
scanadd
Add scan1 and scan2.
scanbias
Adds a bias level to a scan.
scandiv
Divide scan 1 by scan 2.
scanmult
Multiply scan 1 by scan 2.
scanscale
Scale a scan by a value.
scansrr
Performs a signal-reference/reference.
scansub
Subtract scan2 from scan1.
sclear
Clear the accumulator.
select
Select a subset of a scangroup.
setregion
Set the channel range for use in baseline subtraction
show
Display the globalscan1 SdRecord
show1
Display one polarization of the globalscan1 SdRecord
showref
Display the reference scan (vref).
signal
See TPcal
smooth
Smooth (hanning, boxcar or gaussian) an SdRecord.
stat
Generate statistics over a line region.
statefile
Changes file for state saving.
stats
Generate statistics over a region.
store
Store the contents of the uni Record on disk.
summary
Print out a more detailed summary of scans from a scan group.
tellstack
Print out the contents of the stack.
uniget
Get a value known to dish by name.
uniput
Store a value by name for use by dish.
unirec
The record of known values manipulated by uniget and uniput.
upr
Print the current value of the specified variable in the uni-record.
utable
Print channel and data columns to command window
writetofile
Write X,Y axes to an ascii file on disk.
zline
Toggles the display of the zero-line of the y-axis on the plotter.

Example .aipsrc to put in your home directory

#basic
userinfo.name:  Your Name
userinfo.email: yourname@nrao.edu
userinfo.org:   NRAO
system.aipscenter:      NorthAmerica
system.resources.memory: 512

#catalog
catalog.gui.auto:       T
catalog.confirm:        T
catalog.view.PostScript:        ghostview
catalog.edit.ascii:             xterm -e vi

#dish
#make sure this is on a local disk
dish.statefile: /tmp/jmcmulli_aips++/default

#logger
logger.file:    aips++.log
logger.height:  8
logger.default: screen


#progress
#progress.show: F

#toolmanager
#don't start the tool manager initially - comment out if you want it
toolmanager.gui.auto:   F
#toolmanager.refresh:   10s

#user
user.prestart:  none
#user.display.memory: False
user.cache:     ./cache
user.aipsdir:   /tmp/jmcmulli_aips++
user.directories.work:  .
#user.initfiles: dish.g

#viewer
display.axislabels: on
display.colormaps.defaultcolormap: Hot Metal 1

Using dish like UniPOPS

This section discusses various ways that someone familiar with UniPOPS could use dish.

Sample Data Reduction Session

% ssh etamin
% cd /home/etamin/scratch
% mkdir myname
% cd myname
% . /home/aips++/gbt/aipsinit.sh
% aips++ -l uni2.g
- d.import('/home/gbtdata/tigerTeam_02','tiger.ms',startscan=20,stopscan=33)
- d.lscans()
[20 21 22 23 24 25 26 27 28 29 30 31 32 33]
- d.reference(20)
- d.signal(21)
- d.temp()
- d.show()
- d.nfit(5)
# Use the plotter to set the x-axis units to pixels (channel number)
- d.nregion(0,3600,4100,8200)
- d.bshape()                   # to show the fit
- d.baseline()                 # to subtract the baseline
- d.show()
- d.uscale(2.3)                                                           
- d.setYUnit('Jy')
- d.show()
- d.bdrop(2500)
- d.edrop(2500)
- d.show()
- d.sclear()
- d.getc(26)
- d.show()
- d.stats(bchan=1000,echan=2000)
- d.accum()
- d.getc(28)
- d.show()
- d.accum()
- d.stats(bchan=1000,echan=2000)
- d.ave()
- d.show()
- d.stats(bchan=1000,echan=2000)

About the Sample Data

The tigerTeam_02 data in the examples used in this appendix were taken with the GBT on 11 October 2001. The L-band receiver (1.15-1.73 GHz) was used with the intent to observe the HI profiles of an assortment of galaxies. The backend was the GBT spectrometer. The ``OffOn'' procedure in GO was used to drive the position-switched observations. Signal and reference data are recorded in separate, adjacent scans of equal duration.

Processing GBT Scans

The first step in processing data is to identify the input data file. The technique for doing so differs depending on if the data are in the raw GBT FITS format, or have been previously filled into the AIPS++ MeasurementSet format. To import data from FITS files, use the import command:

- d.import('/home/gbtdata/tigerTeam_02','tiger.ms',startscan=20,stopscan=33)

This command creates a MeasurementSet called tiger.ms. If the desired MeasurementSet already exists on disk, use the dopen command to load the data:

- d.open('/home/aips++/data/demo/dishdemo/tiger.ms')

These data sets are specific to the Green Bank installation. For other sites, consult the AIPS++ system administrator to see how to access this data.

List the scans available in your new data set:

- d.lscans()
[20 21 22 23 24 25 26 27 28 29 30 31 32 33]

Calibrate a Sig/Ref pair as follows:

- d.reference(20)
- d.signal(21)
- d.temp()
- d.show()

You can also use the core dish functions to calibrate scans.

- d.calib(20)
or
- d.TPcal(20)
- d.TPcal(21)
- d.SRcal(21,20)
- d.plotc(21)

To calibrate and retrieve a frequency switched scan, only a single get is required:

# This example does not work with the sample data provided, but shows the 
# sequence required for freq switched data.
- d.get(2005)
- d.show()

The red and green plots represent the two polarizations. These are currently handled together (use the getpol function to retrieve a single polarization. Currently you can show an individual polarization with the show1 function, and you can average two polarizations using the avgFeeds function. The spectrum is initially shown with GHz units for the x-axis. These units can be changed using the button on the plotter labeled ``GHz''. Regions of the plot may be zoomed using the middle mouse button, and unzoomed using the unzoom button on the plotter.

To fit a baseline to the data, you must specify a range of the spectrum to use for the fit and the order of the polynomial. In this example we will describe the fit region using channel numbers, so first plot the spectrum against channel number (select the option labeled pix on the plotter x-axis selector button). Then, similar to UniPOPS, use the following procedure:

- d.nfit(5)
- d.nregion(0,3600,4100,8200)
- d.bshape()                   # to show the fit
- d.baseline()                 # to subtract the baseline
- d.show()                     # to show the baseline-subtracted data

The dish function setregion() can be used in place of the nregion function to enter the baseline region interactively using the mouse cursor.

If a calibration scaling factor is known, it can be applied:

- d.uscale(2.3)                                                           
- d.setYUnit('Jy')
- d.show()

The UniPOPS-familiar bdrop and edrop parameters may be utilized in the plots:

- d.bdrop(2500)
- d.edrop(2500)
- d.show()

To recall the value of a UniPOPS-type adverb, simply call the function with no value, as follows:

- d.bdrop()
2500 
- d.nfit()
5

To fit a gaussian function to the data, use the dish gauss function as described elsewhere in this document.

Averaging Scans

Data can be stored away to the accumulator, and can then be averaged. First clear the accumulator:

- d.sclear()