Commits
Sandra M Castro authored 58f5850102e
25 25 | import testutils |
26 26 | except: |
27 27 | import tests.testutils as testutils |
28 28 | |
29 29 | import restfreqtool |
30 30 | from tsdimaging import tsdimaging as sdimaging |
31 31 | from sdutil import tbmanager, toolmanager, table_selector |
32 32 | from task_tsdimaging import image_suffix |
33 33 | |
34 34 | |
35 - | def get_data_req_path(): |
36 - | data_path = os.path.join(os.environ['CASAPATH'].split()[0], 'casa-data-req/') |
37 - | if not os.path.exists(data_path): |
38 - | data_path = os.path.join(os.environ['CASAPATH'].split()[0], 'data/casa-data-req') |
39 - | print('CASA_DATA_REQ_PATH="{}"'.format(data_path)) |
40 - | return data_path |
35 + | # def get_data_req_path(): |
36 + | # data_path = os.path.join(os.environ['CASAPATH'].split()[0], 'casa-data-req/') |
37 + | # if not os.path.exists(data_path): |
38 + | # data_path = os.path.join(os.environ['CASAPATH'].split()[0], 'data/casa-data-req') |
39 + | # print('CASA_DATA_REQ_PATH="{}"'.format(data_path)) |
40 + | # return data_path |
41 41 | |
42 42 | |
43 43 | # |
44 44 | # Unit test of sdimaging task. |
45 45 | # |
46 46 | def construct_refstat_uniform(fluxval, blc_data, trc_data): |
47 47 | """ |
48 48 | Return a dictionary of analytic reference statistics of uniform image |
49 49 | Arguments: |
50 50 | fluxval : the uniform flux of the image |
145 145 | tbsel=tb.query('SCAN_NUMBER<100') |
146 146 | tbc=tbsel.copy('sdimaging.ms',deep=True,valuecopy=True) |
147 147 | tbsel.close() |
148 148 | tb.close() |
149 149 | tbc.close() |
150 150 | |
151 151 | Furthermore, SYSCAL and POINTING tables are downsized. |
152 152 | |
153 153 | """ |
154 154 | taskname='sdimaging' |
155 - | datapath=os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
155 + | datapath=os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
156 156 | #rawfile='sdimaging.ms' |
157 157 | postfix='.im' |
158 158 | ms_nchan = 1024 |
159 159 | # phasecenter='J2000 17:18:29 +59.31.23' |
160 160 | # imsize=[75,75] |
161 161 | # cell=['3.0arcmin','3.0arcmin'] |
162 162 | # gridfunction='PB' |
163 163 | # minweight0 = 0. |
164 164 | statsinteg={'blc': numpy.array([0, 0, 0, 0], dtype=numpy.int32), |
165 165 | 'blcf': '17:32:18.690, +57.37.28.536, I, 1.42064e+09Hz', |
2550 2550 | (1) defined by parameter restfreq (test_restfreq_param) |
2551 2551 | (2) obtain a value in REST_FREQUENCY column in SOURCE subtable |
2552 2552 | (test_restfreq_source) |
2553 2553 | (3) define as mean frequency of representative SPW (test_restfreq_mean) |
2554 2554 | |
2555 2555 | The rest frequency value will affect three numbers in image: |
2556 2556 | - the rest frequency of the image |
2557 2557 | - the default cell size of the image |
2558 2558 | - the beam size of the image |
2559 2559 | """ |
2560 - | datapath=os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
2560 + | datapath=os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
2561 2561 | infiles = 'selection_spw.ms' |
2562 2562 | outfile = 'sdimaging_restfreq.im' |
2563 2563 | param_base = dict(infiles=infiles,outfile=outfile,intent="", |
2564 2564 | outframe='lsrk',stokes='I',spw='1', |
2565 2565 | phasecenter='J2000 00:00:00 00.00.00', |
2566 2566 | restfreq='',overwrite=True) |
2567 2567 | unifval = 5.98155 |
2568 2568 | |
2569 2569 | def setUp(self): |
2570 2570 | self.cache_validator = testutils.TableCacheValidator() |
2646 2646 | This test case defines automatic calculation of phasecenter and |
2647 2647 | imsize. Basic tests has already been defined in test109 and test402 |
2648 2648 | so that some specific tests are defined here: |
2649 2649 | |
2650 2650 | test_azel_pointing -- Verify phasecenter in J2000 is properly calculated |
2651 2651 | from AZELGEO pointing direction |
2652 2652 | test_data_selection -- Verify phasecenter is properly calculated from |
2653 2653 | only selected data |
2654 2654 | test_ephemeris -- Verify phasecenter for ephemeris source |
2655 2655 | """ |
2656 - | datapath=os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
2656 + | datapath=os.environ.get('CASAPATH').split()[0] + '/casatestdata//unittest/tsdimaging/' |
2657 2657 | infiles_ephem = ['Uranus1.cal.Ant0.spw34.ms', |
2658 2658 | 'Uranus2.cal.Ant0.spw34.ms'] |
2659 2659 | infiles_selection = 'selection_misc.ms' |
2660 2660 | infiles_azel = 'azelpointing.ms' |
2661 2661 | outfile = 'sdimaging_test_mapextent.im' |
2662 2662 | |
2663 2663 | scan = '16' |
2664 2664 | region_topright = {'blc': [9, 9, 0, 0], 'trc': [20, 20, 0, 0]} |
2665 2665 | |
2666 2666 | param_base = {'mode': 'channel', |
2806 2806 | The data is taken so that the scanned points are enclosed in a rectangle |
2807 2807 | region if the moving target position (off the solar center) is fixed in the |
2808 2808 | output image. If moving object tracking does not work, the data points will |
2809 2809 | be distributed in a parallelogram-like region. FYI, the data is generated |
2810 2810 | using the following command: |
2811 2811 | mstransform(vis='uid___A002_Xd01cd7_X3f35.ms', outputvis='ephemtest.spw18.ms', |
2812 2812 | reindex=False, spw='18', intent='OBSERVE_TARGET#ON_SOURCE', |
2813 2813 | datacolumn='float_data') |
2814 2814 | """ |
2815 2815 | |
2816 - | datapath=os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
2816 + | datapath=os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
2817 2817 | infiles = 'ephemtest.spw18.ms' |
2818 2818 | ephtab = infiles + '/FIELD/EPHEM0_Sol_58327.6.tab' |
2819 2819 | outfile = 'sdimaging_test_ephemeris.im' |
2820 2820 | |
2821 2821 | param_base = {'infiles': infiles, |
2822 2822 | 'field': 'Sol', |
2823 2823 | 'spw': '18', |
2824 2824 | 'mode': 'channel', |
2825 2825 | 'start': 0, |
2826 2826 | 'nchan': 1, |
2979 2979 | Both 'pointing6.ms' and 'pointing6-2.ms' contain 1000 rows for TP data, while only 10 |
2980 2980 | rows given for POINTING data. |
2981 2981 | The pointing data is given as corner points of a hexagon centered at (RA, Dec) = |
2982 2982 | (0h00m00s, 0d00m00s) and with side of 0.001 radian and 0.0008 radian for 'pointing6.ms' |
2983 2983 | and 'pointing6-2.ms', respectively. |
2984 2984 | The resulting pattern of weight image should be nearly circular if spline interpolation |
2985 2985 | does work, while it should be hexagonal if linear interpolation, the old algorithm, is |
2986 2986 | applied. |
2987 2987 | Also, 'pointing6-2.ms' has 5 hours lag behind 'pointing6.ms'. |
2988 2988 | """ |
2989 - | datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
2989 + | datapath = os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
2990 2990 | params = dict(antenna = "0", |
2991 2991 | intent = "*ON_SOURCE*", |
2992 2992 | gridfunction = "SF", |
2993 2993 | convsupport = 6, |
2994 2994 | imsize = [512, 512], |
2995 2995 | cell = "2arcsec", |
2996 2996 | phasecenter = "J2000 0:00:00.0 00.00.00.0", |
2997 2997 | pointingcolumn = "direction", |
2998 2998 | stokes = 'I') |
2999 2999 | infiles = [] |
3123 3123 | |
3124 3124 | class sdimaging_test_interp_old(sdimaging_unittest_base): |
3125 3125 | """ |
3126 3126 | The test data 'pointing6.ms' contains 1000 rows for TP data, while only 10 rows given |
3127 3127 | for POINTING data. The pointing data is given as corner points of a hexagon centered at |
3128 3128 | (RA, Dec) = (0h00m00s, 0d00m00s) and with side of 0.001 radian. |
3129 3129 | The resulting pattern of weight image should be nearly circular if spline interpolation |
3130 3130 | does work, while it should be hexagonal if linear interpolation, the old algorithm, is |
3131 3131 | applied. |
3132 3132 | """ |
3133 - | datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
3133 + | datapath = os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
3134 3134 | params = dict(infiles = ['pointing6.ms'], |
3135 3135 | outfile = "pointing6.out", |
3136 3136 | antenna = "0", |
3137 3137 | intent = "*ON_SOURCE*", |
3138 3138 | gridfunction = "SF", |
3139 3139 | convsupport = 6, |
3140 3140 | imsize = [512, 512], |
3141 3141 | cell = "2arcsec", |
3142 3142 | phasecenter = "J2000 0:00:00.0 00.00.00.0", |
3143 3143 | pointingcolumn = "direction") |
3636 3636 | } |
3637 3637 | self.run_test_common(self.task_param, refstats, outshape, |
3638 3638 | compstats=self.keys, ignoremask=False, |
3639 3639 | projection=projection) |
3640 3640 | |
3641 3641 | |
3642 3642 | class sdimaging_test_output(sdimaging_unittest_base): |
3643 3643 | """ |
3644 3644 | Tests to check if only appropriate images are output |
3645 3645 | """ |
3646 - | datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/sdimaging/' |
3646 + | datapath = os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
3647 3647 | params = dict(infiles = ['selection_misc.ms'], |
3648 3648 | outfile = "outmisc", |
3649 3649 | imsize = [80,80], # to suppress warning messages |
3650 3650 | intent = '') |
3651 3651 | outfile = params['outfile'] |
3652 3652 | |
3653 3653 | def __copy_table(self, f): |
3654 3654 | remove_table(f) |
3655 3655 | testutils.copytree_ignore_subversion(self.datapath, f) |
3656 3656 | |
3687 3687 | mesg = '{} must be created, but is not found.'.format(filename) |
3688 3688 | self.assertTrue(os.path.exists(filename), msg=mesg) |
3689 3689 | # check data that must not be output |
3690 3690 | for suffix in ['.sumwt', '.psf']: |
3691 3691 | filename = self.outfile + suffix |
3692 3692 | mesg = '{} must not be created, but it exists.'.format(filename) |
3693 3693 | self.assertFalse(os.path.exists(filename), msg=mesg) |
3694 3694 | |
3695 3695 | |
3696 3696 | class sdimaging_antenna_move(sdimaging_unittest_base): |
3697 - | datapath = os.path.join(get_data_req_path(), 'visibilities/almasd') |
3697 + | datapath=os.environ.get('CASAPATH').split()[0] + '/casatestdata/unittest/tsdimaging/' |
3698 3698 | infiles = ['PM04_A108.ms', 'PM04_T704.ms'] |
3699 3699 | outfile = 'antenna_move' |
3700 3700 | |
3701 3701 | def setUp(self): |
3702 3702 | self.__clear_files() |
3703 3703 | |
3704 3704 | self.assertTrue(os.path.exists(self.datapath)) |
3705 3705 | |
3706 3706 | for infile in self.infiles: |
3707 3707 | shutil.copytree(os.path.join(self.datapath, infile), infile) |