Source
# tsdimaging(infiles=self.rawfile,outfile=self.outfile,intent='',cell=self.cell,imsize=self.imsize,phasecenter=self.phasecenter.replace('J2000','J3000'),minweight=self.minweight0)
#########################################################################
# test_task_tsdimaging.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.tsdimaging.html
#
#
##########################################################################
import copy
from enum import Enum
import glob
import math
import os
import shutil
import stat
from typing import Optional
import unittest
import numpy
from casatasks import casalog, flagdata
from casatasks import imhead
from casatasks import split
from casatasks import tsdimaging
from casatasks.private.sdutil import is_ms, calibrater_manager, table_manager, tool_manager
from casatestutils import restfreqtool, selection_syntax
from casatestutils.testhelper import TableCacheValidator
from casatools import ctsys, image, measures
from casatools import ms as mstool
from casatools import msmetadata, quanta, regionmanager
ctsys_resolve = ctsys.resolve
_ia = image()
_rg = regionmanager()
me = measures()
qa = quanta()
ms = mstool()
#
# Unit test of sdimaging task.
#
image_suffix = '.image'
weight_suffix = '.weight'
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',
'npts', 'sum', and 'sumsq'
"""
# the number of valid (unmasked) pixels
ndim = len(blc_data)
nvalid = 1
for idim in range(ndim):
nvalid *= abs(trc_data[idim] - blc_data[idim] + 1)
retstat = {'min': [fluxval], 'max': [fluxval], 'rms': [fluxval],
'sigma': [0.], 'mean': [fluxval], 'npts': [nvalid],
'sum': [fluxval * nvalid], 'sumsq': [fluxval**2 * nvalid]}
return retstat
def merge_dict(d1, d2):
"""Merge two dictionaries into one.
Out of place merge of two dictionaries.
If both dictionary has the same keys, value of the second
dictionary is adopted.