Source
import os
import sys
import shutil
import commands
import numpy
import numpy.ma as ma
import random
from __main__ import default
from tasks import *
from taskinit import *
from cleanhelper import *
import unittest
'''
Unit tests for statwt
'''
#
# ToDo:
# add more tests
# once more independent tests (e.g. comparison
# the AIPS REWAY results) add reference mses
# and do tests against them
#
class statwt_test(unittest.TestCase):
# Input and output names
msfile = 'ngc5921.ms'
res = False
def setUp(self):
if (os.path.exists(self.msfile)):
os.system('rm -rf ' + self.msfile)
datapath=os.environ.get('CASAPATH').split()[0]+'/data/regression/unittest/visstat/'
shutil.copytree(datapath+self.msfile, self.msfile)
def tearDown(self):
if (os.path.exists(self.msfile)):
# os.system('rm -rf ' + self.msfile)
pass
def calcVariance(self,specData):
"""
calculate variance of a single row of complex vis data
input: specData - numpy masked array
"""
dev2 = 0.0
validSpecData=specData[~specData.mask]
dmean = validSpecData.mean()
nchan=len(validSpecData)
for n in xrange(nchan):
dev = validSpecData[n] - dmean
# combine real and imag
dev2 += (dev.real*dev.real + dev.imag*dev.imag)
# use 2*nchan here because we used real and imag
var = (1./(2*nchan-1))*dev2
return var.real
def calcwt(self,selrow,selcorr,datcol,flagcol):
"""
calc weight,sigma from the data
"""
dsel = datcol[selcorr]