Commits

Bob Garwood authored 27714a6f9b5
CAS-13404: Updated tests after further discussions regarding the expected results.
No tags

casatools/tests/tools/linearmosaic/test_linearmosaic.py

Modified
41 41 # field='0,1'
42 42 # conjbeams=False
43 43 # wbawp=True
44 44 # pblimit=0.1
45 45 # deconvolve='hogbom'
46 46 # pbcor=True
47 47 #
48 48 # The two individual pointing images were made with tclean
49 49 # and the same values except field='0' or field='1'.
50 50 #
51 -# The jointmos image is not (yet?) used here so it has not been saved
52 -# in the casatestdata repository. The individual pointing images and
53 -# associated pb and pbcor images are found there and used here.
54 -#
55 51 # Not tested here:
56 52 # independent x and y axis sizes (ny parameter)
57 53 # independent x and y axis cell size (celly parameter)
58 54 #
59 55 ##########################################################################
60 56
61 57
62 58 #### Imports ####
63 59 import os
64 60 import shutil
88 84
89 85 # local image tool to be used in readpix
90 86 cls.ia = image()
91 87
92 88 # this is the center pixel used for comparison - channel 1 is where the source = 1 Jy
93 89 cls.center_pix = [512,617,0,1]
94 90
95 91 # phasecenter of joint image / combined images
96 92 cls.phasecenter ='J2000 19h59m28.5 +40d40m01.5'
97 93
94 + # joint moisaic produced by tclean - image and pbcor
95 + cls.jointmos_im = os.path.join(datapath,'jointmos_test_lmtool.image')
96 + cls.jointmos_im_pbcor = os.path.join(datapath,'jointmos_test_lmtool.image.pbcor')
97 +
98 98 # the individual pointing image and pb to be used during combination
99 99 # use at their location in the datapath, no need for a copy here
100 100 # pointing 0
101 101 cls.pnt0_im = os.path.join(datapath,'pnt0_test_lmtool.image')
102 102 cls.pnt0_pb = os.path.join(datapath,'pnt0_test_lmtool.pb')
103 103 cls.pnt0_im_pbcor = os.path.join(datapath,'pnt0_test_lmtool.image.pbcor')
104 104
105 105 # pointing 1
106 106 cls.pnt1_im = os.path.join(datapath,'pnt1_test_lmtool.image')
107 107 cls.pnt1_pb = os.path.join(datapath,'pnt1_test_lmtool.pb')
130 130
131 131 lm = linearmosaic()
132 132 lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fn.image')
133 133 lm.setlinmostype(linmostype='pbweight') ## flat noise
134 134 lm.makemosaic(images=[self.pnt0_im, self.pnt1_im], weightimages=[self.pnt0_pb, self.pnt1_pb], imageweighttype=1, weighttype=1)
135 135 lm.saultweightimage(outputimage='linmos.fn.sault.image',fracpeak=0.3)
136 136 del lm
137 137
138 138 # center pixel values from each image
139 139
140 + jointmos_im_pbcor_val = self.readpix(self.jointmos_im_pbcor)
140 141 fn_image_val = self.readpix('linmos.fn.image')
141 142 fn_weight_val = self.readpix('linmos.fn.image.weight')
142 143 sw_image_val = self.readpix('linmos.fn.sault.image')
143 144
144 - # fn_image_val / fn_image_weight is not within a few % of 1, as it probably should be
145 - # For now, check against expected values in channel 1 at center pixel
146 - self.assertAlmostEqual(fn_image_val, 0.9902307)
145 + # center pixel value in channel 1 is < 0.5% of center pixel value in the pbcor image of the joint mosaic produced by tclean
146 + self.assertTrue(0.005 > abs((fn_image_val-jointmos_im_pbcor_val)/jointmos_im_pbcor_val))
147 +
148 + # this is just a constistency check that the center pixel value in the weight image is what it has been
147 149 self.assertAlmostEqual(fn_weight_val, 1.3866229)
148 150
149 151 # the sault image value should be the same as the image value
150 152 # possibly AlmostEqual should be used here eventually, but at the
151 153 # moment they are identical.
152 154 self.assertEqual(fn_image_val, sw_image_val)
153 155
154 156 def test_flat_noise_flat_sky_input(self):
155 157 '''test_flat_noise_flat_sky_input (flat noise type with flat sky input)'''
156 158
157 159 self.output_list = ['linmos.fn2.image','linmos.fn2.image.weight','linmos.fn2.sault.image']
158 160
159 161 lm = linearmosaic()
160 162 lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fn2.image')
161 163 lm.setlinmostype(linmostype='pbweight') ## flat noise
162 164 # use pbcor images as input
163 165 lm.makemosaic(images=[self.pnt0_im_pbcor, self.pnt1_im_pbcor], weightimages=[self.pnt0_pb, self.pnt1_pb], imageweighttype=0, weighttype=1)
164 166 lm.saultweightimage(outputimage='linmos.fn2.sault.image',fracpeak=0.3)
165 167 del lm
166 168
167 - fn_image_val = self.readpix('linmos.fn2.image')
168 - fn_weight_val = self.readpix('linmos.fn2.image.weight')
169 + jointmos_im_pbcor_val = self.readpix(self.jointmos_im_pbcor)
170 + fn2_image_val = self.readpix('linmos.fn2.image')
171 + fn2_weight_val = self.readpix('linmos.fn2.image.weight')
169 172 sw_image_val = self.readpix('linmos.fn2.sault.image')
170 173
171 - # fn_image_val / fn_image_weight is not within a few % of 1, as it probably should be
172 - # For now, check against expected values in channel 1 at center pixel
173 - self.assertAlmostEqual(fn_image_val, 0.9902307)
174 - self.assertAlmostEqual(fn_weight_val, 1.3866229)
174 + # center pixel value in channel 1 is < 0.5% of center pixel value in the pbcor image of the joint mosaic produced by tclean
175 + self.assertTrue(0.005 > abs((fn2_image_val-jointmos_im_pbcor_val)/jointmos_im_pbcor_val))
176 +
177 + # this is just a consistency check that the center pixel value in the weight image is what it has been
178 + self.assertAlmostEqual(fn2_weight_val, 1.3866229)
175 179
176 180 # the sault image value should be the same as the image value
177 181 # possibly AlmostEqual should be used here eventually, but at the
178 182 # moment they are identical.
179 - self.assertEqual(fn_image_val, sw_image_val)
183 + self.assertEqual(fn2_image_val, sw_image_val)
180 184
181 185 def test_flat_sky(self):
182 186 '''test_flat_sky (flat sky type with flat noise input'''
183 187
184 188 self.output_list = ['linmos.fs.image','linmos.fs.image.weight','linmos.fs.sault.image']
185 189
186 190 lm = linearmosaic()
187 191 lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fs.image')
188 192 lm.setlinmostype(linmostype='optimal') ## flat sky
189 193 lm.makemosaic(images=[self.pnt0_im, self.pnt1_im], weightimages=[self.pnt0_pb, self.pnt1_pb], imageweighttype=1, weighttype=1)
190 194 lm.saultweightimage(outputimage='linmos.fs.sault.image',fracpeak=0.3)
191 195 del lm
192 196
193 - fn_image_val = self.readpix('linmos.fs.image')
194 - fn_weight_val = self.readpix('linmos.fs.image.weight')
197 + jointmos_im_pbcor_val = self.readpix(self.jointmos_im_pbcor)
198 + fs_image_val = self.readpix('linmos.fs.image')
199 + fs_weight_val = self.readpix('linmos.fs.image.weight')
195 200 sw_image_val = self.readpix('linmos.fs.sault.image')
196 201
197 - # check against expected values in channel 1 at center pixel
198 - self.assertAlmostEqual(fn_image_val, 0.9899020)
199 - self.assertAlmostEqual(fn_weight_val, 1.0370520)
200 - # check that the ratio of these values is as expected (within 5% of 1.0)
201 - self.assertTrue(abs(1.0-fn_image_val/fn_weight_val) < 0.05)
202 + # center pixel value in channel 1 is < 0.5% of center pixel value in the pbcor image of the joint mosaic produced by tclean
203 + self.assertTrue(0.005 > abs((fs_image_val-jointmos_im_pbcor_val)/jointmos_im_pbcor_val))
204 +
205 + # this is just a consistency check that the center pixel value in the weight image is what it has been
206 + self.assertAlmostEqual(fs_weight_val, 1.0370520)
202 207
203 208 # the sault image value should be the same as the image value
204 209 # possibly AlmostEqual should be used here eventually, but at the
205 210 # moment they are identical.
206 - self.assertEqual(fn_image_val, sw_image_val)
211 + self.assertEqual(fs_image_val, sw_image_val)
207 212
208 213 def test_flat_sky_flat_sky_input(self):
209 214 '''test_flat_sky_flat_sky_input (flat sky type with flat sky inputs)'''
210 215
211 216 self.output_list = ['linmos.fs2.image','linmos.fs2.image.weight','linmos.fs2.sault.image']
212 217
213 218 lm = linearmosaic()
214 219 lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fs2.image')
215 220 lm.setlinmostype(linmostype='optimal') ## flat sky
216 221 # use pbcor images as input
217 222 lm.makemosaic(images=[self.pnt0_im_pbcor, self.pnt1_im_pbcor], weightimages=[self.pnt0_pb, self.pnt1_pb], imageweighttype=0, weighttype=1)
218 223 lm.saultweightimage(outputimage='linmos.fs2.sault.image',fracpeak=0.3)
219 224 del lm
220 225
221 - fn_image_val = self.readpix('linmos.fs2.image')
222 - fn_weight_val = self.readpix('linmos.fs2.image.weight')
226 + jointmos_im_pbcor_val = self.readpix(self.jointmos_im_pbcor)
227 + fs2_image_val = self.readpix('linmos.fs2.image')
228 + fs2_weight_val = self.readpix('linmos.fs2.image.weight')
223 229 sw_image_val = self.readpix('linmos.fs2.sault.image')
224 230
225 - # check against expected values in channel 1 at center pixel
226 - self.assertAlmostEqual(fn_image_val, 0.9899020)
227 - self.assertAlmostEqual(fn_weight_val, 1.0370520)
228 - # check that the ratio of these values is as expected (within 5% of 1.0)
229 - self.assertTrue(abs(1.0-fn_image_val/fn_weight_val) < 0.05)
231 + # center pixel value in channel 1 is < 0.5% of center pixel value in the pbcor image of the joint mosaic produced by tclean
232 + self.assertTrue(0.005 > abs((fs2_image_val-jointmos_im_pbcor_val)/jointmos_im_pbcor_val))
233 +
234 + # this is just a consistency check that the center pixel value in the weight image is what it has been
235 + self.assertAlmostEqual(fs2_weight_val, 1.0370520)
230 236
231 237 # the sault image value should be the same as the image value
232 238 # possibly AlmostEqual should be used here eventually, but at the
233 239 # moment they are identical.
234 - self.assertEqual(fn_image_val, sw_image_val)
240 + self.assertEqual(fs2_image_val, sw_image_val)
235 241
236 - def test_flat_sky_existing_image(self):
237 - '''test_flat_sky_existing image (flat sky type onto an existing image)'''
242 + def test_flat_noise_existing_image(self):
243 + '''test_flat_noise_existing image (flat noise type onto an existing image)'''
238 244
239 245 self.output_list = ['linmos.step.image','linmos.step.pb','linmos.step.sault.image']
240 246
241 - # copy pbcorr image and pb for pnt0 to be used as starting output image and weight
242 - shutil.copytree(self.pnt0_im_pbcor, 'linmos.step.image')
247 + # copy image and pb for pnt0 to be used as starting output image and weight
248 + shutil.copytree(self.pnt0_im, 'linmos.step.image')
243 249 shutil.copytree(self.pnt0_pb, 'linmos.step.pb')
244 250
245 251 lm = linearmosaic()
246 252 lm.setoutputimage(outputimage='linmos.step.image', outputweight='linmos.step.pb',imageweighttype=1,weighttype=1)
247 - lm.setlinmostype(linmostype='optimal') ## flat sky
248 - # second image is NOT the pbcor image, pb is used as weight
249 - lm.makemosaic(images=[self.pnt1_im], weightimages=[self.pnt1_pb], imageweighttype=0, weighttype=1)
253 + lm.setlinmostype(linmostype='pbweight') ## flat sky
254 + # Add the second image and weight
255 + lm.makemosaic(images=[self.pnt1_im], weightimages=[self.pnt1_pb], imageweighttype=1, weighttype=1)
250 256 lm.saultweightimage(outputimage='linmos.step.sault.image',fracpeak=0.3)
251 257 del lm
252 258
253 - fn_image_val = self.readpix('linmos.step.image')
254 - fn_weight_val = self.readpix('linmos.step.pb')
259 + jointmos_im_pbcor_val = self.readpix(self.jointmos_im_pbcor)
260 + fne_image_val = self.readpix('linmos.step.image')
261 + fne_weight_val = self.readpix('linmos.step.pb')
255 262 sw_image_val = self.readpix('linmos.step.sault.image')
256 263
257 - # check against expected values in channel 1 at center pixel
258 - self.assertAlmostEqual(fn_image_val, 1.1447070)
259 - self.assertAlmostEqual(fn_weight_val, 1.0370520)
264 + # center pixel value in channel 1 is < 0.5% of center pixel value in the pbcor image of the joint mosaic produced by tclean
265 + self.assertTrue(0.005 > abs((fne_image_val-jointmos_im_pbcor_val)/jointmos_im_pbcor_val))
266 +
267 + # this is just a consistency check that the center pixel value in the weight image is what it has been
268 + self.assertAlmostEqual(fne_weight_val, 1.3866229)
260 269
261 270 # the ratio of these values is > 10% away from 1.0, do not check that ratio
262 271
263 272 # the sault image value should be the same as the image value
264 273 # possibly AlmostEqual should be used here eventually, but at the
265 274 # moment they are identical.
266 - self.assertEqual(fn_image_val, sw_image_val)
275 + self.assertEqual(fne_image_val, sw_image_val)
267 276
268 277 #### Suite: Required for CASA5 ####
269 278 def suite():
270 279 return[linear_mosaic]
271 280
272 281 #### Imports ####
273 282 if __name__ == '__main__':
274 283 unittest.main()
275 284

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

Add shortcut