00001 ########################################################################## 00002 # imfit_test.py 00003 # 00004 # Copyright (C) 2008, 2009 00005 # Associated Universities, Inc. Washington DC, USA. 00006 # 00007 # This script is free software; you can redistribute it and/or modify it 00008 # under the terms of the GNU Library General Public License as published by 00009 # the Free Software Foundation; either version 2 of the License, or (at your 00010 # option) any later version. 00011 # 00012 # This library is distributed in the hope that it will be useful, but WITHOUT 00013 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 # License for more details. 00016 # 00017 # You should have received a copy of the GNU Library General Public License 00018 # along with this library; if not, write to the Free Software Foundation, 00019 # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00020 # 00021 # Correspondence concerning AIPS++ should be adressed as follows: 00022 # Internet email: aips2-request@nrao.edu. 00023 # Postal address: AIPS++ Project Office 00024 # National Radio Astronomy Observatory 00025 # 520 Edgemont Road 00026 # Charlottesville, VA 22903-2475 USA 00027 # 00028 # <author> 00029 # Dave Mehringer 00030 # </author> 00031 # 00032 # <summary> 00033 # Test suite for the CASA tool method ia.summary() 00034 # </summary> 00035 # 00036 # <reviewed reviwer="" date="" tests="" demos=""> 00037 # </reviewed 00038 # 00039 # <prerequisite> 00040 # <ul> 00041 # </ul> 00042 # </prerequisite> 00043 # 00044 # <etymology> 00045 # Test for the ia.summary() tool method 00046 # </etymology> 00047 # 00048 # <synopsis> 00049 # Test for the ia.summary tool method 00050 # </synopsis> 00051 # 00052 # <example> 00053 # 00054 # This test runs as part of the CASA python unit test suite and can be run from 00055 # the command line via eg 00056 # 00057 # `which casapy` --nologger --log2term -c `echo $CASAPATH | awk '{print $1}'`/linux_64b/python/2.6/runUnitTest.py test_ia_summary[test1,test2,...] 00058 # 00059 # </example> 00060 # 00061 # <motivation> 00062 # To provide a test standard for the ia.summary() tool method to ensure 00063 # coding changes do not break the associated bits 00064 # </motivation> 00065 # 00066 00067 ########################################################################### 00068 import shutil 00069 import casac 00070 from tasks import * 00071 from taskinit import * 00072 from __main__ import * 00073 import unittest 00074 00075 class ia_summary_test(unittest.TestCase): 00076 00077 def setUp(self): 00078 self._myia = iatool() 00079 00080 def tearDown(self): 00081 self._myia.done() 00082 00083 def test_beams(self): 00084 """test per plane beams get accounted for correctly""" 00085 myia = self._myia 00086 shape = [10, 10, 10, 4] 00087 myia.fromshape("", shape) 00088 bmaj = qa.quantity("4arcsec") 00089 bmin = qa.quantity("2arcsec") 00090 bpa = qa.quantity("40deg") 00091 myia.setrestoringbeam(major=bmaj, minor=bmin, pa=bpa, channel=0, polarization=0) 00092 cmaj = qa.quantity("7arcsec") 00093 cmin = qa.quantity("5arcsec") 00094 cpa = qa.quantity("80deg") 00095 myia.setrestoringbeam(major=cmaj, minor=cmin, pa=cpa, channel=6, polarization=3) 00096 summary = myia.summary() 00097 self.assertTrue(summary.has_key("perplanebeams")) 00098 beams = summary["perplanebeams"]["beams"] 00099 for c in range(shape[2]): 00100 for p in range(shape[3]): 00101 beam = beams["*" + str(c)]["*" + str(p)] 00102 majax = beam["major"] 00103 minax = beam["minor"] 00104 pa = beam["positionangle"] 00105 if c == 6 and p == 3: 00106 self.assertTrue(majax == cmaj) 00107 self.assertTrue(minax == cmin) 00108 self.assertTrue(pa == cpa) 00109 else: 00110 self.assertTrue(majax == bmaj) 00111 self.assertTrue(minax == bmin) 00112 self.assertTrue(pa == bpa) 00113 00114 def suite(): 00115 return [ia_summary_test]