Commits
60 60 | |
61 61 | |
62 62 | #### Imports #### |
63 63 | import os |
64 64 | import shutil |
65 65 | import unittest |
66 66 | |
67 67 | from casatools import image |
68 68 | from casatools import linearmosaic |
69 69 | |
70 - | # Example of importing helper functions |
71 - | from casatestutils import testhelper as th |
72 - | from casatestutils.imagerhelpers import TestHelpers |
73 - | |
74 70 | from casatools import ctsys |
75 71 | |
76 72 | #### Tests #### |
77 73 | class TestTask(unittest.TestCase): |
78 74 | |
79 75 | def readpix(self, imname=''): |
80 76 | '''get the center pixel value from the named image''' |
81 77 | self.ia.open(imname) |
82 78 | result = self.ia.pixelvalue(self.center_pix)['value']['value'] |
83 79 | self.ia.close() |
146 142 | sw_image_val = self.readpix('linmos.fn.sault.image') |
147 143 | |
148 144 | # fn_image_val / fn_image_weight is not within a few % of 1, as it probably should be |
149 145 | # For now, check against expected values in channel 1 at center pixel |
150 146 | self.assertAlmostEqual(fn_image_val, 0.9902307) |
151 147 | self.assertAlmostEqual(fn_weight_val, 1.3866229) |
152 148 | |
153 149 | # the sault image value should be the same as the image value |
154 150 | # possibly AlmostEqual should be used here eventually, but at the |
155 151 | # moment they are identical. |
156 - | self.assertEquals(fn_image_val, sw_image_val) |
152 + | self.assertEqual(fn_image_val, sw_image_val) |
157 153 | |
158 154 | def test_flat_noise_flat_sky_input(self): |
159 155 | '''test_flat_noise_flat_sky_input (flat noise type with flat sky input)''' |
160 156 | |
161 157 | self.output_list = ['linmos.fn2.image','linmos.fn2.image.weight','linmos.fn2.sault.image'] |
162 158 | |
163 159 | lm = linearmosaic() |
164 160 | lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fn2.image') |
165 161 | lm.setlinmostype(linmostype='pbweight') ## flat noise |
166 162 | # use pbcor images as input |
173 169 | sw_image_val = self.readpix('linmos.fn2.sault.image') |
174 170 | |
175 171 | # fn_image_val / fn_image_weight is not within a few % of 1, as it probably should be |
176 172 | # For now, check against expected values in channel 1 at center pixel |
177 173 | self.assertAlmostEqual(fn_image_val, 0.9902307) |
178 174 | self.assertAlmostEqual(fn_weight_val, 1.3866229) |
179 175 | |
180 176 | # the sault image value should be the same as the image value |
181 177 | # possibly AlmostEqual should be used here eventually, but at the |
182 178 | # moment they are identical. |
183 - | self.assertEquals(fn_image_val, sw_image_val) |
179 + | self.assertEqual(fn_image_val, sw_image_val) |
184 180 | |
185 181 | def test_flat_sky(self): |
186 182 | '''test_flat_sky (flat sky type with flat noise input''' |
187 183 | |
188 184 | self.output_list = ['linmos.fs.image','linmos.fs.image.weight','linmos.fs.sault.image'] |
189 185 | |
190 186 | lm = linearmosaic() |
191 187 | lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fs.image') |
192 188 | lm.setlinmostype(linmostype='optimal') ## flat sky |
193 189 | lm.makemosaic(images=[self.pnt0_im, self.pnt1_im], weightimages=[self.pnt0_pb, self.pnt1_pb], imageweighttype=1, weighttype=1) |
200 196 | |
201 197 | # check against expected values in channel 1 at center pixel |
202 198 | self.assertAlmostEqual(fn_image_val, 0.9899020) |
203 199 | self.assertAlmostEqual(fn_weight_val, 1.0370520) |
204 200 | # check that the ratio of these values is as expected (within 5% of 1.0) |
205 201 | self.assertTrue(abs(1.0-fn_image_val/fn_weight_val) < 0.05) |
206 202 | |
207 203 | # the sault image value should be the same as the image value |
208 204 | # possibly AlmostEqual should be used here eventually, but at the |
209 205 | # moment they are identical. |
210 - | self.assertEquals(fn_image_val, sw_image_val) |
206 + | self.assertEqual(fn_image_val, sw_image_val) |
211 207 | |
212 208 | def test_flat_sky_flat_sky_input(self): |
213 209 | '''test_flat_sky_flat_sky_input (flat sky type with flat sky inputs)''' |
214 210 | |
215 211 | self.output_list = ['linmos.fs2.image','linmos.fs2.image.weight','linmos.fs2.sault.image'] |
216 212 | |
217 213 | lm = linearmosaic() |
218 214 | lm.defineoutputimage(nx=1024, cellx='8arcsec', imagecenter=self.phasecenter, outputimage='linmos.fs2.image') |
219 215 | lm.setlinmostype(linmostype='optimal') ## flat sky |
220 216 | # use pbcor images as input |
228 224 | |
229 225 | # check against expected values in channel 1 at center pixel |
230 226 | self.assertAlmostEqual(fn_image_val, 0.9899020) |
231 227 | self.assertAlmostEqual(fn_weight_val, 1.0370520) |
232 228 | # check that the ratio of these values is as expected (within 5% of 1.0) |
233 229 | self.assertTrue(abs(1.0-fn_image_val/fn_weight_val) < 0.05) |
234 230 | |
235 231 | # the sault image value should be the same as the image value |
236 232 | # possibly AlmostEqual should be used here eventually, but at the |
237 233 | # moment they are identical. |
238 - | self.assertEquals(fn_image_val, sw_image_val) |
234 + | self.assertEqual(fn_image_val, sw_image_val) |
239 235 | |
240 236 | def test_flat_sky_existing_image(self): |
241 237 | '''test_flat_sky_existing image (flat sky type onto an existing image)''' |
242 238 | |
243 239 | self.output_list = ['linmos.step.image','linmos.step.pb','linmos.step.sault.image'] |
244 240 | |
245 241 | # copy pbcorr image and pb for pnt0 to be used as starting output image and weight |
246 242 | shutil.copytree(self.pnt0_im_pbcor, 'linmos.step.image') |
247 243 | shutil.copytree(self.pnt0_pb, 'linmos.step.pb') |
248 244 | |
260 256 | |
261 257 | # check against expected values in channel 1 at center pixel |
262 258 | self.assertAlmostEqual(fn_image_val, 0.9899020) |
263 259 | self.assertAlmostEqual(fn_weight_val, 1.0370520) |
264 260 | # check that the ratio of these values is as expected (within 5% of 1.0) |
265 261 | self.assertTrue(abs(1.0-fn_image_val/fn_weight_val) < 0.05) |
266 262 | |
267 263 | # the sault image value should be the same as the image value |
268 264 | # possibly AlmostEqual should be used here eventually, but at the |
269 265 | # moment they are identical. |
270 - | self.assertEquals(fn_image_val, sw_image_val) |
266 + | self.assertEqual(fn_image_val, sw_image_val) |
271 267 | |
272 268 | #### Suite: Required for CASA5 #### |
273 269 | def suite(): |
274 270 | return[TestTask] |
275 271 | |
276 272 | #### Imports #### |
277 273 | if __name__ == '__main__': |
278 274 | unittest.main() |
279 275 |