from __future__ import absolute_import
from __future__ import print_function
import glob
import copy
import os
import sys
import shutil
import unittest
import numpy
import math
import stat
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import ctsys, image, regionmanager, measures, msmetadata, table, quanta
from casatools import ms as mstool
from casatasks import casalog
from casatasks import flagdata
from casatasks import tsdimaging as sdimaging
from casatasks import split as split_ms
from casatasks.private.sdutil import tbmanager, toolmanager, table_selector, is_ms
from casatestutils import selection_syntax
from casatestutils.testhelper import TableCacheValidator
def default(atask):
pass
ctsys_resolve = ctsys.resolve
from casatasks.private.task_tsdimaging import image_suffix, weight_suffix
from casatestutils import restfreqtool
else:
from __main__ import default
from tasks import *
from taskinit import *
from taskinit import metool as measures
from taskinit import qatool as quanta
from taskinit import tbtool as table
from taskinit import mstool
from taskinit import iatool as image
from taskinit import rgtool as regionmanager
from taskinit import msmdtool as msmetadata
try:
from casatestutils import selection_syntax
except:
import tests.selection_syntax as selection_syntax
try:
from casatestutils.testhelper import TableCacheValidator
except:
from tests.testutils import TableCacheValidator
from tsdimaging import tsdimaging as sdimaging
from sdutil import tbmanager, toolmanager, table_selector
dataRoot = os.path.join(os.environ.get('CASAPATH').split()[0],'casatestdata/')
def ctsys_resolve(apath):
return os.path.join(dataRoot,apath)
from task_tsdimaging import image_suffix
try:
from casatestutils import restfreqtool
except:
import restfreqtool
_ia = image()
_rg = regionmanager()
me = measures()
qa = quanta()
tb = table()
ms = mstool()
def construct_refstat_uniform(fluxval, blc_data, trc_data):
"""
Return a dictionary of analytic reference statistics of uniform image
Arguments:
fluxval : the uniform flux of the image
blc_data : blc of un-masked pixel (e.g., [0,0,0,0] for whole image)
trc_data : trc of un-masked pixel
Returns:
a dictionary of statistics, 'min', 'max', 'rms', 'sigma', 'mean',