Source
"""Test rule that if input image has stokes and template image does not have stokes, output image has stokes"""
from __future__ import print_function
import sys
import traceback
import os
import shutil
import random
import re
import time
import numpy as np
import glob
import struct
import unittest
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import ctsys, image, regionmanager, coordsys, table, measures, componentlist, quanta
from casatasks import imregrid, casalog, imstat
_ia = image()
_rg = regionmanager()
_cs = coordsys()
_tb = table()
_me = measures()
_cl = componentlist()
_qa = quanta()
ctsys_resolve = ctsys.resolve
else:
import casac
from tasks import *
from taskinit import *
_ia = iatool()
_rg = rgtool()
_cs = cstool()
_tb = tbtool()
_me = metool()
_cl = cltool()
_qa = qatool()
dataRoot = os.path.join(os.environ.get('CASAPATH').split()[0],'casatestdata')
from casa_stack_manip import stack_frame_find
casa_stack_rethrow = stack_frame_find().get('__rethrow_casa_exceptions', False)
def ctsys_resolve(apath):
return os.path.join(dataRoot,apath)
sep = os.sep
datapath = ctsys_resolve(os.path.join('unittest','imregrid'))
IMAGE = 'image.im'
gim = "gaussian_source.im"
total = 0
fail = 0
current_test =""
stars = "*************"
def alleqnum(x,num,tolerance=0):
if len(x.shape)==1:
for i in range(x.shape[0]):
if not (abs(x[i]-num) < tolerance):
print("x[",i,"]=", x[i])
return False
if len(x.shape)==2:
for i in range(x.shape[0]):
for j in range(x.shape[1]):
if not (abs(x[i][j]-num) < tolerance):
print("x[",i,"][",j,"]=", x[i][j])
return False
if len(x.shape)==3:
for i in range(x.shape[0]):
for j in range(x.shape[1]):
for k in range(x.shape[2]):
if not (abs(x[i][j][k]-num) < tolerance):
print("x[",i,"][",j,"][",k,"]=", x[i][j][k])
return False
if len(x.shape)==4:
for i in range(x.shape[0]):
for j in range(x.shape[1]):
for k in range(x.shape[2]):
for l in range(x.shape[3]):
if not (abs(x[i][j][k][l]-num) < tolerance):
print("x[",i,"][",j,"][",k,"][",l,"]=", x[i][j][k])
return False
if len(x.shape)>4:
stop('unhandled array shape in alleq')
return True
def test_start(msg):
global total, current_test
total += 1
print()
print(stars + " Test " + msg + " start " + stars)
current_test = msg