Commits

Sandra Castro authored a0a4205bd45
Added main at the end of tests.

Removed unused imports Renamed class of test.
No tags

casatasks/tests/tasks/test_task_gclean.py

Modified
7 7 # This script is free software; you can redistribute it and/or modify it
8 8 # under the terms of the GNU Library General Public License as published by
9 9 # the Free Software Foundation; either version 2 of the License, or (at your
10 10 # option) any later version.
11 11 #
12 12 # This library is distributed in the hope that it will be useful, but WITHOUT
13 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 15 # License for more details.
16 16 #
17 -# Based on the requirements listed in casadocs found here:
18 -# https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.imaging.tclean.html
19 -#
20 -# Each of the following categories (classes) has a set of tests within it.
21 -#
22 -# test_onefield # basic tests, deconvolution algorithms
23 -# test_iterbot # iteration control options for mfs and cube
24 -# test_multifield # multiple fields of same type and with different shapes/deconvolvers/gridders
25 -# test_stokes # multiple stokes planes, imaging with flagged correlations..
26 -# test_cube # all things cube. Spectral frame setup, handling empty channels, etc
27 -# test_widefield # facets, wprojection, imagemosaic, mosaicft, awproject
28 -# test_mask # input mask options : regridding, mask file, automasking, etc
29 -# test_modelvis # saving models (column/otf), using starting models, predict-only (setjy)
30 -# test_ephemeris # ephemeris tests for gridder standard and mosaic, mode mfs and cubesource
31 -#
32 -# To run the tests with python3 or casa in the command line
33 -#
34 -# ./casa -c ./test_tclean.py
35 -# ./python3 ./test_tclean.py
36 -# ./casa -c ./casa6/casatestutils/runtest.py -h # to see all options
37 -# ./casa -c ./casa6/casatestutils/runtest.py ./test_tclean.py # run the local test script
38 -# ./casa -c ./casa6/casatestutils/runtest.py ./test_tclean.py
39 -
40 -# To run from within a casa 6 session:
41 -#
42 -# from casatestutils import runtest
43 -# runtest.run(['test_tclean']) # pull test script from git trunk
44 -# runtest.run(['/path-to-test/test_tclean.py']) # run a local test script
45 -# runtest.run(['test_tclean[test_onefield_clark,test_onefield_hogbom]']) # pull multiple test cases from git trunk
46 -# runtest.run(['test_tclean.py[test_onefield_clark,test_onefield_hogbom]']) # run multiple test cases from local test script
47 -# See documentation for runtest.py in README.md of casatestutils
48 -# To see the full list of tests : grep "\"\"\" \[" test_tclean.py
49 -#
50 -# These tests need data stored in casatestdata/unittest/tclean
51 -# The datasets are symliked to the above directory. If using cp to copy them locally,
52 -# Use cp -RH
53 -#
54 -# For a developer build, to get the datasets locally
55 -#
56 -# --- Get the test data repo : svn co https://svn.cv.nrao.edu/svn/casatestdata casatestdata
57 -# --- Use ~/.casa/config.py to point to the casatestdata
58 -# ########################################################################
59 -# SKIPPED TESTS
60 -# More tests were added to skip (as of 2019,04,26)
61 -#
62 -# (as of 2019.02.05 - Seven tests total)
63 -# The following tests are currently skipped as the supports of the particular
64 -# modes are not available in parallel mode yet
65 -# =>
66 -# test_multifield_both_cube_diffshape
67 -# test_multifield_cube_mfs
68 -# test_multifield_cube_mtmfs
69 -#
70 -# The following tests in pricipal should be working but curently broken
71 -# for parallel until fixes to test or code are properly made.
72 -# => test_multifield_facets_mfs
73 -# test_multifield_facets_mtmfs
74 -#
75 -# Added to skip at least for 5.5
76 -# test_cube_chanchunks
77 -# test_cube_chanchunks_savemodel (possible race conditions)
78 -# test_modelvis_2 (possible race conditions)
79 -# test_modelvis_3 (possible race conditions)
80 -# test_modelvis_5 (possible race conditions)
81 -# test_modelvis_6 (possible race conditions)
82 -# test_modelvis_7 (possible race conditions)
83 -# test_modelvis_8 (possible race conditions)
84 -# test_modelvis_9 (possible race conditions)
85 -# test_modelvis_10 (possible race conditions)
86 -# test_modelvis_11 (possible race conditions)
87 -# test_startmodel_with_mask_mfs(possible race conditions)
88 -# test_startmodel_with_mask_mtmfs(possible race conditions)
89 -
90 -# Ressurected from skipping after some fixes
91 -# test_mask_5
92 -# test_iterbot_cube_2
93 -# test_multifield_both_cube
94 -##########################################################################
95 -#
96 -# Datasets
97 -#
98 -# refim_twochan.ms : 2 channels, one 1Jy point source with spectral index of -1.0
99 -# refim_twopoints_twochan.ms : Two point sources, 1Jy and 5Jy, both with spectral index -1.0. For multifield tests.
100 -# refim_point.ms : 1-2 GHz, 20 channels, 1 spw, one 1Jy point source with spectral index -1.0.
101 -# refim_point_withline.ms : refim_point with a 'line' added into 3 channels (just topo)
102 -# refim_mawproject.ms : Two pointing wideband mosaic with 1 point source in between the two pointings
103 -# refim_mawproject_offcenter.ms : Two pointing wideband mosaic with 1 point source at center of one pointing
104 -# refim_point_stokes.ms : RR=1.0, LL=0.8, RL and LR are zero. Stokes I=0.9, V=0.1, U,Q=0.0
105 -# refim_point_linRL.ms : I=1, Q=2, U=3, V=4 in circular pol basis.
106 -# venus_ephem_test.ms : 7-point mosaic of Venus (ephemeris), Band 6, 1 spw, averaged to 1 chan
107 -#
108 -# List of test classes
109 -#
110 -# [test_onefield, test_iterbot, test_multifield,test_stokes, test_modelvis, test_cube, test_mask, test_startmodel, test_widefield,
111 -# test_pbcor, test_mosaic_mtmfs, test_mosaic_cube, test_ephemeris, test_hetarray_imaging, test_wproject, test_errors_failures]
17 +# Based on the requirements listed in here:
18 +# https://github.com/casangi/casagui/wiki/Interactive-Clean
112 19 #
113 20 ##########################################################################
114 21
115 22 import os
116 -import sys
117 23 import shutil
118 24 import unittest
119 -import inspect
120 25 import numpy as np
121 -import operator
122 26
123 27 from casatools import ctsys, quanta, measures, image, vpmanager, calibrater
124 -from casatasks import casalog, delmod, imsubimage, tclean, uvsub, imhead, imsmooth, immath, widebandpbcor, impbcor, flagdata, makemask
28 +from casatasks import casalog
125 29 from casatasks.private.parallel.parallel_task_helper import ParallelTaskHelper
126 30 from casatasks.private.imagerhelpers.parallel_imager_helper import PyParallelImagerHelper
127 -from casatasks.private.imagerhelpers.summary_minor import SummaryMinor
128 31 from casatasks.private.imagerhelpers._gclean import gclean
129 -from casatasks import impbcor, split, concat
130 32
131 33 from casatestutils.imagerhelpers import TestHelpers
132 34
133 35 _ia = image( )
134 36 _vp = vpmanager( )
135 37 _cb = calibrater( )
136 38 _qa = quanta( )
137 39 _me = measures( )
138 40
139 41 refdatapath = ctsys.resolve('unittest/tclean/')
271 173
272 174 _ia.open(maskname)
273 175 pix = _ia.getchunk()
274 176 masksum = np.sum(pix)
275 177 _ia.close()
276 178
277 179 return masksum
278 180
279 181
280 182
281 -class test_ic(testref_base):
183 +class test_gclean_ic(testref_base):
282 184 """
283 185 Test iteration control options in gclean
284 186 """
285 187
286 188 def __init__(self, testref_base):
287 189 super().__init__(testref_base)
288 190 self.gclean = gclean
289 191
290 192 # Test niter stopping criteria for cubes where niterdone > niter
291 193 @unittest.skipIf(ParallelTaskHelper.isMPIEnabled(), "gclean doesn't work with mpi")
705 607
706 608 print("total iterations ", total_iterations)
707 609
708 610 self.delData()
709 611
710 612 # This should be the same as the number of major cycles done
711 613 self.assertTrue(len(retdict['major']['cyclethreshold']) == 3)
712 614 self.assertTrue(total_iterations == 156)
713 615 self.assertTrue(stopcode == 1)
714 616
617 +if __name__ == '__main__':
618 + unittest.main()
715 619

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

Add shortcut