8 + | from casatasks.private.casa_transition import is_CASA6 |
9 + | if is_CASA6: |
10 + | from casatools import ctsys |
11 + | from casatasks import predictcomp, casalog |
12 + | |
13 + | ctsys_resolve = ctsys.resolve |
14 + | else: |
15 + | from __main__ import default |
16 + | from tasks import predictcomp |
17 + | from taskinit import * |
18 + | |
19 + | dataRoot = os.path.join(os.environ.get('CASAPATH'.split()[0],'data')) |
20 + | def ctsys_resolve(apath): |
21 + | return os.path.join(dataRoot,apath) |
53 72 | def test_valid_objname(self): |
54 73 | '''predictcomp: valid objname''' |
55 74 | self.res=predictcomp(objname='Titan', epoch='2017/09/01/00:00', minfreq='100GHz',maxfreq='120GHz', |
56 75 | standard='Butler-JPL-Horizons 2012') |
57 76 | print("type(self.res) = ",type(self.res)) |
58 77 | self.assertTrue(type(self.res)==dict) |
59 78 | self.assertTrue(os.path.exists(self.res['clist'])) |
60 79 | |
61 80 | def test_invalid_freqrange(self): |
62 - | '''predictcomp: invalud freqrange''' |
63 - | self.res=predictcomp(objname='Titan', epoch='2017/09/01/00:00', minfreq='100',maxfreq='120') |
64 - | self.assertIsNone(self.res) |
65 - | |
81 + | '''predictcomp: invalid freqrange''' |
82 + | if is_CASA6: |
83 + | |
84 + | self.assertRaises(Exception, predictcomp, objname='Titan', epoch='2017/09/01/00:00', minfreq='100', maxfreq='120' ) |
85 + | else: |
86 + | |
87 + | self.res=predictcomp(objname='Titan', epoch='2017/09/01/00:00', minfreq='100',maxfreq='120') |
88 + | self.assertIsNone(self.res) |
89 + | |
67 - | '''predictcomp: generate visibility plot for a given array configuration''' |
68 - | self.res=predictcomp(objname='Titan', epoch='2017/09/01/00:00', minfreq='100GHz',maxfreq='120GHz', |
69 - | standard='Butler-JPL-Horizons 2012',antennalist=datapath+'alma.cycle5.1.cfg', showplot=False,savefig='visplot.png') |
70 - | self.assertTrue(type(self.res)==dict) |
71 - | self.assertTrue(os.path.exists(self.res['clist'])) |
72 - | self.assertTrue(os.path.exists('visplot.png')) |
91 + | |
92 + | if is_CASA6: |
93 + | casalog.post('test_predicted_visplot SKIPPED: no plotting in this part of casa','INFO') |
94 + | else: |
95 + | '''predictcomp: generate visibility plot for a given array configuration''' |
96 + | self.res=predictcomp( objname='Titan', epoch='2017/09/01/00:00', minfreq='100GHz', |
97 + | maxfreq='120GHz', standard='Butler-JPL-Horizons 2012', |
98 + | antennalist=ctsys.resolve(os.path.join(datapath,'alma.cycle5.1.cfg')), |
99 + | showplot=False,savefig='visplot.png' ) |
100 + | self.assertTrue(type(self.res)==dict) |
101 + | self.assertTrue(os.path.exists(self.res['clist'])) |
102 + | self.assertTrue(os.path.exists('visplot.png')) |
76 - | self.res=predictcomp(objname='Mars', epoch='2018/09/01/00:00', minfreq='100GHz',maxfreq='120GHz', |
77 - | antennalist=datapath+'alma.cycle5.1.cfg',showplot=False) |
78 - | self.assertIsNone(self.res) |
106 + | if is_CASA6: |
107 + | |
108 + | self.assertRaises( Exception, predictcomp, objname='Mars', epoch='2018/09/01/00:00', minfreq='100GHz', maxfreq='120GHz', |
109 + | antennalist=ctsys.resolve(os.path.join(datapath,'alma.cycle5.1.cfg')), showplot=False ) |
110 + | else: |
111 + | |
112 + | self.res=predictcomp(objname='Mars', epoch='2018/09/01/00:00', minfreq='100GHz',maxfreq='120GHz', |
113 + | antennalist=datapath+'alma.cycle5.1.cfg',showplot=False) |
114 + | self.assertIsNone(self.res) |