https://casaguides.nrao.edu/api.php?action=feedcontributions&user=Tsawada&feedformat=atomCASA Guides - User contributions [en]2024-03-29T13:30:57ZUser contributionsMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=18066M100 Band3 SingleDish 4.32015-08-26T20:27:33Z<p>Tsawada: /* Image the Science Target */</p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_TP_UncalibratedData.tgz as described in [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are described at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration and imaging starting from the raw visibility data.'''<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the list of the Execution Block ID's of the science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an abridged example extracted from the output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section (not shown here): The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X36f, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary for data taken in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which has been fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
subtb = tb.query('FLAGROW==1')<br />
flaggedrows = subtb.rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
subtb.close()<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you should have run all 9 science datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 9 datasets have been calibrated into units of Kelvins. The next step is to apply Jy/K conversion factors that have been derived from observations of an amplitude calibrator (one Jy/K value determined per day and per SPW). The resulting Jy/K values are given at the end of this section. <br />
<br />
If you want to know details of how the Jy/K values are determined, a summary is given below. Otherwise, you can skip ahead to the next section [[M100_Band3_SingleDish_4.3#Convert the Science Target Units from Kelvin to Jansky]] to continue the calibration.<br />
<br />
Determination of the Jy/K conversion factor is achieved by imaging a source whose continuum flux is known and measuring the observed brightness temperature. One observation of this source - the amplitude calibrator - was made per day, giving a total of four datasets:<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
If you wish to try this out for yourself, you will first need to download the raw amplitude calibrator data file M100_Band3_TP_ampcal_UncalibratedData.tgz. How to obtain the data is described at [[M100_Band3#Obtaining the Data]]. Once you have unpacked the data you will have a directory called M100_Band3_TP_ampcal_UncalibratedData. In this directory, execute the scripts for individual datasets ([[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]], [[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]], [[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]], and [[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]]) to calibrate all four calibrator datasets (e.g., execfile('A002_X85c183_X895.ms.scriptForSDCalibration.py') in CASA). Then, run the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]", which uses for-loops to image the amplitude calibrator and calculate the Jy/K values (run execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the antennas used for the Science observations were not necessarily available for the corresponding amplitude calibrator observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Optionally_Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
Please refer to the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" used there.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271201800GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100_TP_CO_cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100_TP_CO_cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_TP_CO_cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100_TP_CO_cube.image',<br />
linefile='M100_TP_CO_cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100_TP_CO_cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100_TP_CO_cube.bl.image.mom0')<br />
immoments(imagename='M100_TP_CO_cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100_TP_CO_cube.bl.image.mom0')<br />
<br />
viewer('M100_TP_CO_cube.bl.image.mom0')<br />
</source><br />
<br />
== Combination with 12m and 7m Array Data ==<br />
<br />
If you wish to learn how to combine the Total Power data with interferometric 12m and 7m data, see the guide for Data Combination [[M100_Band3_Combine_4.3]]<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=18065M100 Band3 SingleDish 4.32015-08-26T20:21:32Z<p>Tsawada: /* Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K */</p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_TP_UncalibratedData.tgz as described in [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are described at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration and imaging starting from the raw visibility data.'''<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the list of the Execution Block ID's of the science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an abridged example extracted from the output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section (not shown here): The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X36f, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary for data taken in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which has been fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
subtb = tb.query('FLAGROW==1')<br />
flaggedrows = subtb.rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
subtb.close()<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you should have run all 9 science datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 9 datasets have been calibrated into units of Kelvins. The next step is to apply Jy/K conversion factors that have been derived from observations of an amplitude calibrator (one Jy/K value determined per day and per SPW). The resulting Jy/K values are given at the end of this section. <br />
<br />
If you want to know details of how the Jy/K values are determined, a summary is given below. Otherwise, you can skip ahead to the next section [[M100_Band3_SingleDish_4.3#Convert the Science Target Units from Kelvin to Jansky]] to continue the calibration.<br />
<br />
Determination of the Jy/K conversion factor is achieved by imaging a source whose continuum flux is known and measuring the observed brightness temperature. One observation of this source - the amplitude calibrator - was made per day, giving a total of four datasets:<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
If you wish to try this out for yourself, you will first need to download the raw amplitude calibrator data file M100_Band3_TP_ampcal_UncalibratedData.tgz. How to obtain the data is described at [[M100_Band3#Obtaining the Data]]. Once you have unpacked the data you will have a directory called M100_Band3_TP_ampcal_UncalibratedData. In this directory, execute the scripts for individual datasets ([[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]], [[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]], [[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]], and [[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]]) to calibrate all four calibrator datasets (e.g., execfile('A002_X85c183_X895.ms.scriptForSDCalibration.py') in CASA). Then, run the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]", which uses for-loops to image the amplitude calibrator and calculate the Jy/K values (run execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the antennas used for the Science observations were not necessarily available for the corresponding amplitude calibrator observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271201800GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100_TP_CO_cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100_TP_CO_cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_TP_CO_cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100_TP_CO_cube.image',<br />
linefile='M100_TP_CO_cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100_TP_CO_cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100_TP_CO_cube.bl.image.mom0')<br />
immoments(imagename='M100_TP_CO_cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100_TP_CO_cube.bl.image.mom0')<br />
<br />
viewer('M100_TP_CO_cube.bl.image.mom0')<br />
</source><br />
<br />
== Combination with 12m and 7m Array Data ==<br />
<br />
If you wish to learn how to combine the Total Power data with interferometric 12m and 7m data, see the guide for Data Combination [[M100_Band3_Combine_4.3]]<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py&diff=18063File:A002 X86fcfa Xd9.ms.scriptForSDCalibration.py2015-08-26T17:02:26Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X86fcfa Xd9.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_Xd9</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py&diff=18062File:A002 X86fcfa X96c.ms.scriptForSDCalibration.py2015-08-26T17:02:00Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X86fcfa X96c.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_X96c</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_X664.ms.scriptForSDCalibration.py&diff=18061File:A002 X86fcfa X664.ms.scriptForSDCalibration.py2015-08-26T17:01:40Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X86fcfa X664.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_X664</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X864236_X693.ms.scriptForSDCalibration.py&diff=18060File:A002 X864236 X693.ms.scriptForSDCalibration.py2015-08-26T17:01:14Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X864236 X693.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X864236_X693</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X864236_X2d4.ms.scriptForSDCalibration.py&diff=18059File:A002 X864236 X2d4.ms.scriptForSDCalibration.py2015-08-26T17:00:54Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X864236 X2d4.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X864236_X2d4</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X8602fa_X577.ms.scriptForSDCalibration.py&diff=18058File:A002 X8602fa X577.ms.scriptForSDCalibration.py2015-08-26T17:00:32Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X8602fa X577.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X8602fa_X577</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py&diff=18057File:A002 X8602fa X2ab.ms.scriptForSDCalibration.py2015-08-26T17:00:06Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X8602fa X2ab.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X8602fa_X2ab</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X85c183_X60b.ms.scriptForSDCalibration.py&diff=18056File:A002 X85c183 X60b.ms.scriptForSDCalibration.py2015-08-26T16:59:29Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X85c183 X60b.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X85c183_X60b</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X85c183_X36f.ms.scriptForSDCalibration.py&diff=18055File:A002 X85c183 X36f.ms.scriptForSDCalibration.py2015-08-26T16:58:06Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:A002 X85c183 X36f.ms.scriptForSDCalibration.py&quot;</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X85c183_X36f</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=18052M100 Band3 SingleDish 4.32015-08-26T15:54:32Z<p>Tsawada: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_TP_UncalibratedData.tgz as described in [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are described at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration and imaging starting from the raw visibility data.'''<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the list of the Execution Block ID's of the science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an abridged example extracted from the output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section (not shown here): The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X36f, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary for data taken in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which has been fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
subtb = tb.query('FLAGROW==1')<br />
flaggedrows = subtb.rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
subtb.close()<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you should have run all 9 science datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 9 datasets have been calibrated into units of Kelvins. The next step is to apply Jy/K conversion factors that have been derived from observations of an amplitude calibrator (one Jy/K value determined per day and per SPW). The resulting Jy/K values are given at the end of this section. <br />
<br />
If you want to know details of how the Jy/K values are determined, a summary is given below. Otherwise, you can skip ahead to the next section [[M100_Band3_SingleDish_4.3#Convert the Science Target Units from Kelvin to Jansky]] to continue the calibration.<br />
<br />
Determination of the Jy/K conversion factor is achieved by imaging a source whose continuum flux is known and measuring the observed brightness temperature. One observation of this source - the amplitude calibrator - was made per day, giving a total of four datasets:<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
If you wish to try this out for yourself, you will first need to download the raw amplitude calibrator data file M100_Band3_TP_ampcal_UncalibratedData.tgz. How to obtain the data is described at [[M100_Band3#Obtaining the Data]]. Once you have unpacked the data you will have a directory called M100_Band3_TP_ampcal_UncalibratedData. In this directory, execute the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" to calibrate all four calibrator datasets using for-loops (run execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the antennas used for the Science observations were not necessarily available for the corresponding amplitude calibrator observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271201800GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100_TP_CO_cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100_TP_CO_cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_TP_CO_cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100_TP_CO_cube.image',<br />
linefile='M100_TP_CO_cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100_TP_CO_cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100_TP_CO_cube.bl.image.mom0')<br />
immoments(imagename='M100_TP_CO_cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100_TP_CO_cube.bl.image.mom0')<br />
<br />
viewer('M100_TP_CO_cube.bl.image.mom0')<br />
</source><br />
<br />
== Combination with 12m and 7m Array Data ==<br />
<br />
If you wish to learn how to combine the Total Power data with interferometric 12m and 7m data, see the guide for Data Combination [[M100_Band3_Combine_4.3]]<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=17919M100 Band3 SingleDish 4.32015-07-27T15:34:03Z<p>Tsawada: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_TP_UncalibratedData.tgz as described in [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are described at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration and imaging starting from the raw visibility data.'''<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the list of the Execution Block ID's of the science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an abridged example extracted from the output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section (not shown here): The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X36f, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary for data taken in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you should have run all 9 science datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 9 datasets have been calibrated into units of Kelvins. The next step is to apply Jy/K conversion factors that have been derived from observations of an amplitude calibrator (one Jy/K value determined per day and per SPW). The resulting Jy/K values are given at the end of this section. <br />
<br />
If you want to know details of how the Jy/K values are determined, a summary is given below. Otherwise, you can skip ahead to the next section [[M100_Band3_SingleDish_4.3#Convert the Science Target Units from Kelvin to Jansky]] to continue the calibration.<br />
<br />
Determination of the Jy/K conversion factor is achieved by imaging a source whose continuum flux is known and measuring the observed brightness temperature. One observation of this source - the amplitude calibrator - was made per day, giving a total of four datasets:<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
If you wish to try this out for yourself, you will first need to download the raw amplitude calibrator data file M100_Band3_TP_ampcal_UncalibratedData.tgz. How to obtain the data is described at [[M100_Band3#Obtaining the Data]]. Once you have unpacked the data you will have a directory called M100_Band3_TP_ampcal_UncalibratedData. In this directory, execute the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" to calibrate all four calibrator datasets using for-loops (run execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the antennas used for the Science observations were not necessarily available for the corresponding amplitude calibrator observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271201800GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100_TP_CO_cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100_TP_CO_cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_TP_CO_cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100_TP_CO_cube.image',<br />
linefile='M100_TP_CO_cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100_TP_CO_cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100_TP_CO_cube.bl.image.mom0')<br />
immoments(imagename='M100_TP_CO_cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100_TP_CO_cube.bl.image.mom0')<br />
<br />
viewer('M100_TP_CO_cube.bl.image.mom0')<br />
</source><br />
<br />
== Combination with 12m and 7m Array Data ==<br />
<br />
If you wish to learn how to combine the Total Power data with interferometric 12m and 7m data, see the guide for Data Combination [[M100_Band3_Combine_4.3]]<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=17918M100 Band3 SingleDish 4.32015-07-27T15:25:00Z<p>Tsawada: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_TP_UncalibratedData.tgz as described in [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are described at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration and imaging starting from the raw visibility data.'''<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the list of the Execution Block ID's of the science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an abridged example extracted from the output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X36f, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary for data taken in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Optionally Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you should have run all 9 science datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 9 datasets have been calibrated into units of Kelvins. The next step is to apply Jy/K conversion factors that have been derived from observations of an amplitude calibrator (one Jy/K value determined per day and per SPW). The resulting Jy/K values are given at the end of this section. <br />
<br />
If you want to know details of how the Jy/K values are determined, a summary is given below. Otherwise, you can skip ahead to the next section [[M100_Band3_SingleDish_4.3#Convert the Science Target Units from Kelvin to Jansky]] to continue the calibration.<br />
<br />
Determination of the Jy/K conversion factor is achieved by imaging a source whose continuum flux is known and measuring the observed brightness temperature. One observation of this source - the amplitude calibrator - was made per day, giving a total of four datasets:<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
If you wish to try this out for yourself, you will first need to download the raw amplitude calibrator data file M100_Band3_TP_ampcal_UncalibratedData.tgz. How to obtain the data is described at [[M100_Band3#Obtaining the Data]]. Once you have unpacked the data you will have a directory called M100_Band3_TP_ampcal_UncalibratedData. In this directory, execute the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" to calibrate all four calibrator datasets using for-loops (run execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the antennas used for the Science observations were not necessarily available for the corresponding amplitude calibrator observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271201800GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100_TP_CO_cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100_TP_CO_cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_TP_CO_cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100_TP_CO_cube.image',<br />
linefile='M100_TP_CO_cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100_TP_CO_cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100_TP_CO_cube.bl.image.mom0')<br />
immoments(imagename='M100_TP_CO_cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100_TP_CO_cube.bl.image.mom0')<br />
<br />
viewer('M100_TP_CO_cube.bl.image.mom0')<br />
</source><br />
<br />
== Combination with 12m and 7m Array Data ==<br />
<br />
If you wish to learn how to combine the Total Power data with interferometric 12m and 7m data, see the guide for Data Combination [[M100_Band3_Combine_4.3]]<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_Combine_4.3&diff=17132M100 Band3 Combine 4.32015-06-17T07:45:59Z<p>Tsawada: </p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
= Overview =<br />
<br />
This guide describes how to combine the 7m and 12m interferometric data and then how to feather the resulting image with the total power TP image. All of the data for this SV project can be found at https://almascience.nrao.edu/alma-data/science-verification. The guide has been written for data reduced in CASA 4.3.0 or later and assumes that all calibration tables (Tsys and gain tables) have been applied to the visibility weights using calwt=True. If either of these is not the case for your data, '''do not follow this guide.''' <br />
<br />
In order to run this guide you will need to:<br />
<br />
* Either download the fully calibrated 7m data (i.e., M100_Band3_7m_CalibratedData.tgz) or download the uncalibrated 7m data and the relevant, standard calibration scripts available (here). An overview of the 7m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either download the fully calibrated 12m data (i.e. M100_Band3_12m_CalibratedData.tgz) or download the uncalibrated 12m data and the relevant, standard calibration scripts available (here). Note that this is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.''' An overview of the 12m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either run the [[M100_Band3_SingleDish_4.3]] guide to calibrate and image the Total Power data or download the final image (i.e. M100_TP_Image.tgz)<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
= Combine and Image the 7m+12m Interferometric Data =<br />
<br />
<br />
== Split off CO spectral windows (SPWs) ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_*m.ms.listobs')<br />
listobs('M100_Band3_12m_CalibratedData.ms',listfile='m100_12m.ms.listobs')<br />
listobs('M100_Band3_7m_CalibratedData.ms',listfile='m100_7m.ms.listobs')<br />
</source><br />
<br />
Running the task "listobs" provides the setups used in the observations at a glance. Below are the first target scans of the 12m and 7m observations and the spectral window tables as generated by listobs. The six 7m data sets were taken with two slightly different correlator setups (one with four SPWs and the other with two SPWs), so the concatenated data set has six total SPWs. <br />
<br />
<pre style="background-color: #fffacd;"><br />
12m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
10-Aug-2011/19:38:05.8 - 19:50:22.8 11 1 M100 1500 [0,1,2,3] [6.05, 6.05, 6.05, 6.05] [CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (4 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 3840 TOPO 113726.419 488.281 1875000.0 114663.6750 1 XX YY<br />
1 3840 TOPO 111851.419 488.281 1875000.0 112788.6750 2 XX YY<br />
2 3840 TOPO 103663.431 -488.281 1875000.0 102726.1750 3 XX YY<br />
3 3840 TOPO 101850.931 -488.281 1875000.0 100913.6750 4 XX YY<br />
<br />
7m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
17-Mar-2013/04:44:04.3 - 04:50:43.7 11 1 M100 261 [0,1,2,3] [10.1, 10.1, 10.1, 10.1] [OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (6 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
1 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
2 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
3 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
4 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 111798.250 488.281 1992187.5 112794.1000 1 XX YY<br />
5 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 113673.250 488.281 1992187.5 114669.1000 2 XX YY<br />
</pre><br />
<br />
<figure id="12m_mosaic.png"><br />
[[Image:12m_mosaic.png|300px|thumb|right|<caption>FOV of 12m mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="7m_mosaic.png"><br />
[[Image:7m_mosaic.png|300px|thumb|right|<caption>FOV of 7m mosaic.</caption>]]<br />
</figure><br />
<br />
Examination of the listobs files shows that the CO is in SPW='0' for the 12m data and in SPW='3,5' for the 7m data. There are two SPWs containing CO in the 7m data due to the slightly differing correlator setups.<br />
<br />
Also note that the integration time per visibility (average interval parameter in listobs) is different:<br />
6.05s for the 12m data and 10.1s for the 7m. This will be important to know later when we check the visibility weights. <br />
<br />
Next we split out the CO spectral windows.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_12m_CO.ms')<br />
split(vis='M100_Band3_12m_CalibratedData.ms',<br />
outputvis='m100_12m_CO.ms',spw='0',field='M100',<br />
datacolumn='data',keepflags=False)<br />
os.system('rm -rf m100_7m_CO.ms')<br />
split(vis='M100_Band3_7m_CalibratedData.ms',<br />
outputvis='m100_7m_CO.ms',spw='3,5',field='M100',<br />
datacolumn='data',keepflags=False)<br />
</source><br />
<br />
Also of interest is that the 12m data has 47 fields and the 7m has 23 fields (not shown in the excerpts above). The difference in number of pointings is because the 7m antennas have a FWHP (full width half power) primary beam diameter that is 12/7 times larger than the 12m antennas. '''One easy way to see how the mosaics compare is to install the AnalysisUtils package (see [[Analysis_Utilities]])'''. Then with AnalysisUtils you can make the following plots (look at the listobs to obtain the sourceid):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *m_mosaic.png')<br />
au.plotmosaic('m100_12m_CO.ms',sourceid='0',figfile='12m_mosaic.png')<br />
au.plotmosaic('m100_7m_CO.ms',sourceid='0',figfile='7m_mosaic.png')<br />
</source><br />
<br />
We see that the mosaics cover a common area but that the 7m mosaic is a bit larger. This means that the outer edges of the combined mosaic will be noisier than expected if they overlapped perfectly; this is just something to keep in mind. If you had the case where the mosaic coverages are dramatically different, it would be best to exclude the completely non-overlapping fields from the combination.<br />
<br />
NOTE: At this stage one would typically do continuum subtraction (if there is any). However we already know from the individual data reductions that the 3mm continuum emission is quite weak and does not significantly contribute to a 5km/s channel, so we will forgo the the continuum subtraction step. Examples of how to do this if you are so inclined are located in various other ALMA CASAguides.<br />
<br />
== Checking the weights and concatenating the data ==<br />
<br />
<figure id="7m_WT.png"><br />
[[File:12m_WT.png|200px|thumb|right|<caption> 12m weights.</caption>]]<br />
</figure><br />
<br />
<figure id="12m_WT.png"><br />
[[File:7m_WT.png|200px|thumb|right|<caption> 7m weights.</caption>]]<br />
</figure><br />
<br />
When combining data with disparate properties it is very important that the relative weights of each visibility be in the correct proportion to the other data according to the radiometer equation. Formally, the<br />
visibility weights should be proportional to 1/sigma<sup>2</sup> where sigma is the variance or rms noise of a given visibility.<br />
<br />
Assuming that the 7m and 12m antennas have similar apperture and quantization efficiencies (a reasonable assumption since they were designed this way), the rms noise in a single channel for a single visibility is:<br />
<br />
<math> <br />
\sigma_{ij}=\frac{2k}{A_{eff}} <br />
</math><br />
<math> <br />
\sqrt{\frac{T_{sys,i} T_{sys,j}}{\Delta\nu_{ch} t_{ij}}},<br />
</math><br />
<br />
where k is Boltzmann's constant, A<sub>eff</sub> is the effective antenna area, T<sub>sys,i</sub> is the system temperature for antenna i, &Delta;&nu;<sub>ch</sub> is the channel width, and t<sub>ij</sub> is the integration time per visibility.<br />
<br />
CASA initially scales the weights by 2&Delta;&nu;<sub>ch</sub>&Delta;t<sub>ij</sub>, and after the Tsys table applycal step of the calibration process, it further scales the weights by 1/[(Tsys(i) * Tsys(j)] as long as calwt=True. In the subsequent gain calibration table applycal step of the calibration, the weights are further scaled by a factor of [(gain(i))<sup>2</sup> * (gain(j))<sup>2</sup>]. The gains should change very little from antenna to antenna, so this scaling is effectively the average gain<sup>4</sup> (again, as long as calwt=True). In the calibration scripts for all executions of the 12m and 7m data, found (here), both applycal steps set calwt=True. To verify, we plot the weights of the 7m and 12m data and measure their ratio to be, on average, 7m/12m ~ 0.055/0.3 ~ 0.18. Note that in the plots the points are colored by SPW, so there is only one 12m CO SPW but there are two 7m CO SPWs, and that no averaging can be turned on when plotting the weights. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf 7m_WT.png 12m_WT.png')<br />
plotms(vis='m100_12m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0:200',<br />
coloraxis='spw',plotfile='12m_WT.png')<br />
#<br />
plotms(vis='m100_7m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~1:200',<br />
coloraxis='spw',plotfile='7m_WT.png')<br />
</source><br />
<br />
<figure id="combine_CO_WT.png"><br />
[[File:combine_CO_WT.png|200px|thumb|right|<caption> 7m and 12m weights after concatenation.</caption>]]<br />
</figure><br />
<br />
The two key things that are different between the 7m and 12m-array data are that the effective dish areas are different by (7/12)<sup>2</sup>, and the integration times are different by sqrt(10.1/6.05). Since dish area is in the numerator of the radiometer equation and integration time per visibility is in the denominator, and assuming the weight of an individual visibility is proportional to 1/sigma<sup>2</sup>, the ratio of the weights should be (7./12.)<sup>4</sup> x (10.1/6.05) = 0.19. This is very close to the value we measure for the ratio of the weights, particularly given that the 7m flux calibration relied on a source which changed substantially over the course of the six 7m-array observations. <br />
<br />
Now concatenate the two data sets and plot the concatenated weights to verify that they are as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Concat and scale weights<br />
os.system('rm -rf M100_combine_CO.ms')<br />
concat(vis=['m100_12m_CO.ms','m100_7m_CO.ms'],<br />
concatvis='M100_combine_CO.ms')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf combine_CO_WT.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~2:200',<br />
coloraxis='spw',plotfile='combine_CO_WT.png')<br />
</source><br />
<br />
Here, we create more instructive plots of the combined data to check that things are in order. (''Let each plot finish before cutting and pasting next plot. If plotms gui disappears, exit CASA and restart.'')<br />
<br />
<figure id="M100_combine_vel.png"><br />
[[File:M100_combine_vel.png|200px|thumb|right|<caption> Amplitude as a function of velocity.</caption>]]<br />
</figure><br />
<br />
To plot amplitude as a function of uv-distance, noting that the 7m data is noisier than the 12m data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_uvdist.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='uvdist',spw='', avgscan=True,<br />
avgchannel='5000', coloraxis='spw',plotfile='M100_combine_uvdist.png') <br />
</source><br />
<br />
A fairer comparison of these data is achieved by isolating the brightest line channels in individual 12m and 7m data sets (i.e., not the concatenated data sets) and comparing only those channels in amplitude vs. uv-distance. Here the agreement is better, as it is less dominated by the scatter among the several 7m executions.<br />
<br />
To plot the CO line as a function of velocity (this plot takes a while):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_vel.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='velocity',spw='', avgtime='1e8',avgscan=True,coloraxis='spw',avgchannel='5',<br />
transform=True,freqframe='LSRK',restfreq='115.271201800GHz', plotfile='M100_combine_vel.png')<br />
</source><br />
<br />
To see each spectral window independently in plotms, run the command again but remove the call to "plotfile" and add " iteraxis='spw' ".<br />
<br />
== Image Using An Automasking Technique ==<br />
<br />
The commands in this section perform an iterative automasking procedure down<br />
to a user specified threshold=stop*rms where stop is typically 2-3 using the imagemode='mosaic' mode of clean. This mode automatically calculates the correct convolution of the primary beam response of the mosaic when different antenna dish diameters are present. '''NOTE:''' even if these data had only been comprised of a single pointing of 7m and 12m-array data, the imagemode='mosaic' mode would be needed to correctly image data with different antenna sizes.<br />
<br />
The procedure outlined below takes some care to ensure that the generated masks (i) only have values of 0 or 1; (ii) are themselves masked at the minpb level. It also removes very small masked regions that are consistent with noise bumps using a function in scipy. A typical setting is to remove mask regions that are 1/2 the beam area in pixels. This is one technique under exploration for future pipeline use. <br />
<br />
The commands have been split into multiple sections to aid cut and paste. Wait until the current one is done before starting next section. '''If you stop CASA and restart you will need to cut and paste again from the Define Parameters section on down'''.<br />
<br />
For the long series of commands below it is important to include the '''beginning cpaste''' and '''ending --''' in your cut and paste.<br />
<br />
=== Define Parameters ===<br />
<br />
Note that the parameters used here are by design the same as those used to make the stand-alone 7m-array and 12m-array images. <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
<br />
### Initialize <br />
import scipy.ndimage <br />
<br />
### Define clean parameters<br />
vis='M100_combine_CO.ms'<br />
prename='M100_combine_cube'<br />
myimage=prename+'.image'<br />
myflux=prename+'.flux'<br />
mymask=prename+'.mask'<br />
myresidual=prename+'.residual'<br />
imsize=800<br />
cell='0.5arcsec'<br />
minpb=0.2<br />
restfreq='115.271201800GHz'<br />
outframe='LSRK'<br />
spw='0~2'<br />
width='5km/s'<br />
start='1400km/s'<br />
nchan=70<br />
robust=0.5<br />
phasecenter='J2000 12h22m54.9 +15d49m15'<br />
scales=[0]<br />
smallscalebias=0.6<br />
<br />
### Setup stopping criteria with multiplier for rms.<br />
stop=3. <br />
<br />
### Minimum size multiplier for beam area for removing very small mask regions. <br />
pixelmin=0.5 <br />
<br />
--<br />
</source><br />
<br />
=== Make Initial Dirty Image and Determine Synthesized Beam area===<br />
<br />
The dirty image is used to determine the initial peak flux density in the cube and the beam area is used to define the minimum size of masked regions in order to exclude noise bumps from the overall mask.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Make initial dirty image<br />
os.system('rm -rf '+prename+'.* ' +prename+'_*')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask='',<br />
niter=0,interactive=F)<br />
<br />
# Determine the beam area in pixels for later removal of very small mask regions<br />
major=imhead(imagename=myimage,mode='get',hdkey='beammajor')['value']<br />
minor=imhead(imagename=myimage,mode='get',hdkey='beamminor')['value']<br />
pixelsize=float(cell.split('arcsec')[0])<br />
beamarea=(major*minor*pi/(4*log(2)))/(pixelsize**2)<br />
print 'beamarea in pixels =', beamarea<br />
<br />
--<br />
</source><br />
<br />
=== Find properties of the dirty image ===<br />
<br />
For the long series of commands below it is important to include the beginning '''cpaste''' and ending '''--''' in your cut and paste.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Find the peak in the dirty cube.<br />
myimage=prename+'.image'<br />
bigstat=imstat(imagename=myimage)<br />
peak= bigstat['max'][0]<br />
print 'peak (Jy/beam) in cube = '+str(peak)<br />
### Sets threshold of first loop, try 2-4. Subsequent loops are set thresh/2.<br />
thresh = peak / 4.<br />
<br />
### If True: find the rms in two line-free channels; If False: Set rms by hand in else statement.<br />
if True: <br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2) <br />
else:<br />
rms=0.011<br />
<br />
<br />
print 'rms (Jy/beam) in a channel = '+str(rms)<br />
--<br />
</source><br />
<br />
=== Automasking Loop ===<br />
<br />
On a reasonably fast computer the following will take a couple of hours for this spectral mosaic... <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf ' + prename +'_threshmask*')<br />
os.system('rm -rf ' + prename +'_fullmask*')<br />
os.system('rm -rf ' + prename +'.image*')<br />
n=-1<br />
while (thresh >= stop*rms): <br />
n=n+1<br />
print 'clean threshold this loop is', thresh<br />
threshmask = prename+'_threshmask' +str(n)<br />
maskim = prename+'_fullmask' +str(n)<br />
immath(imagename = [myresidual],<br />
outfile = threshmask,<br />
expr = 'iif(IM0 > '+str(thresh) +',1.0,0.0)',<br />
mask=myflux+'>'+str(minpb))<br />
if (n==0):<br />
os.system('cp -r '+threshmask+' '+maskim+'.pb')<br />
print 'This is the first loop'<br />
else:<br />
makemask(mode='copy',inpimage=myimage,<br />
inpmask=[threshmask,mymask],<br />
output=maskim)<br />
imsubimage(imagename=maskim, mask=myflux+'>'+str(minpb),<br />
outfile=maskim+'.pb') <br />
print 'Combined mask ' +maskim+' generated.'<br />
<br />
# Remove small masks<br />
os.system('cp -r '+maskim+'.pb ' +maskim+'.pb.min')<br />
maskfile=maskim+'.pb.min'<br />
ia.open(maskfile)<br />
mask=ia.getchunk() <br />
labeled,j=scipy.ndimage.label(mask) <br />
myhistogram = scipy.ndimage.measurements.histogram(labeled,0,j+1,j+1)<br />
object_slices = scipy.ndimage.find_objects(labeled)<br />
threshold=beamarea*pixelmin<br />
for i in range(j):<br />
if myhistogram[i+1]<threshold:<br />
mask[object_slices[i]] = 0<br />
<br />
<br />
ia.putchunk(mask)<br />
ia.done()<br />
print 'Small masks removed and ' +maskim +'.pb.min generated.'<br />
<br />
os.system('rm -rf '+mymask+'')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask = maskim+'.pb.min',<br />
multiscale=scales,smallscalebias=smallscalebias,<br />
interactive = F,<br />
niter = 10000,<br />
threshold = str(thresh) +'Jy/beam')<br />
<br />
<br />
if thresh==stop*rms: break<br />
thresh = thresh/2.<br />
# Run a final time with stop*rms if more than a little above<br />
# stop*rms. Also make a back-up of next to last image<br />
if (thresh < stop*rms and thresh*2.>1.05*stop*rms):<br />
thresh=stop*rms <br />
os.system('cp -r '+myimage+' '+myimage+str(n))<br />
<br />
--<br />
</source><br />
<br />
=== Notes on the Automasking procedure ===<br />
<br />
This script is meant to be a possible stepping stone to optimal automasking -- it is by no means perfect and is certainly slower than optimal but feel free to try it with other datasets. Some notes below:<br />
<br />
In addition to the final prename.image (prename.flux etc) this script produces and keeps each iteration of the various mask files which will allow you to explore how the masking proceeded as the threshold for masking and cleaning was lowered. The ones denoted "prename. fullmask*.pb.min" are the ones used in the clean steps themselves. At the end of the process the final "prename. fullmask*.pb.min" will also be stored in the prename.mask. Once you've verified you are happy with the masking, you may want to remove the prename.threshmask* and prename.fullmask* files, as they can be large for large cubes. <br />
<br />
Additionally, before running the final loop with thresh=stop*rms the script copies the .image from the preceding clean to prename.image'n' where 'n' equals the loop number of the preceding step. So in this M100 example you will see a M100_combine_cube.image and a M100_combine_cube.image2 where .image is the final image and .image2 is the next to last image. This is done for convenience in the case that thresh=stop*rms is too deep such that clean diverges, you will still be left with the clean image from the preceding loop that you can further investigate to understand why clean diverged. If all goes well with the final loop, the prename.image'n' can also be deleted. Divergence at thresh=stop*rms is often a sign that the image is "dynamic range limited" in other words the rms in channels with bright emission is significantly worse than for a line-free channel.<br />
<br />
== Image Analysis for the 7m+12m Data ==<br />
<br />
=== Moment Maps for 7m+12m CO (1-0) Cube ===<br />
<br />
Start by examining the final image cube. Determine the start and stopping channels for the line emission -- this will be used in the "chans" parameter of immoments.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_combine_cube.image')<br />
</source><br />
<br />
Next determine the rms noise per channel and use that to exclude pixels from the moment images. All images are shown in the gallery at the end of the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
myimage='M100_combine_cube.image'<br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2)<br />
print 'rms in a channel = '+str(rms) <br />
</source><br />
<br />
Next make the moment maps. For the integrated intensity: moment 0, a 2 sigma cut often considerably improves the appearance of the image with little effect on the integrated intensity as long as emission free channels are excluded. For higher order moments it is necessary to exclude all low S/N data. Typically 5-6 sigma for the higher moments works well. We also apply further masking based on the .flux image because the edges of the combined mosaic are especially noisy because the 7m mosaic is somewhat larger than the 12m mosaic as described above (see Figures 1 & 2). <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom0')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [0],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',,<br />
includepix = [rms*2,100.],<br />
outfile = 'M100_combine_cube.image.mom0')<br />
<br />
os.system('rm -rf M100_combine_cube.image.mom1')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [1],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',<br />
includepix = [rms*5.5,100.],<br />
outfile = 'M100_combine_cube.image.mom1')<br />
--<br />
</source><br />
<br />
Now we can make some figures showing the moment maps (*note that this creates different looking files for me than the ones I have included here, which were made in the viewer -- is this true for others?*):<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom*.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.png')<br />
<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom1',<br />
'range': [1440,1695],'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]}, <br />
out='M100_combine_cube.image.mom1.png')<br />
--<br />
</source><br />
<br />
If you plan to use your moment 0 image to make measurements, it needs to be primary beam corrected first. First we need to subimage the .flux cube to extract a single plane that can be used to primary beam correct the moment 0 image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.flux.1ch')<br />
imsubimage(imagename='M100_combine_cube.flux',<br />
outfile='M100_combine_cube.flux.1ch',<br />
chans='35')<br />
</source><br />
<br />
Then primary beam correct the moment 0 image. This is the version that would be used for measurements, though the uncorrected one can be useful for figures. The difference is clear in the images seen below in the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor')<br />
immath(imagename=['M100_combine_cube.image.mom0', \<br />
'M100_combine_cube.flux.1ch'],<br />
expr='IM0/IM1',<br />
outfile='M100_combine_cube.image.mom0.pbcor')<br />
</source><br />
<br />
Have a look at the difference the primary beam correction makes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3},<br />
{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3}],<br />
zoom={'blc': [190,150],'trc': [650,610]})<br />
</source><br />
<br />
With the viewer open, you can flip back and forth between the images to compare them. Next, make a figure.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.pbcor.png')<br />
<br />
</source><br />
<br />
=== Comparison with 7m, 12m Moment Maps ===<br />
<br />
Below the moment maps from the 7m-only and the 12m-only data are shown for comparison. The moment maps were made using clean masks drawn by hand for comparison to the automasking technique; the two appear to be qualitatively similar. The range and scaling for the 12m-only figures are the same as that used for the 7m+12m figures for ease of comparison.<br />
<br />
As expected, the 7m+12m image shows considerably more extended emission than the 12m-only data and finer detail than the 7m-only data. For comparison, the 7m+12m synthesized beam is 3.80"x2.50", while the 12m-only beam is 3.46"x2.37" and the 7m-only beam is 12.72"x10.12".<br />
<br />
<gallery widths=300px heights=300px><br />
File:12m.png | Moment 0 for 12m data alone (no primary beam correction).<br />
File:7m_mom0.png | Moment 0 for 7m data alone (no primary beam correction).<br />
File:combined.png | Moment 0 for 12m+7m data (no primary beam correction).<br />
File:combine_pbcor.png | Moment 0 for 12m+7m data with primary beam correction.<br />
</gallery><br />
<br />
<gallery widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data alone.<br />
File:7m_mom1.png | Moment 1 for 7m data alone.<br />
File:combine_mom1.png | Moment 1 for 12m+7m data.<br />
</gallery><br />
<br />
=== Convert 7m+12m Images to Fits Format ===<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf *.fits')<br />
exportfits(imagename='M100_combine_cube.image',fitsimage='M100_combine_cube.image.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.flux',fitsimage='M100_combine_cube.flux.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0',fitsimage='M100_combine_cube.image.mom0.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0.pbcor',fitsimage='M100_combine_cube.image.mom0.pbcor.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom1',fitsimage='M100_combine_cube.image.mom1.fits')<br />
<br />
--<br />
</source><br />
<br />
= Feathering the Total Power and 7m+12m Interferometric Images =<br />
<br />
In this section the interferometric (7m+12m) image produced above is combined with the Total Power (single dish) image.<br />
The "feather" algorithm is employed, in which the two images are combined in the spatial frequency domain, i.e.,<br />
the low and high spatial frequency components are predominantly taken from the TP and interferometric images, respectively.<br />
<br />
== Prepare Images for Feathering ==<br />
<br />
Regrid the TP image to match the shape of the 7m+12m image using the task {{imregrid}}.<br />
The TP image is resampled onto the same grid as that of the "template" 7m+12m image along the first two axes of the cube (i.e., RA and Dec; it is not necessary to regrid the velocity axis, since the axis is already common to the both images).<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid')<br />
imregrid(imagename='M100TP.CO.cube.bl.image',<br />
template='M100_combined_CO.image',<br />
axes=[0, 1],<br />
output='M100TP.CO.regrid')<br />
</source><br />
<br />
Now we trim the 7m+12m and (regridded) TP images, in order to exclude the regions masked by the {{clean}} task with minpb=0.2 and/or noisy edge regions in the TP image. The {{viewer}} task can be used to determine the trimming box. Here we use (x, y) = (219, 148) and (612, 579) [pixels] as the bottom-left and top-right corners, respectively, and set these values to the "box" parameter of the {{imsubimage}} task.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim')<br />
imsubimage(imagename='M100TP.CO.regrid',<br />
outfile='M100TP.CO.regrid.subim',<br />
box='219,148,612,579')<br />
os.system('rm -rf M100_combined_CO.image.subim')<br />
imsubimage(imagename='M100_combined_CO.image',<br />
outfile='M100_combined_CO.image.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
While the 7m+12m image (before the primary-beam correction) has non-uniform primary beam response (i.e., lower response in the outskirts of the mosaic field), the TP image does not have such non-uniformity.<br />
In order to feather the TP and 7m+12m images together, they should have the common response on the sky.<br />
Hence we need to multiply the TP image by the 7m+12m primary beam response before proceeding.<br />
To do this, create the subimage of the 7m+12m response,<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
then multiply it and the TP image using the task {{immath}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim.depb')<br />
immath(imagename=['M100TP.CO.regrid.subim',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0*IM1',<br />
outfile='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
As a result, the feathered image will have the same response as that of the 7m+12m image.<br />
The primary-beam correction can be done after the feathering process (see below).<br />
<br />
== Feather TP Cube with 7m+12m Cube ==<br />
<br />
Now we are ready to execute the {{feather}} task to combine the TP and 7m+12m images.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image')<br />
feather(imagename='M100_Feather_CO.image',<br />
highres='M100_combined_CO.image.subim',<br />
lowres='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
The task produces the combined image in the following way:<br />
* Convert the input images specified by the "highres" and "lowres" parameters onto the spatial frequency plane.<br />
* Combine them on the spatial frequency plane. The weighting is determined by the beam sizes/shapes of the input images.<br />
* Convert it back to the image plane.<br />
Please refer to the online help and documents for the details.<br />
<br />
== Make Moment Maps of the Feathered Images ==<br />
<br />
We will use the same technique as the [[#Moment_Maps_for_7m.2B12m_CO_.281-0.29_Cube|7m+12m image analysis above]] to make moment maps.<br />
<br />
First (but optionally; this is solely for comparison to the feathered images and not needed to create the final feathered images), make moment maps for the (regridded) TP image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100TP.CO.regrid.subim'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom0')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100TP.CO.regrid.subim.mom0')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom1')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100TP.CO.regrid.subim.mom1')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom*.png')<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom0',<br />
'range': [0., 1080.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100TP.CO.regrid.subim.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100TP.CO.regrid.subim.mom1.png')<br />
</source><br />
<br />
Then make moment maps for the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100_Feather_CO.image'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100_Feather_CO.image.mom0')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom1')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100_Feather_CO.image.mom1')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom*.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100_Feather_CO.image.mom1.png')<br />
</source><br />
<br />
=== Correct the Primary Beam Response ===<br />
<br />
Apply the primary beam response to the feathered image using the task {{immath}},<br />
<br />
<source lang="python"><br />
#In CASA<br />
immath(imagename=['M100_Feather_CO.image',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.pbcor')<br />
</source><br />
<br />
and also to the moment 0 image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.1ch.subim')<br />
imsubimage(imagename='M100_combined_CO.flux.subim',<br />
outfile='M100_combined_CO.flux.1ch.subim',<br />
chans='35')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor')<br />
immath(imagename=['M100_Feather_CO.image.mom0',<br />
'M100_combined_CO.flux.1ch.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.mom0.pbcor')<br />
</source><br />
<br />
Save the primary-beam corrected moment 0 image to a PNG file.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0.pbcor',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.pbcor.png')<br />
</source><br />
<br />
=== Compare the Various Images ===<br />
<br />
Now we compare all the images:<br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_pbcor.png | Primary beam corrected moment 0 for the 12m data.<br />
File:7m_pbcor.png | Primary beam corrected moment 0 for the 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom0.png | Moment 0 for the TP data.<br />
File:combine_pbcor.png | Primary beam corrected moment 0 for 7m+12m data.<br />
File:M100_Feather_CO.mom0.pbcor.png | Primary beam corrected moment 0 for TP+7m+12m data.<br />
</gallery><br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data.<br />
File:7m_mom1.png | Moment 1 for 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom1.png | Moment 1 for the TP data.<br />
File:combine_mom1.png | Moment 1 for 7m+12m data.<br />
File:M100_Feather_CO.mom1.png | Moment 1 for TP+7m+12m data.<br />
</gallery><br />
<br />
You can see that more extended emission is recovered by adding the TP data to the interferometric data.<br />
<br />
For quantitative comparison, we measure the total line fluxes of the various images.<br />
The task {{imstat}} can be used to do this.<br />
For example, for the subimage of the 7m+12m image,<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')<br />
</source><br />
<br />
yields the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '12:23:01.170, +15.47.08.994, I, 1.14733e+11Hz',<br />
'flux': array([ 269.63344004]),<br />
'max': array([ 0.65709084]),<br />
'maxpos': array([172, 253, 0, 49], dtype=int32),<br />
'maxposf': '12:22:55.212, +15.49.15.500, I, 1.14639e+11Hz',<br />
'mean': array([ 0.00097561]),<br />
'medabsdevmed': array([ 0.00850473]),<br />
'median': array([ -3.25056462e-05]),<br />
'min': array([-0.07497632]),<br />
'minpos': array([260, 251, 0, 26], dtype=int32),<br />
'minposf': '12:22:52.163, +15.49.14.499, I, 1.14683e+11Hz',<br />
'npts': array([ 11914560.]),<br />
'quartile': array([ 0.01701281]),<br />
'rms': array([ 0.01756589]),<br />
'sigma': array([ 0.01753878]),<br />
'sum': array([ 11623.92616449]),<br />
'sumsq': array([ 3676.36438921]),<br />
'trc': array([393, 431, 0, 69], dtype=int32),<br />
'trcf': '12:22:47.554, +15.50.44.492, I, 1.146e+11Hz'}<br />
</pre><br />
<br />
The 'flux' value in the result is the total flux in Jy, but the velocity channels are not taken into account.<br />
Since the width of the velocity channels is 5 km/s, the following command gives the integrated line flux in the unit of Jy km/s.<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 1348.16720019])<br />
</pre><br />
<br />
Similarly, the total line fluxes of the TP image (after multiplying the<br />
7m+12m primary beam response), feathered image, and feathered image after the<br />
primary-beam correction are<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100TP.CO.regrid.subim.depb')['flux']*5.0<br />
imstat('M100_Feather_CO.image')['flux']*5.0<br />
imstat('M100_Feather_CO.image.pbcor')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 2766.63524574])<br />
array([ 2766.63528397])<br />
array([ 3057.66449702])<br />
</pre><br />
<br />
We see the followings from these values:<br />
* The flux recovered by the 7m+12m observations is about a half of the total flux (1348/2767 = 0.487).<br />
* The feathering process preserves the flux of the TP data.<br />
* The flux of the primary-beam corrected feathered image is consistent with the values from the literature (2972 +/- 319 Jy km/s from the BIMA SONG; Helfer et al. 2003).<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_Combine_4.3&diff=16998M100 Band3 Combine 4.32015-05-27T20:28:16Z<p>Tsawada: /* Feathering the Total Power and 7m+12m Interferometric Images */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
= Overview =<br />
<br />
This guide describes how to combine the 7m and 12m interferometric data and then how to feather the resulting image with the total power TP image. All of the data for this SV project can be found at https://almascience.nrao.edu/alma-data/science-verification. The guide has been written for data reduced in CASA 4.3.0 or later and assumes that all calibration tables (Tsys and gain tables) have been applied to the visibility weights using calwt=True. If either of these is not the case for your data, '''do not follow this guide.''' <br />
<br />
In order to run this guide you will need to:<br />
<br />
* Either download the fully calibrated 7m data (i.e., M100_Band3_7m_CalibratedData.tgz) or download the uncalibrated 7m data and the relevant, standard calibration scripts available (here). An overview of the 7m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either download the fully calibrated 12m data (i.e. M100_Band3_12m_CalibratedData.tgz) or download the uncalibrated 12m data and the relevant, standard calibration scripts available (here). Note that this is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.''' An overview of the 12m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either run the [[M100_Band3_SingleDish_4.3]] guide to calibrate and image the Total Power data or download the final image (i.e. M100_TP_Image.tgz)<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
= Combine and Image the 7m+12m Interferometric Data =<br />
<br />
<br />
== Split off CO spectral windows (SPWs) ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_*m.ms.listobs')<br />
listobs('M100_Band3_12m_CalibratedData.ms',listfile='m100_12m.ms.listobs')<br />
listobs('M100_Band3_7m_CalibratedData.ms',listfile='m100_7m.ms.listobs')<br />
</source><br />
<br />
Running the task "listobs" provides the setups used in the observations at a glance. Below are the first target scans of the 12m and 7m observations and the spectral window tables as generated by listobs. The six 7m data sets were taken with two slightly different correlator setups (one with four SPWs and the other with two SPWs), so the concatenated data set has six total SPWs. <br />
<br />
<pre style="background-color: #fffacd;"><br />
12m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
10-Aug-2011/19:38:05.8 - 19:50:22.8 11 1 M100 1500 [0,1,2,3] [6.05, 6.05, 6.05, 6.05] [CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (4 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 3840 TOPO 113726.419 488.281 1875000.0 114663.6750 1 XX YY<br />
1 3840 TOPO 111851.419 488.281 1875000.0 112788.6750 2 XX YY<br />
2 3840 TOPO 103663.431 -488.281 1875000.0 102726.1750 3 XX YY<br />
3 3840 TOPO 101850.931 -488.281 1875000.0 100913.6750 4 XX YY<br />
<br />
7m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
17-Mar-2013/04:44:04.3 - 04:50:43.7 11 1 M100 261 [0,1,2,3] [10.1, 10.1, 10.1, 10.1] [OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (6 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
1 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
2 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
3 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
4 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 111798.250 488.281 1992187.5 112794.1000 1 XX YY<br />
5 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 113673.250 488.281 1992187.5 114669.1000 2 XX YY<br />
</pre><br />
<br />
<figure id="12m_mosaic.png"><br />
[[Image:12m_mosaic.png|300px|thumb|right|<caption>FOV of 12m mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="7m_mosaic.png"><br />
[[Image:7m_mosaic.png|300px|thumb|right|<caption>FOV of 7m mosaic.</caption>]]<br />
</figure><br />
<br />
Examination of the listobs files shows that the CO is in SPW='0' for the 12m data and in SPW='3,5' for the 7m data. There are two SPWs containing CO in the 7m data due to the slightly differing correlator setups.<br />
<br />
Also note that the integration time per visibility (average interval parameter in listobs) is different:<br />
6.05s for the 12m data and 10.1s for the 7m. This will be important to know later when we check the visibility weights. <br />
<br />
Next we split out the CO spectral windows.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_12m_CO.ms')<br />
split(vis='M100_Band3_12m_CalibratedData.ms',<br />
outputvis='m100_12m_CO.ms',spw='0',field='M100',<br />
datacolumn='data',keepflags=False)<br />
os.system('rm -rf m100_7m_CO.ms')<br />
split(vis='M100_Band3_7m_CalibratedData.ms',<br />
outputvis='m100_7m_CO.ms',spw='3,5',field='M100',<br />
datacolumn='data',keepflags=False)<br />
</source><br />
<br />
Also of interest is that the 12m data has 47 fields and the 7m has 23 fields (not shown in the excerpts above). The difference in number of pointings is because the 7m antennas have a FWHP (full width half power) primary beam diameter that is 12/7 times larger than the 12m antennas. '''One easy way to see how the mosaics compare is to install the AnalysisUtils package (see [[Analysis_Utilities]])'''. Then with AnalysisUtils you can make the following plots (look at the listobs to obtain the sourceid):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *m_mosaic.png')<br />
au.plotmosaic('m100_12m_CO.ms',sourceid='0',figfile='12m_mosaic.png')<br />
au.plotmosaic('m100_7m_CO.ms',sourceid='0',figfile='7m_mosaic.png')<br />
</source><br />
<br />
We see that the mosaics cover a common area but that the 7m mosaic is a bit larger. This means that the outer edges of the combined mosaic will be noisier than expected if they overlapped perfectly; this is just something to keep in mind. If you had the case where the mosaic coverages are dramatically different, it would be best to exclude the completely non-overlapping fields from the combination.<br />
<br />
NOTE: At this stage one would typically do continuum subtraction (if there is any). However we already know from the individual data reductions that the 3mm continuum emission is quite weak and does not significantly contribute to a 5km/s channel, so we will forgo the the continuum subtraction step. Examples of how to do this if you are so inclined are located in various other ALMA CASAguides.<br />
<br />
== Checking the weights and concatenating the data ==<br />
<br />
<figure id="7m_WT.png"><br />
[[File:12m_WT.png|200px|thumb|right|<caption> 12m weights.</caption>]]<br />
</figure><br />
<br />
<figure id="12m_WT.png"><br />
[[File:7m_WT.png|200px|thumb|right|<caption> 7m weights.</caption>]]<br />
</figure><br />
<br />
When combining data with disparate properties it is very important that the relative weights of each visibility be in the correct proportion to the other data according to the radiometer equation. Formally, the<br />
visibility weights should be proportional to 1/sigma<sup>2</sup> where sigma is the variance or rms noise of a given visibility.<br />
<br />
Assuming that the 7m and 12m antennas have similar apperture and quantization efficiencies (a reasonable assumption since they were designed this way), the rms noise in a single channel for a single visibility is:<br />
<br />
<math> <br />
\sigma_{ij}=\frac{2k}{A_{eff}} <br />
</math><br />
<math> <br />
\sqrt{\frac{T_{sys,i} T_{sys,j}}{\Delta\nu_{ch} t_{ij}}},<br />
</math><br />
<br />
where k is Boltzmann's constant, A<sub>eff</sub> is the effective antenna area, T<sub>sys,i</sub> is the system temperature for antenna i, &Delta;&nu;<sub>ch</sub> is the channel width, and t<sub>ij</sub> is the integration time per visibility.<br />
<br />
CASA initially scales the weights by 2&Delta;&nu;<sub>ch</sub>&Delta;t<sub>ij</sub>, and after the Tsys table applycal step of the calibration process, it further scales the weights by 1/[(Tsys(i) * Tsys(j)] as long as calwt=True. In the subsequent gain calibration table applycal step of the calibration, the weights are further scaled by a factor of [(gain(i))<sup>2</sup> * (gain(j))<sup>2</sup>]. The gains should change very little from antenna to antenna, so this scaling is effectively the average gain<sup>4</sup> (again, as long as calwt=True). In the calibration scripts for all executions of the 12m and 7m data, found (here), both applycal steps set calwt=True. To verify, we plot the weights of the 7m and 12m data and measure their ratio to be, on average, 7m/12m ~ 0.055/0.3 ~ 0.18. Note that in the plots the points are colored by SPW, so there is only one 12m CO SPW but there are two 7m CO SPWs, and that no averaging can be turned on when plotting the weights. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf 7m_WT.png 12m_WT.png')<br />
plotms(vis='m100_12m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0:200',<br />
coloraxis='spw',plotfile='12m_WT.png')<br />
#<br />
plotms(vis='m100_7m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~1:200',<br />
coloraxis='spw',plotfile='7m_WT.png')<br />
</source><br />
<br />
<figure id="combine_CO_WT.png"><br />
[[File:combine_CO_WT.png|200px|thumb|right|<caption> 7m and 12m weights after concatenation.</caption>]]<br />
</figure><br />
<br />
The two key things that are different between the 7m and 12m-array data are that the effective dish areas are different by (7/12)<sup>2</sup>, and the integration times are different by sqrt(10.1/6.05). Since dish area is in the numerator of the radiometer equation and integration time per visibility is in the denominator, and assuming the weight of an individual visibility is proportional to 1/sigma<sup>2</sup>, the ratio of the weights should be (7./12.)<sup>4</sup> x (10.1/6.05) = 0.19. This is very close to the value we measure for the ratio of the weights, particularly given that the 7m flux calibration relied on a source which changed substantially over the course of the six 7m-array observations. <br />
<br />
Now concatenate the two data sets and plot the concatenated weights to verify that they are as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Concat and scale weights<br />
os.system('rm -rf M100_combine_CO.ms')<br />
concat(vis=['m100_12m_CO.ms','m100_7m_CO.ms'],<br />
concatvis='M100_combine_CO.ms')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf combine_CO_WT.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~2:200',<br />
coloraxis='spw',plotfile='combine_CO_WT.png')<br />
</source><br />
<br />
Here, we create more instructive plots of the combined data to check that things are in order. (''Let each plot finish before cutting and pasting next plot. If plotms gui disappears, exit CASA and restart.'')<br />
<br />
<figure id="M100_combine_vel.png"><br />
[[File:M100_combine_vel.png|200px|thumb|right|<caption> Amplitude as a function of velocity.</caption>]]<br />
</figure><br />
<br />
To plot amplitude as a function of uv-distance, noting that the 7m data is noisier than the 12m data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_uvdist.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='uvdist',spw='', avgscan=True,<br />
avgchannel='5000', coloraxis='spw',plotfile='M100_combine_uvdist.png') <br />
</source><br />
<br />
A fairer comparison of these data is achieved by isolating the brightest line channels in individual 12m and 7m data sets (i.e., not the concatenated data sets) and comparing only those channels in amplitude vs. uv-distance. Here the agreement is better, as it is less dominated by the scatter among the several 7m executions.<br />
<br />
To plot the CO line as a function of velocity (this plot takes a while):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_vel.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='velocity',spw='', avgtime='1e8',avgscan=True,coloraxis='spw',avgchannel='5',<br />
transform=True,freqframe='LSRK',restfreq='115.271201800GHz', plotfile='M100_combine_vel.png')<br />
</source><br />
<br />
To see each spectral window independently in plotms, run the command again but remove the call to "plotfile" and add " iteraxis='spw' ".<br />
<br />
== Image Using An Automasking Technique ==<br />
<br />
The commands in this section perform an iterative automasking procedure down<br />
to a user specified threshold=stop*rms where stop is typically 2-3 using the imagemode='mosaic' mode of clean. This mode automatically calculates the correct convolution of the primary beam response of the mosaic when different antenna dish diameters are present. '''NOTE:''' even if these data had only been comprised of a single pointing of 7m and 12m-array data, the imagemode='mosaic' mode would be needed to correctly image data with different antenna sizes.<br />
<br />
The procedure outlined below takes some care to ensure that the generated masks (i) only have values of 0 or 1; (ii) are themselves masked at the minpb level. It also removes very small masked regions that are consistent with noise bumps using a function in scipy. A typical setting is to remove mask regions that are 1/2 the beam area in pixels. This is one technique under exploration for future pipeline use. <br />
<br />
The commands have been split into multiple sections to aid cut and paste. Wait until the current one is done before starting next section. '''If you stop CASA and restart you will need to cut and paste again from the Define Parameters section on down'''.<br />
<br />
For the long series of commands below it is important to include the '''beginning cpaste''' and '''ending --''' in your cut and paste.<br />
<br />
=== Define Parameters ===<br />
<br />
Note that the parameters used here are by design the same as those used to make the stand-alone 7m-array and 12m-array images. <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
<br />
### Initialize <br />
import scipy.ndimage <br />
<br />
### Define clean parameters<br />
vis='M100_combine_CO.ms'<br />
prename='M100_combine_cube'<br />
myimage=prename+'.image'<br />
myflux=prename+'.flux'<br />
mymask=prename+'.mask'<br />
myresidual=prename+'.residual'<br />
imsize=800<br />
cell='0.5arcsec'<br />
minpb=0.2<br />
restfreq='115.271201800GHz'<br />
outframe='LSRK'<br />
spw='0~2'<br />
width='5km/s'<br />
start='1400km/s'<br />
nchan=70<br />
robust=0.5<br />
phasecenter='J2000 12h22m54.9 +15d49m15'<br />
scales=[0]<br />
smallscalebias=0.6<br />
<br />
### Setup stopping criteria with multiplier for rms.<br />
stop=3. <br />
<br />
### Minimum size multiplier for beam area for removing very small mask regions. <br />
pixelmin=0.5 <br />
<br />
--<br />
</source><br />
<br />
=== Make Initial Dirty Image and Determine Synthesized Beam area===<br />
<br />
The dirty image is used to determine the initial peak flux density in the cube and the beam area is used to define the minimum size of masked regions in order to exclude noise bumps from the overall mask.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Make initial dirty image<br />
os.system('rm -rf '+prename+'.* ' +prename+'_*')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask='',<br />
niter=0,interactive=F)<br />
<br />
# Determine the beam area in pixels for later removal of very small mask regions<br />
major=imhead(imagename=myimage,mode='get',hdkey='beammajor')['value']<br />
minor=imhead(imagename=myimage,mode='get',hdkey='beamminor')['value']<br />
pixelsize=float(cell.split('arcsec')[0])<br />
beamarea=(major*minor*pi/(4*log(2)))/(pixelsize**2)<br />
print 'beamarea in pixels =', beamarea<br />
<br />
--<br />
</source><br />
<br />
=== Find properties of the dirty image ===<br />
<br />
For the long series of commands below it is important to include the beginning '''cpaste''' and ending '''--''' in your cut and paste.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Find the peak in the dirty cube.<br />
myimage=prename+'.image'<br />
bigstat=imstat(imagename=myimage)<br />
peak= bigstat['max'][0]<br />
print 'peak (Jy/beam) in cube = '+str(peak)<br />
### Sets threshold of first loop, try 2-4. Subsequent loops are set thresh/2.<br />
thresh = peak / 4.<br />
<br />
### If True: find the rms in two line-free channels; If False: Set rms by hand in else statement.<br />
if True: <br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2) <br />
else:<br />
rms=0.011<br />
<br />
<br />
print 'rms (Jy/beam) in a channel = '+str(rms)<br />
--<br />
</source><br />
<br />
=== Automasking Loop ===<br />
<br />
On a reasonably fast computer the following will take a couple of hours for this spectral mosaic... <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf ' + prename +'_threshmask*')<br />
os.system('rm -rf ' + prename +'_fullmask*')<br />
os.system('rm -rf ' + prename +'.image*')<br />
n=-1<br />
while (thresh >= stop*rms): <br />
n=n+1<br />
print 'clean threshold this loop is', thresh<br />
threshmask = prename+'_threshmask' +str(n)<br />
maskim = prename+'_fullmask' +str(n)<br />
immath(imagename = [myresidual],<br />
outfile = threshmask,<br />
expr = 'iif(IM0 > '+str(thresh) +',1.0,0.0)',<br />
mask=myflux+'>'+str(minpb))<br />
if (n==0):<br />
os.system('cp -r '+threshmask+' '+maskim+'.pb')<br />
print 'This is the first loop'<br />
else:<br />
makemask(mode='copy',inpimage=myimage,<br />
inpmask=[threshmask,mymask],<br />
output=maskim)<br />
imsubimage(imagename=maskim, mask=myflux+'>'+str(minpb),<br />
outfile=maskim+'.pb') <br />
print 'Combined mask ' +maskim+' generated.'<br />
<br />
# Remove small masks<br />
os.system('cp -r '+maskim+'.pb ' +maskim+'.pb.min')<br />
maskfile=maskim+'.pb.min'<br />
ia.open(maskfile)<br />
mask=ia.getchunk() <br />
labeled,j=scipy.ndimage.label(mask) <br />
myhistogram = scipy.ndimage.measurements.histogram(labeled,0,j+1,j+1)<br />
object_slices = scipy.ndimage.find_objects(labeled)<br />
threshold=beamarea*pixelmin<br />
for i in range(j):<br />
if myhistogram[i+1]<threshold:<br />
mask[object_slices[i]] = 0<br />
<br />
<br />
ia.putchunk(mask)<br />
ia.done()<br />
print 'Small masks removed and ' +maskim +'.pb.min generated.'<br />
<br />
os.system('rm -rf '+mymask+'')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask = maskim+'.pb.min',<br />
multiscale=scales,smallscalebias=smallscalebias,<br />
interactive = F,<br />
niter = 10000,<br />
threshold = str(thresh) +'Jy/beam')<br />
<br />
<br />
if thresh==stop*rms: break<br />
thresh = thresh/2.<br />
# Run a final time with stop*rms if more than a little above<br />
# stop*rms. Also make a back-up of next to last image<br />
if (thresh < stop*rms and thresh*2.>1.05*stop*rms):<br />
thresh=stop*rms <br />
os.system('cp -r '+myimage+' '+myimage+str(n))<br />
<br />
--<br />
</source><br />
<br />
=== Notes on the Automasking procedure ===<br />
<br />
This script is meant to be a possible stepping stone to optimal automasking -- it is by no means perfect and is certainly slower than optimal but feel free to try it with other datasets. Some notes below:<br />
<br />
In addition to the final prename.image (prename.flux etc) this script produces and keeps each iteration of the various mask files which will allow you to explore how the masking proceeded as the threshold for masking and cleaning was lowered. The ones denoted "prename. fullmask*.pb.min" are the ones used in the clean steps themselves. At the end of the process the final "prename. fullmask*.pb.min" will also be stored in the prename.mask. Once you've verified you are happy with the masking, you may want to remove the prename.threshmask* and prename.fullmask* files, as they can be large for large cubes. <br />
<br />
Additionally, before running the final loop with thresh=stop*rms the script copies the .image from the preceding clean to prename.image'n' where 'n' equals the loop number of the preceding step. So in this M100 example you will see a M100_combine_cube.image and a M100_combine_cube.image2 where .image is the final image and .image2 is the next to last image. This is done for convenience in the case that thresh=stop*rms is too deep such that clean diverges, you will still be left with the clean image from the preceding loop that you can further investigate to understand why clean diverged. If all goes well with the final loop, the prename.image'n' can also be deleted. Divergence at thresh=stop*rms is often a sign that the image is "dynamic range limited" in other words the rms in channels with bright emission is significantly worse than for a line-free channel.<br />
<br />
== Image Analysis for the 7m+12m Data ==<br />
<br />
=== Moment Maps for 7m+12m CO (1-0) Cube ===<br />
<br />
Start by examining the final image cube. Determine the start and stopping channels for the line emission -- this will be used in the "chans" parameter of immoments.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_combine_cube.image')<br />
</source><br />
<br />
Next determine the rms noise per channel and use that to exclude pixels from the moment images. All images are shown in the gallery at the end of the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
myimage='M100_combine_cube.image'<br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2)<br />
print 'rms in a channel = '+str(rms) <br />
</source><br />
<br />
Next make the moment maps. For the integrated intensity: moment 0, a 2 sigma cut often considerably improves the appearance of the image with little effect on the integrated intensity as long as emission free channels are excluded. For higher order moments it is necessary to exclude all low S/N data. Typically 5-6 sigma for the higher moments works well. We also apply further masking based on the .flux image because the edges of the combined mosaic are especially noisy because the 7m mosaic is somewhat larger than the 12m mosaic as described above (see Figures 1 & 2). <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom0')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [0],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',,<br />
includepix = [rms*2,100.],<br />
outfile = 'M100_combine_cube.image.mom0')<br />
<br />
os.system('rm -rf M100_combine_cube.image.mom1')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [1],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',<br />
includepix = [rms*5.5,100.],<br />
outfile = 'M100_combine_cube.image.mom1')<br />
--<br />
</source><br />
<br />
Now we can make some figures showing the moment maps (*note that this creates different looking files for me than the ones I have included here, which were made in the viewer -- is this true for others?*):<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom*.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.png')<br />
<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom1',<br />
'range': [1440,1695],'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]}, <br />
out='M100_combine_cube.image.mom1.png')<br />
--<br />
</source><br />
<br />
If you plan to use your moment 0 image to make measurements, it needs to be primary beam corrected first. First we need to subimage the .flux cube to extract a single plane that can be used to primary beam correct the moment 0 image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.flux.1ch')<br />
imsubimage(imagename='M100_combine_cube.flux',<br />
outfile='M100_combine_cube.flux.1ch',<br />
chans='35')<br />
</source><br />
<br />
Then primary beam correct the moment 0 image. This is the version that would be used for measurements, though the uncorrected one can be useful for figures. The difference is clear in the images seen below in the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor')<br />
immath(imagename=['M100_combine_cube.image.mom0', \<br />
'M100_combine_cube.flux.1ch'],<br />
expr='IM0/IM1',<br />
outfile='M100_combine_cube.image.mom0.pbcor')<br />
</source><br />
<br />
Have a look at the difference the primary beam correction makes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3},<br />
{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3}],<br />
zoom={'blc': [190,150],'trc': [650,610]})<br />
</source><br />
<br />
With the viewer open, you can flip back and forth between the images to compare them. Next, make a figure.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.pbcor.png')<br />
<br />
</source><br />
<br />
=== Comparison with 7m, 12m Moment Maps ===<br />
<br />
Below the moment maps from the 7m-only and the 12m-only data are shown for comparison. The moment maps were made using clean masks drawn by hand for comparison to the automasking technique; the two appear to be qualitatively similar. The range and scaling for the 12m-only figures are the same as that used for the 7m+12m figures for ease of comparison.<br />
<br />
As expected, the 7m+12m image shows considerably more extended emission than the 12m-only data and finer detail than the 7m-only data. For comparison, the 7m+12m synthesized beam is 3.80"x2.50", while the 12m-only beam is 3.46"x2.37" and the 7m-only beam is 12.72"x10.12".<br />
<br />
<gallery widths=300px heights=300px><br />
File:12m.png | Moment 0 for 12m data alone (no primary beam correction).<br />
File:7m_mom0.png | Moment 0 for 7m data alone (no primary beam correction).<br />
File:combined.png | Moment 0 for 12m+7m data (no primary beam correction).<br />
File:combine_pbcor.png | Moment 0 for 12m+7m data with primary beam correction.<br />
</gallery><br />
<br />
<gallery widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data alone.<br />
File:7m_mom1.png | Moment 1 for 7m data alone.<br />
File:combine_mom1.png | Moment 1 for 12m+7m data.<br />
</gallery><br />
<br />
=== Convert 7m+12m Images to Fits Format ===<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf *.fits')<br />
exportfits(imagename='M100_combine_cube.image',fitsimage='M100_combine_cube.image.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.flux',fitsimage='M100_combine_cube.flux.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0',fitsimage='M100_combine_cube.image.mom0.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0.pbcor',fitsimage='M100_combine_cube.image.mom0.pbcor.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom1',fitsimage='M100_combine_cube.image.mom1.fits')<br />
<br />
--<br />
</source><br />
<br />
= Feathering the Total Power and 7m+12m Interferometric Images =<br />
<br />
In this section the interferometric (7m+12m) image produced above is combined with the Total Power (single dish) image.<br />
The "feather" algorithm is employed, in which the two images are combined in the spatial frequency domain, i.e.,<br />
the low and high spatial frequency components are predominantly taken from the TP and interferometric images, respectively.<br />
<br />
== Prepare Images for Feathering ==<br />
<br />
Regrid the TP image to match the shape of the 7m+12m image using the task {{imregrid}}.<br />
The TP image is resampled onto the same grid as that of the "template" 7m+12m image along the first two axes of the cube (i.e., RA and Dec; it is not necessary to regrid the velocity axis, since the axis is already common to the both images).<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid')<br />
imregrid(imagename='M100TP.CO.cube.bl.image',<br />
template='M100_combined_CO.image',<br />
axes=[0, 1],<br />
output='M100TP.CO.regrid')<br />
</source><br />
<br />
Make subimages of the (regridded) TP and 7m+12m images with the task {{imsubimage}}, excluding regions masked by the clean minpb=0.2 and noisy edge pixels in the TP image. The Viewer ({{viewer}}) can be used to determine a good joint region.<br />
Here we use (x, y) = (219, 148) and (612, 579) [pixels] as the bottom left and top right corners.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.image.subim')<br />
imsubimage(imagename='M100_combined_CO.image',<br />
outfile='M100_combined_CO.image.subim',<br />
box='219,148,612,579')<br />
os.system('rm -rf M100TP.CO.regrid.subim')<br />
imsubimage(imagename='M100TP.CO.regrid',<br />
outfile='M100TP.CO.regrid.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
While the 7m+12m image (before the primary-beam correction) has decreased primary beam response in the outskirts of the mosaic field, the TP image does not have such nonuniformity.<br />
In order to feather the TP and 7m+12m images together, they should have the common response on the sky.<br />
Hence we need to multiply the TP image by the 7m+12m primary beam response before proceeding.<br />
To do this, create the subimage of the 7m+12m response,<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
then multiply it and the TP image using the task {{immath}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim.depb')<br />
immath(imagename=['M100TP.CO.regrid.subim',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0*IM1',<br />
outfile='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
As a result, the feathered image will have the same response as that of the 7m+12m image.<br />
The primary-beam correction can be done after the feathering process (see below).<br />
<br />
== Feather TP Cube with 7m+12m Cube ==<br />
<br />
Now we are ready to execute the {{feather}} task to combine the TP and 7m+12m images.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image')<br />
feather(imagename='M100_Feather_CO.image',<br />
highres='M100_combined_CO.image.subim',<br />
lowres='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
The task produces the combined image in the following way:<br />
* Convert the input images specified by the "highres" and "lowres" parameters onto the spatial frequency plane.<br />
* Combine them on the spatial frequency plane. The weighting is determined by the beam sizes/shapes of the input images.<br />
* Convert it back to the image plane.<br />
Please refer to the online help and documents for the details.<br />
<br />
== Make Moment Maps of TP and Feathered Images ==<br />
<br />
We will use the same technique as the [[#Moment_Maps_for_7m.2B12m_CO_.281-0.29_Cube|7m+12m image analysis above]] to make moment maps.<br />
<br />
First, make moment maps for the (regridded) TP image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100TP.CO.regrid.subim'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom0')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100TP.CO.regrid.subim.mom0')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom1')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100TP.CO.regrid.subim.mom1')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom*.png')<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom0',<br />
'range': [0., 1080.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100TP.CO.regrid.subim.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100TP.CO.regrid.subim.mom1.png')<br />
</source><br />
<br />
Then make moment maps for the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100_Feather_CO.image'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100_Feather_CO.image.mom0')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom1')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100_Feather_CO.image.mom1')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom*.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100_Feather_CO.image.mom1.png')<br />
</source><br />
<br />
=== Correct the Primary Beam Response ===<br />
<br />
Apply the primary beam response to the feathered image using the task {{immath}},<br />
<br />
<source lang="python"><br />
#In CASA<br />
immath(imagename=['M100_Feather_CO.image',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.pbcor')<br />
</source><br />
<br />
and also to the moment 0 image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.1ch.subim')<br />
imsubimage(imagename='M100_combined_CO.flux.subim',<br />
outfile='M100_combined_CO.flux.1ch.subim',<br />
chans='35')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor')<br />
immath(imagename=['M100_Feather_CO.image.mom0',<br />
'M100_combined_CO.flux.1ch.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.mom0.pbcor')<br />
</source><br />
<br />
Save the primary-beam corrected moment 0 image to a PNG file.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0.pbcor',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.pbcor.png')<br />
</source><br />
<br />
=== Compare the Various Images ===<br />
<br />
Now we compare all the images:<br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_pbcor.png | Primary beam corrected moment 0 for the 12m data.<br />
File:7m_pbcor.png | Primary beam corrected moment 0 for the 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom0.png | Moment 0 for the TP data.<br />
File:combine_pbcor.png | Primary beam corrected moment 0 for 7m+12m data.<br />
File:M100_Feather_CO.mom0.pbcor.png | Primary beam corrected moment 0 for TP+7m+12m data.<br />
</gallery><br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data.<br />
File:7m_mom1.png | Moment 1 for 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom1.png | Moment 1 for the TP data.<br />
File:combine_mom1.png | Moment 1 for 7m+12m data.<br />
File:M100_Feather_CO.mom1.png | Moment 1 for TP+7m+12m data.<br />
</gallery><br />
<br />
You can see that more extended emission is recovered by adding the TP data to the interferometric data.<br />
<br />
For quantitative comparison, we measure the total line fluxes of the various images.<br />
The task {{imstat}} can be used to do this.<br />
For example, for the subimage of the 7m+12m image,<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')<br />
</source><br />
<br />
yields the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '12:23:01.170, +15.47.08.994, I, 1.14733e+11Hz',<br />
'flux': array([ 269.63344004]),<br />
'max': array([ 0.65709084]),<br />
'maxpos': array([172, 253, 0, 49], dtype=int32),<br />
'maxposf': '12:22:55.212, +15.49.15.500, I, 1.14639e+11Hz',<br />
'mean': array([ 0.00097561]),<br />
'medabsdevmed': array([ 0.00850473]),<br />
'median': array([ -3.25056462e-05]),<br />
'min': array([-0.07497632]),<br />
'minpos': array([260, 251, 0, 26], dtype=int32),<br />
'minposf': '12:22:52.163, +15.49.14.499, I, 1.14683e+11Hz',<br />
'npts': array([ 11914560.]),<br />
'quartile': array([ 0.01701281]),<br />
'rms': array([ 0.01756589]),<br />
'sigma': array([ 0.01753878]),<br />
'sum': array([ 11623.92616449]),<br />
'sumsq': array([ 3676.36438921]),<br />
'trc': array([393, 431, 0, 69], dtype=int32),<br />
'trcf': '12:22:47.554, +15.50.44.492, I, 1.146e+11Hz'}<br />
</pre><br />
<br />
The 'flux' value in the result is the total flux in Jy, but the velocity channels are not taken into account.<br />
Since the width of the velocity channels is 5 km/s, the following command gives the integrated line flux in the unit of Jy km/s.<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 1348.16720019])<br />
</pre><br />
<br />
Similarly, the total line fluxes of the TP image (after multiplying the<br />
7m+12m primary beam response), feathered image, and feathered image after the<br />
primary-beam correction are<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100TP.CO.regrid.subim.depb')['flux']*5.0<br />
imstat('M100_Feather_CO.image')['flux']*5.0<br />
imstat('M100_Feather_CO.image.pbcor')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 2766.63524574])<br />
array([ 2766.63528397])<br />
array([ 3057.66449702])<br />
</pre><br />
<br />
We see the followings from these values:<br />
* The flux recovered by the 7m+12m observations is about a half of the total flux (1348/2767 = 0.487).<br />
* The feathering process preserves the flux of the TP data.<br />
* The flux of the primary-beam corrected feathered image is consistent with the values from the literature (2972 +/- 319 Jy km/s from the BIMA SONG; Helfer et al. 2003).<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3&diff=16995M100 Band32015-05-26T22:24:45Z<p>Tsawada: /* Morita array (ACA) 7-m Data */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
<br />
M100 Introduction Page.<br />
<br />
== Science Target Overview ==<br />
<br />
M100 (NGC 4321; RA 12h 22m 54.8s, Dec +15 49' 19") is a nearby (~16 Mpc) 'grand-design' barred spiral galaxy in the Virgo cluster. It has long spiral arms dominating its optical disk and an abundance of molecular gas in its center. It has a relatively face-on inclination of ~30 degrees.<br />
<br />
<figure id="M100_NASA.jpg"><br />
[[Image:M100_NASA.jpg|300px|thumb|right|<caption>M100 as seen in the infrared by Spitzer.</caption>]]<br />
</figure><br />
<br />
In the 1990s, M100 was mapped in CO (1-0) at an angular resolution of 6" using the Berkeley-Illinois-Maryland Association (BIMA) millimeter interferometer as part of the BIMA SONG survey (Regan et al. 2001; Helfer et al. 2003; Sheth et al. 2002). Using the Nobeyama mm-wave Array (NMA), the central 1' was mapped by Sakamoto et al. (1995, 1999) at 2.5" resolution. Its nucleus has also been mapped in CO using the IRAM interferometer (Garcia-Burillo et al. 1998). In this CASAguide, CO (1-0) emission is mapped on several different angular scales, corresponding to molecular gas structures with different physical size scales, and combined into a single image.<br />
<br />
== ALMA Data Overview ==<br />
<br />
=== 12-m Data ===<br />
<br />
ALMA Science Verification data at Band 3 was taken for M100 with the ALMA 12-m array on 10 August and 10 September, 2011. Note that the calibration presented in this Guide is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.'''<br />
<br />
The observations consisted of a 47 pointing mosaic centered at RA=12:22:54.6, Dec=+15:48:56.5 and used a spectral setup with four FDM (frequency domain mode) windows with 3840 channels each. The native channel width is 488.281 kHz, or 1.27 km/s, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz in ALMA Band 3. There are three 12m datasets, comprising a total of 124.3 minutes on source. The integration interval for each visibility is 6.05 seconds. <br />
<br />
The names of the three datasets are as follows:<br />
<br />
*uid___A002_X273b43_X146<br />
*uid___A002_X2a5c2f_X220<br />
*uid___A002_X2a5c2f_X54<br />
<br />
In these observations, Titan is used at the amplitude calibrator, 3C273 is used as the bandpass calibrator, and J1224+213 is used as the gain calibrator. In contrast to the first calibration presented for this data, all calibration is done in CASA 4.3 and the gain calibration tables are applied to the data and the visibility weights in the final applycal step (with calwt=T). With these changes, each visibility is weighted appropriately for the final data combination. <br />
<br />
=== Morita array (ACA) 7-m Data ===<br />
<br />
ALMA Science Verification data at Band 3 was taken for M100 with the ACA on 17-18 March, 14 April, and 11 May, 2013. The observations consisted of a 23 pointing mosaic centered at RA=12:22:54.3, Dec=+15:48:51.4 and used a spectral setup with either two or four spectral windows with 4080 channels each. The native channel width is 488.281 kHz, or 1.27 km/s, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz in ALMA Band 3; this setup mirrors the 12m observations. There are six datasets, comprising a total of 188.4 minutes on source. The integration interval for each visibility is 10.1 seconds.<br />
<br />
The names of the six datasets are as follows:<br />
<br />
*uid___A002_X5e971a_X124<br />
*uid___A002_X5e971a_X2e7<br />
*uid___A002_X5e9ff1_X3f3<br />
*uid___A002_X5e9ff1_X5b3<br />
*uid___A002_X60b415_X44<br />
*uid___A002_X62f759_X4eb<br />
<br />
In these observations, 3C273 is used as the amplitude and bandpass calibrator, and J1215+1654 is used as the gain calibrator. For the first five executions, the flux calibration is set using au.getALMAFluxForMS, which checks the ALMA measurements of calibrators to define the appropriate flux for a calibrator as a function of frequency and time of observation. For the final dataset (_X4eb), the flux of 3C273 was observed to change rapidly by both ALMA and CARMA, which is not reflected in the observations in the calibrator database, and so a best estimate has been made. In the 7m datasets, careful flagging of the Tsys tables was necessary in several cases, and the antenna CM01 had to be removed from almost all observations as it was not locked. Standard calibration scripts are used in the calibration of this data, and all extra flagging commands can be found within those files. Finally, all calibration is done using CASA 4.3, and the gain calibration tables are applied to the data and the visibility weights in the final applycal step (with calwt=T). With these changes, each visibility is weighted appropriately for the final data combination. <br />
<br />
Note that in the 7m data, there is a weak continuum detection, but it is too weak to contaminate the line emission (the peak of the continuum detection is well less than the rms in a single line channel); the continuum is not even detected in the 12m data. Therefore in the combined data, no continuum subtraction is performed.<br />
<br />
=== Single-Dish Data ===<br />
<br />
ALMA Science Verification Single-Dish data at Band 3 was taken for M100 on 1, 5, 7, and 17 July, 2014 with the Total-Power array which consisted of 2 or 3 12-m antennas and the ACA correlator.<br />
The rectangular area of 202" x 226" (RA x Dec) centered at RA=12:22:54.36, Dec=+15:48:50.6 was mapped using the on-the-fly technique.<br />
The frequency setup for the single dish observations mirrors that of the interferometer in that four 2-GHz-wide spectral windows are used, each having 4080 channels. The native channel width is set to 488.281 kHz, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz.<br />
<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day). The integration interval for each visibility is 0.144 second for the amplitude calibrator and 1.008 seconds for the science datasets. The total time on source (M100) was 172.4 minutes.<br />
<br />
Amplitude Calibrator:<br />
*uid___A002_X85c183_X895 DA61, PM03, PM04<br />
*uid___A002_X8602fa_Xc3 PM02, PM03, PM04<br />
*uid___A002_X864236_Xe1 PM03, PM04<br />
*uid___A002_X86fcfa_X3ae DV10, PM03, PM04<br />
Science:<br />
*uid___A002_X85c183_X36f DA61, PM03, PM04<br />
*uid___A002_X85c183_X60b DA61, PM03, PM04<br />
*uid___A002_X8602fa_X2ab PM02, PM03, PM04<br />
*uid___A002_X8602fa_X577 PM02, PM03, PM04<br />
*uid___A002_X864236_X2d4 PM03, PM04<br />
*uid___A002_X864236_X693 PM03, PM04<br />
*uid___A002_X86fcfa_Xd9 DV10, PM03, PM04<br />
*uid___A002_X86fcfa_X664 DV10, PM03, PM04<br />
*uid___A002_X86fcfa_X96c DV10, PM03, PM04<br />
<br />
=== Acknowledgements and Data Usage ===<br />
<br />
'''Using the data for publication:''' The following statement should be included in the acknowledgment of papers using the datasets listed above: “This paper makes use of the following ALMA data: <br />
ADS/JAO.ALMA#2011.0.00004.SV . ALMA is a partnership of ESO (representing <br />
its member states), NSF (USA) and NINS (Japan), together with NRC <br />
(Canada) and NSC and ASIAA (Taiwan), in cooperation with the Republic of <br />
Chile. The Joint ALMA Observatory is operated by ESO, AUI/NRAO and NAOJ."<br />
<br />
We thank the following people for suggesting M100 for ALMA Science Verification: Preben Grosbol and Catherine Vlahakis.<br />
<br />
== Obtaining the Data ==<br />
<br />
To download all the data, follow one of the next links:<br />
<br />
[https://almascience.nrao.edu/almadata/sciver/IRAS16293B9 North America]<br />
<br />
[http://almascience.eso.org/almadata/sciver/IRAS16293B9 Europe]<br />
<br />
[http://almascience.nao.ac.jp/almadata/sciver/IRAS16293B9 East Asia]<br />
<br />
== M100 Data Combination Tutorial ==<br />
<br />
==How to Use A CASA Guide==<br />
<br />
For tips on using CASA and ways CASA can be run, see [http://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Calibration_IRC%2B10216#How_to_Use_This_casaguide EVLA_Spectral_Line_Calibration_IRC+10216#How_to_Use_This_casaguide] page.<br />
<br />
'''To learn how to extract executable Python scripts from the tutorial, see''' [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Extracting_scripts_from_these_tutorials].<br />
<br />
Within the guides:<br />
<source lang="python"><br />
# In CASA<br />
Regions of this color are CASA commands (or definitions) that need to be cut and <br />
pasted in sequence. Wait until one command is finished before pasting another. <br />
Tabs matter in python, make sure that commands that span more than one line and <br />
"for" loops keep their spacing. Sometimes (especially "for" loops) you may need to <br />
explicitly hit enter twice to get the command going.<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Information in this color shows excerpts from the CASA Logger output<br />
</pre><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
This color shows you background information about the data or other types of reference material<br />
</pre></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3&diff=16994M100 Band32015-05-26T22:23:35Z<p>Tsawada: /* Single-Dish Data */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
<br />
M100 Introduction Page.<br />
<br />
== Science Target Overview ==<br />
<br />
M100 (NGC 4321; RA 12h 22m 54.8s, Dec +15 49' 19") is a nearby (~16 Mpc) 'grand-design' barred spiral galaxy in the Virgo cluster. It has long spiral arms dominating its optical disk and an abundance of molecular gas in its center. It has a relatively face-on inclination of ~30 degrees.<br />
<br />
<figure id="M100_NASA.jpg"><br />
[[Image:M100_NASA.jpg|300px|thumb|right|<caption>M100 as seen in the infrared by Spitzer.</caption>]]<br />
</figure><br />
<br />
In the 1990s, M100 was mapped in CO (1-0) at an angular resolution of 6" using the Berkeley-Illinois-Maryland Association (BIMA) millimeter interferometer as part of the BIMA SONG survey (Regan et al. 2001; Helfer et al. 2003; Sheth et al. 2002). Using the Nobeyama mm-wave Array (NMA), the central 1' was mapped by Sakamoto et al. (1995, 1999) at 2.5" resolution. Its nucleus has also been mapped in CO using the IRAM interferometer (Garcia-Burillo et al. 1998). In this CASAguide, CO (1-0) emission is mapped on several different angular scales, corresponding to molecular gas structures with different physical size scales, and combined into a single image.<br />
<br />
== ALMA Data Overview ==<br />
<br />
=== 12-m Data ===<br />
<br />
ALMA Science Verification data at Band 3 was taken for M100 with the ALMA 12-m array on 10 August and 10 September, 2011. Note that the calibration presented in this Guide is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.'''<br />
<br />
The observations consisted of a 47 pointing mosaic centered at RA=12:22:54.6, Dec=+15:48:56.5 and used a spectral setup with four FDM (frequency domain mode) windows with 3840 channels each. The native channel width is 488.281 kHz, or 1.27 km/s, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz in ALMA Band 3. There are three 12m datasets, comprising a total of 124.3 minutes on source. The integration interval for each visibility is 6.05 seconds. <br />
<br />
The names of the three datasets are as follows:<br />
<br />
*uid___A002_X273b43_X146<br />
*uid___A002_X2a5c2f_X220<br />
*uid___A002_X2a5c2f_X54<br />
<br />
In these observations, Titan is used at the amplitude calibrator, 3C273 is used as the bandpass calibrator, and J1224+213 is used as the gain calibrator. In contrast to the first calibration presented for this data, all calibration is done in CASA 4.3 and the gain calibration tables are applied to the data and the visibility weights in the final applycal step (with calwt=T). With these changes, each visibility is weighted appropriately for the final data combination. <br />
<br />
=== Morita array (ACA) 7-m Data ===<br />
<br />
ALMA Science Verification data at Band 3 was taken for M100 with the ACA on 17-18 March, 14 April, and 11 May, 2013. The observations consisted of a 23 pointing mosaic centered at RA=12:22:54.3, Dec=+15:48:51.4 and used a spectral setup with either two or four FDM (frequency domain mode) windows with 4080 channels each. The native channel width is 488.281 kHz, or 1.27 km/s, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz in ALMA Band 3; this setup mirrors the 12m observations. There are six datasets, comprising a total of 188.4 minutes on source. The integration interval for each visibility is 10.1 seconds.<br />
<br />
The names of the six datasets are as follows:<br />
<br />
*uid___A002_X5e971a_X124<br />
*uid___A002_X5e971a_X2e7<br />
*uid___A002_X5e9ff1_X3f3<br />
*uid___A002_X5e9ff1_X5b3<br />
*uid___A002_X60b415_X44<br />
*uid___A002_X62f759_X4eb<br />
<br />
In these observations, 3C273 is used as the amplitude and bandpass calibrator, and J1215+1654 is used as the gain calibrator. For the first five executions, the flux calibration is set using au.getALMAFluxForMS, which checks the ALMA measurements of calibrators to define the appropriate flux for a calibrator as a function of frequency and time of observation. For the final dataset (_X4eb), the flux of 3C273 was observed to change rapidly by both ALMA and CARMA, which is not reflected in the observations in the calibrator database, and so a best estimate has been made. In the 7m datasets, careful flagging of the Tsys tables was necessary in several cases, and the antenna CM01 had to be removed from almost all observations as it was not locked. Standard calibration scripts are used in the calibration of this data, and all extra flagging commands can be found within those files. Finally, all calibration is done using CASA 4.3, and the gain calibration tables are applied to the data and the visibility weights in the final applycal step (with calwt=T). With these changes, each visibility is weighted appropriately for the final data combination. <br />
<br />
Note that in the 7m data, there is a weak continuum detection, but it is too weak to contaminate the line emission (the peak of the continuum detection is well less than the rms in a single line channel); the continuum is not even detected in the 12m data. Therefore in the combined data, no continuum subtraction is performed.<br />
<br />
=== Single-Dish Data ===<br />
<br />
ALMA Science Verification Single-Dish data at Band 3 was taken for M100 on 1, 5, 7, and 17 July, 2014 with the Total-Power array which consisted of 2 or 3 12-m antennas and the ACA correlator.<br />
The rectangular area of 202" x 226" (RA x Dec) centered at RA=12:22:54.36, Dec=+15:48:50.6 was mapped using the on-the-fly technique.<br />
The frequency setup for the single dish observations mirrors that of the interferometer in that four 2-GHz-wide spectral windows are used, each having 4080 channels. The native channel width is set to 488.281 kHz, and one of the windows is centered at the CO (1-0) line with a rest frequency of 115.271 GHz.<br />
<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day). The integration interval for each visibility is 0.144 second for the amplitude calibrator and 1.008 seconds for the science datasets. The total time on source (M100) was 172.4 minutes.<br />
<br />
Amplitude Calibrator:<br />
*uid___A002_X85c183_X895 DA61, PM03, PM04<br />
*uid___A002_X8602fa_Xc3 PM02, PM03, PM04<br />
*uid___A002_X864236_Xe1 PM03, PM04<br />
*uid___A002_X86fcfa_X3ae DV10, PM03, PM04<br />
Science:<br />
*uid___A002_X85c183_X36f DA61, PM03, PM04<br />
*uid___A002_X85c183_X60b DA61, PM03, PM04<br />
*uid___A002_X8602fa_X2ab PM02, PM03, PM04<br />
*uid___A002_X8602fa_X577 PM02, PM03, PM04<br />
*uid___A002_X864236_X2d4 PM03, PM04<br />
*uid___A002_X864236_X693 PM03, PM04<br />
*uid___A002_X86fcfa_Xd9 DV10, PM03, PM04<br />
*uid___A002_X86fcfa_X664 DV10, PM03, PM04<br />
*uid___A002_X86fcfa_X96c DV10, PM03, PM04<br />
<br />
=== Acknowledgements and Data Usage ===<br />
<br />
'''Using the data for publication:''' The following statement should be included in the acknowledgment of papers using the datasets listed above: “This paper makes use of the following ALMA data: <br />
ADS/JAO.ALMA#2011.0.00004.SV . ALMA is a partnership of ESO (representing <br />
its member states), NSF (USA) and NINS (Japan), together with NRC <br />
(Canada) and NSC and ASIAA (Taiwan), in cooperation with the Republic of <br />
Chile. The Joint ALMA Observatory is operated by ESO, AUI/NRAO and NAOJ."<br />
<br />
We thank the following people for suggesting M100 for ALMA Science Verification: Preben Grosbol and Catherine Vlahakis.<br />
<br />
== Obtaining the Data ==<br />
<br />
To download all the data, follow one of the next links:<br />
<br />
[https://almascience.nrao.edu/almadata/sciver/IRAS16293B9 North America]<br />
<br />
[http://almascience.eso.org/almadata/sciver/IRAS16293B9 Europe]<br />
<br />
[http://almascience.nao.ac.jp/almadata/sciver/IRAS16293B9 East Asia]<br />
<br />
== M100 Data Combination Tutorial ==<br />
<br />
==How to Use A CASA Guide==<br />
<br />
For tips on using CASA and ways CASA can be run, see [http://casaguides.nrao.edu/index.php?title=EVLA_Spectral_Line_Calibration_IRC%2B10216#How_to_Use_This_casaguide EVLA_Spectral_Line_Calibration_IRC+10216#How_to_Use_This_casaguide] page.<br />
<br />
'''To learn how to extract executable Python scripts from the tutorial, see''' [http://casaguides.nrao.edu/index.php?title=Extracting_scripts_from_these_tutorials Extracting_scripts_from_these_tutorials].<br />
<br />
Within the guides:<br />
<source lang="python"><br />
# In CASA<br />
Regions of this color are CASA commands (or definitions) that need to be cut and <br />
pasted in sequence. Wait until one command is finished before pasting another. <br />
Tabs matter in python, make sure that commands that span more than one line and <br />
"for" loops keep their spacing. Sometimes (especially "for" loops) you may need to <br />
explicitly hit enter twice to get the command going.<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
Information in this color shows excerpts from the CASA Logger output<br />
</pre><br />
<br />
<pre style="background-color: #E0FFFF;"><br />
This color shows you background information about the data or other types of reference material<br />
</pre></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_Combine_4.3&diff=16993M100 Band3 Combine 4.32015-05-26T16:47:00Z<p>Tsawada: /* Feathering the Total Power and 7m+12m Interferometric Images */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
= Overview =<br />
<br />
This guide describes how to combine the 7m and 12m interferometric data and then how to feather the resulting image with the total power TP image. All of the data for this SV project can be found at https://almascience.nrao.edu/alma-data/science-verification. The guide has been written for data reduced in CASA 4.3.0 or later and assumes that all calibration tables (Tsys and gain tables) have been applied to the visibility weights using calwt=True. If either of these is not the case for your data, '''do not follow this guide.''' <br />
<br />
In order to run this guide you will need to:<br />
<br />
* Either download the fully calibrated 7m data (i.e., M100_Band3_7m_CalibratedData.tgz) or download the uncalibrated 7m data and the relevant, standard calibration scripts available (here). An overview of the 7m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either download the fully calibrated 12m data (i.e. M100_Band3_12m_CalibratedData.tgz) or download the uncalibrated 12m data and the relevant, standard calibration scripts available (here). Note that this is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.''' An overview of the 12m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either run the [[M100_Band3_SingleDish_4.3]] guide to calibrate and image the Total Power data or download the final image (i.e. M100_TP_Image.tgz)<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
= Combine and Image the 7m+12m Interferometric Data =<br />
<br />
<br />
== Split off CO spectral windows (SPWs) ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_*m.ms.listobs')<br />
listobs('M100_Band3_12m_CalibratedData.ms',listfile='m100_12m.ms.listobs')<br />
listobs('M100_Band3_7m_CalibratedData.ms',listfile='m100_7m.ms.listobs')<br />
</source><br />
<br />
Running the task "listobs" provides the setups used in the observations at a glance. Below are the first target scans of the 12m and 7m observations and the spectral window tables as generated by listobs. The six 7m data sets were taken with two slightly different correlator setups (one with four SPWs and the other with two SPWs), so the concatenated data set has six total SPWs. <br />
<br />
<pre style="background-color: #fffacd;"><br />
12m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
10-Aug-2011/19:38:05.8 - 19:50:22.8 11 1 M100 1500 [0,1,2,3] [6.05, 6.05, 6.05, 6.05] [CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (4 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 3840 TOPO 113726.419 488.281 1875000.0 114663.6750 1 XX YY<br />
1 3840 TOPO 111851.419 488.281 1875000.0 112788.6750 2 XX YY<br />
2 3840 TOPO 103663.431 -488.281 1875000.0 102726.1750 3 XX YY<br />
3 3840 TOPO 101850.931 -488.281 1875000.0 100913.6750 4 XX YY<br />
<br />
7m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
17-Mar-2013/04:44:04.3 - 04:50:43.7 11 1 M100 261 [0,1,2,3] [10.1, 10.1, 10.1, 10.1] [OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (6 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
1 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
2 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
3 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
4 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 111798.250 488.281 1992187.5 112794.1000 1 XX YY<br />
5 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 113673.250 488.281 1992187.5 114669.1000 2 XX YY<br />
</pre><br />
<br />
<figure id="12m_mosaic.png"><br />
[[Image:12m_mosaic.png|300px|thumb|right|<caption>FOV of 12m mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="7m_mosaic.png"><br />
[[Image:7m_mosaic.png|300px|thumb|right|<caption>FOV of 7m mosaic.</caption>]]<br />
</figure><br />
<br />
Examination of the listobs files shows that the CO is in SPW='0' for the 12m data and in SPW='3,5' for the 7m data. There are two SPWs containing CO in the 7m data due to the slightly differing correlator setups.<br />
<br />
Also note that the integration time per visibility (average interval parameter in listobs) is different:<br />
6.05s for the 12m data and 10.1s for the 7m. This will be important to know later when we check the visibility weights. <br />
<br />
Next we split out the CO spectral windows.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_12m_CO.ms')<br />
split(vis='M100_Band3_12m_CalibratedData.ms',<br />
outputvis='m100_12m_CO.ms',spw='0',field='M100',<br />
datacolumn='data',keepflags=False)<br />
os.system('rm -rf m100_7m_CO.ms')<br />
split(vis='M100_Band3_7m_CalibratedData.ms',<br />
outputvis='m100_7m_CO.ms',spw='3,5',field='M100',<br />
datacolumn='data',keepflags=False)<br />
</source><br />
<br />
Also of interest is that the 12m data has 47 fields and the 7m has 23 fields (not shown in the excerpts above). The difference in number of pointings is because the 7m antennas have a FWHP (full width half power) primary beam diameter that is 12/7 times larger than the 12m antennas. '''One easy way to see how the mosaics compare is to install the AnalysisUtils package (see [[Analysis_Utilities]])'''. Then with AnalysisUtils you can make the following plots (look at the listobs to obtain the sourceid):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *m_mosaic.png')<br />
au.plotmosaic('m100_12m_CO.ms',sourceid='0',figfile='12m_mosaic.png')<br />
au.plotmosaic('m100_7m_CO.ms',sourceid='0',figfile='7m_mosaic.png')<br />
</source><br />
<br />
We see that the mosaics cover a common area but that the 7m mosaic is a bit larger. This means that the outer edges of the combined mosaic will be noisier than expected if they overlapped perfectly; this is just something to keep in mind. If you had the case where the mosaic coverages are dramatically different, it would be best to exclude the completely non-overlapping fields from the combination.<br />
<br />
NOTE: At this stage one would typically do continuum subtraction (if there is any). However we already know from the individual data reductions that the 3mm continuum emission is quite weak and does not significantly contribute to a 5km/s channel, so we will forgo the the continuum subtraction step. Examples of how to do this if you are so inclined are located in various other ALMA CASAguides.<br />
<br />
== Checking the weights and concatenating the data ==<br />
<br />
<figure id="7m_WT.png"><br />
[[File:12m_WT.png|200px|thumb|right|<caption> 12m weights.</caption>]]<br />
</figure><br />
<br />
<figure id="12m_WT.png"><br />
[[File:7m_WT.png|200px|thumb|right|<caption> 7m weights.</caption>]]<br />
</figure><br />
<br />
When combining data with disparate properties it is very important that the relative weights of each visibility be in the correct proportion to the other data according to the radiometer equation. Formally, the<br />
visibility weights should be proportional to 1/sigma<sup>2</sup> where sigma is the variance or rms noise of a given visibility.<br />
<br />
Assuming that the 7m and 12m antennas have similar apperture and quantization efficiencies (a reasonable assumption since they were designed this way), the rms noise in a single channel for a single visibility is:<br />
<br />
<math> <br />
\sigma_{ij}=\frac{2k}{A_{eff}} <br />
</math><br />
<math> <br />
\sqrt{\frac{T_{sys,i} T_{sys,j}}{\Delta\nu_{ch} t_{ij}}},<br />
</math><br />
<br />
where k is Boltzmann's constant, A<sub>eff</sub> is the effective antenna area, T<sub>sys,i</sub> is the system temperature for antenna i, &Delta;&nu;<sub>ch</sub> is the channel width, and t<sub>ij</sub> is the integration time per visibility.<br />
<br />
CASA initially scales the weights by 2&Delta;&nu;<sub>ch</sub>&Delta;t<sub>ij</sub>, and after the Tsys table applycal step of the calibration process, it further scales the weights by 1/[(Tsys(i) * Tsys(j)] as long as calwt=True. In the subsequent gain calibration table applycal step of the calibration, the weights are further scaled by a factor of [(gain(i))<sup>2</sup> * (gain(j))<sup>2</sup>]. The gains should change very little from antenna to antenna, so this scaling is effectively the average gain<sup>4</sup> (again, as long as calwt=True). In the calibration scripts for all executions of the 12m and 7m data, found (here), both applycal steps set calwt=True. To verify, we plot the weights of the 7m and 12m data and measure their ratio to be, on average, 7m/12m ~ 0.055/0.3 ~ 0.18. Note that in the plots the points are colored by SPW, so there is only one 12m CO SPW but there are two 7m CO SPWs, and that no averaging can be turned on when plotting the weights. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf 7m_WT.png 12m_WT.png')<br />
plotms(vis='m100_12m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0:200',<br />
coloraxis='spw',plotfile='12m_WT.png')<br />
#<br />
plotms(vis='m100_7m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~1:200',<br />
coloraxis='spw',plotfile='7m_WT.png')<br />
</source><br />
<br />
<figure id="combine_CO_WT.png"><br />
[[File:combine_CO_WT.png|200px|thumb|right|<caption> 7m and 12m weights after concatenation.</caption>]]<br />
</figure><br />
<br />
The two key things that are different between the 7m and 12m-array data are that the effective dish areas are different by (7/12)<sup>2</sup>, and the integration times are different by sqrt(10.1/6.05). Since dish area is in the numerator of the radiometer equation and integration time per visibility is in the denominator, and assuming the weight of an individual visibility is proportional to 1/sigma<sup>2</sup>, the ratio of the weights should be (7./12.)<sup>4</sup> x (10.1/6.05) = 0.19. This is very close to the value we measure for the ratio of the weights, particularly given that the 7m flux calibration relied on a source which changed substantially over the course of the six 7m-array observations. <br />
<br />
Now concatenate the two data sets and plot the concatenated weights to verify that they are as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Concat and scale weights<br />
os.system('rm -rf M100_combine_CO.ms')<br />
concat(vis=['m100_12m_CO.ms','m100_7m_CO.ms'],<br />
concatvis='M100_combine_CO.ms')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf combine_CO_WT.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~2:200',<br />
coloraxis='spw',plotfile='combine_CO_WT.png')<br />
</source><br />
<br />
Here, we create more instructive plots of the combined data to check that things are in order. (''Let each plot finish before cutting and pasting next plot. If plotms gui disappears, exit CASA and restart.'')<br />
<br />
<figure id="M100_combine_vel.png"><br />
[[File:M100_combine_vel.png|200px|thumb|right|<caption> Amplitude as a function of velocity.</caption>]]<br />
</figure><br />
<br />
To plot amplitude as a function of uv-distance, noting that the 7m data is noisier than the 12m data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_uvdist.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='uvdist',spw='', avgscan=True,<br />
avgchannel='5000', coloraxis='spw',plotfile='M100_combine_uvdist.png') <br />
</source><br />
<br />
A fairer comparison of these data is achieved by isolating the brightest line channels in individual 12m and 7m data sets (i.e., not the concatenated data sets) and comparing only those channels in amplitude vs. uv-distance. Here the agreement is better, as it is less dominated by the scatter among the several 7m executions.<br />
<br />
To plot the CO line as a function of velocity (this plot takes a while):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_vel.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='velocity',spw='', avgtime='1e8',avgscan=True,coloraxis='spw',avgchannel='5',<br />
transform=True,freqframe='LSRK',restfreq='115.271201800GHz', plotfile='M100_combine_vel.png')<br />
</source><br />
<br />
To see each spectral window independently in plotms, run the command again but remove the call to "plotfile" and add " iteraxis='spw' ".<br />
<br />
== Image Using An Automasking Technique ==<br />
<br />
The commands in this section perform an iterative automasking procedure down<br />
to a user specified threshold=stop*rms where stop is typically 2-3 using the imagemode='mosaic' mode of clean. This mode automatically calculates the correct convolution of the primary beam response of the mosaic when different antenna dish diameters are present. '''NOTE:''' even if these data had only been comprised of a single pointing of 7m and 12m-array data, the imagemode='mosaic' mode would be needed to correctly image data with different antenna sizes.<br />
<br />
The procedure outlined below takes some care to ensure that the generated masks (i) only have values of 0 or 1; (ii) are themselves masked at the minpb level. It also removes very small masked regions that are consistent with noise bumps using a function in scipy. A typical setting is to remove mask regions that are 1/2 the beam area in pixels. This is one technique under exploration for future pipeline use. <br />
<br />
The commands have been split into multiple sections to aid cut and paste. Wait until the current one is done before starting next section. '''If you stop CASA and restart you will need to cut and paste again from the Define Parameters section on down'''.<br />
<br />
For the long series of commands below it is important to include the '''beginning cpaste''' and '''ending --''' in your cut and paste.<br />
<br />
=== Define Parameters ===<br />
<br />
Note that the parameters used here are by design the same as those used to make the stand-alone 7m-array and 12m-array images. <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
<br />
### Initialize <br />
import scipy.ndimage <br />
<br />
### Define clean parameters<br />
vis='M100_combine_CO.ms'<br />
prename='M100_combine_cube'<br />
myimage=prename+'.image'<br />
myflux=prename+'.flux'<br />
mymask=prename+'.mask'<br />
myresidual=prename+'.residual'<br />
imsize=800<br />
cell='0.5arcsec'<br />
minpb=0.2<br />
restfreq='115.271201800GHz'<br />
outframe='LSRK'<br />
spw='0~2'<br />
width='5km/s'<br />
start='1400km/s'<br />
nchan=70<br />
robust=0.5<br />
phasecenter='J2000 12h22m54.9 +15d49m15'<br />
scales=[0]<br />
smallscalebias=0.6<br />
<br />
### Setup stopping criteria with multiplier for rms.<br />
stop=3. <br />
<br />
### Minimum size multiplier for beam area for removing very small mask regions. <br />
pixelmin=0.5 <br />
<br />
--<br />
</source><br />
<br />
=== Make Initial Dirty Image and Determine Synthesized Beam area===<br />
<br />
The dirty image is used to determine the initial peak flux density in the cube and the beam area is used to define the minimum size of masked regions in order to exclude noise bumps from the overall mask.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Make initial dirty image<br />
os.system('rm -rf '+prename+'.* ' +prename+'_*')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask='',<br />
niter=0,interactive=F)<br />
<br />
# Determine the beam area in pixels for later removal of very small mask regions<br />
major=imhead(imagename=myimage,mode='get',hdkey='beammajor')['value']<br />
minor=imhead(imagename=myimage,mode='get',hdkey='beamminor')['value']<br />
pixelsize=float(cell.split('arcsec')[0])<br />
beamarea=(major*minor*pi/(4*log(2)))/(pixelsize**2)<br />
print 'beamarea in pixels =', beamarea<br />
<br />
--<br />
</source><br />
<br />
=== Find properties of the dirty image ===<br />
<br />
For the long series of commands below it is important to include the beginning '''cpaste''' and ending '''--''' in your cut and paste.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Find the peak in the dirty cube.<br />
myimage=prename+'.image'<br />
bigstat=imstat(imagename=myimage)<br />
peak= bigstat['max'][0]<br />
print 'peak (Jy/beam) in cube = '+str(peak)<br />
### Sets threshold of first loop, try 2-4. Subsequent loops are set thresh/2.<br />
thresh = peak / 4.<br />
<br />
### If True: find the rms in two line-free channels; If False: Set rms by hand in else statement.<br />
if True: <br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2) <br />
else:<br />
rms=0.011<br />
<br />
<br />
print 'rms (Jy/beam) in a channel = '+str(rms)<br />
--<br />
</source><br />
<br />
=== Automasking Loop ===<br />
<br />
On a reasonably fast computer the following will take a couple of hours for this spectral mosaic... <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf ' + prename +'_threshmask*')<br />
os.system('rm -rf ' + prename +'_fullmask*')<br />
os.system('rm -rf ' + prename +'.image*')<br />
n=-1<br />
while (thresh >= stop*rms): <br />
n=n+1<br />
print 'clean threshold this loop is', thresh<br />
threshmask = prename+'_threshmask' +str(n)<br />
maskim = prename+'_fullmask' +str(n)<br />
immath(imagename = [myresidual],<br />
outfile = threshmask,<br />
expr = 'iif(IM0 > '+str(thresh) +',1.0,0.0)',<br />
mask=myflux+'>'+str(minpb))<br />
if (n==0):<br />
os.system('cp -r '+threshmask+' '+maskim+'.pb')<br />
print 'This is the first loop'<br />
else:<br />
makemask(mode='copy',inpimage=myimage,<br />
inpmask=[threshmask,mymask],<br />
output=maskim)<br />
imsubimage(imagename=maskim, mask=myflux+'>'+str(minpb),<br />
outfile=maskim+'.pb') <br />
print 'Combined mask ' +maskim+' generated.'<br />
<br />
# Remove small masks<br />
os.system('cp -r '+maskim+'.pb ' +maskim+'.pb.min')<br />
maskfile=maskim+'.pb.min'<br />
ia.open(maskfile)<br />
mask=ia.getchunk() <br />
labeled,j=scipy.ndimage.label(mask) <br />
myhistogram = scipy.ndimage.measurements.histogram(labeled,0,j+1,j+1)<br />
object_slices = scipy.ndimage.find_objects(labeled)<br />
threshold=beamarea*pixelmin<br />
for i in range(j):<br />
if myhistogram[i+1]<threshold:<br />
mask[object_slices[i]] = 0<br />
<br />
<br />
ia.putchunk(mask)<br />
ia.done()<br />
print 'Small masks removed and ' +maskim +'.pb.min generated.'<br />
<br />
os.system('rm -rf '+mymask+'')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask = maskim+'.pb.min',<br />
multiscale=scales,smallscalebias=smallscalebias,<br />
interactive = F,<br />
niter = 10000,<br />
threshold = str(thresh) +'Jy/beam')<br />
<br />
<br />
if thresh==stop*rms: break<br />
thresh = thresh/2.<br />
# Run a final time with stop*rms if more than a little above<br />
# stop*rms. Also make a back-up of next to last image<br />
if (thresh < stop*rms and thresh*2.>1.05*stop*rms):<br />
thresh=stop*rms <br />
os.system('cp -r '+myimage+' '+myimage+str(n))<br />
<br />
--<br />
</source><br />
<br />
=== Notes on the Automasking procedure ===<br />
<br />
This script is meant to be a possible stepping stone to optimal automasking -- it is by no means perfect and is certainly slower than optimal but feel free to try it with other datasets. Some notes below:<br />
<br />
In addition to the final prename.image (prename.flux etc) this script produces and keeps each iteration of the various mask files which will allow you to explore how the masking proceeded as the threshold for masking and cleaning was lowered. The ones denoted "prename. fullmask*.pb.min" are the ones used in the clean steps themselves. At the end of the process the final "prename. fullmask*.pb.min" will also be stored in the prename.mask. Once you've verified you are happy with the masking, you may want to remove the prename.threshmask* and prename.fullmask* files, as they can be large for large cubes. <br />
<br />
Additionally, before running the final loop with thresh=stop*rms the script copies the .image from the preceding clean to prename.image'n' where 'n' equals the loop number of the preceding step. So in this M100 example you will see a M100_combine_cube.image and a M100_combine_cube.image2 where .image is the final image and .image2 is the next to last image. This is done for convenience in the case that thresh=stop*rms is too deep such that clean diverges, you will still be left with the clean image from the preceding loop that you can further investigate to understand why clean diverged. If all goes well with the final loop, the prename.image'n' can also be deleted. Divergence at thresh=stop*rms is often a sign that the image is "dynamic range limited" in other words the rms in channels with bright emission is significantly worse than for a line-free channel.<br />
<br />
== Image Analysis for the 7m+12m Data ==<br />
<br />
=== Moment Maps for 7m+12m CO (1-0) Cube ===<br />
<br />
Start by examining the final image cube. Determine the start and stopping channels for the line emission -- this will be used in the "chans" parameter of immoments.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_combine_cube.image')<br />
</source><br />
<br />
Next determine the rms noise per channel and use that to exclude pixels from the moment images. All images are shown in the gallery at the end of the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
myimage='M100_combine_cube.image'<br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2)<br />
print 'rms in a channel = '+str(rms) <br />
</source><br />
<br />
Next make the moment maps. For the integrated intensity: moment 0, a 2 sigma cut often considerably improves the appearance of the image with little effect on the integrated intensity as long as emission free channels are excluded. For higher order moments it is necessary to exclude all low S/N data. Typically 5-6 sigma for the higher moments works well. We also apply further masking based on the .flux image because the edges of the combined mosaic are especially noisy because the 7m mosaic is somewhat larger than the 12m mosaic as described above (see Figures 1 & 2). <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom0')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [0],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',,<br />
includepix = [rms*2,100.],<br />
outfile = 'M100_combine_cube.image.mom0')<br />
<br />
os.system('rm -rf M100_combine_cube.image.mom1')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [1],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',<br />
includepix = [rms*5.5,100.],<br />
outfile = 'M100_combine_cube.image.mom1')<br />
--<br />
</source><br />
<br />
Now we can make some figures showing the moment maps (*note that this creates different looking files for me than the ones I have included here, which were made in the viewer -- is this true for others?*):<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom*.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.png')<br />
<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom1',<br />
'range': [1440,1695],'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]}, <br />
out='M100_combine_cube.image.mom1.png')<br />
--<br />
</source><br />
<br />
If you plan to use your moment 0 image to make measurements, it needs to be primary beam corrected first. First we need to subimage the .flux cube to extract a single plane that can be used to primary beam correct the moment 0 image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.flux.1ch')<br />
imsubimage(imagename='M100_combine_cube.flux',<br />
outfile='M100_combine_cube.flux.1ch',<br />
chans='35')<br />
</source><br />
<br />
Then primary beam correct the moment 0 image. This is the version that would be used for measurements, though the uncorrected one can be useful for figures. The difference is clear in the images seen below in the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor')<br />
immath(imagename=['M100_combine_cube.image.mom0', \<br />
'M100_combine_cube.flux.1ch'],<br />
expr='IM0/IM1',<br />
outfile='M100_combine_cube.image.mom0.pbcor')<br />
</source><br />
<br />
Have a look at the difference the primary beam correction makes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3},<br />
{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3}],<br />
zoom={'blc': [190,150],'trc': [650,610]})<br />
</source><br />
<br />
With the viewer open, you can flip back and forth between the images to compare them. Next, make a figure.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.pbcor.png')<br />
<br />
</source><br />
<br />
=== Comparison with 7m, 12m Moment Maps ===<br />
<br />
Below the moment maps from the 7m-only and the 12m-only data are shown for comparison. The moment maps were made using clean masks drawn by hand for comparison to the automasking technique; the two appear to be qualitatively similar. The range and scaling for the 12m-only figures are the same as that used for the 7m+12m figures for ease of comparison.<br />
<br />
As expected, the 7m+12m image shows considerably more extended emission than the 12m-only data and finer detail than the 7m-only data. For comparison, the 7m+12m synthesized beam is 3.80"x2.50", while the 12m-only beam is 3.46"x2.37" and the 7m-only beam is 12.72"x10.12".<br />
<br />
<gallery widths=300px heights=300px><br />
File:12m.png | Moment 0 for 12m data alone (no primary beam correction).<br />
File:7m_mom0.png | Moment 0 for 7m data alone (no primary beam correction).<br />
File:combined.png | Moment 0 for 12m+7m data (no primary beam correction).<br />
File:combine_pbcor.png | Moment 0 for 12m+7m data with primary beam correction.<br />
</gallery><br />
<br />
<gallery widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data alone.<br />
File:7m_mom1.png | Moment 1 for 7m data alone.<br />
File:combine_mom1.png | Moment 1 for 12m+7m data.<br />
</gallery><br />
<br />
=== Convert 7m+12m Images to Fits Format ===<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf *.fits')<br />
exportfits(imagename='M100_combine_cube.image',fitsimage='M100_combine_cube.image.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.flux',fitsimage='M100_combine_cube.flux.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0',fitsimage='M100_combine_cube.image.mom0.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0.pbcor',fitsimage='M100_combine_cube.image.mom0.pbcor.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom1',fitsimage='M100_combine_cube.image.mom1.fits')<br />
<br />
--<br />
</source><br />
<br />
= Feathering the Total Power and 7m+12m Interferometric Images =<br />
<br />
== Prepare Images for Feathering ==<br />
<br />
Regrid the TP image to match the shape of the 7m+12m image using the task {{imregrid}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid')<br />
imregrid(imagename='M100TP.CO.cube.bl.image',<br />
template='M100_combined_CO.image',<br />
axes=[0, 1],<br />
output='M100TP.CO.regrid')<br />
</source><br />
<br />
Make subimages of the (regridded) TP and 7m+12m images with the task {{imsubimage}}, excluding regions masked by the clean minpb=0.2 and noisy edge pixels in the TP image. The Viewer ({{viewer}}) can be used to determine a good joint region.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.image.subim')<br />
imsubimage(imagename='M100_combined_CO.image',<br />
outfile='M100_combined_CO.image.subim',<br />
box='219,148,612,579')<br />
os.system('rm -rf M100TP.CO.regrid.subim')<br />
imsubimage(imagename='M100TP.CO.regrid',<br />
outfile='M100TP.CO.regrid.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Create the subimage of the mosaic response as well.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Multiply the TP image by the mosaic beam response of the 7m+12m image using the task {{immath}},<br />
so that the TP and 7m+12m images to be feathered together have the same response.<br />
The "primary-beam correction" can be done after the feathering process (see below).<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim.depb')<br />
immath(imagename=['M100TP.CO.regrid.subim',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0*IM1',<br />
outfile='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
== Feather TP Cube with 7m+12m Cube ==<br />
<br />
Run the {{feather}} task to combine the TP and 7m+12m images.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image')<br />
feather(imagename='M100_Feather_CO.image',<br />
highres='M100_combined_CO.image.subim',<br />
lowres='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
The task (1) converts the input images specified by the "highres" and<br />
"lowres" parameters onto the spatial frequency plane,<br />
(2) combines them on the spatial frequency plane, and<br />
(3) converts it back to image plane.<br />
Please refer to the online help and documents for the details.<br />
<br />
== Make Moment Maps of TP and Feathered Images ==<br />
<br />
We will use the same technique as the 7m+12m image analysis above to make moment maps.<br />
<br />
First, make moment maps for the (regridded) TP image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100TP.CO.regrid.subim'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom0')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100TP.CO.regrid.subim.mom0')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom1')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100TP.CO.regrid.subim.mom1')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom*.png')<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom0',<br />
'range': [0., 1080.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100TP.CO.regrid.subim.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100TP.CO.regrid.subim.mom1.png')<br />
</source><br />
<br />
Then make moment maps for the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100_Feather_CO.image'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100_Feather_CO.image.mom0')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom1')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100_Feather_CO.image.mom1')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom*.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100_Feather_CO.image.mom1.png')<br />
</source><br />
<br />
=== Correct the Primary Beam Response ===<br />
<br />
Apply the primary beam response to the feathered image using the<br />
task {{immath}},<br />
<br />
<source lang="python"><br />
#In CASA<br />
immath(imagename=['M100_Feather_CO.image',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.pbcor')<br />
</source><br />
<br />
and also to the moment 0 image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.1ch.subim')<br />
imsubimage(imagename='M100_combined_CO.flux.subim',<br />
outfile='M100_combined_CO.flux.1ch.subim',<br />
chans='35')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor')<br />
immath(imagename=['M100_Feather_CO.image.mom0',<br />
'M100_combined_CO.flux.1ch.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.mom0.pbcor')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0.pbcor',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.3,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.pbcor.png')<br />
</source><br />
<br />
=== Compare the Various Images ===<br />
<br />
Now we compare all the images:<br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_pbcor.png | Primary beam corrected moment 0 for the 12m data.<br />
File:7m_pbcor.png | Primary beam corrected moment 0 for the 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom0.png | Moment 0 for the TP data.<br />
File:combine_pbcor.png | Primary beam corrected moment 0 for 7m+12m data.<br />
File:M100_Feather_CO.mom0.pbcor.png | Primary beam corrected moment 0 for TP+7m+12m data.<br />
</gallery><br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data.<br />
File:7m_mom1.png | Moment 1 for 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom1.png | Moment 1 for the TP data.<br />
File:combine_mom1.png | Moment 1 for 7m+12m data.<br />
File:M100_Feather_CO.mom1.png | Moment 1 for TP+7m+12m data.<br />
</gallery><br />
<br />
For quantitative comparison, we measure the total line fluxes of the<br />
various images.<br />
The task {{imstat}} can be used to do this.<br />
For example, for the subimage of the 7m+12m image,<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')<br />
</source><br />
<br />
yields the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{'blc': array([0, 0, 0, 0], dtype=int32),<br />
'blcf': '12:23:01.170, +15.47.08.994, I, 1.14733e+11Hz',<br />
'flux': array([ 269.63344004]),<br />
'max': array([ 0.65709084]),<br />
'maxpos': array([172, 253, 0, 49], dtype=int32),<br />
'maxposf': '12:22:55.212, +15.49.15.500, I, 1.14639e+11Hz',<br />
'mean': array([ 0.00097561]),<br />
'medabsdevmed': array([ 0.00850473]),<br />
'median': array([ -3.25056462e-05]),<br />
'min': array([-0.07497632]),<br />
'minpos': array([260, 251, 0, 26], dtype=int32),<br />
'minposf': '12:22:52.163, +15.49.14.499, I, 1.14683e+11Hz',<br />
'npts': array([ 11914560.]),<br />
'quartile': array([ 0.01701281]),<br />
'rms': array([ 0.01756589]),<br />
'sigma': array([ 0.01753878]),<br />
'sum': array([ 11623.92616449]),<br />
'sumsq': array([ 3676.36438921]),<br />
'trc': array([393, 431, 0, 69], dtype=int32),<br />
'trcf': '12:22:47.554, +15.50.44.492, I, 1.146e+11Hz'}<br />
</pre><br />
<br />
The 'flux' value in the result is the total flux in Jy.<br />
Since the width of the velocity channel is 5 km/s, the following command<br />
gives the integrated line flux in the unit of Jy km/s.<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100_combined_CO.image.subim')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 1348.16720019])<br />
</pre><br />
<br />
Similarly, the total line fluxes of the TP image (after multiplying the<br />
7m+12m beam response), feathered image, and feathered image after the<br />
primary-beam correction are<br />
<br />
<source lang="python"><br />
#In CASA<br />
imstat('M100TP.CO.regrid.subim.depb')['flux']*5.0<br />
imstat('M100_Feather_CO.image')['flux']*5.0<br />
imstat('M100_Feather_CO.image.pbcor')['flux']*5.0<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
array([ 2766.63524574])<br />
array([ 2766.63528397])<br />
array([ 3057.66449702])<br />
</pre><br />
<br />
We see the followings from these values:<br />
* The flux recovered by the 7m+12m observations is about a half of the total flux (1348/2767 = 0.487).<br />
* The feathering process preserves the flux of the TP data.<br />
* The flux of the primary-beam corrected feathered image is consistent with the values from the literature (2972 +/- 319 Jy km/s from the BIMA SONG; Helfer et al. 2003).<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:M100_Feather_CO.mom1.png&diff=16987File:M100 Feather CO.mom1.png2015-05-26T15:05:43Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:M100 Feather CO.mom1.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:TP_CO_cube_Jy.regrid.subim.mom1.png&diff=16986File:TP CO cube Jy.regrid.subim.mom1.png2015-05-26T15:05:07Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:TP CO cube Jy.regrid.subim.mom1.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:M100_Feather_CO.mom0.pbcor.png&diff=16985File:M100 Feather CO.mom0.pbcor.png2015-05-26T15:04:47Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:M100 Feather CO.mom0.pbcor.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:TP_CO_cube_Jy.regrid.subim.mom0.png&diff=16984File:TP CO cube Jy.regrid.subim.mom0.png2015-05-26T15:04:23Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:TP CO cube Jy.regrid.subim.mom0.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:M100_Feather_CO.mom1.png&diff=16983File:M100 Feather CO.mom1.png2015-05-26T14:49:22Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:M100 Feather CO.mom1.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:TP_CO_cube_Jy.regrid.subim.mom1.png&diff=16982File:TP CO cube Jy.regrid.subim.mom1.png2015-05-26T14:48:56Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:TP CO cube Jy.regrid.subim.mom1.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:M100_Feather_CO.mom0.pbcor.png&diff=16981File:M100 Feather CO.mom0.pbcor.png2015-05-26T14:48:31Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:M100 Feather CO.mom0.pbcor.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:TP_CO_cube_Jy.regrid.subim.mom0.png&diff=16980File:TP CO cube Jy.regrid.subim.mom0.png2015-05-26T14:47:25Z<p>Tsawada: Tsawada uploaded a new version of &quot;File:TP CO cube Jy.regrid.subim.mom0.png&quot;</p>
<hr />
<div></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_Combine_4.3&diff=16979M100 Band3 Combine 4.32015-05-25T22:40:04Z<p>Tsawada: /* Feathering the Total Power and 7m+12m Interferometric Images */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
= Overview =<br />
<br />
This guide describes how to combine the 7m and 12m interferometric data and then how to feather the resulting image with the total power TP image. All of the data for this SV project can be found at https://almascience.nrao.edu/alma-data/science-verification. The guide has been written for data reduced in CASA 4.3.0 or later and assumes that all calibration tables (Tsys and gain tables) have been applied to the visibility weights using calwt=True. If either of these is not the case for your data, '''do not follow this guide.''' <br />
<br />
In order to run this guide you will need to:<br />
<br />
* Either download the fully calibrated 7m data (i.e., M100_Band3_7m_CalibratedData.tgz) or download the uncalibrated 7m data and the relevant, standard calibration scripts available (here). An overview of the 7m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either download the fully calibrated 12m data (i.e. M100_Band3_12m_CalibratedData.tgz) or download the uncalibrated 12m data and the relevant, standard calibration scripts available (here). Note that this is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.''' An overview of the 12m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either run the [[M100_Band3_SingleDish_4.3]] guide to calibrate and image the Total Power data or download the final image (i.e. M100_TP_Image.tgz)<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
= Combine and Image the 7m+12m Interferometric Data =<br />
<br />
<br />
== Split off CO spectral windows (SPWs) ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_*m.ms.listobs')<br />
listobs('M100_Band3_12m_CalibratedData.ms',listfile='m100_12m.ms.listobs')<br />
listobs('M100_Band3_7m_CalibratedData.ms',listfile='m100_7m.ms.listobs')<br />
</source><br />
<br />
Running the task "listobs" provides the setups used in the observations at a glance. Below are the first target scans of the 12m and 7m observations and the spectral window tables as generated by listobs. The six 7m data sets were taken with two slightly different correlator setups (one with four SPWs and the other with two SPWs), so the concatenated data set has six total SPWs. <br />
<br />
<pre style="background-color: #fffacd;"><br />
12m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
10-Aug-2011/19:38:05.8 - 19:50:22.8 11 1 M100 1500 [0,1,2,3] [6.05, 6.05, 6.05, 6.05] [CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (4 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 3840 TOPO 113726.419 488.281 1875000.0 114663.6750 1 XX YY<br />
1 3840 TOPO 111851.419 488.281 1875000.0 112788.6750 2 XX YY<br />
2 3840 TOPO 103663.431 -488.281 1875000.0 102726.1750 3 XX YY<br />
3 3840 TOPO 101850.931 -488.281 1875000.0 100913.6750 4 XX YY<br />
<br />
7m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
17-Mar-2013/04:44:04.3 - 04:50:43.7 11 1 M100 261 [0,1,2,3] [10.1, 10.1, 10.1, 10.1] [OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (6 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
1 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
2 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
3 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
4 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 111798.250 488.281 1992187.5 112794.1000 1 XX YY<br />
5 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 113673.250 488.281 1992187.5 114669.1000 2 XX YY<br />
</pre><br />
<br />
<figure id="12m_mosaic.png"><br />
[[Image:12m_mosaic.png|300px|thumb|right|<caption>FOV of 12m mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="7m_mosaic.png"><br />
[[Image:7m_mosaic.png|300px|thumb|right|<caption>FOV of 7m mosaic.</caption>]]<br />
</figure><br />
<br />
Examination of the listobs files shows that the CO is in SPW='0' for the 12m data and in SPW='3,5' for the 7m data. There are two SPWs containing CO in the 7m data due to the slightly differing correlator setups.<br />
<br />
Also note that the integration time per visibility (average interval parameter in listobs) is different:<br />
6.05s for the 12m data and 10.1s for the 7m. This will be important to know later when we check the visibility weights. <br />
<br />
Next we split out the CO spectral windows.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_12m_CO.ms')<br />
split(vis='M100_Band3_12m_CalibratedData.ms',<br />
outputvis='m100_12m_CO.ms',spw='0',field='M100',<br />
datacolumn='data',keepflags=False)<br />
os.system('rm -rf m100_7m_CO.ms')<br />
split(vis='M100_Band3_7m_CalibratedData.ms',<br />
outputvis='m100_7m_CO.ms',spw='3,5',field='M100',<br />
datacolumn='data',keepflags=False)<br />
</source><br />
<br />
Also of interest is that the 12m data has 47 fields and the 7m has 23 fields (not shown in the excerpts above). The difference in number of pointings is because the 7m antennas have a FWHP (full width half power) primary beam diameter that is 12/7 times larger than the 12m antennas. '''One easy way to see how the mosaics compare is to install the AnalysisUtils package (see [[Analysis_Utilities]])'''. Then with AnalysisUtils you can make the following plots (look at the listobs to obtain the sourceid):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *m_mosaic.png')<br />
au.plotmosaic('m100_12m_CO.ms',sourceid='0',figfile='12m_mosaic.png')<br />
au.plotmosaic('m100_7m_CO.ms',sourceid='0',figfile='7m_mosaic.png')<br />
</source><br />
<br />
We see that the mosaics cover a common area but that the 7m mosaic is a bit larger. This means that the outer edges of the combined mosaic will be noisier than expected if they overlapped perfectly; this is just something to keep in mind. If you had the case where the mosaic coverages are dramatically different, it would be best to exclude the completely non-overlapping fields from the combination.<br />
<br />
NOTE: At this stage one would typically do continuum subtraction (if there is any). However we already know from the individual data reductions that the 3mm continuum emission is quite weak and does not significantly contribute to a 5km/s channel, so we will forgo the the continuum subtraction step. Examples of how to do this if you are so inclined are located in various other ALMA CASAguides.<br />
<br />
== Checking the weights and concatenating the data ==<br />
<br />
<figure id="7m_WT.png"><br />
[[File:12m_WT.png|200px|thumb|right|<caption> 12m weights.</caption>]]<br />
</figure><br />
<br />
<figure id="12m_WT.png"><br />
[[File:7m_WT.png|200px|thumb|right|<caption> 7m weights.</caption>]]<br />
</figure><br />
<br />
When combining data with disparate properties it is very important that the relative weights of each visibility be in the correct proportion to the other data according to the radiometer equation. Formally, the<br />
visibility weights should be proportional to 1/sigma<sup>2</sup> where sigma is the variance or rms noise of a given visibility.<br />
<br />
Assuming that the 7m and 12m antennas have similar apperture and quantization efficiencies (a reasonable assumption since they were designed this way), the rms noise in a single channel for a single visibility is:<br />
<br />
<math> <br />
\sigma_{ij}=\frac{2k}{A_{eff}} <br />
</math><br />
<math> <br />
\sqrt{\frac{T_{sys,i} T_{sys,j}}{\Delta\nu_{ch} t_{ij}}},<br />
</math><br />
<br />
where k is Boltzmann's constant, A<sub>eff</sub> is the effective antenna area, T<sub>sys,i</sub> is the system temperature for antenna i, &Delta;&nu;<sub>ch</sub> is the channel width, and t<sub>ij</sub> is the integration time per visibility.<br />
<br />
CASA initially scales the weights by 2&Delta;&nu;<sub>ch</sub>&Delta;t<sub>ij</sub>, and after the Tsys table applycal step of the calibration process, it further scales the weights by 1/[(Tsys(i) * Tsys(j)] as long as calwt=True. In the subsequent gain calibration table applycal step of the calibration, the weights are further scaled by a factor of [(gain(i))<sup>2</sup> * (gain(j))<sup>2</sup>]. The gains should change very little from antenna to antenna, so this scaling is effectively the average gain<sup>4</sup> (again, as long as calwt=True). In the calibration scripts for all executions of the 12m and 7m data, found (here), both applycal steps set calwt=True. To verify, we plot the weights of the 7m and 12m data and measure their ratio to be, on average, 7m/12m ~ 0.055/0.3 ~ 0.18. Note that in the plots the points are colored by SPW, so there is only one 12m CO SPW but there are two 7m CO SPWs, and that no averaging can be turned on when plotting the weights. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf 7m_WT.png 12m_WT.png')<br />
plotms(vis='m100_12m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0:200',<br />
coloraxis='spw',plotfile='12m_WT.png')<br />
#<br />
plotms(vis='m100_7m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~1:200',<br />
coloraxis='spw',plotfile='7m_WT.png')<br />
</source><br />
<br />
<figure id="combine_CO_WT.png"><br />
[[File:combine_CO_WT.png|200px|thumb|right|<caption> 7m and 12m weights after concatenation.</caption>]]<br />
</figure><br />
<br />
The two key things that are different between the 7m and 12m-array data are that the effective dish areas are different by (7/12)<sup>2</sup>, and the integration times are different by sqrt(10.1/6.05). Since dish area is in the numerator of the radiometer equation and integration time per visibility is in the denominator, and assuming the weight of an individual visibility is proportional to 1/sigma<sup>2</sup>, the ratio of the weights should be (7./12.)<sup>4</sup> x (10.1/6.05) = 0.19. This is very close to the value we measure for the ratio of the weights, particularly given that the 7m flux calibration relied on a source which changed substantially over the course of the six 7m-array observations. <br />
<br />
Now concatenate the two data sets and plot the concatenated weights to verify that they are as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Concat and scale weights<br />
os.system('rm -rf M100_combine_CO.ms')<br />
concat(vis=['m100_12m_CO.ms','m100_7m_CO.ms'],<br />
concatvis='M100_combine_CO.ms')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf combine_CO_WT.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~2:200',<br />
coloraxis='spw',plotfile='combine_CO_WT.png')<br />
</source><br />
<br />
Here, we create more instructive plots of the combined data to check that things are in order. (''Let each plot finish before cutting and pasting next plot. If plotms gui disappears, exit CASA and restart.'')<br />
<br />
<figure id="M100_combine_vel.png"><br />
[[File:M100_combine_vel.png|200px|thumb|right|<caption> Amplitude as a function of velocity.</caption>]]<br />
</figure><br />
<br />
To plot amplitude as a function of uv-distance, noting that the 7m data is noisier than the 12m data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_uvdist.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='uvdist',spw='', avgscan=True,<br />
avgchannel='5000', coloraxis='spw',plotfile='M100_combine_uvdist.png') <br />
</source><br />
<br />
A fairer comparison of these data is achieved by isolating the brightest line channels in individual 12m and 7m data sets (i.e., not the concatenated data sets) and comparing only those channels in amplitude vs. uv-distance. Here the agreement is better, as it is less dominated by the scatter among the several 7m executions.<br />
<br />
To plot the CO line as a function of velocity (this plot takes a while):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_vel.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='velocity',spw='', avgtime='1e8',avgscan=True,coloraxis='spw',avgchannel='5',<br />
transform=True,freqframe='LSRK',restfreq='115.271201800GHz', plotfile='M100_combine_vel.png')<br />
</source><br />
<br />
To see each spectral window independently in plotms, run the command again but remove the call to "plotfile" and add " iteraxis='spw' ".<br />
<br />
== Image Using An Automasking Technique ==<br />
<br />
The commands in this section perform an iterative automasking procedure down<br />
to a user specified threshold=stop*rms where stop is typically 2-3 using the imagemode='mosaic' mode of clean. This mode automatically calculates the correct convolution of the primary beam response of the mosaic when different antenna dish diameters are present. '''NOTE:''' even if these data had only been comprised of a single pointing of 7m and 12m-array data, the imagemode='mosaic' mode would be needed to correctly image data with different antenna sizes.<br />
<br />
The procedure outlined below takes some care to ensure that the generated masks (i) only have values of 0 or 1; (ii) are themselves masked at the minpb level. It also removes very small masked regions that are consistent with noise bumps using a function in scipy. A typical setting is to remove mask regions that are 1/2 the beam area in pixels. This is one technique under exploration for future pipeline use. <br />
<br />
The commands have been split into multiple sections to aid cut and paste. Wait until the current one is done before starting next section. '''If you stop CASA and restart you will need to cut and paste again from the Define Parameters section on down'''.<br />
<br />
For the long series of commands below it is important to include the '''beginning cpaste''' and '''ending --''' in your cut and paste.<br />
<br />
=== Define Parameters ===<br />
<br />
Note that the parameters used here are by design the same as those used to make the stand-alone 7m-array and 12m-array images. <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
<br />
### Initialize <br />
import scipy.ndimage <br />
<br />
### Define clean parameters<br />
vis='M100_combine_CO.ms'<br />
prename='M100_combine_cube'<br />
myimage=prename+'.image'<br />
myflux=prename+'.flux'<br />
mymask=prename+'.mask'<br />
myresidual=prename+'.residual'<br />
imsize=800<br />
cell='0.5arcsec'<br />
minpb=0.2<br />
restfreq='115.271201800GHz'<br />
outframe='LSRK'<br />
spw='0~2'<br />
width='5km/s'<br />
start='1400km/s'<br />
nchan=70<br />
robust=0.5<br />
phasecenter='J2000 12h22m54.9 +15d49m15'<br />
scales=[0]<br />
smallscalebias=0.6<br />
<br />
### Setup stopping criteria with multiplier for rms.<br />
stop=3. <br />
<br />
### Minimum size multiplier for beam area for removing very small mask regions. <br />
pixelmin=0.5 <br />
<br />
--<br />
</source><br />
<br />
=== Make Initial Dirty Image and Determine Synthesized Beam area===<br />
<br />
The dirty image is used to determine the initial peak flux density in the cube and the beam area is used to define the minimum size of masked regions in order to exclude noise bumps from the overall mask.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Make initial dirty image<br />
os.system('rm -rf '+prename+'.* ' +prename+'_*')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask='',<br />
niter=0,interactive=F)<br />
<br />
# Determine the beam area in pixels for later removal of very small mask regions<br />
major=imhead(imagename=myimage,mode='get',hdkey='beammajor')['value']<br />
minor=imhead(imagename=myimage,mode='get',hdkey='beamminor')['value']<br />
pixelsize=float(cell.split('arcsec')[0])<br />
beamarea=(major*minor*pi/(4*log(2)))/(pixelsize**2)<br />
print 'beamarea in pixels =', beamarea<br />
<br />
--<br />
</source><br />
<br />
=== Find properties of the dirty image ===<br />
<br />
For the long series of commands below it is important to include the beginning '''cpaste''' and ending '''--''' in your cut and paste.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Find the peak in the dirty cube.<br />
myimage=prename+'.image'<br />
bigstat=imstat(imagename=myimage)<br />
peak= bigstat['max'][0]<br />
print 'peak (Jy/beam) in cube = '+str(peak)<br />
### Sets threshold of first loop, try 2-4. Subsequent loops are set thresh/2.<br />
thresh = peak / 4.<br />
<br />
### If True: find the rms in two line-free channels; If False: Set rms by hand in else statement.<br />
if True: <br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2) <br />
else:<br />
rms=0.011<br />
<br />
<br />
print 'rms (Jy/beam) in a channel = '+str(rms)<br />
--<br />
</source><br />
<br />
=== Automasking Loop ===<br />
<br />
On a reasonably fast computer the following will take a couple of hours for this spectral mosaic... <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf ' + prename +'_threshmask*')<br />
os.system('rm -rf ' + prename +'_fullmask*')<br />
os.system('rm -rf ' + prename +'.image*')<br />
n=-1<br />
while (thresh >= stop*rms): <br />
n=n+1<br />
print 'clean threshold this loop is', thresh<br />
threshmask = prename+'_threshmask' +str(n)<br />
maskim = prename+'_fullmask' +str(n)<br />
immath(imagename = [myresidual],<br />
outfile = threshmask,<br />
expr = 'iif(IM0 > '+str(thresh) +',1.0,0.0)',<br />
mask=myflux+'>'+str(minpb))<br />
if (n==0):<br />
os.system('cp -r '+threshmask+' '+maskim+'.pb')<br />
print 'This is the first loop'<br />
else:<br />
makemask(mode='copy',inpimage=myimage,<br />
inpmask=[threshmask,mymask],<br />
output=maskim)<br />
imsubimage(imagename=maskim, mask=myflux+'>'+str(minpb),<br />
outfile=maskim+'.pb') <br />
print 'Combined mask ' +maskim+' generated.'<br />
<br />
# Remove small masks<br />
os.system('cp -r '+maskim+'.pb ' +maskim+'.pb.min')<br />
maskfile=maskim+'.pb.min'<br />
ia.open(maskfile)<br />
mask=ia.getchunk() <br />
labeled,j=scipy.ndimage.label(mask) <br />
myhistogram = scipy.ndimage.measurements.histogram(labeled,0,j+1,j+1)<br />
object_slices = scipy.ndimage.find_objects(labeled)<br />
threshold=beamarea*pixelmin<br />
for i in range(j):<br />
if myhistogram[i+1]<threshold:<br />
mask[object_slices[i]] = 0<br />
<br />
<br />
ia.putchunk(mask)<br />
ia.done()<br />
print 'Small masks removed and ' +maskim +'.pb.min generated.'<br />
<br />
os.system('rm -rf '+mymask+'')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask = maskim+'.pb.min',<br />
multiscale=scales,smallscalebias=smallscalebias,<br />
interactive = F,<br />
niter = 10000,<br />
threshold = str(thresh) +'Jy/beam')<br />
<br />
<br />
if thresh==stop*rms: break<br />
thresh = thresh/2.<br />
# Run a final time with stop*rms if more than a little above<br />
# stop*rms. Also make a back-up of next to last image<br />
if (thresh < stop*rms and thresh*2.>1.05*stop*rms):<br />
thresh=stop*rms <br />
os.system('cp -r '+myimage+' '+myimage+str(n))<br />
<br />
--<br />
</source><br />
<br />
=== Notes on the Automasking procedure ===<br />
<br />
This script is meant to be a possible stepping stone to optimal automasking -- it is by no means perfect and is certainly slower than optimal but feel free to try it with other datasets. Some notes below:<br />
<br />
In addition to the final prename.image (prename.flux etc) this script produces and keeps each iteration of the various mask files which will allow you to explore how the masking proceeded as the threshold for masking and cleaning was lowered. The ones denoted "prename. fullmask*.pb.min" are the ones used in the clean steps themselves. At the end of the process the final "prename. fullmask*.pb.min" will also be stored in the prename.mask. Once you've verified you are happy with the masking, you may want to remove the prename.threshmask* and prename.fullmask* files, as they can be large for large cubes. <br />
<br />
Additionally, before running the final loop with thresh=stop*rms the script copies the .image from the preceding clean to prename.image'n' where 'n' equals the loop number of the preceding step. So in this M100 example you will see a M100_combine_cube.image and a M100_combine_cube.image2 where .image is the final image and .image2 is the next to last image. This is done for convenience in the case that thresh=stop*rms is too deep such that clean diverges, you will still be left with the clean image from the preceding loop that you can further investigate to understand why clean diverged. If all goes well with the final loop, the prename.image'n' can also be deleted. Divergence at thresh=stop*rms is often a sign that the image is "dynamic range limited" in other words the rms in channels with bright emission is significantly worse than for a line-free channel.<br />
<br />
== Image Analysis for the 7m+12m Data ==<br />
<br />
=== Moment Maps for 7m+12m CO (1-0) Cube ===<br />
<br />
Start by examining the final image cube. Determine the start and stopping channels for the line emission -- this will be used in the "chans" parameter of immoments.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_combine_cube.image')<br />
</source><br />
<br />
Next determine the rms noise per channel and use that to exclude pixels from the moment images. All images are shown in the gallery at the end of the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
myimage='M100_combine_cube.image'<br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2)<br />
print 'rms in a channel = '+str(rms) <br />
</source><br />
<br />
Next make the moment maps. For the integrated intensity: moment 0, a 2 sigma cut often considerably improves the appearance of the image with little effect on the integrated intensity as long as emission free channels are excluded. For higher order moments it is necessary to exclude all low S/N data. Typically 5-6 sigma for the higher moments works well. We also apply further masking based on the .flux image because the edges of the combined mosaic are especially noisy because the 7m mosaic is somewhat larger than the 12m mosaic as described above (see Figures 1 & 2). <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom0')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [0],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',,<br />
includepix = [rms*2,100.],<br />
outfile = 'M100_combine_cube.image.mom0')<br />
<br />
os.system('rm -rf M100_combine_cube.image.mom1')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [1],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',<br />
includepix = [rms*5.5,100.],<br />
outfile = 'M100_combine_cube.image.mom1')<br />
--<br />
</source><br />
<br />
Now we can make some figures showing the moment maps (*note that this creates different looking files for me than the ones I have included here, which were made in the viewer -- is this true for others?*):<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom*.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.png')<br />
<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom1',<br />
'range': [1440,1695],'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]}, <br />
out='M100_combine_cube.image.mom1.png')<br />
--<br />
</source><br />
<br />
If you plan to use your moment 0 image to make measurements, it needs to be primary beam corrected first. First we need to subimage the .flux cube to extract a single plane that can be used to primary beam correct the moment 0 image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.flux.1ch')<br />
imsubimage(imagename='M100_combine_cube.flux',<br />
outfile='M100_combine_cube.flux.1ch',<br />
chans='35')<br />
</source><br />
<br />
Then primary beam correct the moment 0 image. This is the version that would be used for measurements, though the uncorrected one can be useful for figures. The difference is clear in the images seen below in the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor')<br />
immath(imagename=['M100_combine_cube.image.mom0', \<br />
'M100_combine_cube.flux.1ch'],<br />
expr='IM0/IM1',<br />
outfile='M100_combine_cube.image.mom0.pbcor')<br />
</source><br />
<br />
Have a look at the difference the primary beam correction makes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3},<br />
{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3}],<br />
zoom={'blc': [190,150],'trc': [650,610]})<br />
</source><br />
<br />
With the viewer open, you can flip back and forth between the images to compare them. Next, make a figure.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.pbcor.png')<br />
<br />
</source><br />
<br />
=== Comparison with 7m, 12m Moment Maps ===<br />
<br />
Below the moment maps from the 7m-only and the 12m-only data are shown for comparison. The moment maps were made using clean masks drawn by hand for comparison to the automasking technique; the two appear to be qualitatively similar. The range and scaling for the 12m-only figures are the same as that used for the 7m+12m figures for ease of comparison.<br />
<br />
As expected, the 7m+12m image shows considerably more extended emission than the 12m-only data and finer detail than the 7m-only data. For comparison, the 7m+12m synthesized beam is 3.80"x2.50", while the 12m-only beam is 3.46"x2.37" and the 7m-only beam is 12.72"x10.12".<br />
<br />
<gallery widths=300px heights=300px><br />
File:12m.png | Moment 0 for 12m data alone (no primary beam correction).<br />
File:7m_mom0.png | Moment 0 for 7m data alone (no primary beam correction).<br />
File:combined.png | Moment 0 for 12m+7m data (no primary beam correction).<br />
File:combine_pbcor.png | Moment 0 for 12m+7m data with primary beam correction.<br />
</gallery><br />
<br />
<gallery widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data alone.<br />
File:7m_mom1.png | Moment 1 for 7m data alone.<br />
File:combine_mom1.png | Moment 1 for 12m+7m data.<br />
</gallery><br />
<br />
=== Convert 7m+12m Images to Fits Format ===<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf *.fits')<br />
exportfits(imagename='M100_combine_cube.image',fitsimage='M100_combine_cube.image.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.flux',fitsimage='M100_combine_cube.flux.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0',fitsimage='M100_combine_cube.image.mom0.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0.pbcor',fitsimage='M100_combine_cube.image.mom0.pbcor.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom1',fitsimage='M100_combine_cube.image.mom1.fits')<br />
<br />
--<br />
</source><br />
<br />
= Feathering the Total Power and 7m+12m Interferometric Images=<br />
<br />
== Prepare Images for Feathering ==<br />
<br />
Regrid the TP image to match the shape of the 7m+12m image using the task {{imregrid}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid')<br />
imregrid(imagename='M100TP.CO.cube.bl.image',<br />
template='M100_combined_CO.image',<br />
axes=[0, 1],<br />
output='M100TP.CO.regrid')<br />
</source><br />
<br />
Make subimages of the (regridded) TP and 7m+12m images with the task {{imsubimage}}, excluding regions masked by the clean minpb=0.2 and noisy edge pixels in the TP image. The Viewer ({{viewer}}) can be used to determine a good joint region.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.image.subim')<br />
imsubimage(imagename='M100_combined_CO.image',<br />
outfile='M100_combined_CO.image.subim',<br />
box='219,148,612,579')<br />
os.system('rm -rf M100TP.CO.regrid.subim')<br />
imsubimage(imagename='M100TP.CO.regrid',<br />
outfile='M100TP.CO.regrid.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Create the subimage of the mosaic response as well.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Multiply the TP image by the mosaic beam response of the 7m+12m image using the task {{immath}}.<br />
The "primary-beam correction" can be done after the feathering process (see below).<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim.depb')<br />
immath(imagename=['M100TP.CO.regrid.subim',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0*IM1',<br />
outfile='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
== Feather TP Cube with 7m+12m Cube ==<br />
<br />
Run the {{feather}} task to combine the TP and 7m+12m images.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image')<br />
feather(imagename='M100_Feather_CO.image',<br />
highres='M100_combined_CO.image.subim',<br />
lowres='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
== Make Moment Maps of TP and Feathered Images ==<br />
<br />
We will use the same technique as the 7m+12m image analysis above to make moment maps.<br />
<br />
First, make moment maps for the (regridded) TP image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100TP.CO.regrid.subim'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom0')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100TP.CO.regrid.subim.mom0')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom1')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100TP.CO.regrid.subim.mom1')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom*.png')<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom0',<br />
'range': [0., 1080.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100TP.CO.regrid.subim.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100TP.CO.regrid.subim.mom1.png')<br />
</source><br />
<br />
Then make moment maps for the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100_Feather_CO.image'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100_Feather_CO.image.mom0')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom1')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100_Feather_CO.image.mom1')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom*.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100_Feather_CO.image.mom1.png')<br />
</source><br />
<br />
=== Correct the Primary Beam Response for the Moment 0 Image ===<br />
<br />
Apply the primary beam response to the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.1ch.subim')<br />
imsubimage(imagename='M100_combined_CO.flux.subim',<br />
outfile='M100_combined_CO.flux.1ch.subim',<br />
chans='35')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor')<br />
immath(imagename=['M100_Feather_CO.image.mom0',<br />
'M100_combined_CO.flux.1ch.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.mom0.pbcor')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0.pbcor',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.pbcor.png')<br />
</source><br />
<br />
=== Compare the Different Images ===<br />
<br />
Now lets compare all the different images:<br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_pbcor.png | Primary beam corrected moment 0 for the 12m data.<br />
File:7m_pbcor.png | Primary beam corrected moment 0 for the 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom0.png | Moment 0 for the TP data (UPDATE).<br />
File:combine_pbcor.png | Primary beam corrected moment 0 for 7m+12m data.<br />
File:M100_Feather_CO.mom0.pbcor.png | Primary beam corrected moment 0 for TP+7m+12m data (UPDATE).<br />
</gallery><br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data.<br />
File:7m_mom1.png | Moment 1 for 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom1.png | Moment 1 for the TP data (UPDATE).<br />
File:combine_mom1.png | Moment 1 for 7m+12m data.<br />
File:M100_Feather_CO.mom1.png | Moment 1 for TP+7m+12m data (UPDATE).<br />
</gallery><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_Combine_4.3&diff=16978M100 Band3 Combine 4.32015-05-25T22:26:04Z<p>Tsawada: /* Feathering the Total Power and 7m+12m Interferometric Images */</p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
= Overview =<br />
<br />
This guide describes how to combine the 7m and 12m interferometric data and then how to feather the resulting image with the total power TP image. All of the data for this SV project can be found at https://almascience.nrao.edu/alma-data/science-verification. The guide has been written for data reduced in CASA 4.3.0 or later and assumes that all calibration tables (Tsys and gain tables) have been applied to the visibility weights using calwt=True. If either of these is not the case for your data, '''do not follow this guide.''' <br />
<br />
In order to run this guide you will need to:<br />
<br />
* Either download the fully calibrated 7m data (i.e., M100_Band3_7m_CalibratedData.tgz) or download the uncalibrated 7m data and the relevant, standard calibration scripts available (here). An overview of the 7m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either download the fully calibrated 12m data (i.e. M100_Band3_12m_CalibratedData.tgz) or download the uncalibrated 12m data and the relevant, standard calibration scripts available (here). Note that this is a '''new''' calibration of the same data that were released previously, and so the data reduction path has been updated to current best practices and starts from the raw data files called ASDMs (ALMA Science Data Model). '''Do not use the previously released uncalibrated or calibrated data.''' An overview of the 12m data and its calibration is located at http://casaguides.nrao.edu/index.php?title=M100_Band3.<br />
<br />
* Either run the [[M100_Band3_SingleDish_4.3]] guide to calibrate and image the Total Power data or download the final image (i.e. M100_TP_Image.tgz)<br />
<br />
==Confirm your version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
= Combine and Image the 7m+12m Interferometric Data =<br />
<br />
<br />
== Split off CO spectral windows (SPWs) ==<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_*m.ms.listobs')<br />
listobs('M100_Band3_12m_CalibratedData.ms',listfile='m100_12m.ms.listobs')<br />
listobs('M100_Band3_7m_CalibratedData.ms',listfile='m100_7m.ms.listobs')<br />
</source><br />
<br />
Running the task "listobs" provides the setups used in the observations at a glance. Below are the first target scans of the 12m and 7m observations and the spectral window tables as generated by listobs. The six 7m data sets were taken with two slightly different correlator setups (one with four SPWs and the other with two SPWs), so the concatenated data set has six total SPWs. <br />
<br />
<pre style="background-color: #fffacd;"><br />
12m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
10-Aug-2011/19:38:05.8 - 19:50:22.8 11 1 M100 1500 [0,1,2,3] [6.05, 6.05, 6.05, 6.05] [CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (4 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 3840 TOPO 113726.419 488.281 1875000.0 114663.6750 1 XX YY<br />
1 3840 TOPO 111851.419 488.281 1875000.0 112788.6750 2 XX YY<br />
2 3840 TOPO 103663.431 -488.281 1875000.0 102726.1750 3 XX YY<br />
3 3840 TOPO 101850.931 -488.281 1875000.0 100913.6750 4 XX YY<br />
<br />
7m data:<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
17-Mar-2013/04:44:04.3 - 04:50:43.7 11 1 M100 261 [0,1,2,3] [10.1, 10.1, 10.1, 10.1] [OBSERVE_TARGET#ON_SOURCE]<br />
<br />
Spectral Windows: (6 unique spectral windows and 1 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs<br />
0 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
1 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
2 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
3 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
4 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 111798.250 488.281 1992187.5 112794.1000 1 XX YY<br />
5 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 113673.250 488.281 1992187.5 114669.1000 2 XX YY<br />
</pre><br />
<br />
<figure id="12m_mosaic.png"><br />
[[Image:12m_mosaic.png|300px|thumb|right|<caption>FOV of 12m mosaic.</caption>]]<br />
</figure><br />
<br />
<figure id="7m_mosaic.png"><br />
[[Image:7m_mosaic.png|300px|thumb|right|<caption>FOV of 7m mosaic.</caption>]]<br />
</figure><br />
<br />
Examination of the listobs files shows that the CO is in SPW='0' for the 12m data and in SPW='3,5' for the 7m data. There are two SPWs containing CO in the 7m data due to the slightly differing correlator setups.<br />
<br />
Also note that the integration time per visibility (average interval parameter in listobs) is different:<br />
6.05s for the 12m data and 10.1s for the 7m. This will be important to know later when we check the visibility weights. <br />
<br />
Next we split out the CO spectral windows.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf m100_12m_CO.ms')<br />
split(vis='M100_Band3_12m_CalibratedData.ms',<br />
outputvis='m100_12m_CO.ms',spw='0',field='M100',<br />
datacolumn='data',keepflags=False)<br />
os.system('rm -rf m100_7m_CO.ms')<br />
split(vis='M100_Band3_7m_CalibratedData.ms',<br />
outputvis='m100_7m_CO.ms',spw='3,5',field='M100',<br />
datacolumn='data',keepflags=False)<br />
</source><br />
<br />
Also of interest is that the 12m data has 47 fields and the 7m has 23 fields (not shown in the excerpts above). The difference in number of pointings is because the 7m antennas have a FWHP (full width half power) primary beam diameter that is 12/7 times larger than the 12m antennas. '''One easy way to see how the mosaics compare is to install the AnalysisUtils package (see [[Analysis_Utilities]])'''. Then with AnalysisUtils you can make the following plots (look at the listobs to obtain the sourceid):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *m_mosaic.png')<br />
au.plotmosaic('m100_12m_CO.ms',sourceid='0',figfile='12m_mosaic.png')<br />
au.plotmosaic('m100_7m_CO.ms',sourceid='0',figfile='7m_mosaic.png')<br />
</source><br />
<br />
We see that the mosaics cover a common area but that the 7m mosaic is a bit larger. This means that the outer edges of the combined mosaic will be noisier than expected if they overlapped perfectly; this is just something to keep in mind. If you had the case where the mosaic coverages are dramatically different, it would be best to exclude the completely non-overlapping fields from the combination.<br />
<br />
NOTE: At this stage one would typically do continuum subtraction (if there is any). However we already know from the individual data reductions that the 3mm continuum emission is quite weak and does not significantly contribute to a 5km/s channel, so we will forgo the the continuum subtraction step. Examples of how to do this if you are so inclined are located in various other ALMA CASAguides.<br />
<br />
== Checking the weights and concatenating the data ==<br />
<br />
<figure id="7m_WT.png"><br />
[[File:12m_WT.png|200px|thumb|right|<caption> 12m weights.</caption>]]<br />
</figure><br />
<br />
<figure id="12m_WT.png"><br />
[[File:7m_WT.png|200px|thumb|right|<caption> 7m weights.</caption>]]<br />
</figure><br />
<br />
When combining data with disparate properties it is very important that the relative weights of each visibility be in the correct proportion to the other data according to the radiometer equation. Formally, the<br />
visibility weights should be proportional to 1/sigma<sup>2</sup> where sigma is the variance or rms noise of a given visibility.<br />
<br />
Assuming that the 7m and 12m antennas have similar apperture and quantization efficiencies (a reasonable assumption since they were designed this way), the rms noise in a single channel for a single visibility is:<br />
<br />
<math> <br />
\sigma_{ij}=\frac{2k}{A_{eff}} <br />
</math><br />
<math> <br />
\sqrt{\frac{T_{sys,i} T_{sys,j}}{\Delta\nu_{ch} t_{ij}}},<br />
</math><br />
<br />
where k is Boltzmann's constant, A<sub>eff</sub> is the effective antenna area, T<sub>sys,i</sub> is the system temperature for antenna i, &Delta;&nu;<sub>ch</sub> is the channel width, and t<sub>ij</sub> is the integration time per visibility.<br />
<br />
CASA initially scales the weights by 2&Delta;&nu;<sub>ch</sub>&Delta;t<sub>ij</sub>, and after the Tsys table applycal step of the calibration process, it further scales the weights by 1/[(Tsys(i) * Tsys(j)] as long as calwt=True. In the subsequent gain calibration table applycal step of the calibration, the weights are further scaled by a factor of [(gain(i))<sup>2</sup> * (gain(j))<sup>2</sup>]. The gains should change very little from antenna to antenna, so this scaling is effectively the average gain<sup>4</sup> (again, as long as calwt=True). In the calibration scripts for all executions of the 12m and 7m data, found (here), both applycal steps set calwt=True. To verify, we plot the weights of the 7m and 12m data and measure their ratio to be, on average, 7m/12m ~ 0.055/0.3 ~ 0.18. Note that in the plots the points are colored by SPW, so there is only one 12m CO SPW but there are two 7m CO SPWs, and that no averaging can be turned on when plotting the weights. <br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf 7m_WT.png 12m_WT.png')<br />
plotms(vis='m100_12m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0:200',<br />
coloraxis='spw',plotfile='12m_WT.png')<br />
#<br />
plotms(vis='m100_7m_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~1:200',<br />
coloraxis='spw',plotfile='7m_WT.png')<br />
</source><br />
<br />
<figure id="combine_CO_WT.png"><br />
[[File:combine_CO_WT.png|200px|thumb|right|<caption> 7m and 12m weights after concatenation.</caption>]]<br />
</figure><br />
<br />
The two key things that are different between the 7m and 12m-array data are that the effective dish areas are different by (7/12)<sup>2</sup>, and the integration times are different by sqrt(10.1/6.05). Since dish area is in the numerator of the radiometer equation and integration time per visibility is in the denominator, and assuming the weight of an individual visibility is proportional to 1/sigma<sup>2</sup>, the ratio of the weights should be (7./12.)<sup>4</sup> x (10.1/6.05) = 0.19. This is very close to the value we measure for the ratio of the weights, particularly given that the 7m flux calibration relied on a source which changed substantially over the course of the six 7m-array observations. <br />
<br />
Now concatenate the two data sets and plot the concatenated weights to verify that they are as expected.<br />
<br />
<source lang="python"><br />
# In CASA<br />
# Concat and scale weights<br />
os.system('rm -rf M100_combine_CO.ms')<br />
concat(vis=['m100_12m_CO.ms','m100_7m_CO.ms'],<br />
concatvis='M100_combine_CO.ms')<br />
</source><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf combine_CO_WT.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='wt',xaxis='uvdist',spw='0~2:200',<br />
coloraxis='spw',plotfile='combine_CO_WT.png')<br />
</source><br />
<br />
Here, we create more instructive plots of the combined data to check that things are in order. (''Let each plot finish before cutting and pasting next plot. If plotms gui disappears, exit CASA and restart.'')<br />
<br />
<figure id="M100_combine_vel.png"><br />
[[File:M100_combine_vel.png|200px|thumb|right|<caption> Amplitude as a function of velocity.</caption>]]<br />
</figure><br />
<br />
To plot amplitude as a function of uv-distance, noting that the 7m data is noisier than the 12m data:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_uvdist.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='uvdist',spw='', avgscan=True,<br />
avgchannel='5000', coloraxis='spw',plotfile='M100_combine_uvdist.png') <br />
</source><br />
<br />
A fairer comparison of these data is achieved by isolating the brightest line channels in individual 12m and 7m data sets (i.e., not the concatenated data sets) and comparing only those channels in amplitude vs. uv-distance. Here the agreement is better, as it is less dominated by the scatter among the several 7m executions.<br />
<br />
To plot the CO line as a function of velocity (this plot takes a while):<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_vel.png')<br />
plotms(vis='M100_combine_CO.ms',yaxis='amp',xaxis='velocity',spw='', avgtime='1e8',avgscan=True,coloraxis='spw',avgchannel='5',<br />
transform=True,freqframe='LSRK',restfreq='115.271201800GHz', plotfile='M100_combine_vel.png')<br />
</source><br />
<br />
To see each spectral window independently in plotms, run the command again but remove the call to "plotfile" and add " iteraxis='spw' ".<br />
<br />
== Image Using An Automasking Technique ==<br />
<br />
The commands in this section perform an iterative automasking procedure down<br />
to a user specified threshold=stop*rms where stop is typically 2-3 using the imagemode='mosaic' mode of clean. This mode automatically calculates the correct convolution of the primary beam response of the mosaic when different antenna dish diameters are present. '''NOTE:''' even if these data had only been comprised of a single pointing of 7m and 12m-array data, the imagemode='mosaic' mode would be needed to correctly image data with different antenna sizes.<br />
<br />
The procedure outlined below takes some care to ensure that the generated masks (i) only have values of 0 or 1; (ii) are themselves masked at the minpb level. It also removes very small masked regions that are consistent with noise bumps using a function in scipy. A typical setting is to remove mask regions that are 1/2 the beam area in pixels. This is one technique under exploration for future pipeline use. <br />
<br />
The commands have been split into multiple sections to aid cut and paste. Wait until the current one is done before starting next section. '''If you stop CASA and restart you will need to cut and paste again from the Define Parameters section on down'''.<br />
<br />
For the long series of commands below it is important to include the '''beginning cpaste''' and '''ending --''' in your cut and paste.<br />
<br />
=== Define Parameters ===<br />
<br />
Note that the parameters used here are by design the same as those used to make the stand-alone 7m-array and 12m-array images. <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
<br />
### Initialize <br />
import scipy.ndimage <br />
<br />
### Define clean parameters<br />
vis='M100_combine_CO.ms'<br />
prename='M100_combine_cube'<br />
myimage=prename+'.image'<br />
myflux=prename+'.flux'<br />
mymask=prename+'.mask'<br />
myresidual=prename+'.residual'<br />
imsize=800<br />
cell='0.5arcsec'<br />
minpb=0.2<br />
restfreq='115.271201800GHz'<br />
outframe='LSRK'<br />
spw='0~2'<br />
width='5km/s'<br />
start='1400km/s'<br />
nchan=70<br />
robust=0.5<br />
phasecenter='J2000 12h22m54.9 +15d49m15'<br />
scales=[0]<br />
smallscalebias=0.6<br />
<br />
### Setup stopping criteria with multiplier for rms.<br />
stop=3. <br />
<br />
### Minimum size multiplier for beam area for removing very small mask regions. <br />
pixelmin=0.5 <br />
<br />
--<br />
</source><br />
<br />
=== Make Initial Dirty Image and Determine Synthesized Beam area===<br />
<br />
The dirty image is used to determine the initial peak flux density in the cube and the beam area is used to define the minimum size of masked regions in order to exclude noise bumps from the overall mask.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Make initial dirty image<br />
os.system('rm -rf '+prename+'.* ' +prename+'_*')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask='',<br />
niter=0,interactive=F)<br />
<br />
# Determine the beam area in pixels for later removal of very small mask regions<br />
major=imhead(imagename=myimage,mode='get',hdkey='beammajor')['value']<br />
minor=imhead(imagename=myimage,mode='get',hdkey='beamminor')['value']<br />
pixelsize=float(cell.split('arcsec')[0])<br />
beamarea=(major*minor*pi/(4*log(2)))/(pixelsize**2)<br />
print 'beamarea in pixels =', beamarea<br />
<br />
--<br />
</source><br />
<br />
=== Find properties of the dirty image ===<br />
<br />
For the long series of commands below it is important to include the beginning '''cpaste''' and ending '''--''' in your cut and paste.<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
### Find the peak in the dirty cube.<br />
myimage=prename+'.image'<br />
bigstat=imstat(imagename=myimage)<br />
peak= bigstat['max'][0]<br />
print 'peak (Jy/beam) in cube = '+str(peak)<br />
### Sets threshold of first loop, try 2-4. Subsequent loops are set thresh/2.<br />
thresh = peak / 4.<br />
<br />
### If True: find the rms in two line-free channels; If False: Set rms by hand in else statement.<br />
if True: <br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2) <br />
else:<br />
rms=0.011<br />
<br />
<br />
print 'rms (Jy/beam) in a channel = '+str(rms)<br />
--<br />
</source><br />
<br />
=== Automasking Loop ===<br />
<br />
On a reasonably fast computer the following will take a couple of hours for this spectral mosaic... <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf ' + prename +'_threshmask*')<br />
os.system('rm -rf ' + prename +'_fullmask*')<br />
os.system('rm -rf ' + prename +'.image*')<br />
n=-1<br />
while (thresh >= stop*rms): <br />
n=n+1<br />
print 'clean threshold this loop is', thresh<br />
threshmask = prename+'_threshmask' +str(n)<br />
maskim = prename+'_fullmask' +str(n)<br />
immath(imagename = [myresidual],<br />
outfile = threshmask,<br />
expr = 'iif(IM0 > '+str(thresh) +',1.0,0.0)',<br />
mask=myflux+'>'+str(minpb))<br />
if (n==0):<br />
os.system('cp -r '+threshmask+' '+maskim+'.pb')<br />
print 'This is the first loop'<br />
else:<br />
makemask(mode='copy',inpimage=myimage,<br />
inpmask=[threshmask,mymask],<br />
output=maskim)<br />
imsubimage(imagename=maskim, mask=myflux+'>'+str(minpb),<br />
outfile=maskim+'.pb') <br />
print 'Combined mask ' +maskim+' generated.'<br />
<br />
# Remove small masks<br />
os.system('cp -r '+maskim+'.pb ' +maskim+'.pb.min')<br />
maskfile=maskim+'.pb.min'<br />
ia.open(maskfile)<br />
mask=ia.getchunk() <br />
labeled,j=scipy.ndimage.label(mask) <br />
myhistogram = scipy.ndimage.measurements.histogram(labeled,0,j+1,j+1)<br />
object_slices = scipy.ndimage.find_objects(labeled)<br />
threshold=beamarea*pixelmin<br />
for i in range(j):<br />
if myhistogram[i+1]<threshold:<br />
mask[object_slices[i]] = 0<br />
<br />
<br />
ia.putchunk(mask)<br />
ia.done()<br />
print 'Small masks removed and ' +maskim +'.pb.min generated.'<br />
<br />
os.system('rm -rf '+mymask+'')<br />
clean(vis=vis,imagename=prename,<br />
imagermode='mosaic',ftmachine='mosaic',minpb=minpb,<br />
imsize=imsize,cell=cell,spw=spw,<br />
weighting='briggs',robust=robust,phasecenter=phasecenter,<br />
mode='velocity',width=width,start=start,nchan=nchan, <br />
restfreq=restfreq,outframe=outframe,veltype='radio',<br />
mask = maskim+'.pb.min',<br />
multiscale=scales,smallscalebias=smallscalebias,<br />
interactive = F,<br />
niter = 10000,<br />
threshold = str(thresh) +'Jy/beam')<br />
<br />
<br />
if thresh==stop*rms: break<br />
thresh = thresh/2.<br />
# Run a final time with stop*rms if more than a little above<br />
# stop*rms. Also make a back-up of next to last image<br />
if (thresh < stop*rms and thresh*2.>1.05*stop*rms):<br />
thresh=stop*rms <br />
os.system('cp -r '+myimage+' '+myimage+str(n))<br />
<br />
--<br />
</source><br />
<br />
=== Notes on the Automasking procedure ===<br />
<br />
This script is meant to be a possible stepping stone to optimal automasking -- it is by no means perfect and is certainly slower than optimal but feel free to try it with other datasets. Some notes below:<br />
<br />
In addition to the final prename.image (prename.flux etc) this script produces and keeps each iteration of the various mask files which will allow you to explore how the masking proceeded as the threshold for masking and cleaning was lowered. The ones denoted "prename. fullmask*.pb.min" are the ones used in the clean steps themselves. At the end of the process the final "prename. fullmask*.pb.min" will also be stored in the prename.mask. Once you've verified you are happy with the masking, you may want to remove the prename.threshmask* and prename.fullmask* files, as they can be large for large cubes. <br />
<br />
Additionally, before running the final loop with thresh=stop*rms the script copies the .image from the preceding clean to prename.image'n' where 'n' equals the loop number of the preceding step. So in this M100 example you will see a M100_combine_cube.image and a M100_combine_cube.image2 where .image is the final image and .image2 is the next to last image. This is done for convenience in the case that thresh=stop*rms is too deep such that clean diverges, you will still be left with the clean image from the preceding loop that you can further investigate to understand why clean diverged. If all goes well with the final loop, the prename.image'n' can also be deleted. Divergence at thresh=stop*rms is often a sign that the image is "dynamic range limited" in other words the rms in channels with bright emission is significantly worse than for a line-free channel.<br />
<br />
== Image Analysis for the 7m+12m Data ==<br />
<br />
=== Moment Maps for 7m+12m CO (1-0) Cube ===<br />
<br />
Start by examining the final image cube. Determine the start and stopping channels for the line emission -- this will be used in the "chans" parameter of immoments.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100_combine_cube.image')<br />
</source><br />
<br />
Next determine the rms noise per channel and use that to exclude pixels from the moment images. All images are shown in the gallery at the end of the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
myimage='M100_combine_cube.image'<br />
chanstat=imstat(imagename=myimage,chans='4')<br />
rms1= chanstat['rms'][0]<br />
chanstat=imstat(imagename=myimage,chans='66')<br />
rms2= chanstat['rms'][0]<br />
rms=0.5*(rms1+rms2)<br />
print 'rms in a channel = '+str(rms) <br />
</source><br />
<br />
Next make the moment maps. For the integrated intensity: moment 0, a 2 sigma cut often considerably improves the appearance of the image with little effect on the integrated intensity as long as emission free channels are excluded. For higher order moments it is necessary to exclude all low S/N data. Typically 5-6 sigma for the higher moments works well. We also apply further masking based on the .flux image because the edges of the combined mosaic are especially noisy because the 7m mosaic is somewhat larger than the 12m mosaic as described above (see Figures 1 & 2). <br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom0')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [0],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',,<br />
includepix = [rms*2,100.],<br />
outfile = 'M100_combine_cube.image.mom0')<br />
<br />
os.system('rm -rf M100_combine_cube.image.mom1')<br />
immoments(imagename = 'M100_combine_cube.image',<br />
moments = [1],<br />
axis = 'spectral',chans = '9~61',<br />
mask='M100_combine_cube.flux>0.3',<br />
includepix = [rms*5.5,100.],<br />
outfile = 'M100_combine_cube.image.mom1')<br />
--<br />
</source><br />
<br />
Now we can make some figures showing the moment maps (*note that this creates different looking files for me than the ones I have included here, which were made in the viewer -- is this true for others?*):<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf M100_combine_cube.image.mom*.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.png')<br />
<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom1',<br />
'range': [1440,1695],'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]}, <br />
out='M100_combine_cube.image.mom1.png')<br />
--<br />
</source><br />
<br />
If you plan to use your moment 0 image to make measurements, it needs to be primary beam corrected first. First we need to subimage the .flux cube to extract a single plane that can be used to primary beam correct the moment 0 image.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.flux.1ch')<br />
imsubimage(imagename='M100_combine_cube.flux',<br />
outfile='M100_combine_cube.flux.1ch',<br />
chans='35')<br />
</source><br />
<br />
Then primary beam correct the moment 0 image. This is the version that would be used for measurements, though the uncorrected one can be useful for figures. The difference is clear in the images seen below in the following section.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor')<br />
immath(imagename=['M100_combine_cube.image.mom0', \<br />
'M100_combine_cube.flux.1ch'],<br />
expr='IM0/IM1',<br />
outfile='M100_combine_cube.image.mom0.pbcor')<br />
</source><br />
<br />
Have a look at the difference the primary beam correction makes. <br />
<br />
<source lang="python"><br />
# In CASA<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0',<br />
'range': [-0.3,25.],'scaling': -1.3},<br />
{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3}],<br />
zoom={'blc': [190,150],'trc': [650,610]})<br />
</source><br />
<br />
With the viewer open, you can flip back and forth between the images to compare them. Next, make a figure.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf M100_combine_cube.image.mom0.pbcor.png')<br />
imview (raster=[{'file': 'M100_combine_cube.image.mom0.pbcor',<br />
'range': [-0.3,25.],'scaling': -1.3,'colorwedge': T}],<br />
zoom={'blc': [190,150],'trc': [650,610]},<br />
out='M100_combine_cube.image.mom0.pbcor.png')<br />
<br />
</source><br />
<br />
=== Comparison with 7m, 12m Moment Maps ===<br />
<br />
Below the moment maps from the 7m-only and the 12m-only data are shown for comparison. The moment maps were made using clean masks drawn by hand for comparison to the automasking technique; the two appear to be qualitatively similar. The range and scaling for the 12m-only figures are the same as that used for the 7m+12m figures for ease of comparison.<br />
<br />
As expected, the 7m+12m image shows considerably more extended emission than the 12m-only data and finer detail than the 7m-only data. For comparison, the 7m+12m synthesized beam is 3.80"x2.50", while the 12m-only beam is 3.46"x2.37" and the 7m-only beam is 12.72"x10.12".<br />
<br />
<gallery widths=300px heights=300px><br />
File:12m.png | Moment 0 for 12m data alone (no primary beam correction).<br />
File:7m_mom0.png | Moment 0 for 7m data alone (no primary beam correction).<br />
File:combined.png | Moment 0 for 12m+7m data (no primary beam correction).<br />
File:combine_pbcor.png | Moment 0 for 12m+7m data with primary beam correction.<br />
</gallery><br />
<br />
<gallery widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data alone.<br />
File:7m_mom1.png | Moment 1 for 7m data alone.<br />
File:combine_mom1.png | Moment 1 for 12m+7m data.<br />
</gallery><br />
<br />
=== Convert 7m+12m Images to Fits Format ===<br />
<br />
<source lang="python"><br />
# In CASA<br />
cpaste<br />
os.system('rm -rf *.fits')<br />
exportfits(imagename='M100_combine_cube.image',fitsimage='M100_combine_cube.image.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.flux',fitsimage='M100_combine_cube.flux.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0',fitsimage='M100_combine_cube.image.mom0.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom0.pbcor',fitsimage='M100_combine_cube.image.mom0.pbcor.fits')<br />
<br />
exportfits(imagename='M100_combine_cube.image.mom1',fitsimage='M100_combine_cube.image.mom1.fits')<br />
<br />
--<br />
</source><br />
<br />
= Feathering the Total Power and 7m+12m Interferometric Images=<br />
<br />
== Prepare Images for Feathering ==<br />
<br />
Regrid the TP image to match the shape of the 7m+12m image using the task {{imregrid}}.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid')<br />
imregrid(imagename='M100TP.CO.cube.bl.image',<br />
template='M100_combined_CO.image',<br />
axes=[0, 1],<br />
output='M100TP.CO.regrid')<br />
</source><br />
<br />
Make subimages of the (regridded) TP and 7m+12m images with the task {{imsubimage}}, excluding regions masked by the clean minpb=0.2 and noisy edge pixels in the TP image. The Viewer ({{viewer}}) can be used to determine a good joint region.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.image.subim')<br />
imsubimage(imagename='M100_combined_CO.image',<br />
outfile='M100_combined_CO.image.subim',<br />
box='219,148,612,579')<br />
os.system('rm -rf M100TP.CO.regrid.subim')<br />
imsubimage(imagename='M100TP.CO.regrid',<br />
outfile='M100TP.CO.regrid.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Create the subimage of the mosaic response as well.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.subim',<br />
box='219,148,612,579')<br />
</source><br />
<br />
Multiply the TP image by the mosaic beam response of the 7m+12m image using the task {{immath}}.<br />
The "primary-beam correction" can be done after the feathering process (see below).<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100TP.CO.regrid.subim.depb')<br />
immath(imagename=['M100TP.CO.regrid.subim',<br />
'M100_combined_CO.flux.subim'],<br />
expr='IM0*IM1',<br />
outfile='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
== Feather TP Cube with 7m+12m Cube ==<br />
<br />
Run the {{feather}} task to combine the TP and 7m+12m images.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_Feather_CO.image')<br />
feather(imagename='M100_Feather_CO.image',<br />
highres='M100_combined_CO.image.subim',<br />
lowres='M100TP.CO.regrid.subim.depb')<br />
</source><br />
<br />
== Make Moment Maps of TP and Feathered Images ==<br />
<br />
We will use the same technique as the 7m+12m image analysis above to make moment maps.<br />
<br />
First, make moment maps for the (regridded) TP image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100TP.CO.regrid.subim'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom0')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100TP.CO.regrid.subim.mom0')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom1')<br />
immoments(imagename='M100TP.CO.regrid.subim',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100TP.CO.regrid.subim.mom1')<br />
<br />
os.system('rm -rf M100TP.CO.regrid.subim.mom*.png')<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom0',<br />
'range': [0., 1080.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100TP.CO.regrid.subim.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100TP.CO.regrid.subim.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100TP.CO.regrid.subim.mom1.png')<br />
</source><br />
<br />
Then make moment maps for the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
myimage = 'M100_Feather_CO.image'<br />
chanstat = imstat(imagename=myimage,chans='4')<br />
rms1 = chanstat['rms'][0]<br />
chanstat = imstat(imagename=myimage,chans='66')<br />
rms2 = chanstat['rms'][0]<br />
rms = 0.5*(rms1+rms2) <br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*2., 50],<br />
outfile='M100_Feather_CO.image.mom0')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom1')<br />
immoments(imagename='M100_Feather_CO.image',<br />
moments=[1],<br />
axis='spectral',<br />
chans='10~61',<br />
includepix=[rms*5.5, 50],<br />
outfile='M100_Feather_CO.image.mom1')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom*.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.png')<br />
<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom1',<br />
'range': [1440, 1695],<br />
'colorwedge': T}], <br />
out='M100_Feather_CO.image.mom1.png')<br />
</source><br />
<br />
<br />
=== Correct the Primary Beam Response for the Moment 0 Image ===<br />
<br />
Apply the primary beam response to the feathered image.<br />
<br />
<source lang="python"><br />
#In CASA<br />
os.system('rm -rf M100_combined_CO.flux.1ch.subim')<br />
imsubimage(imagename='M100_combined_CO.flux',<br />
outfile='M100_combined_CO.flux.1ch.subim',<br />
box='219,148,612,579',<br />
chans='35')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor')<br />
immath(imagename=['M100_Feather_CO.image.mom0',<br />
'M100_combined_CO.flux.1ch.subim'],<br />
expr='IM0/IM1',<br />
outfile='M100_Feather_CO.image.mom0.pbcor')<br />
<br />
os.system('rm -rf M100_Feather_CO.image.mom0.pbcor.png')<br />
imview(raster=[{'file': 'M100_Feather_CO.image.mom0.pbcor',<br />
'range': [-0.3, 25.],<br />
'scaling': -1.0,<br />
'colorwedge': T}],<br />
out='M100_Feather_CO.image.mom0.pbcor.png')<br />
</source><br />
<br />
=== Compare the Different Images ===<br />
<br />
Now lets compare all the different images:<br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_pbcor.png | Primary beam corrected moment 0 for the 12m data.<br />
File:7m_pbcor.png | Primary beam corrected moment 0 for the 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom0.png | Moment 0 for the TP data (UPDATE).<br />
File:combine_pbcor.png | Primary beam corrected moment 0 for 7m+12m data.<br />
File:M100_Feather_CO.mom0.pbcor.png | Primary beam corrected moment 0 for TP+7m+12m data (UPDATE).<br />
</gallery><br />
<br />
<gallery perrow=3 widths=300px heights=300px><br />
File:12m_mom1.png | Moment 1 for 12m data.<br />
File:7m_mom1.png | Moment 1 for 7m data.<br />
File:TP_CO_cube_Jy.regrid.subim.mom1.png | Moment 1 for the TP data (UPDATE).<br />
File:combine_mom1.png | Moment 1 for 7m+12m data.<br />
File:M100_Feather_CO.mom1.png | Moment 1 for TP+7m+12m data (UPDATE).<br />
</gallery><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=16977M100 Band3 SingleDish 4.32015-05-22T17:20:18Z<p>Tsawada: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_SD_UncalibratedData.tgz from the ALMA Science Portal (not ready yet) <!-- [[M100_Band3#Obtaining_the_Data]] -->'''<br />
<br />
*'''Details of the ALMA observations are provided elsewhere (not ready yet) <!-- at [[M100_Band3]] --><br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see the guide for data combination (not ready yet)<!-- [[M100_Band3_Combine_4.3]] -->'''.<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page (not ready yet). <!-- , [[M100_Band3_Combine_4.3]] --><br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the lists of the Execution Block ID's of the amplitude calibrator and science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_ampcal = ['uid___A002_X85c183_X895', 'uid___A002_X8602fa_Xc3',<br />
'uid___A002_X864236_Xe1', 'uid___A002_X86fcfa_X3ae']<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_ampcal+basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an example of the (abridged) output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Observation: ALMA<br />
Data records: 76314 Total elapsed time = 2942.21 seconds<br />
Observed from 01-Jul-2014/21:51:26.2 to 01-Jul-2014/22:40:28.4 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
01-Jul-2014/21:51:26.2 - 21:53:29.5 1 0 J1215+1654 6087 [0,1,2,3,4,5,6,7,8] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:55:24.7 - 21:56:25.7 2 0 J1215+1654 6210 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE,CALIBRATE_SIDEBAND_RATIO#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:26.9 - 21:56:53.4 3 0 J1215+1654 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:56.8 - 21:57:17.6 4 0 J1215+1654 582 [0,17,18,19,20,21,22,23,24] [1.15, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01] [CALIBRATE_DELAY#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:58:22.1 - 21:58:47.4 5 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:59:41.6 - 22:07:36.2 6 1 M100 12216 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:07:54.6 - 22:09:19.9 7 1 M100 2202 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:09:38.3 - 22:10:03.6 8 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:10:25.5 - 22:18:19.0 9 1 M100 12207 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:18:38.6 - 22:20:39.6 10 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:20:56.8 - 22:21:23.3 11 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:21:44.1 - 22:29:38.7 12 1 M100 12204 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:30:23.6 - 22:32:24.6 13 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:33:29.1 - 22:33:54.4 14 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:34:19.8 - 22:40:28.4 15 1 M100 9474 [0, 17, 18, 19, 20, 21, 22, 23, 24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
(nRows = Total number of rows per scan) <br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X895, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you supposedly have run all 13 datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 13 datasets have been calibrated into units of Kelvins.<br />
The next step is to determine Jy/K conversion factors from the amplitude calibrator datasets (one per day and per SPW).<br />
This is done by imaging a source whose continuum flux is known and measuring the observed brightness temperature.<br />
The script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" performs this step for all four calibrator datasets (by running execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
The procedure to derive the Jy/K value for a single dataset (uid___A002_X85c183_X895) and single SPW (23) is detailed here, whereas all four datasets and four SPW's are processed using for-loops in the script.<br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
First set variables for the name of a calibrated dataset and a couple of parameters to predict the intrinsic beam size.<br />
The predicted beam size is used to determine the appropriate grid spacing and gridding convolution function to image the source.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msname = 'uid___A002_X85c183_X895.ms.cal'<br />
<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
</source><br />
<br />
Open a file to which the derived Jy/K values will be written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout = open(msname+'.JyPerK.txt', 'w')<br />
</source><br />
<br />
Obtain the spatial sampling of the data (spacings along and perpendicular to the scan direction, and the largest dimension in arcsec) using the function getTPSampling of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
xSampling, ySampling, maxsize = aU.getTPSampling(msname, showplot=False)<br />
</source><br />
<br />
Obtain the list of antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
antlist = msmd.antennanames()<br />
msmd.close()<br />
</source><br />
<br />
Specify a SPW for which the Jy/K value is derived.<br />
The center frequency of the SPW is obtained, and then the expected beam size is calculated using the function primaryBeamArcsec of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
spw = 23<br />
<br />
msmd.open(msname)<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
</source><br />
<br />
The cell spacing and size (i.e., pixel size and number of pixels) of the resulting map are determined from the estimated beam size and the dimension of the observed raster map pattern.<br />
The cell spacing is set to be 1/9 of the beam size, according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Obtain the ID and name of the field.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
fieldid = msmd.fieldsforspw(spw, False)[0]<br />
fieldname = msmd.fieldsforspw(spw, True)[0]<br />
msmd.close()<br />
<br />
phasecenter = fieldid<br />
</source><br />
<br />
Now the image of the source is made for each antenna using the task {{sdimaging}}.<br />
The gridding convolution function used is 'SF' (prolate spheroidal wave function) with the support of 6 cell spacings, also according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in antlist:<br />
sdimaging(infiles=msname,<br />
field=str(fieldname),<br />
spw='%d' % spw,<br />
antenna=ant,<br />
nchan=1,<br />
mode='channel',<br />
width='4080',<br />
gridfunction='SF',<br />
convsupport= 6,<br />
phasecenter=phasecenter,<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='%s.%s.spw%d.image' % (msname, ant, spw))<br />
</source><br />
<br />
The continuum flux of the source is obtained from the ALMA source catalog using the function getALMAFluxForMS of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
srcflux = aU.getALMAFluxForMS(msname,<br />
field=fieldname,<br />
spw=str(spw))[fieldname]['fluxDensity']<br />
</source><br />
<br />
Finally derive the Jy/K values by comparing the flux of the source (in Jy) with the observed brightness temperature (in K).<br />
In the case of this guide the amplitude calibrator is a point source (quasar 3C279), and hence the Jy/K value is simply estimated by the ratio between the source flux obtained above and the peak brightness temperature determined using the task {{imstat}}.<br />
Note that if the amplitude calibrator is a planet, the correction for the source size (multiplying the ratio between the areas of planet-deconvolved beam and apparent beam) is necessary.<br />
This process is not written in the code presented here, but implemented in the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]".<br />
<br />
<source lang="python"><br />
# In CASA<br />
jyperklist = []<br />
for ant in antlist:<br />
peak = imstat('%s.%s.spw%d.image' % (msname, ant, spw))['max'][0]<br />
fwhm = aU.getfwhm2('%s.%s.spw%d.image' % (msname, ant, spw))<br />
jyperk = srcflux/peak<br />
print 'SPW%d %s Jy/K = %.2f' % (spw, ant, jyperk)<br />
fout.write('%d\t%s\t%.2f\n' % (spw, ant, jyperk))<br />
jyperklist.append(jyperk)<br />
<br />
print '### SPW%d mean Jy/K = %.2f ###' % (spw, pl.mean(jyperklist))<br />
fout.write('%d\t%s\t%.2f\n' % (spw, 'mean', pl.mean(jyperklist)))<br />
</source><br />
<br />
Finally close the file in which the Jy/K values were written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout.close()<br />
</source><br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the observatory cannot guarantee that all the antennas used in the Science observations are also available for the corresponding AmpCal observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271204GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271201800GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100.CO.cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100.CO.cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100.CO.cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100.CO.cube.image',<br />
linefile='M100.CO.cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100.CO.cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100.CO.cube.bl.image.mom0')<br />
immoments(imagename='M100.CO.cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100.CO.cube.bl.image.mom0')<br />
<br />
viewer('M100.CO.cube.bl.image.mom0')<br />
</source><br />
<br />
{{Checked 4.3.0}}</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=16976M100 Band3 SingleDish 4.32015-05-22T15:57:04Z<p>Tsawada: /* Calibration into Brightness Temperature in Kelvins */</p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_SD_UncalibratedData.tgz from the ALMA Science Portal (not ready yet) <!-- [[M100_Band3#Obtaining_the_Data]] -->'''<br />
<br />
*'''Details of the ALMA observations are provided elsewhere (not ready yet) <!-- at [[M100_Band3]] --><br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see the guide for data combination (not ready yet)<!-- [[M100_Band3_Combine_4.3]] -->'''.<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page (not ready yet). <!-- , [[M100_Band3_Combine_4.3]] --><br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the lists of the Execution Block ID's of the amplitude calibrator and science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_ampcal = ['uid___A002_X85c183_X895', 'uid___A002_X8602fa_Xc3',<br />
'uid___A002_X864236_Xe1', 'uid___A002_X86fcfa_X3ae']<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X2d4.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_ampcal+basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an example of the (abridged) output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Observation: ALMA<br />
Data records: 76314 Total elapsed time = 2942.21 seconds<br />
Observed from 01-Jul-2014/21:51:26.2 to 01-Jul-2014/22:40:28.4 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
01-Jul-2014/21:51:26.2 - 21:53:29.5 1 0 J1215+1654 6087 [0,1,2,3,4,5,6,7,8] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:55:24.7 - 21:56:25.7 2 0 J1215+1654 6210 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE,CALIBRATE_SIDEBAND_RATIO#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:26.9 - 21:56:53.4 3 0 J1215+1654 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:56.8 - 21:57:17.6 4 0 J1215+1654 582 [0,17,18,19,20,21,22,23,24] [1.15, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01] [CALIBRATE_DELAY#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:58:22.1 - 21:58:47.4 5 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:59:41.6 - 22:07:36.2 6 1 M100 12216 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:07:54.6 - 22:09:19.9 7 1 M100 2202 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:09:38.3 - 22:10:03.6 8 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:10:25.5 - 22:18:19.0 9 1 M100 12207 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:18:38.6 - 22:20:39.6 10 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:20:56.8 - 22:21:23.3 11 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:21:44.1 - 22:29:38.7 12 1 M100 12204 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:30:23.6 - 22:32:24.6 13 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:33:29.1 - 22:33:54.4 14 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:34:19.8 - 22:40:28.4 15 1 M100 9474 [0, 17, 18, 19, 20, 21, 22, 23, 24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
(nRows = Total number of rows per scan) <br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X895, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you supposedly have run all 13 datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 13 datasets have been calibrated into units of Kelvins.<br />
The next step is to determine Jy/K conversion factors from the amplitude calibrator datasets (one per day and per SPW).<br />
This is done by imaging a source whose continuum flux is known and measuring the observed brightness temperature.<br />
The script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" performs this step for all four calibrator datasets (by running execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
The procedure to derive the Jy/K value for a single dataset (uid___A002_X85c183_X895) and single SPW (23) is detailed here, whereas all four datasets and four SPW's are processed using for-loops in the script.<br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
First set variables for the name of a calibrated dataset and a couple of parameters to predict the intrinsic beam size.<br />
The predicted beam size is used to determine the appropriate grid spacing and gridding convolution function to image the source.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msname = 'uid___A002_X85c183_X895.ms.cal'<br />
<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
</source><br />
<br />
Open a file to which the derived Jy/K values will be written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout = open(msname+'.JyPerK.txt', 'w')<br />
</source><br />
<br />
Obtain the spatial sampling of the data (spacings along and perpendicular to the scan direction, and the largest dimension in arcsec) using the function getTPSampling of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
xSampling, ySampling, maxsize = aU.getTPSampling(msname, showplot=False)<br />
</source><br />
<br />
Obtain the list of antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
antlist = msmd.antennanames()<br />
msmd.close()<br />
</source><br />
<br />
Specify a SPW for which the Jy/K value is derived.<br />
The center frequency of the SPW is obtained, and then the expected beam size is calculated using the function primaryBeamArcsec of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
spw = 23<br />
<br />
msmd.open(msname)<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
</source><br />
<br />
The cell spacing and size (i.e., pixel size and number of pixels) of the resulting map are determined from the estimated beam size and the dimension of the observed raster map pattern.<br />
The cell spacing is set to be 1/9 of the beam size, according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Obtain the ID and name of the field.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
fieldid = msmd.fieldsforspw(spw, False)[0]<br />
fieldname = msmd.fieldsforspw(spw, True)[0]<br />
msmd.close()<br />
<br />
phasecenter = fieldid<br />
</source><br />
<br />
Now the image of the source is made for each antenna using the task {{sdimaging}}.<br />
The gridding convolution function used is 'SF' (prolate spheroidal wave function) with the support of 6 cell spacings, also according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in antlist:<br />
sdimaging(infiles=msname,<br />
field=str(fieldname),<br />
spw='%d' % spw,<br />
antenna=ant,<br />
nchan=1,<br />
mode='channel',<br />
width='4080',<br />
gridfunction='SF',<br />
convsupport= 6,<br />
phasecenter=phasecenter,<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='%s.%s.spw%d.image' % (msname, ant, spw))<br />
</source><br />
<br />
The continuum flux of the source is obtained from the ALMA source catalog using the function getALMAFluxForMS of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
srcflux = aU.getALMAFluxForMS(msname,<br />
field=fieldname,<br />
spw=str(spw))[fieldname]['fluxDensity']<br />
</source><br />
<br />
Finally derive the Jy/K values by comparing the flux of the source (in Jy) with the observed brightness temperature (in K).<br />
In the case of this guide the amplitude calibrator is a point source (quasar 3C279), and hence the Jy/K value is simply estimated by the ratio between the source flux obtained above and the peak brightness temperature determined using the task {{imstat}}.<br />
Note that if the amplitude calibrator is a planet, the correction for the source size (multiplying the ratio between the areas of planet-deconvolved beam and apparent beam) is necessary.<br />
This process is not written in the code presented here, but implemented in the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]".<br />
<br />
<source lang="python"><br />
# In CASA<br />
jyperklist = []<br />
for ant in antlist:<br />
peak = imstat('%s.%s.spw%d.image' % (msname, ant, spw))['max'][0]<br />
fwhm = aU.getfwhm2('%s.%s.spw%d.image' % (msname, ant, spw))<br />
jyperk = srcflux/peak<br />
print 'SPW%d %s Jy/K = %.2f' % (spw, ant, jyperk)<br />
fout.write('%d\t%s\t%.2f\n' % (spw, ant, jyperk))<br />
jyperklist.append(jyperk)<br />
<br />
print '### SPW%d mean Jy/K = %.2f ###' % (spw, pl.mean(jyperklist))<br />
fout.write('%d\t%s\t%.2f\n' % (spw, 'mean', pl.mean(jyperklist)))<br />
</source><br />
<br />
Finally close the file in which the Jy/K values were written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout.close()<br />
</source><br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the observatory cannot guarantee that all the antennas used in the Science observations are also available for the corresponding AmpCal observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271204GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271204GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100.CO.cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100.CO.cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100.CO.cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100.CO.cube.image',<br />
linefile='M100.CO.cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100.CO.cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100.CO.cube.bl.image.mom0')<br />
immoments(imagename='M100.CO.cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100.CO.cube.bl.image.mom0')<br />
<br />
viewer('M100.CO.cube.bl.image.mom0')<br />
</source></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=16821M100 Band3 SingleDish 4.32015-04-29T15:25:00Z<p>Tsawada: </p>
<hr />
<div>[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_SD_UncalibratedData.tgz from the ALMA Science Portal (not ready yet) <!-- [[M100_Band3#Obtaining_the_Data]] -->'''<br />
<br />
*'''Details of the ALMA observations are provided elsewhere (not ready yet) <!-- at [[M100_Band3]] --><br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see the guide for data combination (not ready yet)<!-- [[M100_Band3_Combine_4.3]] -->'''.<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page (not ready yet). <!-- , [[M100_Band3_Combine_4.3]] --><br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the lists of the Execution Block ID's of the amplitude calibrator and science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_ampcal = ['uid___A002_X85c183_X895', 'uid___A002_X8602fa_Xc3',<br />
'uid___A002_X864236_Xe1', 'uid___A002_X86fcfa_X3ae']<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
The following piece of code executes these scripts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for basename in basename_ampcal+basename_science:<br />
scriptname = basename[6:]+'.ms.scriptForSDCalibration.py'<br />
if basename == 'uid___A002_X85c183_X36f':<br />
print 'Calibration procedure for %s is described in the Guide.' % basename<br />
print 'Please go through the Guide, '<br />
print 'or run execfile("%s") instead.' % scriptname<br />
else:<br />
print 'Calibrating %s ...' % basename<br />
execfile(scriptname)<br />
</source><br />
<br />
== Import the Data ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an example of the (abridged) output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Observation: ALMA<br />
Data records: 76314 Total elapsed time = 2942.21 seconds<br />
Observed from 01-Jul-2014/21:51:26.2 to 01-Jul-2014/22:40:28.4 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
01-Jul-2014/21:51:26.2 - 21:53:29.5 1 0 J1215+1654 6087 [0,1,2,3,4,5,6,7,8] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:55:24.7 - 21:56:25.7 2 0 J1215+1654 6210 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE,CALIBRATE_SIDEBAND_RATIO#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:26.9 - 21:56:53.4 3 0 J1215+1654 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:56.8 - 21:57:17.6 4 0 J1215+1654 582 [0,17,18,19,20,21,22,23,24] [1.15, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01] [CALIBRATE_DELAY#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:58:22.1 - 21:58:47.4 5 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:59:41.6 - 22:07:36.2 6 1 M100 12216 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:07:54.6 - 22:09:19.9 7 1 M100 2202 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:09:38.3 - 22:10:03.6 8 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:10:25.5 - 22:18:19.0 9 1 M100 12207 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:18:38.6 - 22:20:39.6 10 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:20:56.8 - 22:21:23.3 11 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:21:44.1 - 22:29:38.7 12 1 M100 12204 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:30:23.6 - 22:32:24.6 13 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:33:29.1 - 22:33:54.4 14 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:34:19.8 - 22:40:28.4 15 1 M100 9474 [0, 17, 18, 19, 20, 21, 22, 23, 24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
(nRows = Total number of rows per scan) <br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X895, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you supposedly have run all 13 datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 13 datasets have been calibrated into units of Kelvins.<br />
The next step is to determine Jy/K conversion factors from the amplitude calibrator datasets (one per day and per SPW).<br />
This is done by imaging a source whose continuum flux is known and measuring the observed brightness temperature.<br />
The script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" performs this step for all four calibrator datasets (by running execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
The procedure to derive the Jy/K value for a single dataset (uid___A002_X85c183_X895) and single SPW (23) is detailed here, whereas all four datasets and four SPW's are processed using for-loops in the script.<br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
First set variables for the name of a calibrated dataset and a couple of parameters to predict the intrinsic beam size.<br />
The predicted beam size is used to determine the appropriate grid spacing and gridding convolution function to image the source.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msname = 'uid___A002_X85c183_X895.ms.cal'<br />
<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
</source><br />
<br />
Open a file to which the derived Jy/K values will be written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout = open(msname+'.JyPerK.txt', 'w')<br />
</source><br />
<br />
Obtain the spatial sampling of the data (spacings along and perpendicular to the scan direction, and the largest dimension in arcsec) using the function getTPSampling of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
xSampling, ySampling, maxsize = aU.getTPSampling(msname, showplot=False)<br />
</source><br />
<br />
Obtain the list of antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
antlist = msmd.antennanames()<br />
msmd.close()<br />
</source><br />
<br />
Specify a SPW for which the Jy/K value is derived.<br />
The center frequency of the SPW is obtained, and then the expected beam size is calculated using the function primaryBeamArcsec of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
spw = 23<br />
<br />
msmd.open(msname)<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
</source><br />
<br />
The cell spacing and size (i.e., pixel size and number of pixels) of the resulting map are determined from the estimated beam size and the dimension of the observed raster map pattern.<br />
The cell spacing is set to be 1/9 of the beam size, according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Obtain the ID and name of the field.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
fieldid = msmd.fieldsforspw(spw, False)[0]<br />
fieldname = msmd.fieldsforspw(spw, True)[0]<br />
msmd.close()<br />
<br />
phasecenter = fieldid<br />
</source><br />
<br />
Now the image of the source is made for each antenna using the task {{sdimaging}}.<br />
The gridding convolution function used is 'SF' (prolate spheroidal wave function) with the support of 6 cell spacings, also according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in antlist:<br />
sdimaging(infiles=msname,<br />
field=str(fieldname),<br />
spw='%d' % spw,<br />
antenna=ant,<br />
nchan=1,<br />
mode='channel',<br />
width='4080',<br />
gridfunction='SF',<br />
convsupport= 6,<br />
phasecenter=phasecenter,<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='%s.%s.spw%d.image' % (msname, ant, spw))<br />
</source><br />
<br />
The continuum flux of the source is obtained from the ALMA source catalog using the function getALMAFluxForMS of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
srcflux = aU.getALMAFluxForMS(msname,<br />
field=fieldname,<br />
spw=str(spw))[fieldname]['fluxDensity']<br />
</source><br />
<br />
Finally derive the Jy/K values by comparing the flux of the source (in Jy) with the observed brightness temperature (in K).<br />
In the case of this guide the amplitude calibrator is a point source (quasar 3C279), and hence the Jy/K value is simply estimated by the ratio between the source flux obtained above and the peak brightness temperature determined using the task {{imstat}}.<br />
Note that if the amplitude calibrator is a planet, the correction for the source size (multiplying the ratio between the areas of planet-deconvolved beam and apparent beam) is necessary.<br />
This process is not written in the code presented here, but implemented in the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]".<br />
<br />
<source lang="python"><br />
# In CASA<br />
jyperklist = []<br />
for ant in antlist:<br />
peak = imstat('%s.%s.spw%d.image' % (msname, ant, spw))['max'][0]<br />
fwhm = aU.getfwhm2('%s.%s.spw%d.image' % (msname, ant, spw))<br />
jyperk = srcflux/peak<br />
print 'SPW%d %s Jy/K = %.2f' % (spw, ant, jyperk)<br />
fout.write('%d\t%s\t%.2f\n' % (spw, ant, jyperk))<br />
jyperklist.append(jyperk)<br />
<br />
print '### SPW%d mean Jy/K = %.2f ###' % (spw, pl.mean(jyperklist))<br />
fout.write('%d\t%s\t%.2f\n' % (spw, 'mean', pl.mean(jyperklist)))<br />
</source><br />
<br />
Finally close the file in which the Jy/K values were written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout.close()<br />
</source><br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the observatory cannot guarantee that all the antennas used in the Science observations are also available for the corresponding AmpCal observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271204GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271204GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100.CO.cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100.CO.cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100.CO.cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100.CO.cube.image',<br />
linefile='M100.CO.cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100.CO.cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100.CO.cube.bl.image.mom0')<br />
immoments(imagename='M100.CO.cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100.CO.cube.bl.image.mom0')<br />
<br />
viewer('M100.CO.cube.bl.image.mom0')<br />
</source></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=16818M100 Band3 SingleDish 4.32015-04-28T20:54:18Z<p>Tsawada: </p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
M100 Single Dish Data Reduction (under modification)<br />
[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_SD_UncalibratedData.tgz from [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[M100_Band3_Combine_4.3]]'''.<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page, [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the lists of the Execution Block ID's of the amplitude calibrator and science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_ampcal = ['uid___A002_X85c183_X895', 'uid___A002_X8602fa_Xc3',<br />
'uid___A002_X864236_Xe1', 'uid___A002_X86fcfa_X3ae']<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002_X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets also need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
<br />
== Create Measurement Sets ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an example of the (abridged) output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Observation: ALMA<br />
Data records: 76314 Total elapsed time = 2942.21 seconds<br />
Observed from 01-Jul-2014/21:51:26.2 to 01-Jul-2014/22:40:28.4 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
01-Jul-2014/21:51:26.2 - 21:53:29.5 1 0 J1215+1654 6087 [0,1,2,3,4,5,6,7,8] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:55:24.7 - 21:56:25.7 2 0 J1215+1654 6210 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE,CALIBRATE_SIDEBAND_RATIO#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:26.9 - 21:56:53.4 3 0 J1215+1654 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:56.8 - 21:57:17.6 4 0 J1215+1654 582 [0,17,18,19,20,21,22,23,24] [1.15, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01] [CALIBRATE_DELAY#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:58:22.1 - 21:58:47.4 5 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:59:41.6 - 22:07:36.2 6 1 M100 12216 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:07:54.6 - 22:09:19.9 7 1 M100 2202 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:09:38.3 - 22:10:03.6 8 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:10:25.5 - 22:18:19.0 9 1 M100 12207 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:18:38.6 - 22:20:39.6 10 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:20:56.8 - 22:21:23.3 11 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:21:44.1 - 22:29:38.7 12 1 M100 12204 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:30:23.6 - 22:32:24.6 13 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:33:29.1 - 22:33:54.4 14 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:34:19.8 - 22:40:28.4 15 1 M100 9474 [0, 17, 18, 19, 20, 21, 22, 23, 24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
(nRows = Total number of rows per scan) <br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X895, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you supposedly have run all 13 datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 13 datasets have been calibrated into units of Kelvins.<br />
The next step is to determine Jy/K conversion factors from the amplitude calibrator datasets (one per day and per SPW).<br />
This is done by imaging a source whose continuum flux is known and measuring the observed brightness temperature.<br />
The script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" performs this step for all four calibrator datasets (by running execfile('ScriptForImagingAmpCalAndDerivingJyPerK.py') in CASA).<br />
The procedure to derive the Jy/K value for a single dataset (uid___A002_X85c183_X895) and single SPW (23) is detailed here, whereas all four datasets and four SPW's are processed using for-loops in the script.<br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
First set variables for the name of a calibrated dataset and a couple of parameters to predict the intrinsic beam size.<br />
The predicted beam size is used to determine the appropriate grid spacing and gridding convolution function to image the source.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msname = 'uid___A002_X85c183_X895.ms.cal'<br />
<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
</source><br />
<br />
Open a file to which the derived Jy/K values will be written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout = open(msname+'.JyPerK.txt', 'w')<br />
</source><br />
<br />
Obtain the spatial sampling of the data (spacings along and perpendicular to the scan direction, and the largest dimension in arcsec) using the function getTPSampling of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
xSampling, ySampling, maxsize = aU.getTPSampling(msname, showplot=False)<br />
</source><br />
<br />
Obtain the list of antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
antlist = msmd.antennanames()<br />
msmd.close()<br />
</source><br />
<br />
Specify a SPW for which the Jy/K value is derived.<br />
The center frequency of the SPW is obtained, and then the expected beam size is calculated using the function primaryBeamArcsec of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
spw = 23<br />
<br />
msmd.open(msname)<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
</source><br />
<br />
The cell spacing and size (i.e., pixel size and number of pixels) of the resulting map are determined from the estimated beam size and the dimension of the observed raster map pattern.<br />
The cell spacing is set to be 1/9 of the beam size, according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Obtain the ID and name of the field.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
fieldid = msmd.fieldsforspw(spw, False)[0]<br />
fieldname = msmd.fieldsforspw(spw, True)[0]<br />
msmd.close()<br />
<br />
phasecenter = fieldid<br />
</source><br />
<br />
Now the image of the source is made for each antenna using the task {{sdimaging}}.<br />
The gridding convolution function used is 'SF' (prolate spheroidal wave function) with the support of 6 cell spacings, also according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in antlist:<br />
sdimaging(infiles=msname,<br />
field=str(fieldname),<br />
spw='%d' % spw,<br />
antenna=ant,<br />
nchan=1,<br />
mode='channel',<br />
width='4080',<br />
gridfunction='SF',<br />
convsupport= 6,<br />
phasecenter=phasecenter,<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='%s.%s.spw%d.image' % (msname, ant, spw))<br />
</source><br />
<br />
The continuum flux of the source is obtained from the ALMA source catalog using the function getALMAFluxForMS of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
srcflux = aU.getALMAFluxForMS(msname,<br />
field=fieldname,<br />
spw=str(spw))[fieldname]['fluxDensity']<br />
</source><br />
<br />
Finally derive the Jy/K values by comparing the flux of the source (in Jy) with the observed brightness temperature (in K).<br />
In the case of this guide the amplitude calibrator is a point source (quasar 3C279), and hence the Jy/K value is simply estimated by the ratio between the source flux obtained above and the peak brightness temperature determined using the task {{imstat}}.<br />
Note that if the amplitude calibrator is a planet, the correction for the source size (multiplying the ratio between the areas of planet-deconvolved beam and apparent beam) is necessary.<br />
This process is not written in the code presented here, but implemented in the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]".<br />
<br />
<source lang="python"><br />
# In CASA<br />
jyperklist = []<br />
for ant in antlist:<br />
peak = imstat('%s.%s.spw%d.image' % (msname, ant, spw))['max'][0]<br />
fwhm = aU.getfwhm2('%s.%s.spw%d.image' % (msname, ant, spw))<br />
jyperk = srcflux/peak<br />
print 'SPW%d %s Jy/K = %.2f' % (spw, ant, jyperk)<br />
fout.write('%d\t%s\t%.2f\n' % (spw, ant, jyperk))<br />
jyperklist.append(jyperk)<br />
<br />
print '### SPW%d mean Jy/K = %.2f ###' % (spw, pl.mean(jyperklist))<br />
fout.write('%d\t%s\t%.2f\n' % (spw, 'mean', pl.mean(jyperklist)))<br />
</source><br />
<br />
Finally close the file in which the Jy/K values were written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout.close()<br />
</source><br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the observatory cannot guarantee that all the antennas used in the Science observations are also available for the corresponding AmpCal observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]" (run execfile('ScriptForJyPerKConversion.py') in CASA).<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]" (run execfile('ScriptForImagingScienceTarget.py') in CASA).<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271204GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271204GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100.CO.cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100.CO.cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100.CO.cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100.CO.cube.image',<br />
linefile='M100.CO.cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100.CO.cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100.CO.cube.bl.image.mom0')<br />
immoments(imagename='M100.CO.cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100.CO.cube.bl.image.mom0')<br />
<br />
viewer('M100.CO.cube.bl.image.mom0')<br />
</source></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=M100_Band3_SingleDish_4.3&diff=16816M100 Band3 SingleDish 4.32015-04-28T20:42:11Z<p>Tsawada: </p>
<hr />
<div><div style="background-color:#E0FFFF;border:4px solid #FF9966;"><br />
<div style="font-size:250%; color:red; text-align:center;"><br />
This page is currently under construction.<br />
</div><br />
<div style="font-size:200%; color:black; text-align:center"><br />
DO NOT USE IT.<br />
</div><br />
<div style="font-size:150%; color:black; text-align:center"><br />
To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/<br />
casaguides.nrao.edu<br />
]<br />
</div><br />
</div><br />
<br />
M100 Single Dish Data Reduction (under modification)<br />
[[Category:ALMA]][[Category:Calibration]][[Category:Spectral Line]]<br />
*'''This guide requires CASA 4.3 and assumes that you have downloaded M100_Band3_SD_UncalibratedData.tgz from [[M100_Band3#Obtaining_the_Data]]'''<br />
<br />
*'''Details of the ALMA observations are provided at [[M100_Band3]]<br />
<br />
*'''This portion of the guide covers calibration of the raw visibility data. To skip to the imaging portion of the guide, see: [[M100_Band3_Combine_4.3]]'''.<br />
<br />
= Overview =<br />
<br />
This portion of CASA Guide will cover the data reduction of the Total Power (TP) array observations of M100.<br />
The data consist of "amplitude calibrator" datasets (containing observational data of the quasar 3C279) and "science" datasets containing data for the science target M100.<br />
The data are reduced in the following steps:<br />
* Both the amplitude calibrator and science datasets are calibrated into units of Kelvins.<br />
* The radio continuum emission from 3C279 in the amplitude calibrator data are used to derive the Jansky/Kelvin (Jy/K) factors for individual days and frequencies (spectral windows).<br />
* Using the derived Jy/K values, the science data are calibrated into Jy/beam units.<br />
* The calibrated science data are imaged into a data cube.<br />
The combination of the resultant image with the interferometric (12-m array and 7-m array) data is explained in a separate page, [[M100_Band3_Combine_4.3]].<br />
<br />
This guide is designed for CASA 4.3.0.<br />
<br />
==Confirm Your Version of CASA==<br />
<br />
This guide has been written for CASA release 4.3.0. Please confirm your version before proceeding.<br />
<source lang="python"><br />
# In CASA<br />
version = casadef.casa_version<br />
print "You are using " + version<br />
if (version < '4.3.0'):<br />
print "YOUR VERSION OF CASA IS TOO OLD FOR THIS GUIDE."<br />
print "PLEASE UPDATE IT BEFORE PROCEEDING."<br />
else:<br />
print "Your version of CASA is appropriate for this guide."<br />
</source><br />
<br />
== Import "Analysis Utilities" ==<br />
<br />
The [[Analysis_Utilities]] package will be used for the following processes.<br />
Import the package and instantiate the stuffForScienceDataReduction class therein.<br />
<br />
<source lang="python"><br />
# In CASA<br />
import analysisUtils as aU<br />
es = aU.stuffForScienceDataReduction()<br />
</source><br />
<br />
== Summary of Datasets ==<br />
<br />
The observations were made on the 1st, 5th, 7th, and 17th July 2014, using two or three 12-m antennas and the ACA correlator.<br />
The table below indicates the ID's of the Execution Blocks, their start and end times, and the antennas in the array.<br />
There are four amplitude calibrator datasets (i.e., one per day) and nine science datasets (i.e., two or three per day).<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Amplitude Calibrator<br />
uid___A002_X85c183_X895 Observed from 2014-07-01T23:35:23.1 to 2014-07-02T00:07:54.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_Xc3 Observed from 2014-07-05T23:21:25.6 to 2014-07-05T23:53:41.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_Xe1 Observed from 2014-07-07T22:27:35.4 to 2014-07-07T23:01:05.7 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_X3ae Observed from 2014-07-17T21:48:30.0 to 2014-07-17T22:20:52.2 (UTC) DV10, PM03, PM04<br />
#Science<br />
uid___A002_X85c183_X36f Observed from 2014-07-01T21:51:26.2 to 2014-07-01T22:40:28.4 (UTC) DA61, PM03, PM04<br />
uid___A002_X85c183_X60b Observed from 2014-07-01T22:43:50.0 to 2014-07-01T23:32:39.6 (UTC) DA61, PM03, PM04<br />
uid___A002_X8602fa_X2ab Observed from 2014-07-05T23:58:03.6 to 2014-07-06T00:46:52.0 (UTC) PM02, PM03, PM04<br />
uid___A002_X8602fa_X577 Observed from 2014-07-06T00:55:17.8 to 2014-07-06T01:44:07.3 (UTC) PM02, PM03, PM04<br />
uid___A002_X864236_X2d4 Observed from 2014-07-07T23:03:48.1 to 2014-07-07T23:53:47.9 (UTC) PM03, PM04<br />
uid___A002_X864236_X693 Observed from 2014-07-07T23:56:09.6 to 2014-07-08T00:46:07.1 (UTC) PM03, PM04<br />
uid___A002_X86fcfa_Xd9 Observed from 2014-07-17T20:55:15.5 to 2014-07-17T21:44:06.1 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X664 Observed from 2014-07-17T22:24:17.3 to 2014-07-17T23:13:08.0 (UTC) DV10, PM03, PM04<br />
uid___A002_X86fcfa_X96c Observed from 2014-07-17T23:23:37.0 to 2014-07-18T00:12:25.3 (UTC) DV10, PM03, PM04<br />
</pre><br />
<br />
Here we define the lists of the Execution Block ID's of the amplitude calibrator and science datasets, to facilitate data reduction using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
basename_ampcal = ['uid___A002_X85c183_X895', 'uid___A002_X8602fa_Xc3',<br />
'uid___A002_X864236_Xe1', 'uid___A002_X86fcfa_X3ae']<br />
basename_science = ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b',<br />
'uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577',<br />
'uid___A002_X864236_X2d4', 'uid___A002_X864236_X693',<br />
'uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']<br />
</source><br />
<br />
= Calibration into Brightness Temperature in Kelvins =<br />
<br />
In this section, the data are calibrated into brightness temperature in units of K.<br />
<br />
''This is done in the steps that are described below, using uid___A002_X85c183_X36f as an example.''<br />
If you wish to simply calibrate the data without working through the steps, you can instead execute the script<br />
[[media:A002_X85c183_X36f.ms.scriptForSDCalibration.py|A002_X85c183_X36f.ms.scriptForSDCalibration.py]] using the execfile command.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
# In CASA<br />
execfile('A002 X85c183_X36f.ms.scriptForSDCalibration.py')<br />
</pre><br />
<br />
The other datasets need to be calibrated using the following scripts;<br />
[[media:A002_X85c183_X895.ms.scriptForSDCalibration.py|A002_X85c183_X895.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py|A002_X8602fa_Xc3.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_Xe1.ms.scriptForSDCalibration.py|A002_X864236_Xe1.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py|A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X85c183_X60b.ms.scriptForSDCalibration.py|A002_X85c183_X60b.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py|A002_X8602fa_X2ab.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X8602fa_X577.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X2d4.ms.scriptForSDCalibration.py|A002_X8602fa_X577.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X864236_X693.ms.scriptForSDCalibration.py|A002_X864236_X693.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py|A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py]],<br />
[[media:A002_X86fcfa_X664.ms.scriptForSDCalibration.py|A002_X86fcfa_X664.ms.scriptForSDCalibration.py]], and<br />
[[media:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py|A002_X86fcfa_X96c.ms.scriptForSDCalibration.py]].<br />
<br />
== Create Measurement Sets ==<br />
<br />
The first thing to do is to convert the dataset into the CASA Measurement Set (MS) format.<br />
The raw data have been provided to you in the ASDM (ALMA Science Data Model).<br />
It is the native format of the data produced by the observatory but cannot be processed by CASA.<br />
The conversion from ASDM to MS is done with the task {{importasdm}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
importasdm('uid___A002_X85c183_X36f',<br />
asis='Antenna Station Receiver Source CalAtmosphere CalWVR',<br />
bdfflags=False)<br />
</source><br />
<br />
The converted dataset (with a suffix ".ms") is created.<br />
Then some sort of flags embedded in the binary files in the ASDM dataset (so-called "BDF flags") are transferred to MS using the command bdflags2MS.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system(os.environ['CASAPATH'].split()[0] + \<br />
'/bin/bdflags2MS -f "COR DELA INT MIS SIG SYN TFB WVR ZER" ' + \<br />
'uid___A002_X85c183_X36f uid___A002_X85c183_X36f.ms')<br />
</source><br />
<br />
== Initial Inspection ==<br />
<br />
The usual first step is then to get some basic information about the data.<br />
We do this using the task {{listobs}}, which will output a detailed summary of each dataset supplied.<br />
<br />
<source lang="python"><br />
# In CASA<br />
listobs(vis='uid___A002_X85c183_X36f.ms',<br />
listfile='uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
The output will be sent to the CASA logger, and also written in a file named uid___A002_X85c183_X36f.ms.listobs.<br />
You can print the contents of the file to the terminal by typing:<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.listobs')<br />
</source><br />
<br />
Alternatively you can use your favorite pager or editor, instead of "cat" command.<br />
<br />
Here is an example of the (abridged) output from listobs for uid___A002_X85c183_X36f:<br />
<br />
<pre style="background-color: #fffacd;"><br />
Observation: ALMA<br />
Data records: 76314 Total elapsed time = 2942.21 seconds<br />
Observed from 01-Jul-2014/21:51:26.2 to 01-Jul-2014/22:40:28.4 (UTC)<br />
<br />
ObservationID = 0 ArrayID = 0<br />
Date Timerange (UTC) Scan FldId FieldName nRows SpwIds Average Interval(s) ScanIntent<br />
01-Jul-2014/21:51:26.2 - 21:53:29.5 1 0 J1215+1654 6087 [0,1,2,3,4,5,6,7,8] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:55:24.7 - 21:56:25.7 2 0 J1215+1654 6210 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_SIDEBAND_RATIO#OFF_SOURCE,CALIBRATE_SIDEBAND_RATIO#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:26.9 - 21:56:53.4 3 0 J1215+1654 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:56:56.8 - 21:57:17.6 4 0 J1215+1654 582 [0,17,18,19,20,21,22,23,24] [1.15, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01, 10.1, 1.01] [CALIBRATE_DELAY#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:58:22.1 - 21:58:47.4 5 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
21:59:41.6 - 22:07:36.2 6 1 M100 12216 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:07:54.6 - 22:09:19.9 7 1 M100 2202 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:09:38.3 - 22:10:03.6 8 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:10:25.5 - 22:18:19.0 9 1 M100 12207 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:18:38.6 - 22:20:39.6 10 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:20:56.8 - 22:21:23.3 11 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:21:44.1 - 22:29:38.7 12 1 M100 12204 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:30:23.6 - 22:32:24.6 13 1 M100 3111 [0,17,18,19,20,21,22,23,24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
22:33:29.1 - 22:33:54.4 14 1 M100 1782 [0,9,10,11,12,13,14,15,16] [1.15, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48, 0.48] [CALIBRATE_ATMOSPHERE#OFF_SOURCE,CALIBRATE_ATMOSPHERE#ON_SOURCE,CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE]<br />
22:34:19.8 - 22:40:28.4 15 1 M100 9474 [0, 17, 18, 19, 20, 21, 22, 23, 24] [1.15, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01] [CALIBRATE_WVR#OFF_SOURCE,CALIBRATE_WVR#ON_SOURCE,OBSERVE_TARGET#OFF_SOURCE,OBSERVE_TARGET#ON_SOURCE]<br />
(nRows = Total number of rows per scan) <br />
Fields: 2<br />
ID Code Name RA Decl Epoch SrcId nRows<br />
0 none J1215+1654 12:15:03.979140 +16.54.37.95680 J2000 0 14661<br />
1 none M100 12:22:54.360000 +15.48.50.60000 J2000 1 61653<br />
Spectral Windows: (25 unique spectral windows and 2 unique polarization setups)<br />
SpwID Name #Chans Frame Ch0(MHz) ChanWid(kHz) TotBW(kHz) CtrFreq(MHz) BBC Num Corrs <br />
0 WVR#NOMINAL 4 TOPO 184550.000 1500000.000 7500000.0 187550.0000 0 XX<br />
1 ALMA_RB_03#BB_1#SW-01#FULL_RES 124 TOPO 91955.512 -15625.000 1937500.0 90994.5750 1 XX YY<br />
2 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 90978.950 1734375.000 1734375.0 90978.9500 1 XX YY<br />
3 ALMA_RB_03#BB_2#SW-01#FULL_RES 124 TOPO 93893.012 -15625.000 1937500.0 92932.0750 2 XX YY<br />
4 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 92924.262 1937500.000 1937500.0 92924.2625 2 XX YY<br />
5 ALMA_RB_03#BB_3#SW-01#FULL_RES 124 TOPO 102033.637 15625.000 1937500.0 102994.5750 3 XX YY<br />
6 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 102986.762 1937500.000 1937500.0 102986.7625 3 XX YY<br />
7 ALMA_RB_03#BB_4#SW-01#FULL_RES 124 TOPO 104033.637 15625.000 1937500.0 104994.5750 4 XX YY<br />
8 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 104986.762 1937500.000 1937500.0 104986.7625 4 XX YY<br />
9 ALMA_RB_03#BB_1#SW-01#FULL_RES 128 TOPO 101942.187 -15625.000 2000000.0 100950.0000 1 XX YY<br />
10 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100926.562 1781250.000 1781250.0 100926.5625 1 XX YY<br />
11 ALMA_RB_03#BB_2#SW-01#FULL_RES 128 TOPO 103757.337 -15625.000 2000000.0 102765.1500 2 XX YY<br />
12 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102741.712 1781250.000 1781250.0 102741.7125 2 XX YY<br />
13 ALMA_RB_03#BB_3#SW-01#FULL_RES 128 TOPO 111814.962 15625.000 2000000.0 112807.1500 3 XX YY<br />
14 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112783.712 1781250.000 1781250.0 112783.7125 3 XX YY<br />
15 ALMA_RB_03#BB_4#SW-01#FULL_RES 128 TOPO 113689.962 15625.000 2000000.0 114682.1500 4 XX YY<br />
16 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114658.712 1781250.000 1781250.0 114658.7125 4 XX YY<br />
17 ALMA_RB_03#BB_1#SW-01#FULL_RES 4080 TOPO 101945.850 -488.281 1992187.5 100950.0000 1 XX YY<br />
18 ALMA_RB_03#BB_1#SW-01#CH_AVG 1 TOPO 100949.756 1992187.500 1992187.5 100949.7559 1 XX YY<br />
19 ALMA_RB_03#BB_2#SW-01#FULL_RES 4080 TOPO 103761.000 -488.281 1992187.5 102765.1500 2 XX YY<br />
20 ALMA_RB_03#BB_2#SW-01#CH_AVG 1 TOPO 102764.906 1992187.500 1992187.5 102764.9059 2 XX YY<br />
21 ALMA_RB_03#BB_3#SW-01#FULL_RES 4080 TOPO 111811.300 488.281 1992187.5 112807.1500 3 XX YY<br />
22 ALMA_RB_03#BB_3#SW-01#CH_AVG 1 TOPO 112806.906 1992187.500 1992187.5 112806.9059 3 XX YY<br />
23 ALMA_RB_03#BB_4#SW-01#FULL_RES 4080 TOPO 113686.300 488.281 1992187.5 114682.1500 4 XX YY<br />
24 ALMA_RB_03#BB_4#SW-01#CH_AVG 1 TOPO 114681.906 1992187.500 1992187.5 114681.9059 4 XX YY<br />
Sources: 48<br />
ID Name SpwId RestFreq(MHz) SysVel(km/s) <br />
0 J1215+1654 0 - - <br />
0 J1215+1654 25 - - <br />
0 J1215+1654 26 - - <br />
0 J1215+1654 27 - - <br />
0 J1215+1654 1 - - <br />
0 J1215+1654 2 - - <br />
0 J1215+1654 3 - - <br />
0 J1215+1654 4 - - <br />
0 J1215+1654 5 - - <br />
0 J1215+1654 6 - - <br />
0 J1215+1654 7 - - <br />
0 J1215+1654 8 - - <br />
0 J1215+1654 9 - - <br />
0 J1215+1654 10 - - <br />
0 J1215+1654 11 - - <br />
0 J1215+1654 12 - - <br />
0 J1215+1654 13 - - <br />
0 J1215+1654 14 - - <br />
0 J1215+1654 15 - - <br />
0 J1215+1654 16 - - <br />
0 J1215+1654 17 100950 0 <br />
0 J1215+1654 18 100950 0 <br />
0 J1215+1654 19 102794.1 0 <br />
0 J1215+1654 20 102794.1 0 <br />
0 J1215+1654 21 112794.1 0 <br />
0 J1215+1654 22 112794.1 0 <br />
0 J1215+1654 23 114669.1 0 <br />
0 J1215+1654 24 114669.1 0 <br />
1 M100 0 - - <br />
1 M100 25 - - <br />
1 M100 26 - - <br />
1 M100 27 - - <br />
1 M100 9 - - <br />
1 M100 10 - - <br />
1 M100 11 - - <br />
1 M100 12 - - <br />
1 M100 13 - - <br />
1 M100 14 - - <br />
1 M100 15 - - <br />
1 M100 16 - - <br />
1 M100 17 100950 0 <br />
1 M100 18 100950 0 <br />
1 M100 19 102794.1 0 <br />
1 M100 20 102794.1 0 <br />
1 M100 21 112794.1 0 <br />
1 M100 22 112794.1 0 <br />
1 M100 23 114669.1 0 <br />
1 M100 24 114669.1 0 <br />
Antennas: 3:<br />
ID Name Station Diam. Long. Lat. Offset from array center (m) ITRF Geocentric coordinates (m) <br />
East North Elevation x y z<br />
0 DA61 A075 12.0 m -067.45.17.9 -22.53.21.4 -4.5609 -499.7012 23.0322 2225072.419944 -5440148.858968 -2481499.171703<br />
1 PM03 T701 12.0 m -067.45.18.8 -22.53.22.2 -29.1265 -522.7875 22.2052 2225045.995589 -5440149.141967 -2481520.118569<br />
2 PM04 T703 12.0 m -067.45.16.2 -22.53.23.9 42.8797 -575.6910 21.7763 2225104.700870 -5440102.471978 -2481568.689518<br />
</pre><br />
<br />
From this output you can for example see the followings.<br />
<br />
* From "Data records" section: The execution consists of 15 scans with various scan intents.<br />
** Scans 1 and 2 are pointing and sideband gain ratio calibrations (done interferometrically), which need to be done prior to observing the target, on the quasar J1215+1654.<br />
** Scans 3 and 4 are interferometric delay and system noise temperature (Tsys) measurements also on J1215+1654 (they are in principle unnecessary; just a hack to make things happen on the telescope control software).<br />
** Scans 6, 7, 9, 10, 12, 13, and 15, whose scan intents contain "OBSERVE_TARGET", are for raster mapping of the target M100. The associated spectral window (SPW) ID's are 0 and 17-24.<br />
** Scans 5, 8, 11, and 14 with scan intents "CALIBRATE_ATMOSPHERE" are Tsys measurements for M100. The SPW ID's for Tsys scans are 0 and 9-16.<br />
* From "Spectral Windows" section:<br />
** SPW 0 contains the Water Vapor Radiometer (WVR) data, which are taken for all scans, but which are not used here.<br />
** SPW's 1, 3, 5, and 7 are placed on standard continuum frequencies and are used for the pointing scan only.<br />
** SPW's 9, 11, 13, and 15 cover the same frequency range as the science SPW's (see the next bullet) and are used to measure the Tsys used for calibration. They have 128 spectral channels (15.6 MHz spacing) in 2000 MHz bandwidth.<br />
** SPW's 17, 19, 21, and 23 cover the frequency ranges used for the actual science observations. They have 4080 spectral channels (488 kHz spacing) in 1992 MHz bandwidth. Hereafter these SPW's are referred to as "science" SPW's. The target line, CO J=1-0, is placed in SPW 23, the corresponding Tsys is taken from SPW 15.<br />
** The remaining, even-number SPW's contain channel-averages of the actually used SPW's (e.g., SPW 24 corresponds to SPW 23 averaged into one channel).<br />
* From "Antennas" section: Three 12-m antennas (DA61, PM03, and PM04) were used for the observations.<br />
<br />
The scan pattern of the raster mapping can be visualized by issueing the following command.<br />
A plot will be shown in a window and also saved as a PNG file uid___A002_X85c183_X36f.ms.sampling.png.<br />
<br />
<figure id="X36f.TPSampling.png"><br />
[[File:X36f.TPSampling.png|200px|thumb|right|<caption>The scan pattern of the raster mapping for uid___A002_X85c183_X36f.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
aU.getTPSampling(vis='uid___A002_X85c183_X36f.ms',<br />
showplot=True,<br />
plotfile='uid___A002_X85c183_X36f.ms.sampling.png')<br />
</source><br />
<br />
== Convert MS into Single-Dish Data Format ==<br />
<br />
To calibrate the data, we need the data to be in the single-dish scantable (ASAP) format.<br />
Most of the tasks that we will use for calibration are inherited from the ASAP package, which has been incorporated into CASA.<br />
The ASAP package uses a different data format, so from a global point of view, what we are going to do is, first convert the MS to the ASAP format, then run the necessary calibration tasks, then convert the data back to the MS format.<br />
An effort for transition from ASAP to MS is ongoing; in a future version of CASA this step will become unnecessary.<br />
<br />
We use the task {{sdsave}} to do this.<br />
The option outform, which specifies the format of the output data, is left as the default value 'ASAP'.<br />
We will split the data by antennas by using the option splitant=True.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdsave(infile='uid___A002_X85c183_X36f.ms',<br />
splitant=True,<br />
outfile='uid___A002_X85c183_X36f.ms.asap',<br />
overwrite=True)<br />
</source><br />
<br />
As three antennas were used in the observation, three corresponding ASAP datasets (uid___A002_X85c183_X36f.ms.DA61.asap, uid___A002_X85c183_X36f.ms.PM03.asap, and uid___A002_X85c183_X36f.ms.PM04.asap) are generated.<br />
As usual, we will first obtain information about the content of the datasets, using the task {{sdlist}} (which plays the same role as {{listobs}}).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdlist(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.sdlist' % ant)<br />
</source><br />
<br />
Here is an example of the output for uid___A002_X85c183_X36f.ms.DA61.asap. The displayed information is in principle the same as what you got from {{listobs}} (except for reduced number of antennas), although {{sdlist}} uses different expression (inherited from ASAP) from that of {{listobs}} (CASA native) -- e.g., "ScanIntent" in {{listobs}} is shown as "SrcType" in {{sdlist}} (CALIBRATE_something to CALON, ON_SOURCE to PSON, OFF_SOURCE to PSOFF, etc.), and CASA SPWs correspond to ASAP "IF"s.<br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('cat uid___A002_X85c183_X36f.ms.DA61.asap.sdlist')<br />
</source><br />
<br />
<pre style="background-color: #fffacd;"><br />
--------------------------------------------------------------------------------<br />
Scan Table Summary<br />
--------------------------------------------------------------------------------<br />
Project: uid://A002/X82e287/X3<br />
Obs Date: 2014/07/01/21:49:32<br />
Observer: cvlahakis<br />
Antenna Name: ALMA//DA61@A075<br />
Data Records: 41726 rows<br />
Obs. Type: CALIBRATE_POINTING#ON_SOURCE,CALIBRATE_WVR#ON_SOURCE<br />
Beams: 1 <br />
IFs: 25 <br />
Polarisations: 2 (linear)<br />
Channels: 4080<br />
Flux Unit: K<br />
Abscissa: Channel<br />
Selection: none<br />
<br />
Scan Source Time range Int[s] Record SrcType FreqIDs MolIDs <br />
Beam Position (J2000) <br />
--------------------------------------------------------------------------------<br />
1 J1215+1654 2014/07/01/21:51:26.28 - 21:53:29.48 1.01574 2029 [PSON:CALON] [0, 1, 2, 3, 4, 5, 6, 7, 8] [0]<br />
0 J2000 12:15:03.989 +16.54.37.559<br />
2 J1215+1654 2014/07/01/21:55:24.90 - 21:56:25.45 0.49753 2070 [PSON:CALON, PSOFF:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
3 J1215+1654 2014/07/01/21:56:27.21 - 21:56:53.05 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:15:03.988 +16.54.37.561<br />
4 J1215+1654 2014/07/01/21:56:56.52 - 21:57:17.88 1.76957 194 [PSON:CALON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:15:03.988 +16.54.37.560<br />
5 M100 2014/07/01/21:58:22.41 - 21:58:47.39 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.286 +15.48.50.161<br />
6 M100 2014/07/01/21:59:41.64 - 22:07:36.12 1.01591 7720 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.286 +15.48.50.162<br />
7 M100 2014/07/01/22:07:54.69 - 22:09:19.80 1.01608 1390 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.164<br />
8 M100 2014/07/01/22:09:38.49 - 22:10:03.47 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
9 M100 2014/07/01/22:10:25.58 - 22:18:18.96 1.01586 7717 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.165<br />
10 M100 2014/07/01/22:18:38.66 - 22:20:39.48 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.168<br />
11 M100 2014/07/01/22:20:57.16 - 22:21:23.00 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.285 +15.48.50.174<br />
12 M100 2014/07/01/22:21:44.13 - 22:29:38.62 1.01584 7716 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.285 +15.48.50.169<br />
13 M100 2014/07/01/22:30:23.68 - 22:32:24.51 1.01599 1965 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.173<br />
14 M100 2014/07/01/22:33:29.37 - 22:33:54.35 0.500364 594 [PSOFF:CALON, PSON:CALON] [0, 9, 10, 11, 12, 13, 14, 15, 16] [0]<br />
0 J2000 12:23:13.284 +15.48.50.175<br />
15 M100 2014/07/01/22:34:19.84 - 22:40:28.35 1.01584 5990 [PSOFF, PSON] [0, 17, 18, 19, 20, 21, 22, 23, 24] [0, 1, 2, 3, 4]<br />
0 J2000 12:23:13.284 +15.48.50.179<br />
--------------------------------------------------------------------------------<br />
FREQUENCIES: 9<br />
ID IFNO(SPW) #Chans Frame Ch0[MHz] ChanWid[kHz] Center[MHz] POLNOs<br />
0 0 4 TOPO 183925 2500000 187675 [0]<br />
1 1 124 TOPO 91955.5125 -15625 90994.575 [0, 1]<br />
2 2 1 TOPO 90978.95 -1734375 90978.95 [0, 1]<br />
3 3 124 TOPO 93893.0125 -15625 92932.075 [0, 1]<br />
4 4 1 TOPO 92924.2625 -1937500 92924.2625 [0, 1]<br />
5 5 124 TOPO 102033.637 15625 102994.575 [0, 1]<br />
6 6 1 TOPO 102986.762 1937500 102986.762 [0, 1]<br />
7 7 124 TOPO 104033.637 15625 104994.575 [0, 1]<br />
8 8 1 TOPO 104986.762 1937500 104986.762 [0, 1]<br />
9 9 128 TOPO 101942.187 -15625 100950 [0, 1]<br />
10 10 1 TOPO 100926.562 -1781250 100926.562 [0, 1]<br />
11 11 128 TOPO 103757.337 -15625 102765.15 [0, 1]<br />
12 12 1 TOPO 102741.712 -1781250 102741.712 [0, 1]<br />
13 13 128 TOPO 111814.962 15625 112807.15 [0, 1]<br />
14 14 1 TOPO 112783.712 1781250 112783.712 [0, 1]<br />
15 15 128 TOPO 113689.962 15625 114682.15 [0, 1]<br />
16 16 1 TOPO 114658.712 1781250 114658.712 [0, 1]<br />
17 17 4080 TOPO 101945.85 -488.28125 100950 [0, 1]<br />
18 18 1 TOPO 100949.756 -1992187.5 100949.756 [0, 1]<br />
19 19 4080 TOPO 103761 -488.28125 102765.15 [0, 1]<br />
20 20 1 TOPO 102764.906 -1992187.5 102764.906 [0, 1]<br />
21 21 4080 TOPO 111811.3 488.28125 112807.15 [0, 1]<br />
22 22 1 TOPO 112806.906 1992187.5 112806.906 [0, 1]<br />
23 23 4080 TOPO 113686.3 488.28125 114682.15 [0, 1]<br />
24 24 1 TOPO 114681.906 1992187.5 114681.906 [0, 1]<br />
--------------------------------------------------------------------------------<br />
MOLECULES: <br />
ID RestFreq Name <br />
0 [] []<br />
1 [1.0095e+11] [Manual_window(ID=0)]<br />
2 [1.027941e+11] [Manual_window(ID=0)]<br />
3 [1.127941e+11] [Manual_window(ID=0)]<br />
4 [1.146691e+11] [CO_v_0_1_0(ID=3768098)]<br />
--------------------------------------------------------------------------------<br />
</pre><br />
<br />
== Inspect the System Noise Temperature ==<br />
<br />
Let's start by checking the Tsys.<br />
We use the task {{gencal}} to extract the Tsys into a CASA calibration table.<br />
This table is only used for plotting and for letting CASA figure out the mapping between the science and Tsys SPW's (see [[#Tsys_Calibration|"Tsys Calibration" section]]).<br />
<br />
<source lang="python"><br />
# In CASA<br />
gencal(vis='uid___A002_X85c183_X36f.ms',<br />
caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
caltype='tsys')<br />
</source><br />
<br />
The generated Tsys calibration table can be plotted using the task {{plotbandpass}}<br />
and the checkCalTable function of the Analysis Utilities.<br />
The generated plots are saved in the directories<br />
uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime and uid___A002_X85c183_X36f.ms.tsys.plots.<br />
<br />
<figure id="X36f.Tsys.overlayTime.png"><br />
[[File:X36f.Tsys.overlayTime.png|200px|thumb|right|<caption>The Tsys as a function of frequency for DA61 in uid___A002_X85c183_X36f. Colors represent time.</caption>]]<br />
</figure><br />
<br />
<figure id="X36f.Tsys.overlayAntenna.png.png"><br />
[[File:X36f.Tsys.overlayAntenna.png.png|200px|thumb|right|<caption>The Tsys as a function of frequency for SPW 15 in uid___A002_X85c183_X36f. Colors represent antennas.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
plotbandpass(caltable='uid___A002_X85c183_X36f.ms.tsys',<br />
overlay='time',<br />
xaxis='freq',<br />
yaxis='amp',<br />
subplot=22,<br />
buildpdf=False,<br />
interactive=False,<br />
showatm=True,<br />
pwv='auto',<br />
chanrange='5~123',<br />
showfdm=True,<br />
field='',<br />
figfile='uid___A002_X85c183_X36f.ms.tsys.plots.overlayTime/uid___A002_X85c183_X36f.ms.tsys')<br />
<br />
es.checkCalTable('uid___A002_X85c183_X36f.ms.tsys',<br />
msName='uid___A002_X85c183_X36f.ms',<br />
interactive=False)<br />
</source><br />
<br />
== A Priori Flagging ==<br />
<br />
Now we do some a-priori flagging of the edge channels.<br />
Although the "science" SPW's have 1992 MHz bandwidths with 4080 spectral channels, their edge channels are very noisy, because each intermediate frequency signal path (baseband) is equipped with a bandpass filter of ~1.8 GHz width.<br />
We flag 120 channels on each side of the "science" SPW's.<br />
As a result 3840 channels (1875 MHz bandwidth), i.e., the same number of channels and bandwidth as FDM SPW's in the 12-m array data, remain in each SPW.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdflag(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
mode='manual',<br />
spw='17:0~119;3960~4079,19:0~119;3960~4079,21:0~119;3960~4079,23:0~119;3960~4079',<br />
overwrite = True)<br />
</source><br />
<br />
== Tsys Calibration ==<br />
<br />
We calibrate the data into brightness temperature in units of K, using the equation Ta* = Tsys*(ON-OFF)/OFF, where ON and OFF are the data on-source (i.e., during the raster scanning) and off-source (on a reference position where only background emission exists), respectively.<br />
The calibration is done by the task {{sdcal2}}.<br />
It requires the list of the "science" SPW's and Tsys SPW's, and the correspondence between them.<br />
We can tell from the {{listobs}} (or {{sdlist}}) output that Tsys SPW's 9, 11, 13, and 15 correspond to "science" SPW's 17, 19, 21, and 23, respectively; but the function tsysspwmap helps to map Tsys SPW's to science SPW's in an automated way:<br />
<br />
<source lang="python"><br />
# In CASA<br />
from recipes.almahelpers import tsysspwmap<br />
tsysmap = tsysspwmap(vis='uid___A002_X85c183_X36f.ms',<br />
tsystable='uid___A002_X85c183_X36f.ms.tsys')<br />
</source><br />
<br />
The obtained variable tsysmap is a list which looks like as follows. The ''N''-th (counted from 0) item indicates the Tsys SPW corresponding to the SPW ID ''N'', e.g., the 23rd item is 15, thus the Tsys SPW 15 corresponds to the science SPW 23.<br />
<br />
<pre style="background-color: #fffacd;"><br />
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 13, 13, 15, 15, 9, 9, 11, 11, 13, 13, 15, 15]<br />
</pre><br />
<br />
Now this information needs to be translated into a dictionary variable which {{sdcal2}} requires. The mapping between the science SPW's (17, 19, 21, and 23) and Tsys SPW's is given by the following piece of code:<br />
<br />
<source lang="python"><br />
# In CASA<br />
spwmap = {}<br />
for i in [17, 19, 21, 23]:<br />
if not tsysmap[i] in spwmap.keys():<br />
spwmap[tsysmap[i]] = []<br />
spwmap[tsysmap[i]].append(i)<br />
</source><br />
<br />
The obtained correspondence between Tsys and science SPW's is stored in the dictionary spwmap which looks like the following:<br />
<br />
<pre style="background-color: #fffacd;"><br />
{9: [17], 11: [19], 13: [21], 15: [23]}<br />
</pre><br />
<br />
This is given to sdcal2, along with the comma-separated lists of SPW's.<br />
An important parameter of the task is calmode.<br />
In case of the science dataset uid___A002_X85c183_X895, calmode should be set to 'ps,tsys,apply'.<br />
'ps' means that the data at dedicated reference position are used as "OFF" for the OFF subtraction, (ON-OFF)/OFF.<br />
'tsys' is to calibrate the data using Tsys.<br />
'apply' is to apply both calibrations above (OFF-subtraction and Tsys).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdcal2(infile='uid___A002_X85c183_X36f.ms.%s.asap' % ant,<br />
calmode='ps,tsys,apply',<br />
spw='9,11,13,15,17,19,21,23',<br />
tsysspw='9,11,13,15',<br />
spwmap=spwmap,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
A new ASAP dataset with additional suffix '.cal' is generated for each antenna.<br />
Before proceeding to the next step, we can plot the calibrated spectra using the SDcheckSpectra function of the Analysis Utilities.<br />
PNG files will be created in, e.g., uid___A002_X85c183_X36f.ms.DA61.asap.cal.plots directory.<br />
You will find the CO line in SPW 23 of the science datasets.<br />
<br />
<figure id="X36f.spw23.cal.png"><br />
[[File:X36f.spw23.cal.png|200px|thumb|right|<caption>The spectra calibrated into brightness temperature for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
'''Note:''' For ''amplitude calibrator datasets'', (as opposed to science target maps) the calmode option for sdcal2 should be 'otfraster,tsys,apply' ('otfraster' instead of 'ps').<br />
'otfraster' tells the task to use both ends of each raster row as "OFF" data (as opposed to a dedicated "OFF" sky measurement).<br />
This is because temporal fluctuation of atmospheric emission is the dominant source of noise in radio continuum observations, and hence the "OFF" needs to be as close as possible to the "ON" in time (and spatial location).<br />
<br />
== Application of Non-Linearity Correction Factor ==<br />
<br />
In the period of Early Science Cycle 1/2, single-dish data taken with the ACA correlator suffer from non-linearity which originates in the digital signal processing.<br />
Its impact was thoroughly studied both experimentally and theoretically, and it was concluded that multiplication by a correction factor of 1.25 yields an amplitude accuracy of +/-5%.<br />
This correction is done by the task {{sdscale}}. A new ASAP dataset with additional suffix '.nlc' (for Non-Linearity Correction) will be created for each antenna.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdscale(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
factor=1.25)<br />
</source><br />
<br />
An upgrade of the ACA correlator hardware and software in February 2015 is expected to solve the non-linearity issue.<br />
Thus this step will become unnecessary in the near future.<br />
<br />
== Baseline Subtraction (only for Science Datasets) ==<br />
<br />
'''Note:''' this step is appropriate for spectral line observations (science datasets) but should not be done for the continuum observations (amplitude calibrator datasets) -- ''it would eliminate the continuum emission!''<br />
<br />
We will subtract spectral baselines using the task {{sdbaseline}}.<br />
<br />
A tweak (removing flagged rows) is needed before proceeding, to avoid an issue in CASA 4.3 (which will be fixed in CASA 4.4).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
tb.open('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant, nomodify=False)<br />
flaggedrows = tb.query('FLAGROW==1').rownumbers()<br />
if len(flaggedrows) > 0: tb.removerows(flaggedrows)<br />
tb.flush()<br />
tb.close()<br />
</source><br />
<br />
Now we are ready to execute {{sdbaseline}}.<br />
With the option "maskmode='auto'", the task automatically finds line features from individual spectra and excludes them from baseline fitting.<br />
A caveat is that the line finding may not work very well in some cases, including this dataset<br />
(see [[#.28Optionally.29_Subtract_a_Residual_Background_from_the_Image|"Subtract a Residual Background from the Image" section]] below).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdbaseline(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc' % ant,<br />
spw='17,19,21,23',<br />
maskmode='auto',<br />
thresh=5.0,<br />
avg_limit=4,<br />
blfunc='poly',<br />
order=1,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
overwrite=True)<br />
</source><br />
<br />
Datasets with yet another suffix ".bl" are generated.<br />
The spectra can be checked using SDcheckSpectra which we have already used in a previous step.<br />
<br />
<figure id="X36f.spw23.cal.bl.png"><br />
[[File:X36f.spw23.cal.bl.png|200px|thumb|right|<caption>The spectra after baseline subtraction for DA61 SPW 23 in uid___A002_X85c183_X36f. Colors represent polarizations.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
es.SDcheckSpectra('uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
spwIds='17,19,21,23',<br />
interactive=False)<br />
</source><br />
<br />
== Convert Single-Dish Data back to MS Format ==<br />
<br />
Now the calibrated data need to be coverted back to the CASA MS format, because the imaging task ({{sdimaging}}) only accepts MS.<br />
The CASA task {{sdsave}} will do this.<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in ['DA61', 'PM03', 'PM04']:<br />
sdsave(infile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl' % ant,<br />
outfile='uid___A002_X85c183_X36f.ms.%s.asap.cal.nlc.bl.ms' % ant,<br />
spw='17,19,21,23',<br />
outform='MS2')<br />
</source><br />
<br />
And concatenate the data which were split by antennas, using the task {{concat}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
concat(vis=['uid___A002_X85c183_X36f.ms.DA61.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM03.asap.cal.nlc.bl.ms',<br />
'uid___A002_X85c183_X36f.ms.PM04.asap.cal.nlc.bl.ms'],<br />
concatvis='uid___A002_X85c183_X36f.ms.cal')<br />
</source><br />
<br />
We do not concatenate separate Execution Blocks, because we need to determine and apply day-by-day Jy/K conversion factor.<br />
<br />
Note that one of the antennas, PM02, had a problem in the first baseband (SPW 17) on 2014-07-05, and its impact may not be specific to this one SPW (e.g., it may have resulted in poor pointing calibration).<br />
Therefore the PM02 data should be excluded from the concatenation for the affected datasets: uid___A002_X8602fa_Xc3 (amplitude calibrator),<br />
uid___A002_X8602fa_X2ab (science), and uid___A002_X8602fa_X577 (science).<br />
<br />
= Image the Amplitude Calibrator and Measure the Value of Jy/K =<br />
<br />
At this stage you supposedly have run all 13 datasets through their respective scriptForSDCalibration.py, i.e.,<br />
all 13 datasets have been calibrated into units of Kelvins.<br />
The next step is to determine Jy/K conversion factors from the amplitude calibrator datasets (one per day and per SPW).<br />
This is done by imaging a source whose continuum flux is known and measuring the observed brightness temperature.<br />
The script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]" performs this step for all four calibrator datasets.<br />
The procedure to derive the Jy/K value for a single dataset (uid___A002_X85c183_X895) and single SPW (23) is detailed here, whereas all four datasets and four SPW's are processed using for-loops in the script.<br />
<br />
The true size of the beam (point spread function), on which the Jy/K value depends, in a map is determined be several ingredients.<br />
* The intrinsic beam size is determined by the antenna diameter and optics (and of course wavelength). Here we assume the intrinsic beam size of 1.13*lambda/D, where D=12 [m] is the diameter of the antennas, and the factor 1.13 is derived from the optics design of the ALMA 12-m antennas.<br />
* The effective beam size is broadened by the following causes:<br />
** The scanning pattern used to observe the map (i.e., sample spacing in both directions).<br />
** The method used to grid the individual spectra into a map/cube.<br />
The Analysis Utilities provides several tools to get estimates of these.<br />
<br />
First set variables for the name of a calibrated dataset and a couple of parameters to predict the intrinsic beam size.<br />
The predicted beam size is used to determine the appropriate grid spacing and gridding convolution function to image the source.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msname = 'uid___A002_X85c183_X895.ms.cal'<br />
<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
</source><br />
<br />
Open a file to which the derived Jy/K values will be written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout = open(msname+'.JyPerK.txt', 'w')<br />
</source><br />
<br />
Obtain the spatial sampling of the data (spacings along and perpendicular to the scan direction, and the largest dimension in arcsec) using the function getTPSampling of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
xSampling, ySampling, maxsize = aU.getTPSampling(msname, showplot=False)<br />
</source><br />
<br />
Obtain the list of antennas.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
antlist = msmd.antennanames()<br />
msmd.close()<br />
</source><br />
<br />
Specify a SPW for which the Jy/K value is derived.<br />
The center frequency of the SPW is obtained, and then the expected beam size is calculated using the function primaryBeamArcsec of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
spw = 23<br />
<br />
msmd.open(msname)<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
</source><br />
<br />
The cell spacing and size (i.e., pixel size and number of pixels) of the resulting map are determined from the estimated beam size and the dimension of the observed raster map pattern.<br />
The cell spacing is set to be 1/9 of the beam size, according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Obtain the ID and name of the field.<br />
<br />
<source lang="python"><br />
# In CASA<br />
msmd.open(msname)<br />
fieldid = msmd.fieldsforspw(spw, False)[0]<br />
fieldname = msmd.fieldsforspw(spw, True)[0]<br />
msmd.close()<br />
<br />
phasecenter = fieldid<br />
</source><br />
<br />
Now the image of the source is made for each antenna using the task {{sdimaging}}.<br />
The gridding convolution function used is 'SF' (prolate spheroidal wave function) with the support of 6 cell spacings, also according to the NAASC Memo 114 (draft).<br />
<br />
<source lang="python"><br />
# In CASA<br />
for ant in antlist:<br />
sdimaging(infiles=msname,<br />
field=str(fieldname),<br />
spw='%d' % spw,<br />
antenna=ant,<br />
nchan=1,<br />
mode='channel',<br />
width='4080',<br />
gridfunction='SF',<br />
convsupport= 6,<br />
phasecenter=phasecenter,<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='%s.%s.spw%d.image' % (msname, ant, spw))<br />
</source><br />
<br />
The continuum flux of the source is obtained from the ALMA source catalog using the function getALMAFluxForMS of the Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
srcflux = aU.getALMAFluxForMS(msname,<br />
field=fieldname,<br />
spw=str(spw))[fieldname]['fluxDensity']<br />
</source><br />
<br />
Finally derive the Jy/K values by comparing the flux of the source (in Jy) with the observed brightness temperature (in K).<br />
In the case of this guide the amplitude calibrator is a point source (quasar 3C279), and hence the Jy/K value is simply estimated by the ratio between the source flux obtained above and the peak brightness temperature determined using the task {{imstat}}.<br />
Note that if the amplitude calibrator is a planet, the correction for the source size (multiplying the ratio between the areas of planet-deconvolved beam and apparent beam) is necessary.<br />
This process is not written in the code presented here, but implemented in the script "[[media:ScriptForImagingAmpCalAndDerivingJyPerK.py|ScriptForImagingAmpCalAndDerivingJyPerK.py]]".<br />
<br />
<source lang="python"><br />
# In CASA<br />
jyperklist = []<br />
for ant in antlist:<br />
peak = imstat('%s.%s.spw%d.image' % (msname, ant, spw))['max'][0]<br />
fwhm = aU.getfwhm2('%s.%s.spw%d.image' % (msname, ant, spw))<br />
jyperk = srcflux/peak<br />
print 'SPW%d %s Jy/K = %.2f' % (spw, ant, jyperk)<br />
fout.write('%d\t%s\t%.2f\n' % (spw, ant, jyperk))<br />
jyperklist.append(jyperk)<br />
<br />
print '### SPW%d mean Jy/K = %.2f ###' % (spw, pl.mean(jyperklist))<br />
fout.write('%d\t%s\t%.2f\n' % (spw, 'mean', pl.mean(jyperklist)))<br />
</source><br />
<br />
Finally close the file in which the Jy/K values were written.<br />
<br />
<source lang="python"><br />
# In CASA<br />
fout.close()<br />
</source><br />
<br />
The resulting Jy/K values are as follows. Note that the values for individual antennas are averaged for each day, each SPW, because the observatory cannot guarantee that all the antennas used in the Science observations are also available for the corresponding AmpCal observations.<br />
<br />
<pre style="background-color: #E0FFFF;"><br />
#Date Amp_Cal_Dataset SPW17 SPW19 SPW21 SPW23<br />
2014-07-01 uid___A002_X85c183_X895 41.37 42.39 43.45 42.82<br />
2014-07-05 uid___A002_X8602fa_Xc3 40.99 42.74 40.08 42.09<br />
2014-07-07 uid___A002_X864236_Xe1 39.42 42.08 40.18 40.82<br />
2014-07-17 uid___A002_X86fcfa_X3ae 43.49 43.70 42.01 43.04<br />
</pre><br />
<br />
= Convert the Science Target Units from Kelvin to Jansky =<br />
<br />
The science data, which have been calibrated into brightness temperature in units of K, are now converted into Jy units by multiplying the Jy/K factors derived above.<br />
This step is done by the script "[[media:ScriptForJyPerKConversion.py|ScriptForJyPerKConversion.py]]".<br />
<br />
Define the lists of SPWs and corresponding Jy/K factors to process the data using for-loops.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# List the science spws<br />
spwlist = [17, 19, 21, 23]<br />
<br />
# List the Jy/K values (corresponding to the list of the science spws above)<br />
# that were the output from ScriptForImagingAmpCalAndDerivingJyPerK.py<br />
jyperklist0701 = [41.37, 42.39, 43.45, 42.82]<br />
jyperklist0705 = [40.99, 42.74, 40.08, 42.09]<br />
jyperklist0707 = [39.42, 42.08, 40.18, 40.82]<br />
jyperklist0717 = [43.49, 43.70, 42.01, 43.04]<br />
</source><br />
<br />
Make a copy of calibrated dataset, with an additional suffix ".jy", and multiply the Jy/K value for each SPW.<br />
This is done by the scaleAutocorr function of Analysis Utilities.<br />
<br />
<source lang="python"><br />
# In CASA<br />
<br />
# Data taken on 2014-07-01<br />
for name in ['uid___A002_X85c183_X36f', 'uid___A002_X85c183_X60b']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0701):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-05<br />
for name in ['uid___A002_X8602fa_X2ab', 'uid___A002_X8602fa_X577']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0705):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-07<br />
for name in ['uid___A002_X864236_X2d4', 'uid___A002_X864236_X693']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0707):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
<br />
# Data taken on 2014-07-17<br />
for name in ['uid___A002_X86fcfa_Xd9', 'uid___A002_X86fcfa_X664',<br />
'uid___A002_X86fcfa_X96c']:<br />
os.system('rm -Rf %s.ms.cal.jy' % name)<br />
os.system('cp -Rf %s.ms.cal %s.ms.cal.jy' % (name, name))<br />
for (spw, jyperk) in zip(spwlist, jyperklist0717):<br />
aU.scaleAutocorr(vis='%s.ms.cal.jy' % name, scale=jyperk, spw=spw)<br />
</source><br />
<br />
= Image the Science Target =<br />
<br />
Now all the science datasets have been calibrated into Jy units.<br />
The next (final) step is to image the science data.<br />
This step is done by the script "[[media:ScriptForImagingScienceTarget.py|ScriptForImagingScienceTarget.py]]".<br />
<br />
Define the list of the calibrated science datasets, which the CASA task {{sdimaging}} accepts.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sciencedata = [('%s.ms.cal.jy' % name) for name in basename_science]<br />
</source><br />
<br />
Obtain the data sampling and determine the cell spacing and map size based on the mean frequency of the target SPW.<br />
This part is in principle the same as the corresponding procedure in the [[#Image_the_Amplitude_Calibrator_and_Measure_the_Value_of_Jy.2FK|"Image the Amplitude Calibrator and Measure the Value of Jy/K" section]].<br />
<br />
<source lang="python"><br />
# In CASA<br />
fwhmfactor = 1.13<br />
diameter = 12<br />
<br />
xSampling, ySampling, maxsize = aU.getTPSampling(sciencedata[0], showplot=False)<br />
<br />
spw = 23<br />
<br />
msmd.open(sciencedata[0])<br />
freq = msmd.meanfreq(spw)<br />
msmd.close()<br />
print "SPW %d: %.3f GHz" % (spw, freq*1e-9)<br />
<br />
theorybeam = aU.primaryBeamArcsec(frequency=freq*1e-9,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
cell = theorybeam/9.0<br />
imsize = int(round(maxsize/cell)*2)<br />
</source><br />
<br />
Now the data are imaged.<br />
The velocity channel maps of the CO J=1-0 line (restfreq='115.271204GHz') are created as a data cube which covers the velocity range of 1400-1700 km/s at a spacing of 5 km/s (start='1400km/s', width='5km/s', nchan=70).<br />
<br />
'''Note:''' The Jy/K value depends on the parameters of gridding convolution (i.e., "gridfunction", "cell", and function-specific parameters ["convsupport" for gridfunction='SF']).<br />
That is, the same gridding parameters should be used for both amplitude calibrator and science images -- otherwise the calibration into Jy unit becomes invalid.<br />
<br />
<source lang="python"><br />
# In CASA<br />
sdimaging(infiles=sciencedata,<br />
field='M100',<br />
spw='%d' % spw, #sciencespw<br />
nchan=70,<br />
mode='velocity',<br />
start='1400km/s',<br />
width='5km/s',<br />
veltype='radio',<br />
outframe='lsrk',<br />
restfreq='115.271204GHz',<br />
gridfunction='SF',<br />
convsupport=6,<br />
stokes='',<br />
phasecenter='J2000 12h22m54.9 +15d49m15',<br />
ephemsrcname='',<br />
imsize=imsize,<br />
cell=str(cell)+'arcsec',<br />
overwrite=True,<br />
outfile='M100.CO.cube.image')<br />
</source><br />
<br />
The produced image has the brightness unit of K in the image header, which is not correct.<br />
Modify the header using the task {{imhead}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imhead(imagename='M100.CO.cube.image',<br />
mode='put',<br />
hdkey='bunit',<br />
hdvalue='Jy/beam')<br />
</source><br />
<br />
== (Optionally) Subtract a Residual Background from the Image ==<br />
<br />
Now you can browse the data cube using the viewer.<br />
<br />
<source lang="python"><br />
# In CASA<br />
viewer('M100.CO.cube.image')<br />
</source><br />
<br />
If you plot the line profile using the viewer, you may notice that the background (i.e., line-free channels) level is slightly negative.<br />
To correct this, spectral baselines are subtracted from the image using the task {{imcontsub}}.<br />
<br />
<source lang="python"><br />
# In CASA<br />
imcontsub(imagename='M100.CO.cube.image',<br />
linefile='M100.CO.cube.bl.image',<br />
contfile='M100.ignorethis.image',<br />
fitorder=1,<br />
chans='0~7;62~69')<br />
os.system('rm -rf M100.ignorethis.image')<br />
</source><br />
<br />
The main cause of the negative baseline is the following.<br />
The task {{sdbaseline}} with maskmode='auto' is supposed to find lines from the data and exclude the detected lines from baseline fitting.<br />
However, the CO line from M100 is not bright enough to be detected from individual spectra (1-s integration), and hence sdbaseline included the velocity ranges of the line into baseline fitting.<br />
The impact of this effect would be smaller if the line is brighter, or narrower w.r.t. the correlator bandwidth.<br />
<br />
== Add Restoring Beam Header Information to the Science Image ==<br />
<br />
The image does not have the beam size, which is necessary for combining the image with interferometric data, in the header.<br />
The beam size (including the broadening due to gridding convolution and data sampling) is calculated using the function sfBeam of the Analysis Utilities and then written into the header using the functions of the ia tool.<br />
<br />
<source lang="python"><br />
# In CASA<br />
minor, major, fwhmsfBeam, sfBeam = aU.sfBeam(frequency=freq*1e-9,<br />
pixelsize=cell,<br />
convsupport=6,<br />
img=None, #to use Gaussian theorybeam<br />
stokes='both',<br />
xSamplingArcsec=xSampling,<br />
ySamplingArcsec=ySampling,<br />
fwhmfactor=fwhmfactor,<br />
diameter=diameter)<br />
<br />
ia.open('M100.CO.cube.bl.image')<br />
ia.setrestoringbeam(major=str(sfBeam)+'arcsec', minor=str(sfBeam)+'arcsec', pa='0deg')<br />
ia.done()<br />
</source><br />
<br />
== Quick Look at the Results ==<br />
<br />
Make a 0th moment (integrated intensity) map using the task {{immoments}} and browse it using the viewer.<br />
<br />
<figure id="M100.CO.cube.bl.image.mom0.png"><br />
[[File:M100.CO.cube.bl.image.mom0.png|200px|thumb|right|<caption>The integrated intensity map of M100.</caption>]]<br />
</figure><br />
<br />
<source lang="python"><br />
# In CASA<br />
os.system('rm -rf *M100.CO.cube.bl.image.mom0')<br />
immoments(imagename='M100.CO.cube.bl.image',<br />
moments=[0],<br />
axis='spectral',<br />
chans='8~61',<br />
outfile='M100.CO.cube.bl.image.mom0')<br />
<br />
viewer('M100.CO.cube.bl.image.mom0')<br />
</source></div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X864236_Xe1.ms.scriptForSDCalibration.py&diff=16815File:A002 X864236 Xe1.ms.scriptForSDCalibration.py2015-04-28T20:17:11Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X864236_Xe1</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X864236_Xe1</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X864236_X693.ms.scriptForSDCalibration.py&diff=16814File:A002 X864236 X693.ms.scriptForSDCalibration.py2015-04-28T20:16:51Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X864236_X693</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X864236_X693</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X864236_X2d4.ms.scriptForSDCalibration.py&diff=16812File:A002 X864236 X2d4.ms.scriptForSDCalibration.py2015-04-28T20:16:31Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X864236_X2d4</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X864236_X2d4</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X8602fa_Xc3.ms.scriptForSDCalibration.py&diff=16811File:A002 X8602fa Xc3.ms.scriptForSDCalibration.py2015-04-28T20:16:09Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X8602fa_Xc3</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X8602fa_Xc3</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X8602fa_X577.ms.scriptForSDCalibration.py&diff=16810File:A002 X8602fa X577.ms.scriptForSDCalibration.py2015-04-28T20:15:49Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X8602fa_X577</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X8602fa_X577</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X8602fa_X2ab.ms.scriptForSDCalibration.py&diff=16809File:A002 X8602fa X2ab.ms.scriptForSDCalibration.py2015-04-28T20:15:27Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X8602fa_X2ab</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X8602fa_X2ab</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_Xd9.ms.scriptForSDCalibration.py&diff=16808File:A002 X86fcfa Xd9.ms.scriptForSDCalibration.py2015-04-28T20:14:57Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X86fcfa_Xd9</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_Xd9</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_X664.ms.scriptForSDCalibration.py&diff=16807File:A002 X86fcfa X664.ms.scriptForSDCalibration.py2015-04-28T20:14:35Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X86fcfa_X664</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_X664</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_X96c.ms.scriptForSDCalibration.py&diff=16806File:A002 X86fcfa X96c.ms.scriptForSDCalibration.py2015-04-28T20:14:03Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X86fcfa_X96c</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_X96c</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X86fcfa_X3ae.ms.scriptForSDCalibration.py&diff=16805File:A002 X86fcfa X3ae.ms.scriptForSDCalibration.py2015-04-28T20:13:43Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X86fcfa_X3ae</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X86fcfa_X3ae</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X85c183_X895.ms.scriptForSDCalibration.py&diff=16804File:A002 X85c183 X895.ms.scriptForSDCalibration.py2015-04-28T20:13:23Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X85c183_X895</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X85c183_X895</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X85c183_X60b.ms.scriptForSDCalibration.py&diff=16803File:A002 X85c183 X60b.ms.scriptForSDCalibration.py2015-04-28T20:13:00Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X85c183_X60b</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X85c183_X60b</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:A002_X85c183_X36f.ms.scriptForSDCalibration.py&diff=16802File:A002 X85c183 X36f.ms.scriptForSDCalibration.py2015-04-28T20:11:27Z<p>Tsawada: Script for reducing M100 SD dataset uid___A002_X85c183_X36f</p>
<hr />
<div>Script for reducing M100 SD dataset uid___A002_X85c183_X36f</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:ScriptForJyPerKConversion.py&diff=16800File:ScriptForJyPerKConversion.py2015-04-28T19:56:48Z<p>Tsawada: Script for converting the unit of M100 SD data to Jy</p>
<hr />
<div>Script for converting the unit of M100 SD data to Jy</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:ScriptForImagingScienceTarget.py&diff=16799File:ScriptForImagingScienceTarget.py2015-04-28T19:55:27Z<p>Tsawada: Script for imaging M100 SD data</p>
<hr />
<div>Script for imaging M100 SD data</div>Tsawadahttps://casaguides.nrao.edu/index.php?title=File:ScriptForImagingAmpCalAndDerivingJyPerK.py&diff=16798File:ScriptForImagingAmpCalAndDerivingJyPerK.py2015-04-28T19:54:32Z<p>Tsawada: Script for deriving Jy/K values for M100 SD data</p>
<hr />
<div>Script for deriving Jy/K values for M100 SD data</div>Tsawada