casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
test_calanalysis.py
Go to the documentation of this file.
00001 import os
00002 import sys
00003 import shutil
00004 from __main__ import default
00005 from tasks import *
00006 from taskinit import *
00007 import casac
00008 import unittest
00009 
00010 import numpy
00011 
00012 class calanalysis_tsys1( unittest.TestCase ):
00013 
00014         """This is a very simple unit test for introspective methods.  A Tsys
00015            calibration table is used."""
00016 
00017         ca = casac.casac.calanalysis()
00018 
00019         calName = 'uid___A002_X30a93d_X43e.ms.tsys.s3.tbl'
00020         msName = 'uid___A002_X30a93d_X43e.ms'
00021         parType = 'Float'
00022         polBasis = 'U'
00023         visCal = 'B TSYS'
00024 
00025         fieldName = ['J2253+161; 3c454.3', 'Callisto',
00026             'B0007+106; J0010+109', 'GRB021004']
00027         fieldNumber = ['0', '1', '2', '3']
00028         numField = len( fieldNumber )
00029 
00030         antennaName = ['DA41', 'DA42', 'DA43', 'DV02', 'DV03', 'DV05',
00031             'DV07', 'DV10', 'DV11', 'DV12', 'DV13', 'DV14', 'PM02', 'PM03']
00032         antennaNumber = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
00033             '10', '11', '12', '13']
00034         numAntenna = len( antennaNumber )
00035 
00036         antenna1Name = antennaName
00037         antenna1Number = antennaNumber
00038         numAntenna1 = numAntenna
00039 
00040         antenna2Name = ['NoName']
00041         antenna2Number = ['-1']
00042         numAntenna2 = 1
00043 
00044         feed = ['1', '2']
00045         numFeed = len( feed )
00046 
00047         spwName = ['', '', '', '', '', '', '', '', '', '', '', '', '', '',
00048             '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
00049         spwNumber = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
00050             '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
00051             '21', '22', '23', '24', '25', '26', '27', '28', '29', '30']
00052         numSPW = len( spwNumber )
00053 
00054         numChannel = numpy.array([4, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1,
00055             128, 1, 128, 1, 128, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
00056             4, 4, 4, 4, 4], dtype=numpy.int32)
00057 
00058         time = numpy.array([4827167647.3920002, 4827167780.5439997,
00059             4827168227.2320004, 4827168353.7600002, 4827168887.7600002,
00060             4827169009.632, 4827169543.6800003, 4827169665.6960001,
00061             4827170204.3520002, 4827170332.4160004, 4827170866.5600004,
00062             4827170989.5360003, 4827171523.776, 4827171647.2799997])
00063         numTime = len( time )
00064 
00065         def setUp( self ):
00066                 datapath = os.environ.get( 'CASAPATH' ).split()[0]
00067                 datapath += '/data/regression/unittest/calanalysis/'
00068                 return self.ca.open( datapath+self.calName )
00069 
00070         def tearDown( self ):
00071                 return self.ca.close()
00072 
00073         def test_introspective( self ):
00074 
00075                 """Test of introspective member functions"""
00076 
00077                 self.assertEqual( os.path.split(self.ca.calname())[1],
00078                     self.calName )
00079                 self.assertEqual( os.path.split(self.ca.msname())[1],
00080                     self.msName )
00081                 self.assertEqual( self.ca.partype(), self.parType )
00082                 self.assertEqual( self.ca.polbasis(), self.polBasis )
00083                 self.assertEqual( self.ca.viscal(), self.visCal )
00084 
00085                 self.assertEqual( self.ca.numfield(), self.numField )
00086                 self.assertEqual( self.ca.field(name=True), self.fieldName )
00087                 self.assertEqual( self.ca.field(name=False), self.fieldNumber )
00088 
00089                 self.assertEqual( self.ca.numantenna(), self.numAntenna )
00090                 self.assertEqual( self.ca.antenna(name=True), self.antennaName )
00091                 self.assertEqual( self.ca.antenna(name=False),
00092                     self.antennaNumber )
00093 
00094                 self.assertEqual( self.ca.numantenna1(), self.numAntenna1 )
00095                 self.assertEqual( self.ca.antenna1(name=True),
00096                     self.antenna1Name )
00097                 self.assertEqual( self.ca.antenna1(name=False),
00098                     self.antenna1Number )
00099 
00100                 self.assertEqual( self.ca.numantenna2(), self.numAntenna2 )
00101                 self.assertEqual( self.ca.antenna2(name=True),
00102                     self.antenna2Name )
00103                 self.assertEqual( self.ca.antenna2(name=False),
00104                     self.antenna2Number )
00105 
00106                 self.assertEqual( self.ca.numfeed(), self.numFeed )
00107                 self.assertEqual( self.ca.feed(), self.feed )
00108 
00109                 self.assertEqual( self.ca.numspw(), self.numSPW )
00110                 self.assertEqual( self.ca.spw(name=True), self.spwName )
00111                 self.assertEqual( self.ca.spw(name=False), self.spwNumber )
00112 
00113                 self.assertTrue( numpy.array_equal(self.ca.numchannel(), self.numChannel))
00114                 self.assertEqual( self.ca.numtime(), self.numTime )
00115                 self.assertTrue( numpy.allclose(self.ca.time(), self.time))
00116 
00117                 return None
00118 
00119 def suite():
00120         return [calanalysis_tsys1]