casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
ngc5921_usecase.py
Go to the documentation of this file.
00001 ######################################################################
00002 #                                                                    #
00003 # Use Case Script for NGC 5921                                       #
00004 #                                                                    #
00005 # Converted by STM 2007-05-26                                        #
00006 # Updated      STM 2007-06-15 (Alpha Patch 1)                        #
00007 # Updated      STM 2007-09-05 (Alpha Patch 2+)                       #
00008 # Updated      STM 2007-09-18 (Alpha Patch 2+)                       #
00009 # Updated      STM 2007-09-18 (Pre-Beta) add immoments               #
00010 # Updated      STM 2007-10-04 (Beta) update                          #
00011 # Last Updated STM 2007-10-10 (Beta) add export                      #
00012 #                                                                    #
00013 ######################################################################
00014 
00015 import time
00016 import os
00017 
00018 # 
00019 # Set up some useful variables
00020 #
00021 # Get to path to the CASA home and stip off the name
00022 pathname=os.environ.get('CASAPATH').split()[0]
00023 
00024 # This is where the NGC5921 UVFITS data will be
00025 fitsdata=pathname+'/data/demo/NGC5921.fits'
00026 
00027 # The prefix to use for all output files
00028 prefix='ngc5921.usecase'
00029 
00030 # Clean up old files
00031 os.system('rm -rf '+prefix+'*')
00032 
00033 #
00034 #=====================================================================
00035 #
00036 # Import the data from FITS to MS
00037 #
00038 print '--Import--'
00039 
00040 # Safest to start from task defaults
00041 default('importuvfits')
00042 
00043 # Set up the MS filename and save as new global variable
00044 msfile = prefix + '.ms'
00045 
00046 # Use task importuvfits
00047 fitsfile = fitsdata
00048 vis = msfile
00049 importuvfits()
00050 
00051 #
00052 # Note that there will be a ngc5921.usecase.ms.flagversions
00053 # there containing the initial flags as backup for the main ms
00054 # flags.
00055 #
00056 #=====================================================================
00057 #
00058 # List a summary of the MS
00059 #
00060 print '--Listobs--'
00061 
00062 # Don't default this one and make use of the previous setting of
00063 # vis.  Remember, the variables are GLOBAL!
00064 
00065 # You may wish to see more detailed information, like the scans.
00066 # In this case use the verbose = True option
00067 verbose = True
00068 
00069 listobs()
00070 
00071 # You should get in your logger window and in the casapy.log file
00072 # something like:
00073 #
00074 # MeasurementSet Name:  /home/sandrock2/smyers/Testing2/Sep07/ngc5921.usecase.ms
00075 # MS Version 2
00076 # 
00077 # Observer: TEST     Project:   
00078 # Observation: VLA
00079 # 
00080 # Data records: 22653       Total integration time = 5280 seconds
00081 #    Observed from   09:19:00   to   10:47:00
00082 # 
00083 #    ObservationID = 0         ArrayID = 0
00084 #   Date        Timerange                Scan  FldId FieldName      SpwIds
00085 #   13-Apr-1995/09:19:00.0 - 09:24:30.0     1      0 1331+30500002_0  [0]
00086 #               09:27:30.0 - 09:29:30.0     2      1 1445+09900002_0  [0]
00087 #               09:33:00.0 - 09:48:00.0     3      2 N5921_2        [0]
00088 #               09:50:30.0 - 09:51:00.0     4      1 1445+09900002_0  [0]
00089 #               10:22:00.0 - 10:23:00.0     5      1 1445+09900002_0  [0]
00090 #               10:26:00.0 - 10:43:00.0     6      2 N5921_2        [0]
00091 #               10:45:30.0 - 10:47:00.0     7      1 1445+09900002_0  [0]
00092 # 
00093 # Fields: 3
00094 #   ID   Code Name          Right Ascension  Declination   Epoch   
00095 #   0    C    1331+30500002_013:31:08.29      +30.30.32.96  J2000   
00096 #   1    A    1445+09900002_014:45:16.47      +09.58.36.07  J2000   
00097 #   2         N5921_2       15:22:00.00      +05.04.00.00  J2000   
00098 # 
00099 # Spectral Windows:  (1 unique spectral windows and 1 unique polarization setups)
00100 #   SpwID  #Chans Frame Ch1(MHz)    Resoln(kHz) TotBW(kHz)  Ref(MHz)    Corrs   
00101 #   0          63 LSRK  1412.68608  24.4140625  1550.19688  1413.44902  RR  LL  
00102 # 
00103 # Feeds: 28: printing first row only
00104 #   Antenna   Spectral Window     # Receptors    Polarizations
00105 #   1         -1                  2              [         R, L]
00106 # 
00107 # Antennas: 27:
00108 #   ID   Name  Station   Diam.    Long.         Lat.         
00109 #   0    1     VLA:N7    25.0 m   -107.37.07.2  +33.54.12.9  
00110 #   1    2     VLA:W1    25.0 m   -107.37.05.9  +33.54.00.5  
00111 #   2    3     VLA:W2    25.0 m   -107.37.07.4  +33.54.00.9  
00112 #   3    4     VLA:E1    25.0 m   -107.37.05.7  +33.53.59.2  
00113 #   4    5     VLA:E3    25.0 m   -107.37.02.8  +33.54.00.5  
00114 #   5    6     VLA:E9    25.0 m   -107.36.45.1  +33.53.53.6  
00115 #   6    7     VLA:E6    25.0 m   -107.36.55.6  +33.53.57.7  
00116 #   7    8     VLA:W8    25.0 m   -107.37.21.6  +33.53.53.0  
00117 #   8    9     VLA:N5    25.0 m   -107.37.06.7  +33.54.08.0  
00118 #   9    10    VLA:W3    25.0 m   -107.37.08.9  +33.54.00.1  
00119 #   10   11    VLA:N4    25.0 m   -107.37.06.5  +33.54.06.1  
00120 #   11   12    VLA:W5    25.0 m   -107.37.13.0  +33.53.57.8  
00121 #   12   13    VLA:N3    25.0 m   -107.37.06.3  +33.54.04.8  
00122 #   13   14    VLA:N1    25.0 m   -107.37.06.0  +33.54.01.8  
00123 #   14   15    VLA:N2    25.0 m   -107.37.06.2  +33.54.03.5  
00124 #   15   16    VLA:E7    25.0 m   -107.36.52.4  +33.53.56.5  
00125 #   16   17    VLA:E8    25.0 m   -107.36.48.9  +33.53.55.1  
00126 #   17   18    VLA:W4    25.0 m   -107.37.10.8  +33.53.59.1  
00127 #   18   19    VLA:E5    25.0 m   -107.36.58.4  +33.53.58.8  
00128 #   19   20    VLA:W9    25.0 m   -107.37.25.1  +33.53.51.0  
00129 #   20   21    VLA:W6    25.0 m   -107.37.15.6  +33.53.56.4  
00130 #   21   22    VLA:E4    25.0 m   -107.37.00.8  +33.53.59.7  
00131 #   23   24    VLA:E2    25.0 m   -107.37.04.4  +33.54.01.1  
00132 #   24   25    VLA:N6    25.0 m   -107.37.06.9  +33.54.10.3  
00133 #   25   26    VLA:N9    25.0 m   -107.37.07.8  +33.54.19.0  
00134 #   26   27    VLA:N8    25.0 m   -107.37.07.5  +33.54.15.8  
00135 #   27   28    VLA:W7    25.0 m   -107.37.18.4  +33.53.54.8  
00136 # 
00137 # Tables:
00138 #    MAIN                   22653 rows     
00139 #    ANTENNA                   28 rows     
00140 #    DATA_DESCRIPTION           1 row      
00141 #    DOPPLER             <absent>  
00142 #    FEED                      28 rows     
00143 #    FIELD                      3 rows     
00144 #    FLAG_CMD             <empty>  
00145 #    FREQ_OFFSET         <absent>  
00146 #    HISTORY                  273 rows     
00147 #    OBSERVATION                1 row      
00148 #    POINTING                 168 rows     
00149 #    POLARIZATION               1 row      
00150 #    PROCESSOR            <empty>  
00151 #    SOURCE                     3 rows     
00152 #    SPECTRAL_WINDOW            1 row      
00153 #    STATE                <empty>  
00154 #    SYSCAL              <absent>  
00155 #    WEATHER             <absent>  
00156 # 
00157 #
00158 #=====================================================================
00159 #
00160 # Get rid of the autocorrelations from the MS
00161 #
00162 print '--Flag auto-correlation--'
00163 
00164 default('tflagdata')
00165 vis = msfile
00166 mode = 'manual'
00167 autocorr = True
00168 tflagdata()
00169 
00170 #
00171 #=====================================================================
00172 #
00173 # Set the fluxes of the primary calibrator(s)
00174 #
00175 print '--Setjy--'
00176 default('setjy')
00177 
00178 vis = msfile
00179 
00180 #
00181 # 1331+305 = 3C286 is our primary calibrator
00182 # Use the wildcard on the end of the source name
00183 # since the field names in the MS have inherited the
00184 # AIPS qualifiers
00185 field = '1331+305*'
00186 
00187 # This is 1.4GHz D-config and 1331+305 is sufficiently unresolved
00188 # that we dont need a model image.  For higher frequencies
00189 # (particularly in A and B config) you would want to use one.
00190 modimage = ''
00191 
00192 # Setjy knows about this source so we dont need anything more
00193 
00194 setjy()
00195 
00196 #
00197 # You should see something like this in the logger and casapy.log file:
00198 #
00199 # 1331+30500002_0  spwid=  0  [I=14.76, Q=0, U=0, V=0] Jy, (Perley-Taylor 99)
00200 #
00201 # So its using 14.76Jy as the flux of 1331+305 in the single Spectral Window
00202 # in this MS.
00203 #
00204 #=====================================================================
00205 #
00206 # Bandpass calibration
00207 #
00208 print '--Bandpass--'
00209 default('bandpass')
00210 
00211 # We can first do the bandpass on the single 5min scan on 1331+305
00212 # At 1.4GHz phase stablility should be sufficient to do this without
00213 # a first (rough) gain calibration.  This will give us the relative
00214 # antenna gain as a function of frequency.
00215 
00216 vis = msfile
00217 
00218 # set the name for the output bandpass caltable
00219 btable = prefix + '.bcal'
00220 caltable = btable
00221 
00222 # No gain tables yet
00223 gaintable = ''
00224 gainfield = ''
00225 interp = ''
00226 
00227 # Use flux calibrator 1331+305 = 3C286 (FIELD_ID 0) as bandpass calibrator
00228 field = '0'
00229 # all channels
00230 spw = ''
00231 # No other selection
00232 selectdata = False
00233 
00234 # In this band we do not need a-priori corrections for
00235 # antenna gain-elevation curve or atmospheric opacity
00236 # (at 8GHz and above you would want these)
00237 gaincurve = False
00238 opacity = 0.0
00239 
00240 # Choose bandpass solution type
00241 # Pick standard time-binned B (rather than BPOLY)
00242 bandtype = 'B'
00243 
00244 # set solution interval arbitrarily long (get single bpass)
00245 solint = 86400.0
00246 
00247 # reference antenna Name 15 (15=VLA:N2) (Id 14)
00248 refant = '15'
00249 
00250 bandpass()
00251 
00252 # You can use plotcal to examine the solutions
00253 #default('plotcal')
00254 #tablein = btable
00255 #yaxis = 'amp'
00256 #field = '0'
00257 #multiplot = True
00258 #plotcal()
00259 #
00260 #yaxis = 'phase'
00261 #plotcal()
00262 #
00263 # Note the rolloff in the start and end channels.  Looks like
00264 # channels 6-56 (out of 0-62) are the best
00265 
00266 #=====================================================================
00267 #
00268 # Gain calibration
00269 #
00270 print '--Gaincal--'
00271 default('gaincal')
00272 
00273 # Armed with the bandpass, we now solve for the
00274 # time-dependent antenna gains
00275 
00276 vis = msfile
00277 
00278 # set the name for the output gain caltable
00279 gtable = prefix + '.gcal'
00280 caltable = gtable
00281 
00282 # Use our previously determined bandpass
00283 # Note this will automatically be applied to all sources
00284 # not just the one used to determine the bandpass
00285 gaintable = btable
00286 gainfield = ''
00287 
00288 # Use nearest (there is only one bandpass entry)
00289 interp = 'nearest'
00290 
00291 # Gain calibrators are 1331+305 and 1445+099 (FIELD_ID 0 and 1)
00292 field = '0,1'
00293 
00294 # We have only a single spectral window (SPW 0)
00295 # Choose 51 channels 6-56 out of the 63
00296 # to avoid end effects.
00297 # Channel selection is done inside spw
00298 spw = '0:6~56'
00299 
00300 # No other selection
00301 selectdata = False
00302 
00303 # In this band we do not need a-priori corrections for
00304 # antenna gain-elevation curve or atmospheric opacity
00305 # (at 8GHz and above you would want these)
00306 gaincurve = False
00307 opacity = 0.0
00308 
00309 # scan-based G solutions for both amplitude and phase
00310 gaintype = 'G'
00311 solint = 0.
00312 calmode = 'ap'
00313 
00314 # minimum SNR allowed
00315 minsnr = 1.0
00316 
00317 # reference antenna 15 (15=VLA:N2)
00318 refant = '15'
00319 
00320 gaincal()
00321 
00322 # You can use plotcal to examine the gain solutions
00323 #default('plotcal')
00324 #tablein = gtable
00325 #yaxis = 'amp'
00326 #field = '0,1'
00327 #multiplot = True
00328 #plotcal()
00329 #
00330 #yaxis = 'phase'
00331 #plotcal()
00332 #
00333 # The amp and phase coherence looks good
00334 
00335 #=====================================================================
00336 #
00337 # Bootstrap flux scale
00338 #
00339 print '--Fluxscale--'
00340 default('fluxscale')
00341 
00342 vis = msfile
00343 
00344 # set the name for the output rescaled caltable
00345 ftable = prefix + '.fluxscale'
00346 fluxtable = ftable
00347 
00348 # point to our first gain cal table
00349 caltable = gtable
00350 
00351 # we will be using 1331+305 (the source we did setjy on) as
00352 # our flux standard reference - note its extended name as in
00353 # the FIELD table summary above (it has a VLA seq number appended)
00354 reference = '1331*'
00355 
00356 # we want to transfer the flux to our other gain cal source 1445+099
00357 transfer = '1445*'
00358 
00359 fluxscale()
00360 
00361 # In the logger you should see something like:
00362 # Flux density for 1445+09900002_0 in SpW=0 is:
00363 #     2.48576 +/- 0.00123122 (SNR = 2018.94, nAnt= 27)
00364 
00365 # If you run plotcal() on the tablein = 'ngc5921.usecase.fluxscale'
00366 # you will see now it has brought the amplitudes in line between
00367 # the first scan on 1331+305 and the others on 1445+099
00368 
00369 #=====================================================================
00370 #
00371 # Apply our calibration solutions to the data
00372 # (This will put calibrated data into the CORRECTED_DATA column)
00373 #
00374 print '--ApplyCal--'
00375 default('applycal')
00376 
00377 vis = msfile
00378 
00379 # We want to correct the calibrators using themselves
00380 # and transfer from 1445+099 to itself and the target N5921
00381 
00382 # Start with the fluxscale/gain and bandpass tables
00383 gaintable = [ftable,btable]
00384 
00385 # pick the 1445+099 out of the gain table for transfer
00386 # use all of the bandpass table
00387 gainfield = ['1','*']
00388 
00389 # interpolation using linear for gain, nearest for bandpass
00390 interp = ['linear','nearest']
00391 
00392 # only one spw, do not need mapping
00393 spwmap = []
00394 
00395 # all channels
00396 spw = ''
00397 selectdata = False
00398 
00399 # as before
00400 gaincurve = False
00401 opacity = 0.0
00402 
00403 # select the fields for 1445+099 and N5921
00404 field = '1,2'
00405 
00406 applycal()
00407 
00408 # Now for completeness apply 1331+305 to itself
00409 
00410 field = '0'
00411 gainfield = ['0','*']
00412 
00413 # The CORRECTED_DATA column now contains the calibrated visibilities
00414 
00415 applycal()
00416 
00417 #=====================================================================
00418 #
00419 # Split the gain calibrater data, then the target
00420 #
00421 print '--Split 1445+099 Data--'
00422 default('split')
00423 
00424 vis = msfile
00425 
00426 # We first want to write out the corrected data for the calibrator
00427 
00428 # Make an output vis file
00429 calsplitms = prefix + '.cal.split.ms'
00430 outputvis = calsplitms
00431 
00432 # Select the 1445+099 field, all chans
00433 field = '1445*'
00434 spw = ''
00435 
00436 # pick off the CORRECTED_DATA column
00437 datacolumn = 'corrected'
00438 
00439 split()
00440 
00441 #
00442 # Now split NGC5921 data (before continuum subtraction)
00443 #
00444 print '--Split NGC5921 Data--'
00445 
00446 splitms = prefix + '.src.split.ms'
00447 outputvis = splitms
00448 
00449 # Pick off N5921 
00450 field = 'N5921*'
00451 
00452 split()
00453 
00454 #=====================================================================
00455 #
00456 # Export the NGC5921 data as UVFITS
00457 # Start with the split file.
00458 #
00459 print '--Export UVFITS--'
00460 default('exportuvfits')
00461 
00462 srcuvfits = prefix + '.split.uvfits'
00463 
00464 vis = splitms
00465 fitsfile = srcuvfits
00466 
00467 # Since this is a split dataset, the calibrated data is
00468 # in the DATA column already.
00469 datacolumn = 'data'
00470 
00471 # Write as a multisource UVFITS (with SU table)
00472 # even though it will have only one field in it
00473 multisource = True
00474 
00475 # Run asynchronously so as not to interfere with other tasks
00476 # (BETA: also avoids crash on next importuvfits)
00477 async = True
00478 
00479 exportuvfits()
00480 
00481 #=====================================================================
00482 #
00483 # UV-plane continuum subtraction on the target
00484 # (this will update the CORRECTED_DATA column)
00485 #
00486 print '--UV Continuum Subtract--'
00487 default('uvcontsub')
00488 
00489 vis = msfile
00490 
00491 # Pick off N5921 
00492 field = 'N5921*'
00493 
00494 # Use channels 4-6 and 50-59 for continuum
00495 #spw = '0:4~6;50~59'
00496 # BETA ALERT: still does not use standard notation
00497 spw = '0'
00498 channels = range(4,7)+range(50,60)
00499 
00500 # Averaging time (none)
00501 solint = 0.0
00502 
00503 # Fit only a mean level
00504 fitorder = 0
00505 
00506 # Do the uv-plane subtraction
00507 fitmode = 'subtract'
00508 
00509 # Let it split out the data automatically for us
00510 splitdata = True
00511 
00512 uvcontsub()
00513 
00514 # You will see it made two new MS:
00515 # ngc5921.usecase.ms.cont
00516 # ngc5921.usecase.ms.contsub
00517 
00518 srcsplitms = msfile + '.contsub'
00519 
00520 # Note that ngc5921.usecase.ms.contsub contains the uv-subtracted
00521 # visibilities (in its DATA column), and ngc5921.usecase.ms.contsub
00522 # the pseudo-continuum visibilities (as fit).
00523 
00524 # The original ngc5921.usecase.ms now contains the uv-continuum
00525 # subtracted vis in its CORRECTED_DATA column and the continuum
00526 # in its MODEL_DATA column as per the fitmode='subtract'
00527 
00528 #=====================================================================
00529 #
00530 # Done with calibration
00531 # Now clean an image cube of N5921
00532 #
00533 print '--Clean--'
00534 default('clean')
00535 
00536 # Pick up our split source data
00537 vis = srcsplitms
00538 
00539 # Make an image root file name
00540 imname = prefix + '.clean'
00541 imagename = imname
00542 
00543 # Set up the output image cube
00544 mode = 'channel'
00545 nchan = 46
00546 start = 5
00547 step = 1
00548 
00549 # This is a single-source MS with one spw
00550 field = '0'
00551 spw = ''
00552 
00553 # Standard gain factor 0.1
00554 gain = 0.1
00555 
00556 # Set the output image size and cell size (arcsec)
00557 #imsize = [256,256]
00558 
00559 # Do a simple Clark clean
00560 alg = 'clark'
00561 
00562 # If desired, you can do a Cotton-Schwab clean
00563 # but will have only marginal improvement for this data
00564 #alg = 'csclean'
00565 # Twice as big for Cotton-Schwab (cleans inner quarter)
00566 #imsize = [512,512]
00567 
00568 # Pixel size 15 arcsec for this data (1/3 of 45" beam)
00569 # VLA D-config L-band
00570 cell = [15.,15.]
00571 
00572 # Fix maximum number of iterations
00573 niter = 6000
00574 
00575 # Also set flux residual threshold (in mJy)
00576 threshold=8.0
00577 
00578 # Set up the weighting
00579 # Use Briggs weighting (a moderate value, on the uniform side)
00580 weighting = 'briggs'
00581 rmode = 'norm'
00582 robust = 0.5
00583 
00584 # No clean mask or cleanbox for now
00585 mask = ''
00586 cleanbox = []
00587 
00588 # But if you had a cleanbox saved in a file, e.g. "regionfile.txt"
00589 # you could use it:
00590 #cleanbox='regionfile.txt'
00591 #
00592 # and if you wanted to use interactive clean
00593 #cleanbox='interactive'
00594 
00595 clean()
00596 
00597 # Should find stuff in the logger like:
00598 #
00599 # Fitted beam used in restoration: 51.5643 by 45.6021 (arcsec)
00600 #     at pa 14.5411 (deg)
00601 #
00602 # It will have made the images:
00603 # -----------------------------
00604 # ngc5921.usecase.clean.image
00605 # ngc5921.usecase.clean.model
00606 # ngc5921.usecase.clean.residual
00607 
00608 clnimage = imname+'.image'
00609 
00610 #=====================================================================
00611 #
00612 # Done with imaging
00613 # Now view the image cube of N5921
00614 #
00615 #print '--View image--'
00616 #viewer(clnimage,'image')
00617 
00618 #=====================================================================
00619 #
00620 # Export the Final CLEAN Image as FITS
00621 #
00622 print '--Final Export CLEAN FITS--'
00623 default('exportfits')
00624 
00625 clnfits = prefix + '.clean.fits'
00626 
00627 imagename = clnimage
00628 fitsimage = clnfits
00629 
00630 # Run asynchronously so as not to interfere with other tasks
00631 # (BETA: also avoids crash on next importfits)
00632 async = True
00633 
00634 exportfits()
00635 
00636 #=====================================================================
00637 #
00638 # Get some image statistics
00639 #
00640 print '--Imhead--'
00641 default('imhead')
00642 
00643 imagename = clnimage
00644 
00645 mode = 'stats'
00646 
00647 cubestats = imhead()
00648 
00649 # A summary of the cube will be seen in the logger
00650 # cubestats will contain a dictionary of the statistics
00651 
00652 #=====================================================================
00653 #
00654 # Get some image moments
00655 #
00656 print '--ImMoments--'
00657 default('immoments')
00658 
00659 imagename = clnimage
00660 
00661 # Do first and second moments
00662 moments = [0,1]
00663 
00664 # Need to mask out noisy pixels, currently done
00665 # using hard global limits
00666 excludepix = [-100,0.009]
00667 
00668 # Include all planes
00669 planes = ''
00670 
00671 # Output root name
00672 momfile = prefix + '.moments'
00673 outfile = momfile
00674 
00675 immoments()
00676 
00677 momzeroimage = momfile + '.integrated'
00678 momoneimage = momfile + '.weighted_coord'
00679 
00680 # It will have made the images:
00681 # --------------------------------------
00682 # ngc5921.usecase.moments.integrated
00683 # ngc5921.usecase.moments.weighted_coord
00684 
00685 #=====================================================================
00686 #
00687 # Get some statistics of the moment images
00688 #
00689 print '--Imhead--'
00690 default('imhead')
00691 
00692 mode = 'stats'
00693 imagename = momzeroimage
00694 
00695 momzerostats = imhead()
00696 
00697 imagename = momoneimage
00698 
00699 momonestats = imhead()
00700 
00701 #=====================================================================
00702 #
00703 # Can do some image statistics if you wish
00704 # Treat this like a regression script
00705 # WARNING: currently requires toolkit
00706 #
00707 print ' NGC5921 results '
00708 print ' =============== '
00709 
00710 #
00711 # Use the ms tool to get max of the MSs
00712 # Eventually should be available from a task
00713 #
00714 # Pull the max cal amp value out of the MS
00715 ms.open(calsplitms)
00716 thistest_cal = max(ms.range(["amplitude"]).get('amplitude'))
00717 ms.close()
00718 oldtest_cal = 34.0338668823
00719 print ' Cal Max amplitude should be ',oldtest_cal
00720 print ' Found : Max = ',thistest_cal
00721 diff_cal = abs((oldtest_cal-thistest_cal)/oldtest_cal)
00722 print ' Difference (fractional) = ',diff_cal
00723 
00724 print ''
00725 # Pull the max src amp value out of the MS
00726 ms.open(srcsplitms)
00727 thistest_src = max(ms.range(["amplitude"]).get('amplitude'))
00728 ms.close()
00729 #oldtest_src =  1.37963354588 # This was in chans 5-50
00730 oldtest_src =  46.2060050964 # now in all chans
00731 print ' Src Max amplitude should be ',oldtest_src
00732 print ' Found : Max = ',thistest_src
00733 diff_src = abs((oldtest_src-thistest_src)/oldtest_src)
00734 print ' Difference (fractional) = ',diff_src
00735 
00736 #
00737 # Now use the stats produced by imhead above
00738 #
00739 print ''
00740 # Pull the max from the cubestats dictionary
00741 # created above using imhead
00742 thistest_immax=cubestats['max'][0]
00743 oldtest_immax = 0.052414759993553162
00744 print ' Clean image max should be ',oldtest_immax
00745 print ' Found : Image Max = ',thistest_immax
00746 diff_immax = abs((oldtest_immax-thistest_immax)/oldtest_immax)
00747 print ' Difference (fractional) = ',diff_immax
00748 
00749 print ''
00750 # Pull the rms from the cubestats dictionary
00751 thistest_imrms=cubestats['rms'][0]
00752 oldtest_imrms = 0.0020218724384903908
00753 print ' Clean image rms should be ',oldtest_imrms
00754 print ' Found : Image rms = ',thistest_imrms
00755 diff_imrms = abs((oldtest_imrms-thistest_imrms)/oldtest_imrms)
00756 print ' Difference (fractional) = ',diff_imrms
00757 
00758 print ''
00759 # Pull the max from the momzerostats dictionary
00760 thistest_momzeromax=momzerostats['max'][0]
00761 oldtest_momzeromax = 1.40223777294
00762 print ' Moment 0 image max should be ',oldtest_momzeromax
00763 print ' Found : Moment 0 Max = ',thistest_momzeromax
00764 diff_momzeromax = abs((oldtest_momzeromax-thistest_momzeromax)/oldtest_momzeromax)
00765 print ' Difference (fractional) = ',diff_momzeromax
00766 
00767 print ''
00768 # Pull the mean from the momonestats dictionary
00769 thistest_momoneavg=momonestats['mean'][0]
00770 oldtest_momoneavg = 1479.77119646
00771 print ' Moment 1 image mean should be ',oldtest_momoneavg
00772 print ' Found : Moment 1 Mean = ',thistest_momoneavg
00773 diff_momoneavg = abs((oldtest_momoneavg-thistest_momoneavg)/oldtest_momoneavg)
00774 print ' Difference (fractional) = ',diff_momoneavg
00775 
00776 print ''
00777 print '--- Done ---'
00778 
00779 #
00780 #=====================================================================