Source
########################################################################
# test_task_sdpolaverage.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.single.sdpolaverage.html
#
#
##########################################################################
import math
import os
import sys
import unittest
from casatasks import sdpolaverage
from casatasks.private.sdutil import table_manager
from casatools import ctsys
datapath = ctsys.resolve('unittest/sdpolaverage/')
def weighToSigma(weight):
if weight > sys.float_info.min:
return 1.0 / math.sqrt(weight)
else:
return -1.0
def sigmaToWeight(sigma):
if sigma > sys.float_info.min:
return 1.0 / math.pow(sigma, 2)
else:
return 0.0
def check_eq(val, expval, tol=None):
"""Check that val matches expval within tol."""
# print val
if type(val) == dict:
for k in val:
check_eq(val[k], expval[k], tol)
else:
try:
if tol and hasattr(val, '__rsub__'):
are_eq = abs(val - expval) < tol
else:
are_eq = val == expval
if hasattr(are_eq, 'all'):
are_eq = are_eq.all()