Source
##############################################################################
# #
# Test Name: #
# imagepoltest_regression.py #
# Rationale for Inclusion: #
# This is a Python translation of the Glish assay test #
# imagepolservertest.g It tests many imagepol tool methods. #
# The first test is a general test of everything at a basic level. #
# Succeeding tests work on individual areas of the imagepol tool. #
# Some of the tests included forced errors. As long as imagepoltest #
# finally returns True it has succeeded (regardless of what error #
# messages you might see). #
# Features Tested: #
# open, done, summary, stokesi, stokesq, stokesu, stokesv, stokes, #
# linpolint, linpolposang, totpolint, fraclinpol, fractotpol, pol, #
# sigmalinpolint, sigmalinpolposang, sigmatotpolint, stokes #
# sigmastokesi, sigmastokesq, sigmastokesu, sigmastokesv, sigmastokes #
# sigmafraclinpol, sigmafractotpol, imagepoltestimage, rotationmeasure #
# fourierrotationmeasure, complexlinpol, complexfraclinpol, makecomplex, #
# depolratio, sigmadepolratio #
# Success/failure criteria: #
# Internally tests each method for pass/fail. Throws an uncaught #
# exception ending test when an unexpected failure occurs. #
# All tests pass if script runs to completion. #
# #
##############################################################################
# #
# Converted by RRusk 2007-11-16 from imagepolservertest.g #
# #
##############################################################################
import os
import shutil
import time
import math
import random
from regression_utility import note
po = casac.imagepol()
def imagepoltest(which=None):
#
dowait = True
#
def info(message):
note(message, origin="imagepoltest")
def stop(message):
note(message, priority="SEVERE", origin="imagepoltest")
raise RuntimeError, message
def fail(message=""):
stop(message)
def cleanup(dir):
if (os.path.isdir(dir)):
info("Cleaning up directory "+dir)
def errFunc(raiser, problemPath, excInfo):
note(raiser.__name__+'failed on'+problemPath,"SEVERE")
raise RuntimeError, "Cleanup of " + dir + " fails!"
shutil.rmtree(dir,0,errFunc)
return True
def addnoise(data, sigma):
if len(data.shape)==3:
for i in range(data.shape[0]):