Example #1
0
# -*- coding: future_fstrings -*-
import sys

from scabha import config, parse_parameters, prun

# If a list of fields is given, insert them as repeated arguments.
# Other arguments not allowed to be lists.
args = [config.binary] + parse_parameters(repeat=True,
                                          positional=["antenna-file"], mandatory=["antenna-file"])

# run the command
if prun(args) is not 0:
    sys.exit(1)
Example #2
0
        ll, mm = " ".join(map(str, perr[0])), " ".join(map(str, perr[-1]))
        options['oms_pointing_errors.pe_l.values_str'] = "'%s'" % ll
        options['oms_pointing_errors.pe_l.values_str'] = "'%s'" % mm

field_center = params.pop("field-center", None)
if field_center and skymodel:
    if field_center.lower() == "ms":
        ftab = table(msname + "/FIELD")
        ra, dec = ftab.getcol("PHASE_DIR")[params.get('field-id', 0)][0]
        field_center = "J2000,%frad,%frad" % (ra, dec)
    tmp = "recentered_" + os.path.basename(skymodel)

    utils.xrun("tigger-convert",
               ["--recenter", field_center, skymodel, tmp, "-f"])
    options["tiggerlsm.filename"] = tmp

prefix = ['-s {}'.format(saveconf) if saveconf else ''] + \
    ["--mt {0} -c {1} [{2}]".format(threads, tdlconf, section)]
CATTERY_PATH = os.path.dirname(Cattery.__file__)
suffix = ["%s/Siamese/turbo-sim.py =_simulate_MS" % CATTERY_PATH]

args = []
for key, value in options.items():
    if isinstance(value, str) and value.find(' ') > 0:
        value = '"{:s}"'.format(value)
    args.append('{0}={1}'.format(key, value))

_runc = " ".join([config.binary] + prefix + args + suffix)
if prun(_runc) != 0:
    sys.exit(0)
Example #3
0
    conf.read(parset[0])
    if 'jones' in conf.options('sol'):
        soljones = conf.get('sol', 'jones')
        if "[" in soljones:
            soljones = ast.literal_eval(soljones)
        else:
            soljones = soljones.split(",")
    else:
        soljones = ['g', 'de']
    if type(soljones) is list:
        soljones = ",".join(soljones)

for jones in joneses:
    if jones.lower() not in soljones.lower():
        jopts = filter(lambda a: a.startswith(
            "{0:s}-".format(jones)), args.keys())
        for item in list(jopts):
            del args[item]

opts = ["{0:s}sol-jones {1:s}".format(config.prefix, soljones)] + \
    ['{0}{1} {2}'.format(config.prefix, name, value)
     for name, value in args.items()]

_runc = " ".join([config.binary] + parset + opts)

argslist = shlex.split(_runc)

# run the command
if prun(argslist) is not 0:
    sys.exit(1)
Example #4
0
def run_meqtrees(msname):

    prefix = ["--mt %d -c %s [%s]" % (THREADS, TDL, SECTION)]
    CATTERY_PATH = os.path.dirname(Cattery.__file__)
    suffix = ["%s/Calico/calico-stefcal.py =stefcal" % CATTERY_PATH]
    options = {}
    options.update(params)
    if jdict.pop("add-vis-model", 0):
        options["read_ms_model"] = 1
        options["ms_sel.model_column"] = model_column

    taql = jdict.get('data-selection', None)
    if taql:
        options["ms_sel.ms_taql_str"] = taql

    args = []
    for key, value in options.items():
        if isinstance(value, str) and value.find(' ') > 0:
            value = '"{:s}"'.format(value)
        args.append('{0}={1}'.format(key, value))

    args = prefix + args + suffix

    _runc = " ".join([binary] + args + \
            ['-s {}'.format(saveconf) if saveconf else ''])
    if prun(_runc) != 0:
        sys.exit(1)

    log.info("MeqTrees Done!")
    # now plot the gains
    if makeplots:
        log.info("Preparing to make gain plots")
        import Owlcat.Gainplots as plotgains
        feed_tab = table(msname + "/FEED")
        log.info("Extracting feed type from MS")
        feed_type = set(feed_tab.getcol("POLARIZATION_TYPE")['array'])
        feed_type = "".join(feed_type)
        log.info("Feed type is [%s]" % feed_type)

        if feed_type.upper() in ["XY", "YX"]:
            feed_type = "XY"
        else:
            feed_type = "RL"

        if gjones:
            log.info("Making Gain plots (G)...")
            plotgains.make_gain_plots(gjones_gains,
                                      prefix=gjones_plotprefix,
                                      feed_type=feed_type)

        if bjones:
            log.info("Making Gain plots (B)...")
            plotgains.make_gain_plots(bjones_gains,
                                      gain_label='B',
                                      prefix=bjones_plotprefix,
                                      feed_type=feed_type)

        if ddjones:
            log.info("Making differential gain plots...")
            plotgains.make_diffgain_plots(ddjones_gains,
                                          prefix=ddjones_plotprefix,
                                          feed_type=feed_type)

        if ifrjones:
            log.info("Making IFR gain plots...")
            plotgains.make_ifrgain_plots(ifrjones_gains,
                                         prefix=ifrjones_plotprefix,
                                         feed_type=feed_type)