Beispiel #1
0
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    spw = va(taskvals, 'crosscal', 'spw', str, default='')

    specavg = va(taskvals, 'crosscal', 'width', int, default=1)
    timeavg = va(taskvals, 'crosscal', 'timeavg', str, default='8s')
    keepmms = va(taskvals, 'crosscal', 'keepmms', bool)

    msmd.open(visname)
    newvis = split_vis(visname, spw, fields, specavg, timeavg, keepmms)

    config_parser.overwrite_config(args['config'],
                                   conf_dict={'vis': "'{0}'".format(newvis)},
                                   conf_sec='data')
    config_parser.overwrite_config(
        args['config'],
        conf_dict={'crosscal_vis': "'{0}'".format(visname)},
        conf_sec='run',
        sec_comment='# Internal variables for pipeline execution')

    fnames = msmd.namesforfields()
    config_parser.overwrite_config(
        args['config'],
        conf_dict={'fieldnames': "{0}".format(fnames)},
        conf_sec='run',
        sec_comment='# Internal variables for pipeline execution')

    msmd.done()
Beispiel #2
0
def main(args,taskvals):

    visname = va(taskvals, 'run', 'crosscal_vis', str)
    keepmms = va(taskvals, 'crosscal', 'keepmms', bool)

    fields = bookkeeping.get_field_ids(taskvals['fields'])

    run_tclean(visname, fields, keepmms)
Beispiel #3
0
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    refant = va(taskvals, 'crosscal', 'refant', str, default='m005')
    minbaselines = va(taskvals, 'crosscal', 'minbaselines', int, default=4)

    do_parallel_cal_apply(visname, fields, calfiles)
def main(args,taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    minbaselines = va(taskvals, 'crosscal', 'minbaselines', int, default=4)
    standard = va(taskvals, 'crosscal', 'standard', str, default='Stevens-Reynolds 2016')
    refant = va(taskvals, 'crosscal', 'refant', str, default='m059')

    do_parallel_cal(visname, fields, calfiles, refant, caldir, minbaselines, standard)
def main(args, taskvals):

    visname = va(taskvals, 'run', 'crosscal_vis', str)
    keepmms = va(taskvals, 'crosscal', 'keepmms', bool)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    msmd.open(visname)

    if not os.path.exists(PLOT_DIR):
        os.mkdir(PLOT_DIR)

    # #Superseded by 'plotcal_spw.py'
    # #Plot solutions for bandpass calibrator
    # plotms(vis=calfiles.bpassfile, xaxis='Real', yaxis='Imag', coloraxis='corr', plotfile='{0}/bpass_real_imag.png'.format(PLOT_DIR),showgui=False)
    # plotms(vis=calfiles.bpassfile, xaxis='freq', yaxis='Amp', coloraxis='antenna1', plotfile='{0}/bpass_freq_amp.png'.format(PLOT_DIR),showgui=False)
    # plotms(vis=calfiles.bpassfile, xaxis='freq', yaxis='Phase', coloraxis='antenna1', plotfile='{0}/bpass_freq_phase.png'.format(PLOT_DIR),showgui=False)
    #
    # #Plot solutions for phase calibrator
    # plotms(vis=calfiles.gainfile, xaxis='Real', yaxis='Imag', coloraxis='corr', plotfile='{0}/phasecal_real_imag.png'.format(PLOT_DIR),showgui=False)
    # plotms(vis=calfiles.gainfile, xaxis='Time', yaxis='Amp', coloraxis='antenna1', plotfile='{0}/phasecal_time_amp.png'.format(PLOT_DIR),showgui=False)
    # plotms(vis=calfiles.gainfile, xaxis='Time', yaxis='Phase', coloraxis='antenna1', plotfile='{0}/phasecal_time_phase.png'.format(PLOT_DIR),showgui=False)
    #
    # #Plot solutions for individual antennas of bandpass and phase calibrator in 3x2 panels
    # plot_antennas('bpass',fields,calfiles,xaxis='freq',yaxis='amp')
    # plot_antennas('bpass',fields,calfiles,xaxis='freq',yaxis='phase')
    # plot_antennas('phasecal',fields,calfiles,xaxis='time',yaxis='amp')
    # plot_antennas('phasecal',fields,calfiles,xaxis='time',yaxis='phase')

    extn = 'mms' if keepmms else 'ms'
    for field in fields:
        for subf in field.split(','):
            fname = msmd.namesforfields(int(subf))[0]
            inname = '%s.%s.%s' % (os.path.splitext(visname)[0], fname, extn)
            if not os.path.exists('{0}/{1}_freq_amp.png'.format(
                    PLOT_DIR, fname)):
                plotms(vis=inname,
                       xaxis='freq',
                       yaxis='Amp',
                       coloraxis='corr',
                       plotfile='{0}/{1}_freq_amp.png'.format(PLOT_DIR, fname),
                       showgui=False)
                plotms(vis=inname,
                       xaxis='Real',
                       yaxis='Imag',
                       coloraxis='corr',
                       plotfile='{0}/{1}_real_imag.png'.format(
                           PLOT_DIR, fname),
                       showgui=False)

    msmd.done()
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    do_pre_flag_2(visname, fields)
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    do_cross_cal_apply(visname, fields, calfiles, caldir)
Beispiel #8
0
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)
    name = visname.split('/')[-1].replace('.ms', '')

    listobs(vis=visname, listfile=name + "_listobs.txt")

    return
Beispiel #9
0
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)
    calcrefant = va(taskvals, 'crosscal', 'calcrefant', bool, default=False)
    refant = va(taskvals, 'crosscal', 'refant', str, default='m005')
    SPWs = va(taskvals, 'crosscal', 'spw', str, default='')
    #tasks = va(taskvals, 'slurm', 'ntasks_per_node', int)
    preavg = va(taskvals, 'crosscal', 'chanbin', int, default=1)
    include_crosshand = va(taskvals, 'run', 'dopol', bool, default=False)
    createmms = va(taskvals, 'crosscal', 'createmms', bool, default=True)

    msmd.open(visname)
    npol = msmd.ncorrforpol()[0]

    if not include_crosshand and npol == 4:
        npol = 2

    #CPUs = npol if tasks*npol <= processMeerKAT.CPUS_PER_NODE_LIMIT else 1 #hard-code for number of polarisations
    CPUs = int(sys.argv[-1])

    for spw in SPWs.split(','):
        mvis = do_partition(visname, spw, preavg, CPUs, include_crosshand,
                            createmms)
        mvis = "'{0}'".format(mvis)
        vis = "'{0}'".format(visname)

    config_parser.overwrite_config(args['config'],
                                   conf_sec='data',
                                   conf_dict={'vis': mvis})
    config_parser.overwrite_config(
        args['config'],
        conf_sec='run',
        sec_comment='# Internal variables for pipeline execution',
        conf_dict={'orig_vis': vis})
    msmd.done()
Beispiel #10
0
def main(args, taskvals):

    visname = va(taskvals, "data", "vis", str)

    if os.path.exists(os.path.join(os.getcwd(), "caltables")):
        shutil.rmtree(os.path.join(os.getcwd(), "caltables"))

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals["fields"])

    spw = va(taskvals, "crosscal", "spw", str, default="")
    standard = va(taskvals,
                  "crosscal",
                  "standard",
                  str,
                  default="Stevens-Reynolds 2016")
    dopol = va(taskvals, 'run', 'dopol', bool, default=False)
    createmms = va(taskvals, 'crosscal', 'createmms', bool, default=True)

    do_setjy(visname, spw, fields, standard, dopol, createmms)
def main(args,taskvals):

    visname = va(taskvals, 'data', 'vis', str)

    badfreqranges = taskvals['crosscal'].pop('badfreqranges', ['935~947MHz', '1160~1310MHz', '1476~1611MHz', '1670~1700MHz'])
    badants = taskvals['crosscal'].pop('badants')

    calfiles, caldir = bookkeeping.bookkeeping(visname)
    fields = bookkeeping.get_field_ids(taskvals['fields'])

    do_pre_flag(visname, fields, badfreqranges, badants)
Beispiel #12
0
def main(args, taskvals):

    visname = va(taskvals, 'data', 'vis', str)
    spw = va(taskvals, 'crosscal', 'spw', str, default='')
    nspw = va(taskvals, 'crosscal', 'nspw', int, default='')
    fields = bookkeeping.get_field_ids(taskvals['fields'])
    dirs = config_parser.parse_spw(args['config'])[3]

    if ',' in spw:
        newvis = do_concat(visname, fields, dirs)
        config_parser.overwrite_config(
            args['config'],
            conf_dict={'vis': "'{0}'".format(newvis)},
            conf_sec='data')
        config_parser.overwrite_config(
            args['config'],
            conf_dict={'crosscal_vis': "'{0}'".format(visname)},
            conf_sec='run',
            sec_comment='# Internal variables for pipeline execution')
    else:
        logger.error(
            "Only found one SPW in '{0}', so will skip concat.".format(
                args['config']))
Beispiel #13
0
def main(args,taskvals):
    
    spw = sys.argv[-1]
    
    visname = va(taskvals, "data", "vis", str)
    visname = visname.split('/')[-1]
    mmsfile = visname.replace('ms',spw+'.mms')
    mmsfile = "'{0}'".format(mmsfile)
    
    config_parser.overwrite_config(args['config'], conf_sec='data', conf_dict={'vis':mmsfile})
    logger.info('Updated (vis) in [data] section written to "{0}".'.format(args['config']))
    
    spw = '0:'+spw
    spw = "'{0}'".format(spw)
    config_parser.overwrite_config(args['config'], conf_sec='crosscal', conf_dict={'spw':spw})
    config_parser.overwrite_config(args['config'], conf_sec='crosscal', conf_dict={'nspw':1})
        
    logger.info('Updated (spw,nspw) in [crosscal] section written to "{0}".'.format(args['config']))
    
    return
