1 ############################################################################### 2 # # 3 # Use Python Script for CASA (5.3.0) and newer # 4 # Jun-Hui Zhao (SAO): 2018-11-01 for reduction of SMA data # 5 # Update- # 6 # jhz 2018-11-01 setup # 7 # jhz 2018-11-08 for entry 1-5 # 8 # jhz 2018-11-09 for entry 6-8 # 9 # jhz 2019-02-21 rename the script (swarmDataAnalysis.py) # 10 # from the original (swarmGUIdatainspect.py) that was under # 11 # /home/miriad/jhz/SMADATA2CASA/SMA2UVFITS/SWARM2CASA/bin # 12 # jhz 2019-04-10 provides notes to the excutive lines # 13 ############################################################################### 14 # 15 #Useful links for SMA data editing - 16 #Baseline corrections: https://www.cfa.harvard.edu/rtdc/SMAdata/baseline/ 17 # 18 #!/usr/bin/python 19 ############################### 20 #export CASA modules to python# 21 ############################### 22 from sys import exit 23 import time 24 import os 25 from gencal import gencal 26 from plotweather import plotweather 27 from listobs import listobs 28 from plotants import plotants 29 from plotms import plotms 30 from flagdata import flagdata 31 from setjy import setjy 32 from gaincal import gaincal 33 from plotcal import plotcal 34 from bandpass import bandpass 35 from blcal import blcal 36 from applycal import applycal 37 from fluxscale import fluxscale 38 from split import split 39 from clearcal import clearcal 40 from uvcontsub import uvcontsub 41 from vishead import vishead 42 from cvel import cvel 43 from clean import clean 44 from viewer import viewer 45 from immoments import immoments 46 from imstat import imstat 47 from concat import concat 48 from uvsub import uvsub 49 from ft import ft 50 from exportuvfits import exportuvfits 51 from hanningsmooth import hanningsmooth 52 from widebandpbcor import widebandpbcor 53 from casac import casac 54 ##################### 55 #define variables - # 56 ##################### 57 cl=casac.componentlist() 58 T = True 59 F = False 60 ########################################## 61 #setup import data - # 62 #the input measurementSet # 63 #must be created via the swarm2casa path # 64 ########################################## 65 # 66 #make sure the existing SMAswarmdata.ms 67 #is what you want to look at. 68 #If not existing, make a sympolic link to 69 #you target data 70 # 71 ########################################## 72 datain = 'SMAswarmdata.ms' # 73 allspw = '0~15:3001~13000' # 74 ########################################## 75 def step0(): 76 print "List observing parameters -\n" 77 user_check=raw_input('hit Return to run listobs -') 78 listobs(vis=datain) 79 print "Done with listobs for observing parameters!" 80 # 81 print "Plot uv coverage -\n" 82 user_check=raw_input('hit Return to run plotms for uv coverage -') 83 plotms(vis=datain, 84 xaxis='uwave', 85 yaxis='vwave', 86 coloraxis='spw', 87 avgchannel='1024') 88 print "Done with plotms for uwave-vwave!" 89 # 90 print "Plot Elev coverage -\n" 91 user_check=raw_input('hit Return to run plotms for Elev range -') 92 plotms(vis=datain, 93 xaxis='time', 94 yaxis='elevation', 95 coloraxis='field', 96 spw='0:3001~13000', 97 avgchannel='10000') 98 print "Done with plotms for time-elevation!" 99 # 100 print "Plot hour angle (HA) range -\n" 101 user_check=raw_input('hit Return to run plotms for HA range -') 102 plotms(vis=datain, 103 xaxis='hourang', 104 yaxis='amp', 105 coloraxis='field', 106 spw=allspw, 107 avgchannel='10000') 108 print "Done with plotms for HA range!" 109 # 110 print "Plot fringe ampl vs time (spw as iteraxis) -\n" 111 user_check=raw_input('hit Return to run plotms for ampl vs UTC through each spw -') 112 plotms(vis=datain, 113 xaxis='time', 114 yaxis='amp', 115 coloraxis='field', 116 spw=allspw, 117 avgchannel='10000', 118 iteraxis='spw') 119 user_check=raw_input('hit Return to plot fringe ampl vs time through each BL -\n') 120 plotms(vis=datain, 121 xaxis='time', 122 yaxis='amp', 123 coloraxis='field', 124 spw=allspw, 125 avgchannel='10000', 126 iteraxis='baseline') 127 print "Done with plotms for amplitude vs time!" 128 # 129 print "Plot fringe phas vs time (spw as iteraxis) -\n" 130 user_check=raw_input('hit Return to run plotms for phas vs UTC through each spw -') 131 plotms(vis=datain, 132 xaxis='time', 133 yaxis='phase', 134 coloraxis='field', 135 spw=allspw, 136 avgchannel='10000', 137 iteraxis='spw') 138 user_check=raw_input('hit Return to plot fringe pha vs time (BL as iteraxis) -\n') 139 plotms(vis=datain, 140 xaxis='time', 141 yaxis='phase', 142 coloraxis='field', 143 spw=allspw, 144 avgchannel='10000', 145 iteraxis='baseline') 146 print "Done with plotms for phase vs time!" 147 # 148 print "Plot spectra - Amplitude vs Frequency -" 149 user_check=raw_input('hit Return for Amplitude -') 150 plotms(vis=datain, 151 xaxis='frequency', 152 yaxis='amp', 153 coloraxis='spw', 154 field='0', 155 avgchannel='128', 156 iteraxis='baseline') 157 print "Done with plotms for spectra: amplitude vs frequency!" 158 # 159 print "Plot spectra - Phase vs Frequency -" 160 user_check=raw_input('hit Return for Phase -') 161 plotms(vis=datain, 162 xaxis='frequency', 163 yaxis='phase', 164 coloraxis='spw', 165 field='0', 166 avgchannel='128', 167 iteraxis='baseline') 168 print "Done with plotms for spectra: phase vs frequency!" 169 # 170 print "Plot Structure of vis function - Amplitude vs UVwave -" 171 user_check=raw_input('hit Return for Amplitude -') 172 plotms(vis=datain, 173 xaxis='UVwave', 174 yaxis='amp', 175 coloraxis='spw', 176 avgchannel='200', 177 spw=allspw, 178 iteraxis='field') 179 print "Done with plotms for spectra: amplitude vs frequency!" 180 # 181 print "Plot Structure of vis function - Phase vs UVwave -" 182 user_check=raw_input('hit Return for Phase -') 183 plotms(vis=datain, 184 xaxis='UVwave', 185 yaxis='phase', 186 coloraxis='spw', 187 avgchannel='200', 188 spw=allspw, 189 iteraxis='field') 190 print "Done with plotms for vis-structure: phase vs frequency!" 191 # 192 # 193 def start(): 194 print "You are in casapy for inspecting your data with GUI in CASA" 195 print "Type any key to start this program." 196 next = raw_input("> ") 197 if "0" in next: 198 step0() 199 elif "1" in next: 200 step0() 201 elif "2" in next: 202 step0() 203 elif "3" in next: 204 step0() 205 elif "4" in next: 206 step0() 207 elif "5" in next: 208 step0() 209 elif "6" in next: 210 step0() 211 elif "7" in next: 212 step0() 213 elif "8" in next: 214 step0() 215 elif "9" in next: 216 step0() 217 elif "a" in next: 218 step0() 219 else: 220 step0() 221 # 222 #===================================================================== 223 # Done 224 # 225 print "Done with the reduction" 226 start()