Exemplo n.º 1
0
def fill_selfcal_model():
    imcfg = _img_config(tavgvis, 'prepeel')

    cfg = tasks.FtConfig()
    cfg.vis = tavgvis
    cfg.usescratch = True  # important! silently fails otherwise
    cfg.complist = '../repo/scmodel0.cl'
    cfg.incremental = False
    cfg.wprojplanes = imcfg.wprojplanes
    tasks.ft(cfg)
Exemplo n.º 2
0
def fill_pwork_model(idx):
    idx = int(idx)
    assert idx >= 0 and idx < len(peels)

    peelmodel = peelmodelfmt.format(idx=idx)
    peelwork = peelworkfmt.format(idx=idx)
    imcfg = _img_config(peelwork, 'prepeel')

    cfg = tasks.FtConfig()
    cfg.vis = peelwork
    cfg.usescratch = True  # important! silently fails otherwise
    cfg.complist = peelmodel
    cfg.incremental = False
    cfg.wprojplanes = imcfg.wprojplanes
    tasks.ft(cfg)
Exemplo n.º 3
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()
Exemplo n.º 4
0
def fill_peel_model(idx):
    from os.path import isdir

    idx = int(idx)
    assert idx >= 0 and idx < len(peels)

    imcfg = _img_config(peelvis, 'prepeel')
    ref_mod_paths = [
        _ttstem(imcfg, peelrefstem, i) for i in range(imcfg.nterms)
    ]

    for p in ref_mod_paths:
        if not isdir(p):
            raise Exception(
                f'required reference CLEAN-component model image {p} not found'
            )

    # First, create the temporary CLEAN component image(s) we'll use for the
    # baseline UV model. This consists of the reference image with this
    # source, and the prior peeled sources, zero'ed out. We zero out this
    # source to because we need to preserve it for calibration! We zero out
    # the prior sources since we'll augment the model with their post-peel
    # models, which will be more accurate than the pre-peel reference image.

    work_mod_paths = [
        _ttstem(imcfg, 'fillpeeltemp', i) for i in range(imcfg.nterms)
    ]

    for i in range(imcfg.nterms):
        ref_path = ref_mod_paths[i]
        work_path = work_mod_paths[i]

        # Blow away the work and copy the reference
        shell('rm -rf \'%s\'' % work_path)
        shell('cp -r \'%s\' \'%s\'' % (ref_path, work_path))

        # Zero out the relevant slices
        for peelsrc in peels[:idx + 1]:
            x = peelsrc['xslice']
            y = peelsrc['yslice']
            _set_slice_rect(work_path, x[0], x[1], y[0], y[1], 0)

    # Now, FT this temporary image into peelvis:MODEL_DATA.

    cfg = tasks.FtConfig()
    cfg.vis = peelvis
    cfg.usescratch = True  # important! silently fails otherwise
    cfg.model = work_mod_paths
    cfg.incremental = False
    cfg.wprojplanes = imcfg.wprojplanes
    tasks.ft(cfg)

    # Done with the temporary model images (note: might want to keep
    # these for debugging)

    for work_path in work_mod_paths:
        shell('rm -rf \'%s\'' % work_path)

    # Now, update the model data with the FTs from all of the peeled
    # sources that have been done up until this point

    for i2, peelsrc in enumerate(peels[:idx]):
        peelwork = peelworkfmt.format(idx=i2)
        argv = ['rubbl-rxpackage', 'peel', '--incremental', peelvis, peelwork]
        shell(argv, shell=False)