Beispiel #1
0
def main(options, args):
    # Setup configuration source
    katconf.set_config(katconf.environ(options.config))

    # Set up Python logging
    katconf.configure_logging(options.logging)
    logfile = "kat.%s" % APP_NAME
    logger = logging.getLogger(logfile)

    # Load the configuration
    sysconf = katconf.SystemConfig()

    db_uri = sysconf.conf.get("katobs", "db_uri")

    logger.info("Logging started")
    logger.info("Katobs obsbuild: db_uri=%s Make a Schedule Block" % db_uri)

    obs = obsbuild(user=options.user, db_uri=db_uri)
    print "===obs.status()==="
    obs.status()
    print "===obs.status()==="
    #Create a new sb
    sb_id_code = obs.sb.new(owner=options.user)
    print "===NEW SB CREATED===", sb_id_code
    obs.sb.description = "%s" % (options.description)
    obs.sb.type = ScheduleBlockTypes.OBSERVATION
    instruction_set = "run-obs-script /home/kat/katusescripts/ptuse/beamform_single_pulsar.py  --proposal-id='FST-TRNS' --program-block-id='%s' --issue-id='%s' -B 856 -F 1284 -t %d '%s' --horizon 20" % (
        options.issue, options.issue, options.duration, options.target)

    #     instruction_set = "run-obs-script /home/kat/katsdpscripts/AR1/observations/beamform_AR1.py --proposal-id='COMM-AR1' --program-block-id='COMM-173' -B %s -F 1284 '%s' -t %d --horizon 20" % (options.bandwidth, options.target, options.duration)
    #    if options.backend is not None:
    #        instruction_set += " --backend='%s'" % (options.backend)
    #    if options.backend_args is not None:
    #        instruction_set += " --backend-args='%s'" % (options.backend_args)
    #    if options.drift_scan:
    #        instruction_set += " --drift-scan"
    obs.sb.instruction_set = "%s" % (instruction_set)
    obs.sb.antenna_spec = options.antennas
    obs.sb.controlled_resources_spec = 'cbf,sdp,ptuse_1'
    obs.sb.to_defined()
    obs.sb.to_approved()
    obs.sb.unload()

    #Display the created sb
    print "\n===obs.sb==="
    print obs.sb

    logger.info("Katobs done.")
Beispiel #2
0
import os

from datetime import datetime, timedelta

from .simulate import user_logger, setobserver, MEERKAT_REFERENCE_LOCATION
from .targets import katpoint_target_string

try:
    import katconf

    # Set up configuration source
    _config_path = "/var/kat/config"
    _node_file = "/var/kat/node.conf"
    _settings = {}
    if os.path.isdir(_config_path):
        katconf.set_config(katconf.environ(override=_config_path))
    elif os.path.isfile(_node_file):
        with open(_node_file, "r") as fh:
            _node_conf = json.loads(fh.read())
        for _key, _val in _node_conf.items():
            # Remove comments at the end of the line
            _val = _val.split("#", 1)[0]
            _settings[_key] = _val.strip()
        if _settings.get("configuri", False):
            katconf.set_config(katconf.environ(_node_conf["configuri"]))
        else:
            raise ValueError("Could not open node config file using configuri")
    else:
        raise ValueError("Could not open node config file")

except (ImportError, ValueError):