from casatasks import importasdm, importfits, listobs, flagdata, gencal, setjy, fluxscale
from casatasks import gaincal, bandpass, mstransform, tclean, immoments, sdcal
from casatestutils import sparse_check
class BaseClass(unittest.TestCase):
""" Base class with helper functions """
def getdata(testfiles=None):
sparse_check.download_data(testfiles)
class CasaTasksTests(BaseClass):
""" Unit tests for CASA tasks
The test script will download test data automatically to
the local directory and will remove them afterwards
def setUpClass(cls) -> None:
cls.asdm = 'AutocorrASDM'
cls.fitsimage = 'two_gaussian_model.fits'
cls.listobs_ms = 'uid___X02_X3d737_X1_01_small.ms'
cls.flagdata_ms = 'ngc5921.ms'
cls.gencal_ms = 'tdem0003gencal.ms'
cls.setjy_ms = 'ngc5921.ms'
cls.fluxscale_ms = 'CalMSwithModel.ms'
cls.fluxscale_gtable = 'ModelGcal.G0'
cls.gaincal_ms = 'gaincaltest2.ms'
cls.split_ms = 'Four_ants_3C286.ms'
cls.tclean_ms = 'refim_oneshiftpoint.mosaic.ms'
cls.immoments_img = 'n1333_both.image'
cls.sdcal_ms = "otf_ephem.ms"
cls.asdm, cls.fitsimage, cls.listobs_ms, cls.flagdata_ms,
cls.gencal_ms, cls.fluxscale_ms, cls.fluxscale_gtable,
cls.gaincal_ms, cls.split_ms, cls.tclean_ms, cls.immoments_img,
cls.getdata(testfiles=cls.input_files)
cls.asdm_ms = f'{cls.asdm}.ms'
cls.onlineflags = 'onlineflags.txt'
cls.casaimage = f'{cls.fitsimage}.image'
cls.gentable = 'gencal_antpos.cal'
cls.fluxscale_out = 'fluxout.cal'
cls.gaincal_out = 'gaincaltable.cal'
cls.bandpass_out = 'bandpass.bcal'
cls.split_out = 'split_model.ms'
cls.tclean_img = 'tclean_test_'
cls.immoments_out = 'immoment.mom0'
cls.sdcal_out = 'otf_ephem.ms.otfcal'
cls.asdm_ms, cls.onlineflags, cls.casaimage, cls.gentable,
cls.fluxscale_out, cls.gaincal_out, cls.bandpass_out,
cls.split_out, cls.immoments_out, cls.sdcal_out
def tearDownClass(cls) -> None:
for inpfile in cls.input_files:
os.system(f'rm -rf {inpfile}')
for outfile in cls.output_files: