Commits

Benjamin Bean authored d2b77e4231b
CAS-12586 updated special use case tests in tsdimaging to expect fewer output channels

casa5/gcwrap/python/scripts/tests/test_tsdimaging.py

Modified
1346 1346 region_bottomleft = {'blc': [0, 0, 0, 0], 'trc': [11, 11, 0, 0]}
1347 1347 region_bottomright = {'blc': [9, 0, 0, 0], 'trc': [20, 11, 0, 0]}
1348 1348 # --- for "selection_spw_unifreq.ms" and "selection_spw.ms"
1349 1349 # flux taken from ms.statistics((column='CORRECTED_DATA', complex_value='amp', spw=idx)['mean']
1350 1350 spw_flux_unifreq = [3.0008814930915833, 5.0014331340789795, 6.001709461212158]
1351 1351 spw_flux = [5.001473307609558, 5.982952607795596, 3.011193051868015] #NOTE spw=1 and 2 has relatively large O(10^-4) dispersion in intensity.
1352 1352 spw_imsize_auto = [12, 12]
1353 1353 spw_nchan = 10
1354 1354 spw_blc_auto = [0, 0, 0, 0]
1355 1355 spw_trc_auto = [11, 11, 0, 9]
1356 + spw_trc_1spw_chan1 = [11, 11, 0, 5]
1356 1357 # blcf and trcf => qa.formxxx(+-qa.mul(cell_auto, 6.), "hms"/"dms", prec=3)
1357 1358 spw_stat_common = {'blc': spw_blc_auto,'trc': spw_trc_auto}
1359 + spw_stat_1spw_chan1 = {'blc': spw_blc_auto,'trc': spw_trc_1spw_chan1}
1358 1360 spw_region_all = {'blc': [1,1,0,0], 'trc': [11,11,0,9]}
1359 1361 # select channels 2 - 7
1360 1362 spw_region_chan1 = {'blc': [1,1,0,2], 'trc': [11,11,0,7]}
1363 + spw_region_1spw_chan1 = {'blc': [1,1,0,2], 'trc': [11,11,0,5]}
1361 1364
1362 1365 @property
1363 1366 def task(self):
1364 1367 return sdimaging
1365 1368
1366 1369 @property
1367 1370 def spw_channel_selection(self):
1368 1371 return True
1369 1372
1370 1373 def setUp(self):
1861 1864 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1862 1865 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1863 1866 refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1864 1867 out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1865 1868 # Tests
1866 1869 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-5)
1867 1870
1868 1871 def test_spw_id_exact_channel(self):
1869 1872 """test spw selection w/ channel selection (spw='2:2~7')"""
1870 1873 spw = '2:2~7' #chan=2-7 of spw=2 should be selected
1874 + nchan = 6 # special use case: 1ms, 1spw, subset of selected channels
1871 1875 selspw = [2]
1872 - region = self.spw_region_chan1
1876 + region = self.spw_region_1spw_chan1
1873 1877 infile = self.spwsel_ms
1874 1878 flux_list = self.__get_flux_value(infile)
1875 1879 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1876 1880 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1877 - refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1878 - out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1881 + refstats = merge_dict(self.spw_stat_1spw_chan1, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1882 + out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,nchan)
1879 1883 # Tests
1880 1884 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-3,rtol=1.e-3)
1881 1885
1882 1886 def test_spw_id_exact_frequency(self):
1883 1887 """test spw selection w/ channel selection (spw='1:300.4749~300.5251GHz')"""
1884 1888 spw = '1:300.4749~300.5251GHz' #chan=2-7 of spw=1 should be selected
1889 + nchan = 6 # special use case: 1ms, 1spw, subset of selected channels
1885 1890 selspw = [1]
1886 - region = self.spw_region_chan1
1891 + region = self.spw_region_1spw_chan1
1887 1892 infile = self.spwsel_ms
1888 1893 flux_list = self.__get_flux_value(infile)
1889 1894 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1890 1895 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1891 - refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1892 - out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1896 + refstats = merge_dict(self.spw_stat_1spw_chan1, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1897 + out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,nchan)
1893 1898 # Tests
1894 1899 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-3,rtol=1.e-3)
1895 1900
1896 1901 @unittest.expectedFailure
1897 1902 def test_spw_id_exact_velocity(self):
1898 1903 """test spw selection w/ channel selection (spw='0:X~Ykm/s') NOT SUPPORTED YET"""
1899 1904 self._default_test()
1900 1905
1901 1906 def test_spw_id_exact_list(self):
1902 1907 """test spw selection w/ channel selection (spw='2:6~7;2~5')"""
1903 1908 spw = '2:6~7;2~5' #chan=2-7 of spw=2 should be selected
1909 + nchan = 6 # special use case: 1ms, 1spw, subset of selected channels
1904 1910 selspw = [2]
1905 - region = self.spw_region_chan1
1911 + region = self.spw_region_1spw_chan1
1906 1912 infile = self.spwsel_ms
1907 1913 flux_list = self.__get_flux_value(infile)
1908 1914 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1909 1915 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1910 - refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1911 - out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1916 + refstats = merge_dict(self.spw_stat_1spw_chan1, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1917 + out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,nchan)
1912 1918 # Tests
1913 1919 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-3,rtol=1.e-3)
1914 1920
1915 1921 def test_spw_id_pattern_channel(self):
1916 1922 """test spw selection w/ channel selection (spw='*:2~7')"""
1917 1923 spw = '*:2~7'
1918 1924 region = self.spw_region_chan1
1919 1925 infile = self.unifreq_ms
1920 1926 flux_list = self.__get_flux_value(infile)
1921 1927 selspw = range(len(flux_list))
1961 1967 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1962 1968 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1963 1969 refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1964 1970 out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1965 1971 # Tests
1966 1972 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-5)
1967 1973
1968 1974 def test_spw_value_frequency_channel(self):
1969 1975 """test spw selection w/ channel selection (spw='300.4~300.5GHz:2~7')"""
1970 1976 spw = '300.4~300.5GHz:2~7'
1977 + nchan = 6 # special use case: 1ms, 1spw, subset of selected channels
1971 1978 selspw = [1]
1972 - region = self.spw_region_chan1
1979 + region = self.spw_region_1spw_chan1
1973 1980 infile = self.spwsel_ms
1974 1981 flux_list = self.__get_flux_value(infile)
1975 1982 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1976 1983 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1977 - refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1978 - out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1984 + refstats = merge_dict(self.spw_stat_1spw_chan1, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1985 + out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,nchan)
1979 1986 # Tests
1980 1987 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-3,rtol=1.e-3)
1981 1988
1982 1989 def test_spw_value_frequency_frequency(self):
1983 1990 """test spw selection w/ channel selection (spw='300.4~300.5GHz:300.4749~300.5251GHz')"""
1984 1991 spw = '300.4~300.5GHz:300.4749~300.5251GHz' #chan=2-7 of spw=1 should be selected'
1992 + nchan = 6 # special use case: 1ms, 1spw, subset of selected channels
1985 1993 selspw = [1]
1986 - region = self.spw_region_chan1
1994 + region = self.spw_region_1spw_chan1
1987 1995 infile = self.spwsel_ms
1988 1996 flux_list = self.__get_flux_value(infile)
1989 1997 self.task_param.update(dict(infiles=infile,spw=spw,imsize=self.spw_imsize_auto))
1990 1998 flux = sum([flux_list[idx] for idx in selspw])/float(len(selspw))
1991 - refstats = merge_dict(self.spw_stat_common, construct_refstat_uniform(flux, region['blc'], region['trc']) )
1992 - out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,self.spw_nchan)
1999 + refstats = merge_dict(self.spw_stat_1spw_chan1, construct_refstat_uniform(flux, region['blc'], region['trc']) )
2000 + out_shape = (self.spw_imsize_auto[0],self.spw_imsize_auto[1],1,nchan)
1993 2001 # Tests
1994 2002 self.run_test(self.task_param,refstats,out_shape,box=region,atol=1.e-3,rtol=1.e-3)
1995 2003
1996 2004 @unittest.expectedFailure
1997 2005 def test_spw_value_frequency_velocity(self):
1998 2006 """test spw selection w/ channel selection (spw='A~BHz:X~Ykm/s') NOT SUPPORTED YET"""
1999 2007 self._default_test()
2000 2008
2001 2009 @unittest.expectedFailure
2002 2010 def test_spw_value_frequency_list(self):

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut