示例#1
0
def subsplit_peel_work(idx):
    idx = int(idx)
    assert idx >= 0 and idx < len(peels)

    peelwork = peelworkfmt.format(idx=idx)

    # uvsub subtracts MODEL_DATA from CORRECTED_DATA, defaulting
    # CORRECTED_DATA to DATA if it doesn't exist. The way we work, we punch
    # out individual sources when peeling, so modifying CORRECTED_DATA
    # iteratively doesn't work very well as a workflow. So, kill
    # CORRECTED_DATA to get it to reset to DATA.
    tb = util.tools.table()
    tb.open(peelvis, nomodify=False)
    if 'CORRECTED_DATA' in tb.colnames():
        tb.removecols(['CORRECTED_DATA'])
    tb.close()

    cfg = tasks.UvsubConfig()
    cfg.vis = peelvis
    cfg.reverse = False
    tasks.uvsub(cfg)

    cfg = tasks.SplitConfig()
    cfg.vis = peelvis
    cfg.out = peelwork
    cfg.col = 'corrected_data'
    tasks.split(cfg)
示例#2
0
def average():
    cfg = tasks.SplitConfig()
    cfg.vis = targvis
    cfg.out = peelvis
    cfg.timebin = average_timebin
    cfg.col = 'corrected_data'
    cfg.antenna = '*&*'  # discard autos
    # You can't average 2 ways in one step, because derp.
    # cfg.step = 2
    tasks.split(cfg)
示例#3
0
def done_peeling():
    """Rewrite peelvis:MODEL_DATA to contain only the fancy peeled visibilities,
    and *not* the pre-peel static model of the non-peeled sources. Then uvsub
    and split out, averaging pretty heavily in frequency space. So, if we
    image the resulting dataset, we'll see everything except the sources that
    have been peeled out.

    """
    from os.path import isdir

    for idx in range(len(peels)):
        peelwork = peelworkfmt.format(idx=idx)
        if not isdir(peelwork):
            raise Exception(f'missing peel-work MS {peelwork}')

    for idx in range(len(peels)):
        peelwork = peelworkfmt.format(idx=idx)

        argv = ['rubbl-rxpackage', 'peel']
        if idx > 0:
            argv += ['--incremental']
        argv += [peelvis, peelwork]

        shell(argv, shell=False)

    # uvsub subtracts MODEL_DATA from CORRECTED_DATA, defaulting
    # CORRECTED_DATA to DATA if it doesn't exist. The way we work, we punch
    # out individual sources when peeling, so modifying CORRECTED_DATA
    # iteratively doesn't work very well as a workflow. So, kill
    # CORRECTED_DATA to get it to reset to DATA.
    tb = util.tools.table()
    tb.open(peelvis, nomodify=False)
    if 'CORRECTED_DATA' in tb.colnames():
        tb.removecols(['CORRECTED_DATA'])
    tb.close()

    cfg = tasks.UvsubConfig()
    cfg.vis = peelvis
    cfg.reverse = False
    tasks.uvsub(cfg)

    # We use this opportunity to freq-average, since we've already
    # time-averaged. Might be better to reverse the ordering!
    cfg = tasks.SplitConfig()
    cfg.vis = peelvis
    cfg.out = tavgvis
    cfg.col = 'corrected_data'
    cfg.step = 16  # blah, lazy hardcoding
    tasks.split(cfg)
示例#4
0
def justsub(*names):
    """HACK redo sub?"""
    if not len(names):
        names = default_ftsubs

    cb = util.tools.calibrater()
    vis = tavgvis

    for name in names:
        ftcfg = ftsubs[name]
        imcfg = _img_config(vis, ftcfg['image'])

        cfg = tasks.FtConfig()
        cfg.vis = vis
        cfg.usescratch = True  # important! silently fails otherwise
        cfg.model = [
            _ttstem(imcfg, name + '.ftmodel', i) for i in range(imcfg.nterms)
        ]
        cfg.incremental = False
        cfg.wprojplanes = imcfg.wprojplanes
        tasks.ft(cfg)

        cfg = tasks.UvsubConfig()
        cfg.vis = vis
        cfg.reverse = False
        tasks.uvsub(cfg)

        cfg = tasks.SplitConfig()
        for k, v in ftcfg.items():
            setattr(cfg, k, v)
        cfg.vis = vis
        cfg.out = name + '.sub.ms'
        cfg.col = 'corrected_data'
        cfg.antenna = '*&*'  # discard autos
        tasks.split(cfg)

    # It is important to clear the CORRECTED_DATA column now, because otherwise
    # it will be used if/when we image again and everything except the source of
    # interest will disappear!

    import casadef
    if casadef.casa_version.startswith('5.'):
        cb.setvi(old=True,
                 quiet=False)  # as is evident, this is needed in CASA 5.x
    cb.open(vis, addcorr=False, addmodel=False)
    cb.initcalset(calset=True)
    cb.close()
示例#5
0
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.')
            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
            rmtree(msfile + '.tmp')
        else:
            call([
                'asdm2MS', '--ocm', 'co', '--icm', 'co', '--lazy', '--scans',
                scan, sdmfile, msfile
            ])

    return msfile