VLA CASA Bandpass Slope-CASA6.4.1

From CASA Guides
Jump to navigationJump to search

This CASA Guide is for CASA version 6.4.1

If new to CASA, or to VLA data reduction in CASA,

it is strongly recommended to start with the Getting Started in CASA guide, the IRC+10216 spectral line tutorial, or the VLA 3C391 Continuum Tutorial

before proceeding with this tutorial.

Also note that this guide is meant to be used with monolithic CASA and not pip-wheel, because the GUIs have not been validated.


Overview

For the standard VLA flux density calibrators 3C138, 3C147, 3C286 and 3C48, the CASA distribution includes angular and spectral models that are referenced during calibration. The models account for the observational source characteristics, resulting in improved calibration solutions that therefore more accurately represent the instrumental and atmospheric corrections. These VLA standard calibrators, however, exhibit a negative spectral index (flux density decreasing with increasing frequency) and become relatively weak at high frequencies.

Although the standard VLA flux density calibrators are usually still sufficiently bright enough for absolute flux density calibration even at the higher frequency bands, a good bandpass determination — which is important for spectral line observations or measuring the spectral index of continuum sources — requires high signal-to-noise ratio bandpass solutions derived from either a long integration time or a very bright source (refer to the [https://science.nrao.edu/facilities/vla/docs/manuals/obsguide/modes/line#section-8 Spectral Line (Bandpass Setup) section within the Guide to Observing with the VLA]). Generally, instead of a long integration on a fainter source, additional observations of non-standard, but bright bandpass calibrators are used. Unfortunately, the spectral characteristics of these sources will be undetermined, and no a-priori flux density model is available. If not accounted for, using undetermined spectral knowledge will introduce bias in the bandpass calibration. This tutorial describes how to determine the spectral characteristics for a source and how to correct the bandpass solution for such an effect using these additional sources.

This guide will follow these four general steps (below) to obtain a bandpass and delay calibration as determined from a non-standard bandpass calibrator source:

1) Determine a good delay and bandpass calibration using the standard flux density (or other modeled) calibrator.
2) Use this first order calibration to calibrate the non-standard bandpass calibrator source.
3) Exctract the (now correctly calibrated) spectral characteristics of the non-standard bandpass calibrator.
4) Determine a new, second order delay and bandpass calibration using the non-standard bandpass calibrator source.

These resulting delay and bandpass solution tables then can be applied to the rest of the (target) data.


Obtaining the Data

The data used in this guide are taken for a target field in Ka-band with four 2-GHz basebands paired to two chunks of 4 GHz contiguous frequency coverage centered at 29 and 36.5 GHz for a total of 8 GHz frequency coverage. That is, each baseband consists of a series of 16 consecutive 128-MHz subbands "attached" to another baseband for a total of 64 individual spectral windows.

As this tutorial only concerns bandpass calibration, all scans on fields other than the flux density and bandpass calibrator fields were removed from the measurement set (MS). All pre-calibration steps including flagging, antenna position offsets, requantizer gains, opacity corrections, and gain-elevation curves were applied. The original data (TVER0004.sb14459364.eb14492359.56295.26287841435) can be obtained through the NRAO archive and has a raw size of 57.04 GB.

