Source
#TODO I'm not sure exactly how to do this one. I'm unsure what effects that this task is supposed to have on the image
##########################################################################
# test_task_rmfit.py
#
# Copyright (C) 2018
# Associated Universities, Inc. Washington DC, USA.
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# [Add the link to the JIRA ticket here once it exists]
#
# Based on the requirements listed in plone found here:
# https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.analysis.rmfit.html
#
#
##########################################################################
import sys
import os
import numpy
import unittest
import shutil
from filecmp import dircmp
import math
import casatools
from casatasks import rmfit
myia = casatools.image()
tb = casatools.table()
mypo = casatools.imagepol()
myia = casatools.image()
ctsys_resolve = casatools.ctsys.resolve
## DATA ##
casaim = ctsys_resolve('unittest/rmfit/ngc5921.clean.image')
eq_beams = ctsys_resolve('unittest/rmfit/pol_eq_beams.fits')
neq_beams = ctsys_resolve('unittest/rmfit/pol_neq_beams.fits')
outfile = 'out.im'
def table_comp(im1, im2):
tb.open(im1)
table1 = tb.getcol('map')
tb.close()
tb.open(im2)
table2= tb.getcol('map')
tb.close()
return((table1 == table2).all())
class rmfit_test(unittest.TestCase):
def setUp(self):
myia.fromshape(outfile, [20, 20, 4, 20])
myia.addnoise()
myia.done()
def tearDown(self):
mypo.done()
for f in (
outfile, 'rm.im', 'out2.im', 'rm2.im', 'rm1.im',
'rm_input.im', 'xx.im', 'yy.im'
):
if os.path.exists(f):
shutil.rmtree(f)
def test_makesImage(self):
'''
test_makesImage
------------------
This test checks that a rotation measure image is generated when the task is run.
'''
rmfit(imagename=outfile, rm='rm.im')
self.assertTrue(os.path.exists('rm.im'))
def test_needsQUV(self):
'''
test_needsQUV
----------------
This test checks that if the image provided doesn't have Stokes Q, U, or V the task will fail to execute
'''