Source
#########################################################################
# test_task_exportasdm.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.
#
#
# Based on the requirements listed in casadocs found here:
# https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.data.exportasdm.html
#
##########################################################################
import os
import shutil
import unittest
import sys
from casatools import ctsys, ms
from casatasks import exportasdm, importasdm
from casatestutils import testhelper as th
_ms = ms( )
datapath = ctsys.resolve('unittest/exportasdm/')
class exportasdm_test(unittest.TestCase):
#vis_a = 'ngc4826.ms'
vis_b = 'ARP299F_sma_2scans_24spws_negative_chanwidth.ms'
vis_c = 'M100-X220-shortened.ms'
vis_d = 'ngc4826.tutorial.ngc4826.ll.5.ms'
vis_e = 'g19_d2usb_targets_line-shortened.ms'
vis_f = 'Itziar.ms'
vis_g = 'M51.ms'
vis_h = 'xosro2ref.ms'
vis_i = 'asdm.ms'
out = 'exportasdm-output.asdm'
rval = False
def setUp(self):
self.rval = False
#if(not os.path.exists(self.vis_a)):
# _ms.fromfits( self.vis_a, '/regression/ngc4826/fitsfiles/ngc4826.ll.fits5')
# _ms.close( )
if(not os.path.exists(self.vis_b)):
os.system('cp -RL '+os.path.join(datapath,'ARP299F_sma_2scans_24spws_negative_chanwidth.ms')+' .')
if(not os.path.exists(self.vis_c)):
os.system('cp -RL '+os.path.join(datapath,'M100-X220-shortened.ms')+' .')
if(not os.path.exists(self.vis_d)):
# CASA6 will fetch this from the repo without the need for ctsys.resolve
_ms.fromfits( self.vis_d, os.path.join(datapath,'ngc4826.ll.fits5') )
_ms.close( )
if(not os.path.exists(self.vis_e)):
os.system('cp -RL '+os.path.join(datapath,'g19_d2usb_targets_line-shortened.ms')+' .')
print('ls -l')
if(not os.path.exists(self.vis_f)):
os.system('cp -RL '+os.path.join(datapath,'Itziar.ms')+' .')
if(not os.path.exists(self.vis_g)):
os.system('cp -RL '+os.path.join(datapath,'M51.ms')+' .')
if(not os.path.exists(self.vis_h)):
os.system('ln -sf '+os.path.join(datapath,'X_osro_013.55979.93803716435'))
# the final two arguments are equivalent to the defaults for the original importevla used here
importasdm('X_osro_013.55979.93803716435', vis = 'xosro2ref.ms', process_flags=False, scans='0:2', ocorr_mode='co', with_pointing_correction=True)
if(not os.path.exists(self.vis_i)):
os.system('ln -sf '+os.path.join(datapath,'uid___A002_X72bc38_X000'))
importasdm('uid___A002_X72bc38_X000', vis = 'asdm.ms', scans='0:2')
def tearDown(self):
os.system('rm -rf myinput.ms')
os.system('rm -rf ' + self.out)
def verify_asdm(self,asdmname, withPointing):
print("Verifying asdm %s" % asdmname)
if(not os.path.exists(asdmname)):
print("asdm %s doesn't exist." % asdmname)
raise Exception
# test for the existence of all obligatory tables
allTables = [ "Antenna.xml",
"ASDM.xml",
# "CalData.xml",
# "CalDelay.xml",
# "CalReduction.xml",