def main(args, taskvals):

    visname = va(taskvals, "data", "vis", str)
    fields = read_fields(visname)

    if len(fields) > 0:
        config_parser.overwrite_config(args['config'],
                                       conf_dict=fields,
                                       conf_sec='fields')

        logger.info(
            '[fields] section written to "{0}". Edit this section if you need to change field IDs (comma-separated string for multiple IDs, not supported for calibrators).'
            .format(args['config']))

    else:
        logger.info(
            'No updated [fields] section written to "{0}". Edit this section manually (comma-separated string for multiple IDs, not supported for calibrators).'
            .format(args['config']))

    return
Beispiel #15
0
def do_concat(visname, fields, dirs='*MHz'):

    #msmd.open(visname)
    fieldnames = va(taskvals, 'run', 'fieldnames', str)

    newvis = visname
    logger.info('Beginning {0}.'.format(sys.argv[0]))
    basename, ext = os.path.splitext(visname)
    filebase = os.path.split(basename)[1]

    for field in [fields.targetfield, fields.gainfields, fields.extrafields]:
        if field != '':
            for target in field.split(','):
                #fname = msmd.namesforfields(int(target))[0]
                fname = fieldnames[int(target)]

                #Concat tt0 images (into continuum cube)
                suffix = 'images/*{0}*image.tt0'.format(fname)
                files, pattern = get_infiles(dirs, suffix)
                out = '{0}.{1}.contcube'.format(filebase, fname)
                images = check_output(fname,
                                      files,
                                      pattern,
                                      out,
                                      job='imageconcat',
                                      filetype='image')
                if images is not None:
                    images.sort(key=sortbySPW)
                    logger.info(
                        'Creating continuum cube with following command:')
                    logger.info(
                        'ia.imageconcat(infiles={0}, outfile={1}, axis=-1, relax=True)'
                        .format(images, out))
                    ia.imageconcat(infiles=images,
                                   outfile=out,
                                   axis=-1,
                                   relax=True)

                    if os.path.exists(out):
                        if not os.path.exists(out + '.fits'):
                            exportfits(imagename=out, fitsimage=out + '.fits')
                    else:
                        logger.error(
                            "Output image '{0}' attempted to write but was not written."
                            .format(out))

                #Concat images (into continuum cube)
                suffix = 'images/*{0}*image'.format(fname)
                files, pattern = get_infiles(dirs, suffix)
                out = '{0}.{1}.contcube'.format(filebase, fname)
                images = check_output(fname,
                                      files,
                                      pattern,
                                      out,
                                      job='imageconcat',
                                      filetype='image')
                if images is not None:
                    images.sort(key=sortbySPW)
                    logger.info(
                        'Creating continuum cube with following command:')
                    logger.info(
                        'ia.imageconcat(infiles={0}, outfile={1}, axis=-1, relax=True)'
                        .format(images, out))
                    ia.imageconcat(infiles=images,
                                   outfile=out,
                                   axis=-1,
                                   relax=True)

                    if os.path.exists(out):
                        if not os.path.exists(out + '.fits'):
                            exportfits(imagename=out, fitsimage=out + '.fits')
                    else:
                        logger.error(
                            "Output image '{0}' attempted to write but was not written."
                            .format(out))

                #Concat MSs
                suffix = '*{0}*.ms'.format(fname)
                files, pattern = get_infiles(dirs, suffix)
                out = '{0}.{1}.ms'.format(filebase, fname)
                MSs = check_output(fname,
                                   files,
                                   pattern,
                                   out,
                                   job='concat',
                                   filetype='MS')
                if MSs is not None:
                    MSs.sort(key=sortbySPW)
                    logger.info('Concatenating MSs with following command:')
                    logger.info('concat(vis={0}, concatvis={1})'.format(
                        MSs, out))
                    concat(vis=MSs, concatvis=out)
                    if target == fields.targetfield.split(',')[0]:
                        newvis = out

                    if not os.path.exists(out):
                        logger.error(
                            "Output MS '{0}' attempted to write but was not written."
                            .format(out))

                #Concat MMSs
                suffix = '*{0}*.mms'.format(fname)
                files, pattern = get_infiles(dirs, suffix)
                out = '{0}.{1}.mms'.format(filebase, fname)
                MMSs = check_output(fname,
                                    files,
                                    pattern,
                                    out,
                                    job='virtualconcat',
                                    filetype='MMS')
                if MMSs is not None:
                    MMSs.sort(key=sortbySPW)
                    logger.info('Concatenating MMSs with following command:')
                    logger.info('virtualconcat(vis={0}, concatvis={1})'.format(
                        MMSs, out))
                    virtualconcat(vis=MMSs, concatvis=out)
                    if target == fields.targetfield.split(',')[0]:
                        newvis = out

                    if not os.path.exists(out):
                        logger.error(
                            "Output MMS '{0}' attempted to write but was not written."
                            .format(out))

    #msmd.done()
    logger.info('Completed {0}.'.format(sys.argv[0]))

    return newvis