Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
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_restoringbeam_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_global_beam(self):
00084 """Test adding, deleting, and setting beams"""
00085 myia = self._myia
00086 myia.fromshape(shape=[10, 10, 4, 10])
00087 self.assertFalse(bool(myia.restoringbeam()))
00088 major = "4arcsec"
00089 minor = "3arcsec"
00090 pa = "10deg"
00091 myia.setrestoringbeam(major=major, minor=minor, pa=pa)
00092 beam = myia.restoringbeam()
00093 self.assertTrue(beam["major"] == qa.quantity(major))
00094 self.assertTrue(beam["minor"] == qa.quantity(minor))
00095 self.assertTrue(beam["positionangle"] == qa.quantity(pa))
00096 for channel in [-1, 0, 1, 2]:
00097 for polarization in [-1, 0, 1, 2]:
00098 beam = myia.restoringbeam(channel=channel, polarization=polarization)
00099 self.assertTrue(beam["major"] == qa.quantity(major))
00100 self.assertTrue(beam["minor"] == qa.quantity(minor))
00101 self.assertTrue(beam["positionangle"] == qa.quantity(pa))
00102 myia.setrestoringbeam(remove=T)
00103 self.assertFalse(bool(myia.restoringbeam()))
00104
00105 def test_per_plane_beams(self):
00106 myia = self._myia
00107 nchan = 10
00108 npol = 4
00109 myia.fromshape(shape=[10, 10, npol, nchan])
00110 self.assertFalse(bool(myia.restoringbeam()))
00111 major = "4arcsec"
00112 minor = "3arcsec"
00113 pa = "10deg"
00114 myia.setrestoringbeam(major=major, minor=minor, pa=pa, channel=20, polarization=2)
00115 nmajor = "10arcsec"
00116 nminor = "5arcsec"
00117 npa = "40deg"
00118 myia.setrestoringbeam(
00119 major=nmajor, minor=nminor, pa=npa,
00120 channel=2, polarization=1
00121 )
00122 beams = myia.restoringbeam()
00123 self.assertTrue(beams["nChannels"] == nchan)
00124 self.assertTrue(beams["nStokes"] == npol)
00125 self.assertTrue(len(beams["beams"]) == nchan)
00126 for chan in range(nchan):
00127 rec = beams["beams"]["*" + str(chan)]
00128 for pol in range(npol):
00129 bmaj = major
00130 bmin = minor
00131 bpa = pa
00132 if chan == 2 and pol == 1:
00133 bmaj = nmajor
00134 bmin = nminor
00135 bpa = npa
00136 beam = rec["*" + str(pol)]
00137 self.assertTrue(beam["major"] == qa.quantity(bmaj))
00138 self.assertTrue(beam["minor"] == qa.quantity(bmin))
00139 self.assertTrue(beam["positionangle"] == qa.quantity(bpa))
00140 beam = myia.restoringbeam(channel=chan, polarization=pol)
00141 self.assertTrue(beam["major"] == qa.quantity(bmaj))
00142 self.assertTrue(beam["minor"] == qa.quantity(bmin))
00143 self.assertTrue(beam["positionangle"] == qa.quantity(bpa))
00144 for chan in [-1, 10]:
00145 for pol in [-1, 10]:
00146 if chan != -1 or pol != -1:
00147 self.assertRaises(
00148 Exception, myia.restoringbeam,
00149 channel=chan, polarization=pol
00150 )
00151
00152 def suite():
00153 return [ia_restoringbeam_test]