The trimmed measurement set used here can be downloaded directly from [http://casa.nrao.edu/Data/EVLA/G192/G192-BP.ms.tar.gz http://casa.nrao.edu/Data/EVLA/G192/G192-BP.ms.tar.gz] (dataset size: 3.4 GB)

The first step will be to uncompress and untar the file in a terminal (before starting CASA):

# in a terminal, outside of CASA:
tar -xzf G192-BP.ms.tar.gz 

Then move to the working directory (if not the same as the location of the raw data) and optionally move/copy or link the data to a preferred shortcut name. This is particularly useful if the original observation name has it's full extent like TVER0004.sb14459364.eb14492359.56295.26287841435, for example:

# in a terminal, outside of CASA:
ln -s <path-to-data>/G192-BP.ms <i>my-vis.ms</i>  

Starting CASA

To start CASA, type:

# in a terminal, outside of CASA:
casa

or better, to make sure to be running the CASA version for which this tutorial was designed (list the installed versions to choose from by typing casa -ls):

# in a terminal, outside of CASA:
casa -r 6.4.1-12-pipeline-2022.2.0.64

This will initialize CASA and set the necessary paths appropriately. This will also create two files; one is ipython-<unique-timestamp>.log which contains a record of all the text entered at the CASA prompt, and another as casapy-<unique-timestamp>.log which will contain all the messages that are printed to the CASA logger window. It is recommended to keep these log files intact as a reminder of the steps completed in the data reduction. These log files may also be helpful when submitting a helpdesk ticket.

Once CASA has started, a logger window will appear. Note that this window can be rescaled and the font size can be changed as desired; see the options under the View menu. I personally like to remove clutter columns by moving the mouse to the logger window and press "Ctrl-N", "Ctrl-Y","Ctrl-E", (New Years Eve is one way to remember).

Examining the Measurement Set (MS)

From here on in this tutorial, the G192-BP.ms name in the directory will be replaced by the variable value stored in id_ms (identify-the-MS). This makes the instructions below less dependent on the actual name of the data root so that if another measurement set name is used, only the definition here needs to be edited to the other file name. In order to do that first define these parameters as variables inside of CASA:

# In CASA
visbase = 'G192-BP'       (or whatever base name the data set or link to be used has, like <i>my-vis</i> above)
id_ms = visbase + '.ms'   (this should match and find the measurement set created earlier)


Use listobs to summarize the MS:

# In CASA: listobs on the initial data set
listobs(vis=id_ms, listfile=visbase+'_list.txt');
  • Note the use of a semicolon after the parentheses. This will prevent the return dictionary to be printed in the terminal.

This will write the listobs output of the input MS (stored as the variable id_ms) to a file called <visbase>_list.txt, which can be examined using various operating tools in a terminal, or within CASA by using an explanation mark (!) before the command, such as cat, less, or more. Preferably use an editor and keep it on the desktop for frequent consultation with e.g. emacs, vi, or nedit:

# In CASA, e.g.
!emacs <visbase>_list.txt
================================================================================
           MeasurementSet Name:  <path-to-data>/<visbase>.ms      MS Version 2
================================================================================
   Observer: Dr. Observer     Project: uid://evla/pdb/7303457  
Observation: EVLA
Data records: 1769355       Total elapsed time = 4563 seconds
   Observed from   03-Jan-2013/06:31:48.0   to   03-Jan-2013/07:47:51.0 (UTC)

   ObservationID = 0         ArrayID = 0
  Date        Timerange (UTC)          Scan  FldId FieldName             nRows     SpwIds   Average Interval(s)    ScanIntent
  03-Jan-2013/06:31:48.0 - 06:36:42.0     6      0 3C147                   704865  [0,1,2,3,4,5,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]  [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5.94, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6] [CALIBRATE_FLUX#UNSPECIFIED,OBSERVE_TARGET#UNSPECIFIED]
              07:40:27.0 - 07:47:51.0    64      1 3c84-J0319+413         1064490  [0, 1, 2, 3, 4, 5, 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]  [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6] [CALIBRATE_BANDPASS#UNSPECIFIED,OBSERVE_TARGET#UNSPECIFIED]
           (nRows = Total number of rows per scan) 
Fields: 2
  ID   Code Name                RA               Decl           Epoch   SrcId      nRows
  0    E    3C147               05:42:36.137916 +49.51.07.23356 J2000   0         704865
  1    F    3c84-J0319+413      03:19:48.160102 +41.30.42.10305 J2000   1        1064490
Spectral Windows:  (64 unique spectral windows and 1 unique polarization setups)
  SpwID  Name            #Chans   Frame   Ch0(MHz)  ChanWid(kHz)  TotBW(kHz) CtrFreq(MHz) BBC Num  Corrs  
  0      EVLA_KA#A1C1#2     128   TOPO   34476.000      1000.000    128000.0  34539.5000       10  RR  LL
  1      EVLA_KA#A1C1#3     128   TOPO   34604.000      1000.000    128000.0  34667.5000       10  RR  LL
  2      EVLA_KA#A1C1#4     128   TOPO   34732.000      1000.000    128000.0  34795.5000       10  RR  LL
  3      EVLA_KA#A1C1#5     128   TOPO   34860.000      1000.000    128000.0  34923.5000       10  RR  LL
<snip>
  13     EVLA_KA#A1C1#15    128   TOPO   36140.000      1000.000    128000.0  36203.5000       10  RR  LL
  14     EVLA_KA#A1C1#16    128   TOPO   36268.000      1000.000    128000.0  36331.5000       10  RR  LL
  15     EVLA_KA#A1C1#17    128   TOPO   36396.000      1000.000    128000.0  36459.5000       10  RR  LL
  16     EVLA_KA#A2C2#18    128   TOPO   36476.000      1000.000    128000.0  36539.5000       11  RR  LL
  17     EVLA_KA#A2C2#19    128   TOPO   36604.000      1000.000    128000.0  36667.5000       11  RR  LL
  18     EVLA_KA#A2C2#20    128   TOPO   36732.000      1000.000    128000.0  36795.5000       11  RR  LL
<snip>
  29     EVLA_KA#A2C2#31    128   TOPO   38140.000      1000.000    128000.0  38203.5000       11  RR  LL
  30     EVLA_KA#A2C2#32    128   TOPO   38268.000      1000.000    128000.0  38331.5000       11  RR  LL
  31     EVLA_KA#A2C2#33    128   TOPO   38396.000      1000.000    128000.0  38459.5000       11  RR  LL
  32     EVLA_KA#B1D1#34    128   TOPO   26976.000      1000.000    128000.0  27039.5000       13  RR  LL
  33     EVLA_KA#B1D1#35    128   TOPO   27104.000      1000.000    128000.0  27167.5000       13  RR  LL
  34     EVLA_KA#B1D1#36    128   TOPO   27232.000      1000.000    128000.0  27295.5000       13  RR  LL
<snip>
  45     EVLA_KA#B1D1#47    128   TOPO   28640.000      1000.000    128000.0  28703.5000       13  RR  LL
  46     EVLA_KA#B1D1#48    128   TOPO   28768.000      1000.000    128000.0  28831.5000       13  RR  LL
  47     EVLA_KA#B1D1#49    128   TOPO   28896.000      1000.000    128000.0  28959.5000       13  RR  LL
  48     EVLA_KA#B2D2#50    128   TOPO   28976.000      1000.000    128000.0  29039.5000       14  RR  LL
  49     EVLA_KA#B2D2#51    128   TOPO   29104.000      1000.000    128000.0  29167.5000       14  RR  LL
  50     EVLA_KA#B2D2#52    128   TOPO   29232.000      1000.000    128000.0  29295.5000       14  RR  LL
<snip>
  61     EVLA_KA#B2D2#63    128   TOPO   30640.000      1000.000    128000.0  30703.5000       14  RR  LL
  62     EVLA_KA#B2D2#64    128   TOPO   30768.000      1000.000    128000.0  30831.5000       14  RR  LL
  63     EVLA_KA#B2D2#65    128   TOPO   30896.000      1000.000    128000.0  30959.5000       14  RR  LL

Sources: 128
  ID   Name                SpwId RestFreq(MHz)  SysVel(km/s) 
  0    3C147               0     -              -            
  0    3C147               1     -              -            
  0    3C147               2     -              -            
<snip>
  0    3C147               61    -              -            
  0    3C147               62    -              -            
  0    3C147               63    -              -            
  1    3c84-J0319+413      0     -              -            
  1    3c84-J0319+413      1     -              -            
  1    3c84-J0319+413      2     -              -            
<snip>
  1    3c84-J0319+413      61    -              -            
  1    3c84-J0319+413      62    -              -            
  1    3c84-J0319+413      63    -              -            
<snip>
Antennas: 22:
  ID   Name  Station   Diam.    Long.         Lat.                Offset from array center (m)                ITRF Geocentric coordinates (m)        
                                                                     East         North     Elevation               x               y               z
  1    ea02  N56       25.0 m   -107.37.47.9  +34.00.38.4      -1105.2071    12254.3069      -34.2426 -1600128.383400 -5035104.146500  3565024.672100
  2    ea03  N16       25.0 m   -107.37.10.9  +33.54.48.0       -155.8511     1426.6436       -9.3827 -1601061.956000 -5041175.880700  3556058.037600
  3    ea05  W08       25.0 m   -107.37.21.6  +33.53.53.0       -432.1184     -272.1472       -1.5070 -1601614.092200 -5042001.650900  3554652.508900
<snip>

This redacted MS contains only scans on the flux density calibrator 3C147 (field 0) and the bandpass calibrator 3C84 (field 1). Both fields have 64 spectral windows (spws); each spw consists of 128 dual (RR, LL) polarization 1 MHz wide channels, for a total bandwidth of 128 MHz per spw.

As the intents for these fields are clearly included in the scan listing (CALIBRATE_FLUX and CALIBRATE_BANDPASS), for convenience now introduce new variables to recall the general use of these intents without having to remember their details like field ID numbers or name strings — variable names aren't string-values so therefore using them also avoids typing the quotes when filling in task parameters (as will be seen in most of the below):

# In CASA
id_flx = '3C147' (or '0' for using the field name or field ID respectively)
id_bp  = '3c84-J0319+413' (or '1')


Setting the Model of the Flux Density Calibrator

To start, insert the spectral and angular models for the flux density calibrator, here 3C147 (field 0), with the [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.imaging.setjy.html setjy] task. Use the 'Perley-Butler 2017' standard and 3C147_A.im for Ka-band (which can be written as id_flx+'_A.im because here fortunately id_flx and the model name agree):

# In CASA: model for the flux density calibrator
setjy(vis=id_ms, field=id_flx, scalebychan=True,
      standard='Perley-Butler 2017', model=id_flx+'_A.im');
  • scalebychan=True: If scalebychan=False
 [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.imaging.setjy.html
 setjy] would use a single value per spectral window.
Figure 1: plotms() output for model amplitudes as function of freqency for the flux density calibrator 3C147

Inspecting the logger report shows that the flux density calibrator (3C147 here) has amplitudes ranging from about 1.0 to about 1.5 Jy across the spws. (Note the output sorting in increasing spw number, not in frequency)

The model data can be plotted, e.g. for antenna 'ea03', using [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.visualization.plotms.html plotms] (Figure 1):

# In CASA
plotms(vis=id_ms, field=id_flx, antenna='ea03', 
       xaxis='freq', yaxis='amp', ydatacolumn='model',coloraxis='ant2')

This plot shows baselines to antenna "ea03". Since both a spectral and an angular model for this well resolved calibrator was provided, each baseline has a somewhat different amplitude and phase behavior as function of frequency.

Calibrating delays and initial bandpass solutions

As a first step, a reference antenna for all phase calibrations needs to be specified. Since observations were performed with the VLA in the most extended A-configuration, it is desirable to use an antenna that is near the center of the array. Futhermore, it needs to have valid calibrator data on all baselines with the least amount of data flagged. The array can be mapped with [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.visualization.plotants.html plotants]:

# In CASA: plotting antenna locations
plotants(vis=id_ms)

Although the plot is a bit crowded (Figure 2), zooming in with the magnifying glass icon shows that antenna "ea05" is located close to the center. Using the [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.visualization.plotants.html flagdata] task with mode='summary' it can be seen that "ea05" has small number of flags. Therefore, this antenna can be used relatively safely as the reference antenna; for convenience (and for people with memory issues) introduce a variable name for it:

# In CASA:
id_ref = 'ea05' (or '3' or 'W08' which are the antenna ID number or pad name for ea05)


Figure 2: Antenna locations plotted with plotants() task.

Start this calibration with a phase-only, time-dependent calibration solution for the bandpass calibrator, which should be easy for these supposedly bright sources. Note that the calibration solutions are written to a calibration table, cal.ign, where 'ign' stands for per-integration gain. This table is not a variable but a string/name so it needs to be quoted in the input parameter. Solutions for each integration will remove most of the (phase) decorrelation of the signal. For best results, the phase variations will be derived from a narrow range of channels (say 60~68 here, out of the 128 available per spw) near the centers of each spw, narrow enough to not be affected by uncorrected delay (i.e., reduce possible decorrelation by excluding any large phase differences due to a phase slope over the frequency range of the spw):

# In CASA: phase only calibration
gaincal(vis=id_ms, caltable='cal.ign', 
        field=id_bp, spw='*:60~68',
        gaintype='G', refant=id_ref, calmode='p', 
        solint='int', minsnr=3)
  • refant=id_ref : Use the variable identifying the reference antenna (ea05 here) as the reference antenna.
  • solint='int' : Do a per-integration solve (every 6 seconds, which is the time-averaging applied to the data for this tutorial).
  • minsnr=3 : Apply a minimum signal-to-noise cutoff of three. Solutions with less signal-to-noise than this value will be flagged.
  • gaintable is not set here as earlier calibrations (to prepare for this tutorial have already been applied.


Plot the phase solutions (using full phase range -180 to 180 instead of autorange):

# In CASA
plotms(vis='cal.ign', xaxis='time', yaxis='phase', 
        iteraxis='antenna', plotrange=[-1,-1,-180,180])

Note that antenna the first plot showing the results for ea01 is empty as ea01 previously was fully flagged, and so were ea10 and ea19. Click on the green arrows to pass through the plots for the other antennas. Also note that the reference antenna (ea05 here) has all phases equal to zero degrees, which they should be by definition for the reference antenna.

Multipanel plots of the phase solutions can be written to output files as well as to the screen display (Figures 3a, 3b, & 3c). The output files that are generated are PNG files and can be viewed at any occasion using CASA by executing an external viewer program, e.g., !xv <visbase>_cal.ign_p1*.png; or by running an image viewing application such as xv, Preview, Gimp, Photoshop, etc., external to CASA at the operating system level.

# In CASA
plotms(vis='cal.ign', xaxis='time', yaxis='phase',
       antenna='0~11', gridrows=3, gridcols=3, iteraxis='antenna',
       coloraxis='spw',
       plotfile=visbase+'_cal.ign_p1.png', width=1300, height=800)
  • width=1300 and height=800 specify the output PNG pixel dimensions.
Note that recently the name of the output file gets appended with the selection of the iteraxis and there unfortunately seems to be no possibility to switch that off; to get the file name as specified in the plotfile-parameter one would edit the file name using the operating system tools.
plotms(vis='cal.ign', xaxis='time', yaxis='phase', 
       antenna='12~20', gridrows=3, gridcols=3, iteraxis='antenna',
       coloraxis='spw',
       plotfile=visbase+'_cal.ign_p2.png', width=1300, height=800)

#
plotms(vis='cal.ign', xaxis='time', yaxis='phase', 
       antenna='21~26', gridrows=2, gridcols=3, iteraxis='antenna',
       coloraxis='spw',
       plotfile=visbase+'_cal.ign_p3.png', width=1300, height=800)
Figure 3a: Gain phase calibration solutions for antennas ea01 to ea11
|
Figure 3b: Gain phase calibration solutions for antennas ea12 to ea20
|
Figure 3c: Gain phase calibration solutions for antennas ea21 to ea26
|

}


The next step is to solve for the residual delays using the parameter gaintype='K' option in [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.calibration.gaincal.html gaincal] and store the solutions in the cal.dly table. Note that this currently does not do a global fringe-fitting solution for delays. Instead it determines a baseline-based delay solution per spw for all baselines to the reference antenna, treating these as antenna-based delays. In most cases, with high enough S/N to get baseline-based delay solutions, this will suffice. Avoid the edge channels of each spectral window by de-selecting them (say select channels 5~122 here, from the 128 available per spw):

# In CASA: residual delays
gaincal(vis=id_ms, caltable='cal.dly', 
        field=id_bp, spw='*:5~122', gaintype='K', 
        gaintable=['cal.ign'],
        refant=id_ref, solint='inf', minsnr=3)

Note that we are now applying our initial phase table cal.ign to reduce decorrelation due to short-term phase fluctuations (as they will be corrected by the solutions in cal.ign).

Alternatively, one can derive a delay across all spws of a baseband. If this is desired, use parameter combine='spw' in [https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.calibration.gaincal.html gaincal] and run the task for each baseband separately. The solutions from the second and following runs can be appended to the same calibration table via parameter append=True.

Figure 4: Antenna based delays after running gaincal().

Now plot the delays, in nanoseconds, as a function of antenna index (you will get one for each spw and polarization):

# In CASA
plotms(vis='cal.dly', xaxis='ant1', yaxis='delay', coloraxis='spw')

The delays range from around -5 to 4 nanoseconds (Figure 4).

Now solve for the antenna bandpasses using the previously generated tables cal.ign and cal.dly correcting for possible decorrelation due to phase and delay inaccuracies, and store the solutions in cal.bp:

# In CASA: antenna bandpasses
bandpass(vis=id_ms, caltable='cal.bp', 
         gaintable=['cal.ign', 'cal.dly'], 
         field=id_bp, refant=id_ref, solnorm=False, 
         bandtype='B', solint='inf')

WARNING: Set solnorm=False here; otherwise there will be some offsets seen later between spws due to the way the amplitude scaling adjusts weights internally during solving.


Expect to see solutions failing due to "Insufficient unflagged antennas" — these are for bad channels that have been pre-flagged.

Plot the amplitude and phase soutions of this new bandpass. Note that the first panel with ea01 is empty as it is completely flagged. Proceed to ea06 to see the plots as shown in Figures 5a, 5b, 6a, and 6b:

# In CASA
plotms(vis='cal.bp', xaxis='freq', yaxis='amp', 
       spw='0~31', iteraxis='antenna', coloraxis='spw')

#
plotms(vis='cal.bp', xaxis='freq', yaxis='amp', 
       spw='32~63', iteraxis='antenna', coloraxis='spw')

#
plotms(vis='cal.bp', xaxis='freq', yaxis='phase', 
       spw='0~31', iteraxis='antenna', coloraxis='spw', 
       plotrange=[-1,-1,-180,180])

#
plotms(vis='cal.bp', xaxis='freq', yaxis='phase', 
       spw='32~63', iteraxis='antenna', coloraxis='spw', 
       plotrange=[-1,-1,-180,180])
Figure 5a: Gain amplitude bandpass calibration solutions for antenna ea06 in spectral windows from 0 to 31.
|
Figure 5b: Gain amplitude bandpass calibration solutions for antenna ea06 in spectral windows from 32 to 63.
|
Figure 6a: Gain phase bandpass calibration solutions for antenna ea06 in spectral windows from 0 to 31
|
Figure 6b: Gain phase bandpass calibration solutions for antenna ea06 in spectral windows from 32 to 63.
|

}

Bootstrapping the bandpass calibrator spectrum

Since there is no a priori spectral information for the chosen bandpass calibrator (here 3C84), bootstrapping it is needed to determine its spectral index. This information is then used to recalibrate the bandpass in order to avoid folding the intrinsic spectral shape of the bandpass calibrator into the bandpass calibration.

First, repeat the phase-only calibration solution, this time for both the bandpass and the flux density calibrator (which need to be separated by a comma) and store the solutions in cal.ign2pha (use the 2pha to distinguish it as the second stage for phase-only). This will correct for short-term phase decorrelation of the signals. Similarly to avoid decorrelation due to a wide frequency range, use the narrow center channel range (which was channel 60~68) and apply the bandpass and delay calibration tables:

# In CASA: flux and bandpass calibrators gain
gaincal(vis=id_ms, caltable='cal.ign2pha', field=id_flx+','+id_bp, 
        gaintable=['cal.dly', 'cal.bp'], 
        gaintype='G', refant=id_ref, calmode='p', solint='int', minsnr=3)

This again allows to calibrate both phase and gain for each scan, now corrected with the delay and bandpass of the flux density calibrator as used when determining the spectral characteristics of the bandpass calibrator. Store the solutions in cal.ign2 (use the 2 to distinguish it as the second stage gain calibration):

# In CASA: flux and bandpass calibrators gain
gaincal(vis=id_ms, caltable='cal.ign2', field=id_flx+','+id_bp, 
        gaintable=['cal.dly', 'cal.bp','cal.ign2pha'], 
        gaintype='G', refant=id_ref, calmode='ap', solint='inf', minsnr=3)


With gain solutions for the flux density and bandpass calibrators, now use fluxscale to scale the gain amplitudes of the bandpass calibrator using those of the flux density calibrator. Store the solutions in cal.flx2 and the model for the bandpass calibrator in <visbase>+'_'+id_bp+'_fluxinfo.txt':


# In CASA: bandpass calibrator gain amplitudes scaling
flux1 = fluxscale(vis=id_ms, caltable='cal.ign2', 
                  fluxtable='cal.flx2', reference=id_flx, transfer=id_bp, 
                  listfile=visbase+'_'+id_bp+'_fluxinfo.txt', fitorder=1)
  • flux1 = fluxscale(...): the Python dictionary returned by the fluxscale task will be stored in the flux1 variable. Inspect the dictionary flux1 by typing "print flux1" at the CASA command line. Alternatively, when not interested in the dictionary type fluxscale(...); with a semicolon after the parentheses and not assigning it to a variable. This will prevent the dictionary to be printed in the terminal. Here however the dictionary is captured in flux1 as it is going to be used below
  • fluxtable='cal.flx2': this is the output scaled gain table. Since we are only using this to find the spectral index of the bandpass calibrator source field, we won't be using this table.
  • listfile=visbase+'_'+id_bp+'_fluxinfo.txt': an output file that contains the derived flux values and fit information.
  • fitorder=1: only find a (linear) spectral index, ignoring curvature in the spectrum.
  • reference=id_flx: the reference field from which the flux scaling is transferred (here: the flux density calibrator 3C147, field 0, assigned by id_flx)
  • transfer=id_bp: the target field to which the flux scaling is transferred (here: the bandpass calibrator 3C84, field 1, assigned by id_bp)


The last line in the file (and displayed in the logger) shows:

Fitted spectrum for 3c84-J0319+413 with fitorder=1: Flux density = 29.0286 +/- 0.0308709 (freq=32.5128 GHz) spidx=-0.538803 +/- 0.00883078
Figure 7: Bootstrapped 3C84 flux density spectrum.

Using the information in the returned flux1 dictionary, we can plot the derived spectrum seen in Figure 7; for that the two loops below fill the parameter variables used in the plotting:

(Note, IPython 5.1.0 requires the use of "%cpaste" to allow the copy/paste of loops, conditions, etc.. Press "Enter" (or "Return") after "--" at the end, this stops (or exits) the copy/paste prompt and will return you to the CASA prompt.)

# In CASA
%cpaste

# Press Enter or Return, then copy/paste the following:
freq = flux1['freq'] / 1e9
spw_list = range(0,64)
spw_str = []
for i in spw_list:
   thisspw = str(i)
   spw_str.append(thisspw)
--
# In CASA
%cpaste

# Press Enter or Return, then copy/paste the following:
bootstrapped_fluxes = []
for j in spw_str:
    thisflux = flux1['1'][j]['fluxd'][0]
    if thisflux ==None:
        continue
    else:
        bootstrapped_fluxes.append(thisflux)
--
# In CASA - this section creates the plot seen in Figure 7
import matplotlib.pyplot as pl
%cpaste

# Press Enter or Return, then copy/paste the following:
pl.clf()
pl.plot(freq, bootstrapped_fluxes, 'bo')
pl.xlabel('Frequency (GHz)')
pl.ylabel('Flux Density (Jy)')
pl.title(id_bp)
pl.show()
--

We can use the model from fluxscale to fill the MODEL column with the banpass source's spectral information using setjy. With standard='fluxscale', we can directly use the flux1 Python dictionary as input via fluxdict:

Figure 8: Model amplitude of 3C84 as a function of frequency.
# In CASA: spectral information
setjy(vis=id_ms, field=id_bp, scalebychan=True, 
      standard = 'fluxscale', fluxdict=flux1);

Check with plotms that the data have been appropriately filled (Figure 8):

# In CASA
plotms(vis=id_ms, field=id_bp, antenna='ea05&ea02', 
       xaxis='freq', yaxis='amp', ydatacolumn='model')

Next, we redo the previous calibration using this new model information. Although the commands are the same as issued earlier, keep in mind that the model values for the bandpass calibrator have changed and, therefore, the results of these calibration calculations will differ:

# In CASA: phase only recalibration
gaincal(vis=id_ms, caltable='cal.ign.redo', 
        field=id_bp, spw='*:60~68', 
        gaintype='G', refant=id_ref, calmode='p', 
        solint='int', minsnr=3) 

# In CASA: residual delays recalibration
gaincal(vis=id_ms, caltable='cal.dly.redo', 
        gaintable=['cal.ign.redo'], 
        field=id_bp, spw='*:5~122', gaintype='K', 
        refant=id_ref, solint='inf', minsnr=3)

# In CASA: antenna bandpasses recalibration
bandpass(vis=id_ms, caltable='cal.bp.redo', 
         gaintable=['cal.ign.redo', 'cal.dly.redo'], 
         field=id_bp, refant=id_ref, solnorm=False, 
         bandtype='B', solint='inf')

Finally, we inspect these solutions (Figures 9a, 9b, 10a, and 10b; again note that antenna ea01 is fully flagged):

# In CASA - Figure 9a
plotms(vis='cal.bp.redo', xaxis='freq', yaxis='amp', 
       spw='0~31', iteraxis='antenna', coloraxis='spw')

#
plotms(vis='cal.bp.redo', xaxis='freq', yaxis='amp', 
       spw='32~63', iteraxis='antenna', coloraxis='spw')

#
plotms(vis='cal.bp.redo', xaxis='freq', yaxis='phase', 
       spw='0~31', iteraxis='antenna', coloraxis='spw', 
       plotrange=[-1,-1,-180,180])

#
plotms(vis='cal.bp.redo', xaxis='freq', yaxis='phase', 
       spw='32~63', iteraxis='antenna', coloraxis='spw', 
       plotrange=[-1,-1,-180,180])
They look virtually unchanged from the previous solutions with the exception that the amplitude scaling is corrected for the spectrum of the bandpass calibrator. We have the final version of our delay and bandpass calibration tables, cal.dly.redo and cal.bp.redo, which can be used for all subsequent calibration steps.

Last checked on CASA Version 6.4.1