1	#! /bin/csh -f
     2	#
     3	#jhz 2015-07-20
     4	#jhz 2015-07-22
     5	#jhz 2015-07-23
     6	#jhz 2015-07-24
     7	#jhz 2015-07-24 for swarm+asic data
     8	#jhz 2016-06-22 for two quadrant swarm + asic
     9	#jhz 2017-01-15 for swarm only
    10	#jhz 2017-09-14 creating swarmDRX03pp.csh based on swarmDRXproc1.csh
    11	#jhz 2017-09-15 for swarm only in dual receivers
    12	#jhz 2017-10-18 for receiver data seperation
    13	#jhz 2017-11-24 for receiver pair 230(rx0)-240(rx3)
    14	#jhz 2017-12-11 testing for Miriad beta 1.5.1 with binned SWARM spectral data
    15	#jhz 2017-12-12 figured out the issue of ch0 data and implementing the script
    16	#jhz 2018-01-12 implemented uvfits output and making tarballs
    17	#               test Miriad-SMA-WB5.0.7 on hilo system hilodr1
    18	#jhz 2018-01-22 added a handle "TARBAL" for an option to make a tarball for Tsys corrected 
    19	#               data 
    20	#jhz 2018-02-12 corrected typos for the UVFITS output section: in the names of wideband
    21	#               files,  the part of suffix "sw" has been replaced with "wb" 
    22	echo ""
    23	echo "######################################################################"
    24	echo "# swarmDRX03pp.csh: script to further pre-process Miriad-formatted    "
    25	echo "# SMA data generated from SWARM correlator sampled with two receivers,"
    26	echo "# 230(rx0)-240(rx3), simultaneously, in following tasks:              "
    27	echo "# 1. separate receiver data                                           "
    28	echo "# 2. create spectral windows (sw) data with full SWARM spectral       "
    29	echo "#    resolution                                                       "
    30	echo "# 3. create wide-band (wb) data corresponds to each SWARM chunks      "
    31	echo "#    or spectral windows                                              "
    32	echo "# 4. apply tsys corrections to both .sw and .wb  data                 "
    33	echo "# 5. extract ch0 data and apply Tsys correction                       "
    34	echo "# 6. clean the working files                                          "
    35	echo "# 7. make uvfits output and tarballs                                  "   
    36	echo "######################################################################"
    37	echo "                                                                      "
    38	#begin of users' input
    39	#
    40	#set the name of the SMA raw data
    41	#
    42	date
    43	set file = 170923_11:03:17 
    44	echo $file
    45	#
    46	#the observing date for the prefix of the output file names 
    47	#
    48	set dt    = 170923
    49	#
    50	#locate the two files 170923_rx0.lsb  and  170923_rx0.usb which were produced
    51	#from running swarmDRXload.csh
    52	#
    53	set DATPATH = ./
    54	echo "Setup input parameters -"
    55	echo "get the frequency configurations near the bottom of  170923_rx0.lsb.uvindex.log"  
    56	echo "and 170923_rx0.usb.uvindex.log which were reported from swarmDRXload.csh in the"
    57	echo "process of Miriad data inspection; then replace the relevant frequencies in the"
    58	echo "following variable setup of the first channel frequnecy in each spectral window"
    59	echo "corresponding to each sideband and each receiver -                             "
    60	echo ""
    61	echo "setup LSB: Frequency Configuration 1"
    62	set frx0lsbch0 = 217.49475 
    63	set frx0lsbsw1 = 221.64413
    64	set frx0lsbsw2 = 217.34433
    65	set frx0lsbsw3 = 217.64420
    66	set frx0lsbsw4 = 213.34433
    67	echo "Channels  Freq(chan=1) "
    68	echo "     1   "    $frx0lsbch0  "GHz"  
    69	echo " 16384   "    $frx0lsbsw1  "GHz"
    70	echo " 16384   "    $frx0lsbsw2  "GHz"
    71	echo " 16384   "    $frx0lsbsw3  "GHz"
    72	echo " 16384   "    $frx0lsbsw4  "GHz"
    73	echo ""
    74	echo "setup LSB: Frequency Configuration 2"
    75	set frx3lsbch0 = 245.99398
    76	set frx3lsbsw1 = 250.14335
    77	set frx3lsbsw2 = 245.84356
    78	set frx3lsbsw3 = 246.14342
    79	set frx3lsbsw4 = 241.84356
    80	echo "Channels  Freq(chan=1) "
    81	echo "     1   "    $frx3lsbch0  "GHz"  
    82	echo " 16384   "    $frx3lsbsw1  "GHz"
    83	echo " 16384   "    $frx3lsbsw2  "GHz"
    84	echo " 16384   "    $frx3lsbsw3  "GHz"
    85	echo " 16384   "    $frx3lsbsw4  "GHz"
    86	echo ""
    87	echo "setup USB: Frequency Configuration 1"
    88	set frx0usbch0 = 233.49389 
    89	set frx0usbsw1 = 229.34426
    90	set frx0usbsw2 = 233.64406
    91	set frx0usbsw3 = 233.34420
    92	set frx0usbsw4 = 237.64406
    93	echo "Channels  Freq(chan=1) "
    94	echo "     1   "    $frx0usbch0  "GHz"  
    95	echo " 16384   "    $frx0usbsw1  "GHz"
    96	echo " 16384   "    $frx0usbsw2  "GHz"
    97	echo " 16384   "    $frx0usbsw3  "GHz"
    98	echo " 16384   "    $frx0usbsw4  "GHz"
    99	echo ""
   100	echo "setup USB: Frequency Configuration 2"
   101	set frx3usbch0 = 261.99312
   102	set frx3usbsw1 = 257.84349
   103	set frx3usbsw2 = 262.14328
   104	set frx3usbsw3 = 261.84342
   105	set frx3usbsw4 = 266.14328
   106	echo "Channels  Freq(chan=1) "
   107	echo "     1   "    $frx3usbch0  "GHz"  
   108	echo " 16384   "    $frx3usbsw1  "GHz"
   109	echo " 16384   "    $frx3usbsw2  "GHz"
   110	echo " 16384   "    $frx3usbsw3  "GHz"
   111	echo " 16384   "    $frx3usbsw4  "GHz"
   112	echo ""
   113	echo "Double check the input frequencies."
   114	echo "Incorrect frequency values will cause failures in the subsequent process!"
   115	echo "Type Enter-key to continue -"
   116	$<
   117	#
   118	#handles for specific processes -
   119	#
   120	#goto RXSPRT        #process to separate rx data
   121	#goto UVSPCT        #process to inspect rx-subband spectra
   122	#goto SWARMD        #process to create full-spectral-resolution SWARM channel data 
   123	#goto SWARMW        #process to create SWARM-chunk based or SWARM-spw based wideband data
   124	#goto SYSTMP        #process to apply system temperature (Tsys) corrections
   125	#goto FRINGA        #process to check Tsys corrected data in amplitude
   126	#goto FRINGP        #process to check Tsys corrected data in phase
   127	#goto FRINGS        #process to check Tsys corrected spectral data given a source 
   128	#goto HDLCH0        #process to handle CH0, apply Tsys corrections and check the fringes
   129	#goto ZCLEAN        #delete all intermediate working files and stay in Miriad for 
   130	                    #further data reduction 
   131	#goto TARBAL        #make a tarball of the pre-processed or Tsys-corrected datasets for 
   132	                    #further reduction
   133	goto UVFITS        #make UVFITS output for pre-processed or Tsys-corrected datasets and 
   134	                    #delete all intermediate working files
   135	RXSPRT:
   136	echo "Process 1: separation rx data -"
   137	echo "LSB: rx=0 or 230 -"
   138	\rm -r ${dt}_rx00.lsb
   139	uvcat vis=${dt}_rx0.lsb \
   140		select='window(1),freq('$frx0lsbch0'),window(2),freq('$frx0lsbsw1'),window(3),freq('$frx0lsbsw2'),window(4),freq('$frx0lsbsw3'),window(5),freq('$frx0lsbsw4'),' \
   141		out=${dt}_rx00.lsb
   142	echo "LSB: rx=3 or 240 -"
   143	\rm -r ${dt}_rx03.lsb
   144	uvcat vis=${dt}_rx0.lsb \
   145	        select='window(1),freq('$frx3lsbch0'),window(2),freq('$frx3lsbsw1'),window(3),freq('$frx3lsbsw2'),window(4),freq('$frx3lsbsw3'),window(5),freq('$frx3lsbsw4'),' \
   146	        out=${dt}_rx03.lsb
   147	echo "USB: rx=0 or 230 -"
   148	\rm -r ${dt}_rx00.usb
   149	uvcat vis=${dt}_rx0.usb \
   150	        select='window(1),freq('$frx0usbch0'),window(2),freq('$frx0usbsw1'),window(3),freq('$frx0usbsw2'),window(4),freq('$frx0usbsw3'),window(5),freq('$frx0usbsw4'),' \
   151	        out=${dt}_rx00.usb
   152	echo "USB: rx=3 or 240 -"
   153	\rm -r ${dt}_rx03.usb
   154	uvcat vis=${dt}_rx0.usb \
   155	        select='window(1),freq('$frx3usbch0'),window(2),freq('$frx3usbsw1'),window(3),freq('$frx3usbsw2'),window(4),freq('$frx3usbsw3'),window(5),freq('$frx3usbsw4'),' \
   156	        out=${dt}_rx03.usb
   157	echo ""
   158	echo "Four output files have been produced -"
   159	echo "1." ${dt}_rx00.lsb
   160	echo "2." ${dt}_rx03.lsb
   161	echo "3." ${dt}_rx00.usb
   162	echo "4." ${dt}_rx03.usb
   163	echo ""
   164	echo "Type Enter-key to continue -"
   165	UVSPCT:
   166	echo "Process 2: inspect rx-subband spectra -"
   167	set bpcal = '3c84'
   168	echo ""
   169	echo "bandpass calibrator = " $bpcal
   170	echo ""
   171	echo "if bandpass calibrator is incorrect, go back to your script to set it correctly!"
   172	echo "Otherwise, type Enter-key to continue -"
   173	$<
   174	echo $bpcal "LSB: rx0 -"
   175	smauvspec vis=${dt}_rx00.lsb \
   176	        select='source('$bpcal')' \
   177	        hann=15 interval=1000 \
   178	        axis=freq,both device=/xs nxy=4,7
   179	echo $bpcal "LSB: rx3 -"
   180	smauvspec vis=${dt}_rx03.lsb \
   181	        select='source('$bpcal')' \
   182	        hann=15 interval=1000 \
   183	        axis=freq,both device=/xs nxy=4,7
   184	echo $bpcal "USB: rx0 -"
   185	smauvspec vis=${dt}_rx00.usb \
   186	        select='source('$bpcal')' \
   187	        hann=15 interval=1000 \
   188	        axis=freq,both device=/xs nxy=4,7
   189	echo $bpcal "USB: rx3 -"
   190	smauvspec vis=${dt}_rx03.usb \
   191	        select='source('$bpcal')' \
   192	        hann=15 interval=1000 \
   193	        axis=freq,both device=/xs nxy=4,7
   194	echo "Done with inspection of spectra with rx and sideband." 
   195	echo "Type Enter-key to continue -"
   196	SWARMD:
   197	echo "process to create full-spectral-resolution SWARM channel data -"
   198	echo ""
   199	echo "LSB: rx=0 or 230 -"
   200	\rm -r ${dt}_rx00.lsb.sw
   201	uvaver vis=${dt}_rx00.lsb select='window(2,3,4,5)' out=${dt}_rx00.lsb.sw
   202	echo "LSB: rx=3 or 240 -"
   203	\rm -r ${dt}_rx03.lsb.sw
   204	uvaver vis=${dt}_rx03.lsb select='window(2,3,4,5)' out=${dt}_rx03.lsb.sw
   205	echo "USB: rx=0 or 230 -"
   206	\rm -r ${dt}_rx00.usb.sw
   207	uvaver vis=${dt}_rx00.usb select='window(2,3,4,5)' out=${dt}_rx00.usb.sw
   208	echo "USB: rx=3 or 240 -"
   209	\rm -r ${dt}_rx03.usb.sw
   210	uvaver vis=${dt}_rx03.usb select='window(2,3,4,5)' out=${dt}_rx03.usb.sw
   211	echo ""
   212	echo "Four high-spectral-resolution SWARM data files have been produced -"
   213	echo "1." ${dt}_rx00.lsb.sw
   214	echo "2." ${dt}_rx03.lsb.sw
   215	echo "3." ${dt}_rx00.usb.sw
   216	echo "4." ${dt}_rx03.usb.sw
   217	echo "Done with creation of high-spectral-resolution SWARM data"
   218	echo "Type Enter-key to continue -"
   219	SWARMW:
   220	echo "process to create SWARM-chunk based or SWARM-spw based wideband data -"
   221	echo ""
   222	echo "LSB: rx=0 or 230 -"
   223	#
   224	# drop first and last 2048 channels and average 12288 channels
   225	# producing spectral-chunk-based continuum 
   226	#
   227	\rm -r ${dt}_rx00.lsb.wb
   228	uvaver vis=${dt}_rx00.lsb.sw line=chan,4,2048,12288,16384 out=${dt}_rx00.lsb.wb
   229	echo "LSB: rx=3 or 240 -"
   230	\rm -r ${dt}_rx03.lsb.wb
   231	uvaver vis=${dt}_rx03.lsb.sw line=chan,4,2048,12288,16384 out=${dt}_rx03.lsb.wb
   232	echo "USB: rx=0 or 230 -"
   233	\rm -r ${dt}_rx00.usb.wb
   234	uvaver vis=${dt}_rx00.usb.sw line=chan,4,2048,12288,16384 out=${dt}_rx00.usb.wb
   235	echo "USB: rx=3 or 240 -"
   236	\rm -r ${dt}_rx03.usb.wb
   237	uvaver vis=${dt}_rx03.usb.sw line=chan,4,2048,12288,16384 out=${dt}_rx03.usb.wb
   238	echo ""
   239	echo "Four SWARM-chunk based wideband data files have been produced -"
   240	echo "1." ${dt}_rx00.lsb.wb
   241	echo "2." ${dt}_rx03.lsb.wb
   242	echo "3." ${dt}_rx00.usb.wb
   243	echo "4." ${dt}_rx03.usb.wb
   244	echo "Done with creation of SWARM-chunk based wideband data"
   245	echo "Type Enter-key to continue -"
   246	SYSTMP:
   247	echo "process to apply system temperature corrections -"
   248	echo 'LSB: rx0 or 230 swarm channels - '
   249	\rm -r ${dt}_rx00.lsb.sw.tsys
   250	smafix vis=${dt}_rx00.lsb.sw out=${dt}_rx00.lsb.sw.tsys \
   251	        device=/xs xaxis=time \
   252	        yaxis=systemp nxy=2,4   \
   253	        options=tsyscorr
   254	echo 'LSB: rx3 or 240 swarm channels - '
   255	\rm -r ${dt}_rx03.lsb.sw.tsys
   256	smafix vis=${dt}_rx03.lsb.sw out=${dt}_rx03.lsb.sw.tsys \
   257	        device=/xs xaxis=time \
   258	        yaxis=systemp nxy=2,4   \
   259	        options=tsyscorr
   260	echo 'USB: rx0 or 230 swarm channels - '
   261	\rm -r ${dt}_rx00.usb.sw.tsys
   262	smafix vis=${dt}_rx00.usb.sw out=${dt}_rx00.usb.sw.tsys \
   263	        device=/xs xaxis=time \
   264	        yaxis=systemp nxy=2,4   \
   265	        options=tsyscorr
   266	echo 'USB: rx3 or 240 swarm channels - '
   267	\rm -r ${dt}_rx03.usb.sw.tsys
   268	smafix vis=${dt}_rx03.usb.sw out=${dt}_rx03.usb.sw.tsys \
   269	        device=/xs xaxis=time \
   270	        yaxis=systemp nxy=2,4   \
   271	        options=tsyscorr
   272	echo 'LSB: rx0 or 230 swarm wideband - '
   273	\rm -r ${dt}_rx00.lsb.wb.tsys
   274	smafix vis=${dt}_rx00.lsb.wb out=${dt}_rx00.lsb.wb.tsys \
   275	        device=/xs xaxis=time \
   276	        yaxis=systemp nxy=2,4   \
   277	        options=tsyscorr
   278	echo 'LSB: rx3 or 240 swarm wideband - '
   279	\rm -r ${dt}_rx03.lsb.wb.tsys
   280	smafix vis=${dt}_rx03.lsb.wb out=${dt}_rx03.lsb.wb.tsys \
   281	        device=/xs xaxis=time \
   282	        yaxis=systemp nxy=2,4   \
   283	        options=tsyscorr
   284	echo 'USB: rx0 or 230 swarm wideband - '
   285	\rm -r ${dt}_rx00.usb.wb.tsys
   286	smafix vis=${dt}_rx00.usb.wb out=${dt}_rx00.usb.wb.tsys \
   287	        device=/xs xaxis=time \
   288	        yaxis=systemp nxy=2,4   \
   289	        options=tsyscorr
   290	echo 'USB: rx3 or 240 swarm wideband - '
   291	\rm -r ${dt}_rx03.usb.wb.tsys
   292	smafix vis=${dt}_rx03.usb.wb out=${dt}_rx03.usb.wb.tsys \
   293	        device=/xs xaxis=time \
   294	        yaxis=systemp nxy=2,4   \
   295	        options=tsyscorr
   296	echo "Four high-spectral-resolution SWARM data files with Tsys correction have been produced -"
   297	echo "1." ${dt}_rx00.lsb.sw.tsys
   298	echo "2." ${dt}_rx03.lsb.sw.tsys
   299	echo "3." ${dt}_rx00.usb.sw.tsys
   300	echo "4." ${dt}_rx03.usb.sw.tsys
   301	echo "Four SWARM-chunk based wideband data filesi with Tsy correction have been produced -"
   302	echo "1." ${dt}_rx00.lsb.wb.tsys
   303	echo "2." ${dt}_rx03.lsb.wb.tsys
   304	echo "3." ${dt}_rx00.usb.wb.tsys
   305	echo "4." ${dt}_rx03.usb.wb.tsys
   306	echo "Done with Tsys corrections"
   307	echo "Type Enter-key to continue -"
   308	FRINGA:
   309	echo "process to check Tsys corrected data in amplitude -"
   310	echo 'LSB: rx0 or 230 swarm wideband - '
   311	#smauvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   312	#or
   313	uvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   314	echo "type Enter-key to continue -"
   315	$<
   316	echo 'LSB: rx3 or 240 swarm wideband - '
   317	#smauvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7 
   318	#or
   319	uvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   320	echo "type Enter-key to continue -"
   321	$<
   322	echo 'USB: rx0 or 230 swarm wideband - '
   323	#smauvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   324	#or
   325	uvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   326	echo "type Enter-key to continue -"
   327	$<
   328	echo 'USB: rx3 or 240 swarm wideband - '
   329	#smauvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   330	#or
   331	uvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,ampl device=/xs nxy=3,7
   332	FRINGP:
   333	echo "process to check Tsys corrected data in phase -"
   334	echo "type Enter-key to continue -"
   335	$<
   336	echo 'LSB: rx0 or 230 swarm wideband - '
   337	#smauvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   338	#or
   339	uvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   340	echo "type Enter-key to continue -"
   341	$<
   342	echo 'LSB: rx3 or 240 swarm wideband - '
   343	#smauvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   344	#or
   345	uvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   346	echo "type Enter-key to continue -"
   347	$<
   348	echo 'USB: rx0 or 230 swarm wideband - '
   349	#smauvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   350	#or
   351	uvplt vis=${dt}_rx00.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   352	echo "type Enter-key to continue -"
   353	$<
   354	echo 'USB: rx3 or 240 swarm wideband - '
   355	#smauvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   356	#or
   357	uvplt vis=${dt}_rx03.lsb.wb.tsys axis=time,phas device=/xs nxy=3,7
   358	echo "Done with fringe ampl and phase inspection"
   359	echo "type Enter-key to continue -"
   360	FRINGS:
   361	echo "set the source to be checked with its fine SWARM spectra"
   362	set sour = '3c84'
   363	echo ""
   364	echo "source = " $sour
   365	echo ""
   366	echo "if the name of the source is incorrect, go back to your script to set it correctly!"
   367	echo "Otherwise, type Enter-key to continue -"
   368	echo $sour "LSB: rx0 -"
   369	smauvspec vis=${dt}_rx00.lsb.sw.tsys \
   370	        select='source('$sour')' \
   371	        hann=15 interval=1000 \
   372	        axis=freq,ampl device=/xs nxy=4,7
   373	echo "type Enter-key to continue -"
   374	$<
   375	echo $sour "LSB: rx3 -"
   376	smauvspec vis=${dt}_rx03.lsb.sw.tsys \
   377	        select='source('$sour')' \
   378	        hann=15 interval=1000 \
   379	        axis=freq,both device=/xs nxy=4,7
   380	echo "type Enter-key to continue -"
   381	$<
   382	echo $sour "USB: rx0 -"
   383	smauvspec vis=${dt}_rx00.usb.sw.tsys \
   384	        select='source('$sour')' \
   385	        hann=15 interval=1000 \
   386	        axis=freq,both device=/xs nxy=4,7
   387	echo "type Enter-key to continue -"
   388	$<
   389	echo $sour "USB: rx3 -"
   390	smauvspec vis=${dt}_rx03.usb.sw.tsys \
   391	        select='source('$sour')' \
   392	        hann=15 interval=1000 \
   393	        axis=freq,both device=/xs nxy=4,7
   394	echo "Done with inspection for Tsys corrected SWARM full-spectral-resolution data"
   395	echo "For handling CH0, type Enter-key to continue -"
   396	HDLCH0:
   397	echo "unflaging ch0 data -" 
   398	echo "LSB: rx 0 -"
   399	uvflag vis=${dt}_rx00.lsb select='win(1)' flagval=unflag
   400	echo "LSB: rx 3 -"
   401	uvflag vis=${dt}_rx03.lsb select='win(1)' flagval=unflag
   402	echo "USB: rx 0 -"
   403	uvflag vis=${dt}_rx00.usb select='win(1)' flagval=unflag
   404	echo "USB: rx 3 -"
   405	uvflag vis=${dt}_rx03.usb select='win(1)' flagval=unflag
   406	echo "Extract ch0 data -"
   407	echo "LSB: rx 0 -"
   408	uvaver vis=${dt}_rx00.lsb select='win(1)' out=${dt}_rx00.lsb.ch0
   409	echo "LSB: rx 3 -"
   410	uvaver vis=${dt}_rx03.lsb select='win(1)' out=${dt}_rx03.lsb.ch0
   411	echo "USB: rx 0 -"
   412	uvaver vis=${dt}_rx00.usb select='win(1)' out=${dt}_rx00.usb.ch0
   413	echo "USB: rx 3 -"
   414	uvaver vis=${dt}_rx03.usb select='win(1)' out=${dt}_rx03.usb.ch0
   415	echo "applying Tsys correction to ch0 data -"
   416	echo 'LSB: rx0 or 230 swarm wideband - '
   417	\rm -r ${dt}_rx00.lsb.ch0.tsys
   418	smafix vis=${dt}_rx00.lsb.ch0 out=${dt}_rx00.lsb.ch0.tsys \
   419	        device=/xs xaxis=time \
   420	        yaxis=systemp nxy=2,4   \
   421	        options=tsyscorr
   422	echo 'LSB: rx3 or 240 swarm wideband - '
   423	\rm -r ${dt}_rx03.lsb.ch0.tsys
   424	smafix vis=${dt}_rx03.lsb.ch0 out=${dt}_rx03.lsb.ch0.tsys \
   425	        device=/xs xaxis=time \
   426	        yaxis=systemp nxy=2,4   \
   427	        options=tsyscorr
   428	echo 'USB: rx0 or 230 swarm wideband - '
   429	\rm -r ${dt}_rx00.usb.ch0.tsys
   430	smafix vis=${dt}_rx00.usb.ch0 out=${dt}_rx00.usb.ch0.tsys \
   431	        device=/xs xaxis=time \
   432	        yaxis=systemp nxy=2,4   \
   433	        options=tsyscorr
   434	echo 'USB: rx3 or 240 swarm wideband - '
   435	\rm -r ${dt}_rx03.usb.ch0.tsys
   436	smafix vis=${dt}_rx03.usb.ch0 out=${dt}_rx03.usb.ch0.tsys \
   437	        device=/xs xaxis=time \
   438	        yaxis=systemp nxy=2,4   \
   439	        options=tsyscorr
   440	echo "process to check Tsys corrected ch0 data in amplitude -"
   441	echo 'LSB: rx0 or 230 swarm wideband - '
   442	#smauvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   443	#or
   444	uvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   445	echo "type Enter-key to continue -"
   446	$<
   447	echo 'LSB: rx3 or 240 ch0 - '
   448	#smauvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7 
   449	#or
   450	uvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   451	echo "type Enter-key to continue -"
   452	$<
   453	echo 'USB: rx0 or 230 ch0 - '
   454	#smauvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   455	#or
   456	uvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   457	echo "type Enter-key to continue -"
   458	$<
   459	echo 'USB: rx3 or 240 ch0 - '
   460	#smauvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   461	#or
   462	uvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,ampl device=/xs nxy=3,7
   463	FRINGP:
   464	echo "process to check Tsys corrected ch0 data in phase -"
   465	echo "type Enter-key to continue -"
   466	$<
   467	echo 'LSB: rx0 or 230 ch0 - '
   468	#smauvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   469	#or
   470	uvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   471	echo "type Enter-key to continue -"
   472	$<
   473	echo 'LSB: rx3 or 240 ch0 - '
   474	#smauvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   475	#or
   476	uvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   477	echo "type Enter-key to continue -"
   478	$<
   479	echo 'USB: rx0 or 230 ch0 - '
   480	#smauvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   481	#or
   482	uvplt vis=${dt}_rx00.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   483	echo "type Enter-key to continue -"
   484	$<
   485	echo 'USB: rx3 or 240 ch0 - '
   486	#smauvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   487	#or
   488	uvplt vis=${dt}_rx03.lsb.ch0.tsys axis=time,phas device=/xs nxy=3,7
   489	echo "Done with fringe ampl and phase inspection"
   490	echo "For staying Miriad and delete intermediate working files, type Enter-key to continue -"
   491	$<
   492	ZCLEAN:
   493	echo "Cleaning ..."
   494	echo "Deleting *.ch0 files ..."
   495	\rm -fr *.ch0 
   496	echo "Deleting *.sw files ..."
   497	\rm -fr *.sw 
   498	echo "Deleting *.wb files ..."
   499	\rm -fr *.wb 
   500	echo "Deleting *rx00.lsb & *rx00.usb files ..."
   501	\rm -fr *rx00.*sb 
   502	echo "Deleting  *rx03.lsb & *rx03.usb files"
   503	\rm -fr *rx03.*sb
   504	echo "Done!"
   505	echo "Type Enter-key to continue making a tarball of preprocessed data for Miriad -"
   506	$<
   507	TARBAL:
   508	\rm -r ${dt}.tsys.miriad.tar
   509	tar -cvf ${dt}_drx.tsys.miriad.tar *.tsys
   510	echo "A tarball" ${dt}_drx.tsys.miriad.tar "has been created!"
   511	date
   512	exit
   513	UVFITS:
   514	echo "Making UVFITS output for the pre-processedor Tsys-corrected datasets ..." 
   515	$<
   516	echo "LSB: rx0 or 230 full-spectral-resoultion swarm dataset ..." 
   517	fits in=${dt}_rx00.lsb.sw.tsys op='uvout' out=${dt}_rx00.lsb.sw.tsys.uvfits
   518	echo "LSB: rx3 or 240 full-spectral-resoultion swarm dataset ..." 
   519	fits in=${dt}_rx03.lsb.sw.tsys op='uvout' out=${dt}_rx03.lsb.sw.tsys.uvfits
   520	echo "USB: rx0 or 230 full-spectral-resoultion swarm dataset ..." 
   521	fits in=${dt}_rx00.usb.sw.tsys op='uvout' out=${dt}_rx00.usb.sw.tsys.uvfits
   522	echo "USB: rx3 or 240 full-spectral-resoultion swarm dataset ..."
   523	fits in=${dt}_rx03.usb.sw.tsys op='uvout' out=${dt}_rx03.usb.sw.tsys.uvfits
   524	echo "Done with full-spectral-resoultion swarm datasets."
   525	echo "For swarm wideband UVFITS output, type Enter-key to continue -"
   526	$< 
   527	echo "LSB: rx0 or 230 swarm wideband dataset ..." 
   528	fits in=${dt}_rx00.lsb.wb.tsys op='uvout' out=${dt}_rx00.lsb.wb.tsys.uvfits
   529	echo "LSB: rx3 or 240 swarm wideband dataset ..."
   530	fits in=${dt}_rx03.lsb.wb.tsys op='uvout' out=${dt}_rx03.lsb.wb.tsys.uvfits
   531	echo "USB: rx0 or 230 swarm wideband dataset ..."
   532	fits in=${dt}_rx00.usb.wb.tsys op='uvout' out=${dt}_rx00.usb.wb.tsys.uvfits
   533	echo "USB: rx3 or 240 swarm wideband dataset ..."
   534	fits in=${dt}_rx03.usb.wb.tsys op='uvout' out=${dt}_rx03.usb.wb.tsys.uvfits
   535	echo "Done with swarm wideband datasets."
   536	echo "For ch0 UVFITS output, type Enter-key to continue -" 
   537	$<
   538	echo "LSB: rx0 or 230 ch0 dataset ..."
   539	fits in=${dt}_rx00.lsb.ch0.tsys op='uvout' out=${dt}_rx00.lsb.ch0.tsys.uvfits
   540	echo "LSB: rx3 or 240 ch0 dataset ..."
   541	fits in=${dt}_rx03.lsb.ch0.tsys op='uvout' out=${dt}_rx03.lsb.ch0.tsys.uvfits
   542	echo "USB: rx0 or 230 ch0 dataset ..."
   543	fits in=${dt}_rx00.usb.ch0.tsys op='uvout' out=${dt}_rx00.usb.ch0.tsys.uvfits
   544	echo "USB: rx3 or 240 ch0 dataset ..."
   545	fits in=${dt}_rx03.usb.ch0.tsys op='uvout' out=${dt}_rx03.usb.ch0.tsys.uvfits
   546	echo "Done with ch0 datasets."
   547	echo "For making tarballs for the UVFITS outputs, type Enter-key to continue -"
   548	$<
   549	echo "Tarring full-spectral-resoultion swarm UVFITS files ..."
   550	tar -cvf ${dt}_drx.sw.tsys.uvfits.tar ${dt}_rx0*.*sb.sw.tsys.uvfits 
   551	echo "Done with a tarball for full-spectral-resoultion swarm  UVFITS files."
   552	echo "For tarring wideband swarm UVFITS files, type Enter-key to continue -"
   553	$<
   554	echo "Tarring wideband swarm UVFITS files ..."
   555	tar -cvf ${dt}_drx.wb.tsys.uvfits.tar ${dt}_rx0*.*sb.wb.tsys.uvfits
   556	echo "Done with a tarball for wideband swarm  UVFITS files."
   557	echo "For tarring ch0 UVFITS files, type Enter-key to continue -"
   558	$<
   559	echo "Tarring ch0 UVFITS files ..."
   560	tar -cvf ${dt}_drx.ch0.tsys.uvfits.tar ${dt}_rx0*.*sb.ch0.tsys.uvfits
   561	echo "Done with a tarball for ch0  UVFITS files."
   562	echo "For leaving Miriad and delete intermediate working files, type Enter-key to continue -"
   563	$<
   564	echo "Cleaning ..."
   565	echo "Deleting *.ch0 files ..."
   566	\rm -fr *.ch0
   567	echo "Deleting *.sw files ..."
   568	\rm -fr *.sw
   569	echo "Deleting *.wb files ..."
   570	\rm -fr *.wb
   571	echo "Deleting *rx00.lsb & *rx00.usb files ..."
   572	\rm -fr *rx00.*sb
   573	echo "Deleting *rx03.lsb & *rx03.usb files ..."
   574	\rm -fr *rx03.*sb
   575	echo "Deleting *.ch0.tsys files ..."
   576	\rm -fr *.ch0.tsys
   577	echo "Deleting *.sw.tsys files ..."
   578	\rm -fr *.sw.tsys
   579	echo "Deleting *.wb.tsys files ..."
   580	\rm -fr *.wb.tsys
   581	echo "Deleting *rx00.lsb.tsys & *rx00.usb.tsys files ..."
   582	\rm -fr *rx00.*sb.tsys
   583	echo "Deleting *rx03.lsb.tsys & *rx03.usb.tsys files ..."
   584	\rm -fr *rx03.*sb.tsys
   585	echo "Done!"
   586	date
   587	exit