def sdm2ms(sdmfile, msfile, scan, inttime='0'): """ Converts sdm to ms format for a single scan. msfile defines the name template for the ms. Should end in .ms, but "s<scan>" will be put in. scan is string of (sdm counted) scan number. inttime is string to feed to split command. gives option of integrated data down in time. """ # fill ms file msfile2 = msfile[:-3] + '_s' + scan + '.ms' if os.path.exists(msfile2): print '%s already set.' % msfile2 else: # if filtering ants, use tmp file to split. **NOT TESTED YET** # if (antlist != [row.find('name').text for row in anttree.getiterator('row')]) or (inttime != '0s'): if inttime != '0': print 'Filtering by int time.' subprocess.call(['asdm2MS', '--ocm co --icm co --lazy --scans', scan, sdmfile, 'tmp_'+msfile2]) cfg = tasklib.SplitConfig() # configure split cfg.vis = 'tmp_'+msfile2 cfg.out = msfile2 cfg.timebin=inttime cfg.col = 'data' cfg.antenna='*&*' # discard autos tasklib.split(cfg) # run task # clean up shutil.rmtree('tmp_'+msfile2) else: subprocess.call(['asdm2MS', '--ocm co --icm co --lazy --scans', scan, sdmfile, msfile2]) return msfile2
def sdm2ms(sdmfile, msfile, scan, inttime='0'): """ Converts sdm to ms format for a single scan. msfile defines the name template for the ms. Should end in .ms, but "s<scan>" will be put in. scan is string of (sdm counted) scan number. inttime is string to feed to split command. gives option of integrated data down in time. """ # fill ms file if os.path.exists(msfile): logger.debug('%s already set.' % msfile) else: logger.info('No %s found. Creating anew.' % msfile) if inttime != '0': logger.info('Filtering by int time.') subprocess.call(['asdm2MS', '--ocm', 'co', '--icm', 'co', '--lazy', '--scans', scan, sdmfile, msfile + '.tmp']) cfg = tasklib.SplitConfig() # configure split cfg.vis = msfile + '.tmp' cfg.out = msfile cfg.timebin = inttime cfg.col = 'data' cfg.antenna = '*&*' # discard autos tasklib.split(cfg) # run task # clean up shutil.rmtree(msfile+'.tmp') else: subprocess.call(['asdm2MS', '--ocm', 'co', '--icm', 'co', '--lazy', '--scans', scan, sdmfile, msfile]) return msfile
def asdm2ms(asdmfile, msfile, scan, inttime="0"): """ Converts asdm to ms format for a single scan. msfile defines the name template for the ms. Should end in .ms, but "s<scan>" will be put in. scan is string of (asdm counted) scan number. inttime is string to feed to split command. gives option of integrated data down in time. """ # fill ms file msfile2 = msfile[:-3] + "_s" + scan + ".ms" if os.path.exists(msfile2): print "%s already set." % msfile2 else: # if filtering ants, use tmp file to split. **NOT TESTED YET** # if (antlist != [row.find('name').text for row in anttree.getiterator('row')]) or (inttime != '0s'): if inttime != "0": print "Filtering by int time." subprocess.call(["asdm2MS", "--ocm co --icm co --lazy --scans", scan, asdmfile, "tmp_" + msfile2]) # importasdm(asdm=asdmfile, vis='tmp_'+msfile2, scans=scans, ocorr_mode='co', savecmds=False, applyflags=True, process_flags=False) # replaced! # split(vis='tmp_'+msfile2, outputvis=msfile2, datacolumn='data', timebin=inttime, antenna=ants) # split(vis='tmp_'+msfile2, outputvis=msfile2, datacolumn='data', timebin=inttime) cfg = tasklib.SplitConfig() # configure split cfg.vis = "tmp_" + msfile2 cfg.out = msfile2 cfg.timebin = inttime cfg.col = "data" cfg.antenna = "*&*" # discard autos tasklib.split(cfg) # run task # clean up shutil.rmtree("tmp_" + msfile2) else: subprocess.call(["asdm2MS", "--ocm co --icm co --lazy --scans", scan, asdmfile, msfile2]) # importasdm(asdm=asdmfile, vis=msfile2, scans=scans, ocorr_mode='co', corr_mode='co', savecmds=False, applyflags=True, process_flags=False, lazy=True) # replaced! return msfile2
def sdm2ms(sdmfile, msfile, scan, inttime='0'): """ Converts sdm to ms format for a single scan. msfile defines the name template for the ms. Should end in .ms, but "s<scan>" will be put in. scan is string of (sdm counted) scan number. inttime is string to feed to split command. gives option of integrated data down in time. """ # fill ms file if os.path.exists(msfile): logger.debug('%s already set.' % msfile) else: logger.info('No %s found. Creating anew.' % msfile) if inttime != '0': logger.info('Filtering by int time.') subprocess.call([ 'asdm2MS', '--ocm', 'co', '--icm', 'co', '--lazy', '--scans', scan, sdmfile, msfile + '.tmp' ]) cfg = tasklib.SplitConfig() # configure split cfg.vis = msfile + '.tmp' cfg.out = msfile cfg.timebin = inttime cfg.col = 'data' cfg.antenna = '*&*' # discard autos tasklib.split(cfg) # run task # clean up shutil.rmtree(msfile + '.tmp') else: subprocess.call([ 'asdm2MS', '--ocm', 'co', '--icm', 'co', '--lazy', '--scans', scan, sdmfile, msfile ]) return msfile
#!/usr/bin/env python import tasklib as tl import argparse parser = argparse.ArgumentParser() parser.add_argument("msfile", help="Input ms file name") parser.add_argument("msfile2", help="Output ms file name") parser.add_argument("scan", help="CASA string to select scans (e.g., 1~5; inclusive)") args = parser.parse_args() if args.msfile: msfile = args.msfile.rstrip('/') if args.msfile2: msfile2 = args.msfile2.rstrip('/') cfg = tl.SplitConfig() # configure split cfg.vis = msfile cfg.out = msfile2 cfg.col = 'data' cfg.scan=args.scan # discard autos tl.split(cfg) # run task