Jupiter: continuum polarization calibration 6.4.1: Difference between revisions
Line 31: | Line 31: | ||
</source> | </source> | ||
Use '''[https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.information.listobs.html?highlight=listobs listobs]''' to check the observation setup and print verbose summary of the observations to the CASA logger. | Use '''[https://casadocs.readthedocs.io/en/v6.4.1/api/tt/casatasks.information.listobs.html?highlight=listobs listobs]''' to check the observation setup and print verbose summary of the observations to the CASA logger. The listfile input parameter is optional, but is good practice to print the listobs output to a text file for future reference. | ||
<source lang="python"> | <source lang="python"> |
Revision as of 17:19, 29 December 2022
DISCLAIMER |
This is an advanced reference guide to calibration and imaging of pre-upgrade VLA polarimetric data with CASA 6.4.1. If you are a beginning or novice user, please consult relevant CASA guides first. |
Data Import
This CASA guide discusses how to set the flux scale for calibration of an archival VLA 6cm data set (circa 1999), taken in D-configuration, with a resolution of around 14 arcsec. The original observation included several planets, among them was Jupiter, which will be the focus of this guide.
- The data set for this tutorial can be downloaded from this link: planets_6cm.fits (129MB).
To choose which version of CASA to run type,
casa -ls
To run CASA version 6.4.1 type,
casa -r 6.4.1-12-pipeline-2022.2.0.64
CASA task importuvfits will read the original AIPS friendly UVFITS format and create a CASA native measurement set (MS).
importuvfits(fitsfile='planets_6cm.fits', vis='jupiter6cm.demo.ms', antnamescheme='old')
Use listobs to check the observation setup and print verbose summary of the observations to the CASA logger. The listfile input parameter is optional, but is good practice to print the listobs output to a text file for future reference.
listobs(vis='jupiter6cm.demo.ms',listfile='jupiter-demo.tx')
The output of this task is fairly long, the abridged version is shown below since we may need some of this information later on during our calibration.
########################################## ##### Begin Task: listobs ##### Observer: FLUX99 Project: Observation: VLA Data records: 2021424 Total elapsed time = 85136.5 seconds Observed from 15-Apr-1999/23:15:25.0 to 16-Apr-1999/22:54:21.6 (TAI) ObservationID = 0 ArrayID = 0 Date Timerange (TAI) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent 15-Apr-1999/23:15:25.0 - 23:16:11.7 1 0 0137+331 8218 [0,1] [3.3, 3.3] 23:38:38.4 - 23:48:01.7 2 1 0813+482 87618 [0,1] [3.3, 3.3] 23:53:38.3 - 23:55:21.7 3 2 0542+498 19462 [0,1] [3.3, 3.3] 16-Apr-1999/00:22:08.4 - 00:23:51.6 4 3 0437+296 20728 [0,1] [3.3, 3.3] 00:28:21.7 - 00:30:01.7 5 4 VENUS 20560 [0,1] [3.3, 3.3] 00:48:38.4 - 00:50:21.7 6 1 0813+482 21016 [0,1] [3.3, 3.3] 00:56:11.7 - 00:57:51.6 7 2 0542+498 19914 [0,1] [3.3, 3.3] 01:10:18.4 - 01:12:01.6 8 5 0521+166 21248 [0,1] [3.3, 3.3] 01:23:28.3 - 01:25:01.7 9 3 0437+296 19604 [0,1] [3.3, 3.3] 01:29:31.7 - 01:31:11.7 10 4 VENUS 20634 [0,1] [3.3, 3.3] 01:49:48.3 - 01:51:31.7 11 6 1411+522 16446 [0,1] [3.3, 3.3] 02:02:58.4 - 02:04:31.6 12 7 1331+305 15366 [0,1] [3.3, 3.3] 02:17:28.3 - 02:19:11.6 13 1 0813+482 21136 [0,1] [3.3, 3.3] 02:24:18.3 - 02:26:01.7 14 2 0542+498 21248 [0,1] [3.3, 3.3] 02:37:48.3 - 02:39:31.6 15 5 0521+166 20196 [0,1] [3.3, 3.3] 02:50:48.4 - 02:52:21.7 16 3 0437+296 15456 [0,1] [3.3, 3.3] 02:59:18.3 - 03:01:01.6 17 6 1411+522 19474 [0,1] [3.3, 3.3] 03:12:28.3 - 03:14:11.7 18 7 1331+305 20398 [0,1] [3.3, 3.3] 03:27:51.7 - 03:29:41.6 19 1 0813+482 21124 [0,1] [3.3, 3.3] 03:34:58.3 - 03:36:41.7 20 2 0542+498 21660 [0,1] [3.3, 3.3] 03:49:48.4 - 03:51:31.7 21 6 1411+522 20316 [0,1] [3.3, 3.3] 04:03:08.3 - 04:04:51.6 22 7 1331+305 21118 [0,1] [3.3, 3.3] 04:18:48.3 - 04:20:41.7 23 1 0813+482 21360 [0,1] [3.3, 3.3] 04:25:54.9 - 04:27:41.6 24 2 0542+498 21680 [0,1] [3.3, 3.3] 04:42:48.3 - 04:44:41.7 25 8 MARS 15804 [0,1] [3.3, 3.3] 04:56:48.4 - 04:58:31.7 26 6 1411+522 20830 [0,1] [3.3, 3.3] 05:24:01.7 - 05:33:41.6 27 7 1331+305 112178 [0,1] [3.3, 3.3] 05:47:58.4 - 05:49:51.6 28 1 0813+482 21040 [0,1] [3.3, 3.3] 05:58:35.0 - 06:00:31.6 29 8 MARS 20892 [0,1] [3.3, 3.3] 06:13:18.4 - 06:15:01.6 30 6 1411+522 20618 [0,1] [3.3, 3.3] 06:27:38.3 - 06:29:21.7 31 7 1331+305 20686 [0,1] [3.3, 3.3] 06:44:11.7 - 06:46:01.6 32 1 0813+482 18564 [0,1] [3.3, 3.3] 06:55:05.0 - 06:57:01.6 33 8 MARS 20744 [0,1] [3.3, 3.3] 07:10:38.4 - 07:12:21.7 34 6 1411+522 19950 [0,1] [3.3, 3.3] 07:28:18.3 - 07:30:11.7 35 7 1331+305 19460 [0,1] [3.3, 3.3] 07:42:48.3 - 07:44:31.6 36 8 MARS 21428 [0,1] [3.3, 3.3] 07:58:41.6 - 08:00:41.6 37 6 1411+522 22212 [0,1] [3.3, 3.3] 08:13:28.4 - 08:15:21.6 38 7 1331+305 22024 [0,1] [3.3, 3.3] 08:27:51.7 - 08:29:31.6 39 8 MARS 19500 [0,1] [3.3, 3.3] 08:42:58.3 - 08:44:51.7 40 6 1411+522 22158 [0,1] [3.3, 3.3] 08:57:08.3 - 08:58:51.6 41 7 1331+305 21470 [0,1] [3.3, 3.3] 09:13:01.6 - 09:14:51.7 42 9 NGC7027 16062 [0,1] [3.3, 3.3] 09:26:58.3 - 09:28:41.6 43 6 1411+522 19808 [0,1] [3.3, 3.3] 09:40:31.7 - 09:42:11.6 44 7 1331+305 19742 [0,1] [3.3, 3.3] 09:56:18.3 - 09:58:11.7 45 9 NGC7027 19458 [0,1] [3.3, 3.3] 10:12:58.3 - 10:14:51.7 46 8 MARS 20202 [0,1] [3.3, 3.3] 10:27:08.3 - 10:28:51.6 47 6 1411+522 20504 [0,1] [3.3, 3.3] 10:40:28.4 - 10:42:01.6 48 7 1331+305 19554 [0,1] [3.3, 3.3] 10:56:08.4 - 10:57:51.7 49 9 NGC7027 19912 [0,1] [3.3, 3.3] 11:28:28.3 - 11:35:31.7 50 10 NEPTUNE 87260 [0,1] [3.3, 3.3] 11:48:18.3 - 11:50:11.7 51 6 1411+522 21338 [0,1] [3.3, 3.3] 12:01:35.1 - 12:03:11.7 52 7 1331+305 15962 [0,1] [3.3, 3.3] 12:35:31.6 - 12:37:41.6 53 11 URANUS 21824 [0,1] [3.3, 3.3] 12:46:28.3 - 12:48:11.7 54 10 NEPTUNE 15016 [0,1] [3.3, 3.3] 13:00:28.3 - 13:02:11.6 55 6 1411+522 19954 [0,1] [3.3, 3.3] 13:15:21.6 - 13:17:11.7 56 9 NGC7027 19732 [0,1] [3.3, 3.3] 13:33:41.6 - 13:35:41.6 57 11 URANUS 20576 [0,1] [3.3, 3.3] 13:44:28.3 - 13:46:11.6 58 10 NEPTUNE 15026 [0,1] [3.3, 3.3] 14:00:45.0 - 14:01:41.6 59 0 0137+331 8380 [0,1] [3.3, 3.3] 14:10:38.3 - 14:12:11.6 60 12 JUPITER 15324 [0,1] [3.3, 3.3] 14:24:05.0 - 14:25:41.7 61 11 URANUS 18528 [0,1] [3.3, 3.3] 14:34:28.4 - 14:36:11.7 62 10 NEPTUNE 21050 [0,1] [3.3, 3.3] 14:59:11.7 - 15:00:01.6 63 0 0137+331 8576 [0,1] [3.3, 3.3] 15:09:01.7 - 15:10:41.7 64 12 JUPITER 19802 [0,1] [3.3, 3.3] 15:24:28.3 - 15:26:21.7 65 9 NGC7027 19518 [0,1] [3.3, 3.3] 15:40:08.3 - 15:45:01.6 66 11 URANUS 18910 [0,1] [3.3, 3.3] 15:53:48.3 - 15:55:21.6 67 10 NEPTUNE 19384 [0,1] [3.3, 3.3] 16:18:51.8 - 16:19:51.6 68 0 0137+331 9980 [0,1] [3.3, 3.3] 16:29:08.4 - 16:30:51.6 69 12 JUPITER 20634 [0,1] [3.3, 3.3] 16:42:51.7 - 16:44:31.6 70 11 URANUS 19574 [0,1] [3.3, 3.3] 16:54:51.7 - 16:56:41.6 71 9 NGC7027 21448 [0,1] [3.3, 3.3] 17:23:05.0 - 17:30:41.6 72 2 0542+498 60338 [0,1] [3.3, 3.3] 17:41:48.4 - 17:43:21.7 73 3 0437+296 19058 [0,1] [3.3, 3.3] 17:55:35.0 - 17:57:41.6 74 4 VENUS 19844 [0,1] [3.3, 3.3] 18:19:21.6 - 18:20:11.6 75 0 0137+331 8490 [0,1] [3.3, 3.3] 18:30:21.6 - 18:32:01.7 76 12 JUPITER 19516 [0,1] [3.3, 3.3] 18:44:48.3 - 18:46:31.6 77 9 NGC7027 19952 [0,1] [3.3, 3.3] 18:59:11.7 - 19:01:01.6 78 2 0542+498 20482 [0,1] [3.3, 3.3] 19:19:08.4 - 19:21:21.7 79 5 0521+166 20228 [0,1] [3.3, 3.3] 19:32:48.4 - 19:34:31.6 80 3 0437+296 19506 [0,1] [3.3, 3.3] 19:39:01.7 - 19:40:41.7 81 4 VENUS 19106 [0,1] [3.3, 3.3] 20:08:05.0 - 20:09:01.6 82 0 0137+331 10468 [0,1] [3.3, 3.3] 20:18:08.4 - 20:19:51.7 83 12 JUPITER 21480 [0,1] [3.3, 3.3] 20:33:51.6 - 20:35:41.7 84 1 0813+482 15666 [0,1] [3.3, 3.3] 20:40:58.3 - 20:42:41.6 85 2 0542+498 21522 [0,1] [3.3, 3.3] 21:00:15.0 - 21:02:21.7 86 5 0521+166 19586 [0,1] [3.3, 3.3] 21:13:51.7 - 21:15:31.6 87 3 0437+296 19072 [0,1] [3.3, 3.3] 21:20:41.7 - 21:22:31.6 88 4 VENUS 20792 [0,1] [3.3, 3.3] 21:47:25.0 - 21:48:21.7 89 0 0137+331 10478 [0,1] [3.3, 3.3] 21:57:28.3 - 21:59:11.7 90 12 JUPITER 17994 [0,1] [3.3, 3.3] 22:12:11.6 - 22:14:01.7 91 2 0542+498 20752 [0,1] [3.3, 3.3] 22:28:31.7 - 22:30:21.6 92 4 VENUS 20162 [0,1] [3.3, 3.3] 22:53:31.6 - 22:54:21.6 93 0 0137+331 8356 [0,1] [3.3, 3.3] (nRows = Total number of rows per scan) Fields: 13 ID Code Name RA Decl Epoch SrcId nRows 0 A 0137+331 01:37:41.299500 +33.09.35.13400 J2000 0 72946 1 T 0813+482 08:13:36.051800 +48.13.02.26200 J2000 1 227524 2 A 0542+498 05:42:36.137900 +49.51.07.23400 J2000 2 227058 3 T 0437+296 04:37:04.174700 +29.40.15.13600 J2000 3 113424 4 VENUS 04:06:54.109428 +22.30.35.90609 J2000 4 121098 5 A 0521+166 05:21:09.886000 +16.38.22.05200 J2000 5 81258 6 T 1411+522 14:11:20.647700 +52.12.09.14100 J2000 6 243608 7 A 1331+305 13:31:08.288100 +30.30.32.96000 J2000 7 307958 8 MARS 14:21:41.365747 -12.21.49.45444 J2000 8 118570 9 NGC7027 21:07:01.593000 +42.14.10.18600 J2000 9 136082 10 NEPTUNE 20:26:01.136316 -18.54.54.21127 J2000 10 157736 11 URANUS 21:15:42.828572 -16.35.05.59272 J2000 11 99412 12 JUPITER 00:55:34.043951 +04.45.44.70633 J2000 12 114750 Spectral Windows: (2 unique spectral windows and 1 unique polarization setups) SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) Corrs 0 none 1 TOPO 4885.100 50000.000 50000.0 4885.1000 RR RL LR LL 1 none 1 TOPO 4835.100 50000.000 50000.0 4835.1000 RR RL LR LL Sources: 26 ID Name SpwId RestFreq(MHz) SysVel(km/s) 0 0137+331 0 0 0 0 0137+331 1 0 0 1 0813+482 0 0 0 1 0813+482 1 0 0 2 0542+498 0 0 0 2 0542+498 1 0 0 3 0437+296 0 0 0 3 0437+296 1 0 0 4 VENUS 0 0 0 4 VENUS 1 0 0 5 0521+166 0 0 0 5 0521+166 1 0 0 6 1411+522 0 0 0 6 1411+522 1 0 0 7 1331+305 0 0 0 7 1331+305 1 0 0 8 MARS 0 0 0 8 MARS 1 0 0 9 NGC7027 0 0 0 9 NGC7027 1 0 0 10 NEPTUNE 0 0 0 10 NEPTUNE 1 0 0 11 URANUS 0 0 0 11 URANUS 1 0 0 12 JUPITER 0 0 0 12 JUPITER 1 0 0 Antennas: 27: ... ##### End Task: listobs ##### ##########################################
Next use plotants to check the array configuration and select a reference antenna. Here, we will use antenna '11' as a reference since it's located in the middle of the array.
plotants(vis='jupiter6cm.demo.ms', figfile='jupiter6cm.demo.ant.png')
Note (for uvfits sourced directly from archive only): CASA 5.4 and earlier versions will not plot the antennas properly. This is to be resolved in future CASA versions. If this occurs then a reference antenna can be selected using the listobs task and choosing an antenna located on a pad close to the center of the array (Pads numbers increase with distance from the center of the array, ie. "VLA:_N1" and "EVLA:W2" are pads close to the center of the array, where as, "VLA:_N18" is not).
Data Inspection and Flagging
In this section we present two methods of flagging the data:
- Interactive flagging using plotms, which is destructive to the data set and cannot be undone. If a mistake is made, you must start over with a new copy of the data set. Because of the destructive nature of this method, it is generally not recommended.
- Non-interactive flagging using flagdata, which is not destructive to the data set and can be undone (be sure to set flagbackup=True). If a mistake is made, you may undo the flagged data. This is the recommended approach to flagging any data set, new (JVLA) or old (VLA).
For both methods (interactive and non-interactive flagging), we will use plotms to inspect the data.
plotms(vis='jupiter6cm.demo.ms', selectdata=True, field='1331+305', correlation='RR,LL', xaxis='uvdist', yaxis='amp')
Inspect the following in the data set:
- The primary flux density scale and polarization angle calibrator, 1331+305 (3C286).
- RR,LL and RL,LR correlations separately due to large amplitude differences between them (when all correlations are plotted together, the RL,LR will seem like bad data due to their much lower amplitudes as compared to RR,LL).
- The other two sources we are interested in, the polarization leakage calibrator (0137+331) and the target source (JUPITER).
Interactive Flagging
- Use Mark Regions within the plotms GUI to draw boxes around points to flag, and hit Flag to flag.
Non-Interactive Flagging
- Use plotms to inspect the data set and flagdata to flag the data. While inspecting the data, you may notice that Antenna 9 (ID=8) in spw='1' is often bad. The bad data on Antenna 9 are in the last 4 scans in spw='1' for the 0137+331 calibrator and for the target source (JUPITER), as well as in the last scan for all antennas in both spws on the target source. We can flag these points with the following flagdata task executions.
flagdata(vis='jupiter6cm.demo.ms', mode='manual', field='0137+331', spw='1', antenna='9', timerange='42:00:00~48:00:00', flagbackup=True)
flagdata(vis='jupiter6cm.demo.ms', mode='manual', field='JUPITER', spw='1', antenna='9', timerange='16:26:00~22:20:00', flagbackup=True)
flagdata(vis='jupiter6cm.demo.ms', mode='manual', field='JUPITER', spw='', timerange='21:40:00~22:20:00', flagbackup=True)
- There are more data points to flag -- keep flagging until you are happy with the results. The following commands will get rid of most bad data, but depending on how clean the data you want to proceed with, you may still want to inspect them in plotms and flag interactively the remainder of bad data points.
flagdata(vis='jupiter6cm.demo.ms',mode='clip',field='1331+305',correlation='ABS_RR,LL',clipoutside=False,clipminmax=[0,0.75], flagbackup=True)
flagdata(vis='jupiter6cm.demo.ms',mode='clip',field='1331+305',correlation='ABS_RL,LR',clipoutside=False,clipminmax=[0,0.04], flagbackup=True)
flagdata(vis='jupiter6cm.demo.ms',mode='clip',field='0137+331',correlation='ABS_RR,LL',clipoutside=False,clipminmax=[0,0.55], flagbackup=True)
flagdata(vis='jupiter6cm.demo.ms',mode='clip',field='0137+331',correlation='ABS_RL,LR',clipoutside=False,clipminmax=[0,0.01], flagbackup=True)
If you are unfamiliar with flagging in CASA, consult the detailed topical guide Flagging VLA Data.
Calibration
Flux Density Scale
Next we will use setjy to set the absolute flux density scale, only for Stokes I at the moment (the total flux density model).
- Our primary flux calibrator here is 1331+305 (3C286).
- The default model for CASA 5.5+ is 'Perley-Butler 2017'.
setjy(vis='jupiter6cm.demo.ms', field='1331+305', model='3C286_C.im')
Initial Gain Calibration
At this stage the data have an overall flux density scaling determined, but full gain solutions aren't there yet. The relevant task is gaincal (analogous to the AIPS task CALIB). Gaincal will produce a separate table with solutions, and we will use appropriate extensions to keep track of the different tables and their corresponding solutions (e.g., gain curve table = .gc).
NOTE: Since we have only two single-channel continuum spw, we do not want to do bandpass calibration nor solve for delays within spws as is currently done with wide bandwidth JVLA data.
First, generate an antenna zenith-angle dependent VLA gain curve calibration table.
gencal(vis='jupiter6cm.demo.ms', caltable='jupiter6cm.demo.gc', caltype='gc')
Now, solve for antenna gains on 1331+305 and 0137+331, using the generated gain curve table (.gc).
gaincal(vis='jupiter6cm.demo.ms', caltable='jupiter6cm.demo.G', field='1331+305,0137+331', spw='', gaintype='G', calmode='ap', solint='inf', combine='', refant='11', minsnr=3, gaintable=['jupiter6cm.demo.gc'], parang=False)
# And check the solutions
plotms(vis='jupiter6cm.demo.G', xaxis='time', yaxis='amp', gridrows=3, gridcols=3, iteraxis='antenna')
plotms(vis='jupiter6cm.demo.G', xaxis='time', yaxis='phase', plotrange=[-1,-1,-200,200], gridrows=3, gridcols=3, iteraxis='antenna')
If all looks good, bootstrap the flux density scale of the flux calibrator onto the phase calibrators (CASA's fluxscale task is equivalent to GETJY in AIPS). When executing fluxscale, the calibration table with the extension .G is modified and stored as a new table with the extension .Gflx.
myFluxscale = fluxscale(vis='jupiter6cm.demo.ms', caltable='jupiter6cm.demo.G', fluxtable='jupiter6cm.demo.Gflx', reference='1331+305', transfer='0137+331', incremental=True, append=False, display=False)
The output is displayed in the logger as well as stored in the myFluxscale python dictionary.
Beginning fluxscale--(MSSelection version)------- Found reference field(s): 1331+305 Found transfer field(s): 0137+331 Flux density for 0137+331 in SpW=0 (freq=4.8851e+09 Hz) is: 5.29665 +/- 0.00449217 (SNR = 1179.09, N = 54) Flux density for 0137+331 in SpW=1 (freq=4.8351e+09 Hz) is: 5.34890 +/- 0.00176819 (SNR = 3025.07, N = 54) Fitted spectrum for 0137+331 with fitorder=1: Flux density = 5.32271 +/- 1.70229e-07 (freq=4.86004 GHz) spidx=-0.954124 (degenerate) Storing result in jupiter6cm.demo.Gflx Writing solutions to table: jupiter6cm.demo.Gflx
Before proceeding, inspect the flux density calibration and save results to a file.
plotms(vis='jupiter6cm.demo.Gflx', xaxis='time', yaxis='amp', showgui=True, plotfile='jupiter6cm.demo.Gflx.amp.png')
plotms(vis='jupiter6cm.demo.Gflx', xaxis='time', yaxis='phase', plotrange=[-1,-1,-200,200], showgui=True, plotfile='jupiter6cm.demo.Gflx.phase.png')
Polarization Calibration
Just as in the step of the initial gain calibration, since our old VLA data have single-channel continuum spws, we do not want to solve for KCROSS delays in our polarization calibration. Instead, we directly solve for D and X terms.
Set the Polarization Model
First, set the polarization model for the polarized position-angle calibrator (here 1331+305=3C286 which is also our primary flux calibrator). For polarization properties of your primary polarization calibrator see the Polarimetry section of the VLA Observing Guide.
i0=7.3109 # Stokes I value for spw 0 ch 0
f0=4.8851 # Frequency for spw0 ch0 (note that in our data the 'lower' spw is actually higher frequency)
alpha=log(i0/7.35974932)/log(4.8351/f0) # Values from our setjy() run on Stokes I earlier
c0=0.114 # Fractional polarisation 11.4% for 5GHz
d0=33*pi/180 # Polarization angle 33deg in radians
myPolSetjy = setjy(vis='jupiter6cm.demo.ms', field='1331+305', standard='manual', spw='', fluxdensity=[i0,0,0,0], spix=[alpha,0], reffreq=str(f0)+'GHz', polindex=[c0,0], polangle=[d0,0], scalebychan=True, usescratch=False)
The results are displayed in the CASA logger as well as saved in the myPolSetjy python dictionary
#In CASA CASA <49>: myPolSetjy Out[49]: {'7': {'0': {'fluxd': array([ 7.3109 , 0.33899165, 0.7613877 , 0. ])}, '1': {'fluxd': array([ 7.26237491, 0.33674164, 0.7563341 , 0. ])}, 'fieldName': '1331+305'}, 'format': "{field Id: {spw Id: {fluxd: [I,Q,U,V] in Jy}, 'fieldName':field name }}"}
Solve for the Leakage Terms (D terms)
Solve for polarization leakage on 0137+331. In this step we solve for the instrumental polarization. We will assume here our calibrator has unknown polarization (poltype='D+QU' if good parallactic coverage, otherwise poltype='D', consult polcal for more information on options).
polcal(vis='jupiter6cm.demo.ms', caltable='jupiter6cm.demo.D', field='0137+331', spw='', refant='11', poltype='D+QU', solint='inf', combine='scan',minsnr=3, gaintable=['jupiter6cm.demo.gc', 'jupiter6cm.demo.G'], gainfield=['','0137+331',''])
Check the solutions
plotms(vis='jupiter6cm.demo.D', xaxis='antenna', yaxis='amp', showgui=True, plotfile='jupiter6cm.demo.D.amp.png')
plotms(vis='jupiter6cm.demo.D', xaxis='antenna', yaxis='phase', plotrange=[-1,-1,-200,200], showgui=True, plotfile='jupiter6cm.demo.D.phase.png')
plotms(vis='jupiter6cm.demo.D', xaxis='antenna', yaxis='snr', showgui=True, plotfile='jupiter6cm.demo.D.snr.png')
Solve for the R-L Polarization angle (X term)
The total polarization is now correct (since we just calibrated the instrumental polarization, i.e., D terms). Now the R-L phase needs to be calibrated to obtain an accurate polarization position angle.
polcal(vis='jupiter6cm.demo.ms', caltable='jupiter6cm.demo.X', field='1331+305', spw='', refant='11', poltype='Xf', solint='inf', combine='scan',minsnr=3, gaintable=['jupiter6cm.demo.gc', 'jupiter6cm.demo.G', 'jupiter6cm.demo.D'], gainfield=['','1331+305','',''])
Check the solutions in the CASA logger window
The following calibration term is arranged for solve: . Xf Jones: table=jupiter6cm.demo.X append=false solint=inf,none refantmode='flex' refant='none' minsnr=3 apmode=AP solnorm=false For solint = inf, found 2 solution intervals. Mean position angle offset solution for 1331+305 (spw = 0) = 80.7525 deg. Mean position angle offset solution for 1331+305 (spw = 1) = 48.9853 deg. Found good Xf Jones solutions in 2 solution intervals.
NOTE: If you are using CASA 4.7 or earlier, you may want to use poltype='X' in X-term calculations (Mueller matrices). For CASA 5.0 and later this option will not work (the relevant CASA documentation is being updated), and hence you need to use poltype='Xf' (Jones matrices). Although 'Xf' should be used predominantly for large bandwidths, which clearly is not the case here, it can also be used for the single channel old VLA data as long as you make sure the interp parameter is set to default (which should be nearest).
Apply the Calibration
Now that we have derived all the calibration solutions and saved them in the tables of multiple extensions, we need to apply them to the actual data. The applycal task commands will apply the solution tables to the DATA and write a new column CORRECTED_DATA as it is standard for CASA. Important: make sure you set parang=True.
applycal(vis='jupiter6cm.demo.ms', field='1331+305', spw='', selectdata=False, gaintable=['jupiter6cm.demo.gc', 'jupiter6cm.demo.G', 'jupiter6cm.demo.D','jupiter6cm.demo.X'], gainfield=['','1331+305'], calwt=[False], parang=True)
applycal(vis='jupiter6cm.demo.ms', field='0137+331', spw='', selectdata=False, gaintable=['jupiter6cm.demo.gc', 'jupiter6cm.demo.G', 'jupiter6cm.demo.Gflx','jupiter6cm.demo.D','jupiter6cm.demo.X'], gainfield=['','0137+331','0137+331'], calwt=[False], parang=True)
applycal(vis='jupiter6cm.demo.ms', field='JUPITER', spw='', selectdata=False, gaintable=['jupiter6cm.demo.gc', 'jupiter6cm.demo.G', 'jupiter6cm.demo.Gflx','jupiter6cm.demo.D','jupiter6cm.demo.X'], gainfield=['','0137+331','0137+331'], calwt=[False], parang=True)
Next, we will split the corrected (i.e., calibrated) Jupiter target data from the MS we started with and write it to a new single-source MS.
split(vis='jupiter6cm.demo.ms', outputvis='jupiter6cm.demo.JUPITER.split.ms', field='JUPITER', datacolumn='corrected')
You can use the plotms task to look at the split calibrated data.
Initial Imaging (Stokes I)
Next we will image and clean the Jupiter data. In this step we will self-calibrate, therefore in the initial imaging we will not clean too deeply and we will save the model in the MS data (with the use of parameter savemodel in tclean).
Since we set mask="" in tclean, the interactive GUI will not allow you to do the deconvolution before you draw the mask on at least one plane. When drawing a mask, make sure to extend it to all channels and all polarization.
tclean(vis='jupiter6cm.demo.JUPITER.split.ms', stokes='I', field='', spw='', imagename='jupiter6cm.demo.JUPITER.I.clean1', robust = 0.0, imsize=[288], cell=['3arcsec'], specmode='mfs', deconvolver='hogbom', weighting='briggs', threshold='0.1mJy', mask='', niter=500, interactive=True, cycleniter=100, savemodel='modelcolumn', pblimit=-0.2)
Inspect the quality of the cleaned images with imstat.
imstat(imagename='jupiter6cm.demo.JUPITER.I.clean1.image', stokes='I', box='216,1,287,72')
In this initial imaging, the deconvolution will stop with the iteration limit since we set it fairly low. We 'cleaned' approximately 4.3 Jy in this initial imaging step, and reached rms of about 3.52 mJy/bm.
Self-Calibration
In the self-calibration step we run gaincal that will make use of the newly created MODEL column in our MS file.
gaincal(vis='jupiter6cm.demo.JUPITER.split.ms', caltable='jupiter6cm.demo.JUPITER.split.selfcal1', field='', spw='', gaintype='G', calmode='p', solint='30s', combine='', refant='11', parang=False, append=False, selectdata=False)
Inspect the solutions using plotms.
plotms(vis='jupiter6cm.demo.JUPITER.split.selfcal1',xaxis='time',yaxis='amp',gridrows=2, gridcols=3, iteraxis='antenna')
plotms(vis='jupiter6cm.demo.JUPITER.split.selfcal1',xaxis='time',yaxis='phase', gridrows=2, gridcols=3 ,iteraxis='antenna',plotrange=[-1,-1,-180,180])
Next, use applycal to apply the calibration to the DATA (creating a CORRECTED column in the MS).
applycal(vis='jupiter6cm.demo.JUPITER.split.ms', field='', spw='', selectdata=False, gaintable=['jupiter6cm.demo.JUPITER.split.selfcal1'], gainfield=[''], interp=['nearest'],calwt=[False], applymode='calflag')
Now, use tclean to image the self-calibrated data.
tclean(vis='jupiter6cm.demo.JUPITER.split.ms', stokes='I', field='', spw='', imagename='jupiter6cm.demo.JUPITER.I.clean2', robust= 0.0, imsize=[288], cell=['3arcsec'], specmode='mfs', deconvolver='hogbom', weighting='briggs', threshold='0.05mJy', mask='', niter=10000, interactive=True, cycleniter=100, pblimit=-0.2)
Check the image statistics using imstat.
imstat(imagename='jupiter6cm.demo.JUPITER.I.clean2.image', stokes='I', box='216,1,287,72')
After one cycle of self-calibration with tclean we reached rms=1.10 mJy/bm. However, keep in mind that the rms values may differ for you since they will depend on how deeply you cleaned and how good a mask you applied.
Full Stokes Imaging
At this stage we will perform full Stokes imaging using tclean to create an image of each Stokes parameter that we will later use to create polarized intensity and angle images.
tclean(vis='jupiter6cm.demo.JUPITER.split.ms', stokes='IQUV', field='', spw='', imagename='jupiter6cm.demo.JUPITER.IQUV.clean', robust= 0.0, imsize=[288], cell=['3arcsec'], specmode='mfs', deconvolver='clarkstokes', weighting='briggs', threshold='0.05mJy', mask='', niter=10000, interactive=True, cycleniter=100, pblimit=-0.2)
Inspect the quality of the cleaned images with imstat. Do so for each Stokes separately, otherwise imstat will return an average of all Stokes.
You should be reaching values of about:
- 1.1 mJy/bm (I)
- 0.62 mJy/bm (Q)
- 0.90 mJy/bm (U)
- 0.16 mJy/bm (V)
Polarization Intensity and Position Angle Images
Next, we will save each Stokes plane as separate images. We can use either the imsubimage or immath tasks to do so.
Run the imsubimage task:
imsubimage(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image',outfile='JUPITER.I.image',stokes='I')
imsubimage(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image',outfile='JUPITER.Q.image',stokes='Q')
imsubimage(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image',outfile='JUPITER.U.image',stokes='U')
Or run the immath task:
immath(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image', mode='evalexpr', stokes='I', expr='IM0', outfile='JUPITER.I.image')
immath(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image', mode='evalexpr', stokes='Q', expr='IM0', outfile='JUPITER.Q.image')
immath(imagename='jupiter6cm.demo.JUPITER.IQUV.clean.image', mode='evalexpr', stokes='U', expr='IM0', outfile='JUPITER.U.image')
Finally, we want to create the polarization intensity (POLI) and position angle (POLA) images using immath.
immath(imagename=['JUPITER.Q.image','JUPITER.U.image'], mode='poli', outfile='JUPITER.POLI.image')
We will now use the polithresh parameter when creating the polarization angle image to get rid of the noise. First check the statistic in the POLI image, and then use it as a threshold while creating the POLA image (in the example below equal to 4 sigma).
imstat(imagename='JUPITER.POLI.image', box='216,1,287,72')
immath(imagename=['JUPITER.Q.image','JUPITER.U.image'], mode='pola', outfile='JUPITER.POLA.image',polithresh='4.5mJy/beam')
Again, check the statistics of these final images with imstat and/or CARTA. (Note, CARTA is replacing the viewer task.)
That concludes this tutorial.
For the tutorial on how to perform analysis, display, and manipulation of the polarization images, consult the VLA Continuum Tutorial 3C391.
Last checked on CASA Version 6.4.1