Skip to content
Snippets Groups Projects
Commit 53d6e3e8 authored by Vlad Kondratiev's avatar Vlad Kondratiev
Browse files

enabled the use of yaml config file in addition to command-line options. The...

enabled the use of yaml config file in addition to command-line options. The latter though still takes precedence
parent 7d35b7cb
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,8 @@ option belonging to scheduling constraints that will work is --tstart to specify ...@@ -54,6 +54,8 @@ option belonging to scheduling constraints that will work is --tstart to specify
default="tmss.lofar.eu", type=str) default="tmss.lofar.eu", type=str)
parser.add_argument("--port", help="Port to connect to TMSS server [int, default: 443]", parser.add_argument("--port", help="Port to connect to TMSS server [int, default: 443]",
default=443, type=int) default=443, type=int)
parser.add_argument("--config", help="Configuration file in YAML file to modify parameters for a given strategy or spec file. If extra options are used in the command line to also modify some values, command-line values have precedence [str]",
default="", type=str)
parser.add_argument("--project", help="Specify project for which a SU will be created", parser.add_argument("--project", help="Specify project for which a SU will be created",
default="", type=str) default="", type=str)
parser.add_argument("--specfile", help="JSON file with SU specifications [str, mandatory option unless --strategy[-id] is used]. If both \ parser.add_argument("--specfile", help="JSON file with SU specifications [str, mandatory option unless --strategy[-id] is used]. If both \
...@@ -89,15 +91,15 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -89,15 +91,15 @@ the coordinates, or use --pointing option", action="store_true")
default="", type=str) default="", type=str)
parser.add_argument("--subband", help="Subbands to select, can be comma-separated, range is allowed with .. [str]", parser.add_argument("--subband", help="Subbands to select, can be comma-separated, range is allowed with .. [str]",
default="", type=str) default="", type=str)
parser.add_argument("--subbands-per-file", help="Number of subbands per file [int, default - all given subbands from --subband option. If not given, then 976 for mode='I' and mode='IQUV', and 20 subbands for mode='XXYY'. If mode is not given, then 976 subbands will be written into a single file]", parser.add_argument("--subbands-per-file", help="Number of subbands per file [int, default - 488 for mode='I' and mode='IQUV', and 20 subbands for mode='XXYY'. If mode is not given, then without this option the value from the strategy or specification is used]",
default=0, type=int) default=0, type=int)
parser.add_argument("--channels-per-subband", help="Number of channels per subband [int, default - 1 for mode='XXYY' and 16 for mode='I' or 'IQUV'. If mode is not given, then default number of channels per subband is 16]", parser.add_argument("--channels-per-subband", help="Number of channels per subband [int, default - 1 for mode='XXYY' and 16 for mode='I' or 'IQUV'. If mode is not given, then without this option the value from the strategy or specification is used]",
default=0, type=int) default=0, type=int)
parser.add_argument("--downsample", help="Downsampling factor [int, default - 1 for mode='XXYY' and 16 for mode='I' or 'IQUV'. If mode is not given, then downsampling factor is 1]", parser.add_argument("--downsample", help="Downsampling factor [int, default - 1 for mode='XXYY' and 16 for mode='I' or 'IQUV'. If mode is not given, then without this option the value from the strategy or specification is used]",
default=0, type=int) default=0, type=int)
parser.add_argument("--quantisation" , help="Enable quantisation to 8 bits for the raw data [default - False (without this option)]", parser.add_argument("--quantisation" , help="Enable quantisation to 8 bits for the raw data [default - False (without this option)]",
action="store_true") action="store_true")
parser.add_argument("--tstart", help="Start time (isot), also allowed \"now\" string [str]", parser.add_argument("--tstart", help="Start time (isot), also allowed \"now\" string. Can be comma-separated list of several start times, then scheduling units are created for every start time. Same name and description will be used for these scheduling units. The \"now\" string can not be combined with other start times [str]",
default="", type=str) default="", type=str)
parser.add_argument("--length", help="Observation length (s) [int]", parser.add_argument("--length", help="Observation length (s) [int]",
default=0, type=int) default=0, type=int)
...@@ -115,14 +117,26 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -115,14 +117,26 @@ the coordinates, or use --pointing option", action="store_true")
print ("Error: no name for the scheduling unit is given (mandatory)!") print ("Error: no name for the scheduling unit is given (mandatory)!")
sys.exit(1) sys.exit(1)
# Dictionary with user-specified settings
config = {}
if args.config != "":
with open(args.config, "r") as cfg:
config = yaml.load(cfg, Loader=yaml.FullLoader)
# first check that project is given # first check that project is given
if args.project == "": if args.project != "": config["project"] = args.project
print ("Error: Project is not specified, use --project") if "project" not in config or config["project"] == "":
print ("Error: Project is not specified, use --project or 'project' keyword in the configuration file!")
sys.exit(1) sys.exit(1)
# check if either the strategy is given or JSON specs are provided # check if either the strategy is given or JSON specs are provided
if args.specfile == "" and args.strategy == "" and args.strategy_id == 0: if args.specfile != "": config["specfile"] = args.specfile
print ("Error: Neither JSON specs are provided with --specfile option NOR the --strategy NOR the --strategy-id is given!") if args.strategy != "": config["strategy"] = args.strategy
if args.strategy_id != 0: config["strategy_id"] = args.strategy_id
if args.strategy_version != 0: config["strategy_version"] = args.strategy_version
if ("specfile" not in config or config["specfile"] == "") and ("strategy" not in config or config["strategy"] == "") and ("strategy_id" not in config or config["strategy_id"] == 0):
print ("Error: Neither JSON specs are provided with --specfile option NOR the --strategy NOR the --strategy-id is given!\nYou can also use configuration file to set up these values or use both")
sys.exit(1) sys.exit(1)
# Read credentials # Read credentials
...@@ -157,29 +171,31 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -157,29 +171,31 @@ the coordinates, or use --pointing option", action="store_true")
print() print()
# Get pointing # Get pointing
if args.target != "": if args.target != "": config["target"] = args.target
if "target" in config:
if not args.no_target_resolve: if not args.no_target_resolve:
point = get_icrs_coordinates(args.target) point = get_icrs_coordinates(args.target)
if "PSR" in args.target: if "PSR" in args.target:
args.target = args.target.split(" ")[-1].strip() config["target"] = config["target"].split(" ")[-1].strip()
else: else:
if args.ra == "" or args.dec == "": if args.ra == "" or args.dec == "":
print ("RA and/or DEC are not given with --ra and/or --dec options. These options are mandatory when --no-target-resolve is used!") print ("RA and/or DEC are not given with --ra and/or --dec options. These options are mandatory when --no-target-resolve is used!")
sys.exit(1) sys.exit(1)
if "PSR" in args.target: if "PSR" in config["target"]:
args.target = args.target.split(" ")[-1].strip() config["target"] = config["target"].split(" ")[-1].strip()
coords = f"{args.ra} {args.dec}" coords = f"{args.ra} {args.dec}"
point = SkyCoord(coords, frame=ICRS, unit=(u.hourangle, u.deg)) point = SkyCoord(coords, frame=ICRS, unit=(u.hourangle, u.deg))
pointing = {"target": args.target, pointing = {"target": config["target"],
"angle1": point.ra.rad, "angle1": point.ra.rad,
"angle2": point.dec.rad, "angle2": point.dec.rad,
"direction_type": "J2000" "direction_type": "J2000"
} }
if args.pointing != "": if args.pointing != "": config["pointing"] = args.pointing
parts = args.pointing.split(",") if "pointing" in config and config["pointing"] != "":
args.target = parts[0] parts = config["pointing"].split(",")
config["target"] = parts[0]
pointing = {"target": parts[0], pointing = {"target": parts[0],
"angle1": float(parts[1]), "angle1": float(parts[1]),
"angle2": float(parts[2]), "angle2": float(parts[2]),
...@@ -187,54 +203,70 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -187,54 +203,70 @@ the coordinates, or use --pointing option", action="store_true")
} }
# Decode subbands # Decode subbands
if args.subband != "": if args.subband != "": config["subband"] = args.subband
if "," in args.subband: if "subband" in config and config["subband"] != "":
subband_list = [int(part) for part in args.subband.split(",")] if "," in config["subband"]:
elif ".." in args.subband: subband_list = [int(part) for part in config["subband"].split(",")]
smin = int(args.subband.split("..")[0]) elif ".." in config["subband"]:
smax = int(args.subband.split("..")[-1]) smin = int(config["subband"].split("..")[0])
smax = int(config["subband"].split("..")[-1])
subband_list = list(range(smin, smax + 1)) subband_list = list(range(smin, smax + 1))
else: else:
subband_list = [int(args.subband)] subband_list = [int(config["subband"])]
if args.subbands_per_file == 0:
args.subbands_per_file = len(subband_list) if args.mode != "": config["mode"] = args.mode
if args.antennafield != "": config["antennafield"] = args.antennafield
# Updating the number of subbands per file (if still needd after the previous check for args.subband != "") if args.filter != "": config["filter"] = args.filter
if args.subbands_per_file == 0: if args.quantisation: config["quantisation"] = True
if args.mode == "XXYY": if "quantisation" in config:
args.subbands_per_file = 20 quantisation = { "bits": 8, "enabled": config["quantisation"], "scale_max": 5, "scale_min": -5 }
else: # if mode is not given, or it is Stokes I or IQUV
args.subbands_per_file = 976 # Updating the number of subbands per file
if args.subbands_per_file != 0: config["subbands_per_file"] = args.subbands_per_file
# Number of channels per subband if "subbands_per_file" not in config:
if args.channels_per_subband == 0: if "mode" in config:
if args.mode == "XXYY": if config["mode"] == "XXYY":
args.channels_per_subband = 1 config["subbands_per_file"] = 20
else: # if mode is not given, or it is Stokes I or IQUV
args.channels_per_subband = 16
# Downsampling factor
if args.downsample == 0:
if args.mode == "XXYY" or args.mode == "":
args.downsample = 1
else: else:
args.downsample = 16 config["subbands_per_file"] = 488
# Updating the number of channels per subband
if args.channels_per_subband != 0: config["channels_per_subband"] = args.channels_per_subband
if "channels_per_subband" not in config:
if "mode" in config:
if config["mode"] == "XXYY":
config["channels_per_subband"] = 1
else:
config["channels_per_subband"] = 16
# Updating the downsampling factor
if args.downsample != 0 : config["downsample"] = args.downsample
if "downsample" not in config:
if "mode" in config:
if config["mode"] == "XXYY":
config["downsample"] = 1
else:
config["downsample"] = 16
# Start time # Start time
if args.tstart != "": if args.tstart != "": config["tstart"] = args.tstart
if args.tstart == "now": if "tstart" in config and config["tstart"] != "":
if config["tstart"] == "now":
# Round to start of minute # Round to start of minute
tstart = datetime.now(timezone.utc) + timedelta(seconds=args.delay) tstart = datetime.now(timezone.utc) + timedelta(seconds=args.delay)
tstart = tstart.strftime("%Y-%m-%dT%H:%M:00") tstart = tstart.strftime("%Y-%m-%dT%H:%M:00")
else: else:
tstart = datetime.strptime(args.tstart, "%Y-%m-%dT%H:%M:%S") tstart = datetime.strptime(config["tstart"], "%Y-%m-%dT%H:%M:%S")
tstart = tstart.strftime("%Y-%m-%dT%H:%M:%S") tstart = tstart.strftime("%Y-%m-%dT%H:%M:%S")
if args.length > 0: config["length"] = args.length
# Station groups for Fly's Eye observations # Station groups for Fly's Eye observations
if args.stationlist != "": if args.stationlist != "": config["stationlist"] = args.stationlist
stationlist = [item for item in args.stationlist.split(",")] if "stationlist" in config and config["stationlist"] != "":
stationlist = [item for item in config["stationlist"].split(",")]
station_groups = [{"stations": stationlist, "max_nr_missing": 0}] station_groups = [{"stations": stationlist, "max_nr_missing": 0}]
try: try:
with TMSSsession (host=settings["host"], with TMSSsession (host=settings["host"],
port=settings["port"], port=settings["port"],
...@@ -245,14 +277,14 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -245,14 +277,14 @@ the coordinates, or use --pointing option", action="store_true")
scheduling_sets = client.get_path_as_json_object("scheduling_set") scheduling_sets = client.get_path_as_json_object("scheduling_set")
set_id = 0 set_id = 0
for scheduling_set in scheduling_sets: for scheduling_set in scheduling_sets:
if scheduling_set['project_id'] == args.project and scheduling_set['name'] == "%s_sched_set" % (args.project): if scheduling_set['project_id'] == config["project"] and scheduling_set['name'] == "%s_sched_set" % (config["project"]):
set_id = scheduling_set['id'] set_id = scheduling_set['id']
break break
if set_id == 0: # so, we need to create the new scheduling set for this project if set_id == 0: # so, we need to create the new scheduling set for this project
set_spec = { set_spec = {
"name": "%s_sched_set" % (args.project), "name": "%s_sched_set" % (config["project"]),
"project": "https://tmss.lofar.eu/api/project/%s" % (args.project), "project": "https://tmss.lofar.eu/api/project/%s" % (config["project"]),
"project_id": args.project, "project_id": config["project"],
"description": "scheduling set used by BF scheduler", "description": "scheduling set used by BF scheduler",
"scheduling_unit_drafts": [] "scheduling_unit_drafts": []
} }
...@@ -260,32 +292,32 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -260,32 +292,32 @@ the coordinates, or use --pointing option", action="store_true")
received_set = client.do_request_and_get_result_as_json_object(method="POST", full_url=url, json_data=set_spec) received_set = client.do_request_and_get_result_as_json_object(method="POST", full_url=url, json_data=set_spec)
set_id = received_set['id'] set_id = received_set['id']
if args.specfile != "": if "specfile" in config and config["specfile"] != "":
try: try:
with open(args.specfile) as fd: with open(config["specfile"]) as fd:
spec_doc = json.load(fd) spec_doc = json.load(fd)
if args.verbose: if args.verbose:
pprint(spec_doc) pprint(spec_doc)
except Exception as err: except Exception as err:
print (f"Error reading the spec JSON file: {args.specfile}: {err}") print (f"Error reading the spec JSON file: {config["specfile"]}: {err}")
sys.exit(1) sys.exit(1)
else: # will be using strategy to create SU else: # will be using strategy to create SU
if args.strategy == "" and args.strategy_id != 0: if ("strategy" not in config or config["strategy"] == "") and ("strategy_id" in config and config["strategy_id"] != 0):
# will get the strategy name by its ID number # will get the strategy name by its ID number
strategy_templates = client.get_scheduling_unit_observing_strategy_templates() strategy_templates = client.get_scheduling_unit_observing_strategy_templates()
for tt in strategy_templates: for tt in strategy_templates:
if tt['id'] == args.strategy_id: if tt['id'] == config["strategy_id"]:
args.strategy = tt['name'] config["strategy"] = tt['name']
args.strategy_version = tt['version'] config["strategy_version"] = tt['version']
break break
if args.strategy != "": if ("strategy" in config and config["strategy"] != ""):
try: try:
# get the latest strategy template # get the latest strategy template
if args.strategy_version == 0: if "strategy_version" not in config or config["strategy_version"] == 0:
strategy_template = client.get_scheduling_unit_observing_strategy_template(args.strategy) strategy_template = client.get_scheduling_unit_observing_strategy_template(config["strategy"])
else: else:
strategy_template = client.get_scheduling_unit_observing_strategy_template(args.strategy, args.strategy_version) strategy_template = client.get_scheduling_unit_observing_strategy_template(config["strategy"], config["strategy_version"])
print (f"Using strategy='{strategy_template['name']}', version={strategy_template['version']}, template={strategy_template['url']}") print (f"Using strategy='{strategy_template['name']}', version={strategy_template['version']}, template={strategy_template['url']}")
# get the specifications document # get the specifications document
original_spec_doc = client.get_scheduling_unit_observing_strategy_template_specification_with_just_the_parameters(strategy_template['name'], strategy_template['version']) original_spec_doc = client.get_scheduling_unit_observing_strategy_template_specification_with_just_the_parameters(strategy_template['name'], strategy_template['version'])
...@@ -300,7 +332,7 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -300,7 +332,7 @@ the coordinates, or use --pointing option", action="store_true")
if args.verbose: if args.verbose:
pprint(spec_doc) pprint(spec_doc)
except Exception as err: except Exception as err:
print (f"Error reading the observing strategy template '{args.strategy}': {err}") print (f"Error reading the observing strategy template '{config["strategy"]}': {err}")
sys.exit(1) sys.exit(1)
else: else:
print ("Error: you should not be able to get to this point. Weird...") print ("Error: you should not be able to get to this point. Weird...")
...@@ -308,29 +340,29 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -308,29 +340,29 @@ the coordinates, or use --pointing option", action="store_true")
# Modifying the specs with the values from the command-line options # Modifying the specs with the values from the command-line options
print ("Modifying the specs with the values from the command-line options...") print ("Modifying the specs with the values from the command-line options...")
if args.target != "" or args.pointing != "": #
if "target" in config or ("pointing" in config and config["pointing"] != ""):
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['SAPs'][0]['digital_pointing'] = pointing spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['SAPs'][0]['digital_pointing'] = pointing
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['tile_beam'] = pointing spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['tile_beam'] = pointing
spec_doc['tasks']['Observation']['short_description'] = args.target spec_doc['tasks']['Observation']['short_description'] = config["target"]
if "Pipeline" in spec_doc['tasks']: if "Pipeline" in spec_doc['tasks']:
descr_suffix = spec_doc['tasks']['Pipeline']['short_description'].split("/", 1)[-1] descr_suffix = spec_doc['tasks']['Pipeline']['short_description'].split("/", 1)[-1]
spec_doc['tasks']['Pipeline']['short_description'] = f"{args.target}/{descr_suffix}" spec_doc['tasks']['Pipeline']['short_description'] = f"{config["target"]}/{descr_suffix}"
if args.antennafield != "":
if "Observation" in spec_doc['tasks']: if "antennafield" in config and config["antennafield"] != "":
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['antenna_set'] = args.antennafield
else:
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
if "antenna_set" in spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']: spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['antenna_set'] = config["antennafield"]
args.antennafield = spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['antenna_set']
if args.filter != "": if "filter" in config and config["filter"] != "":
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['filter'] = args.filter spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['filter'] = config["filter"]
if args.length > 0:
if "length" in config and config["length"] > 0:
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
spec_doc['tasks']['Observation']['specifications_doc']['duration'] = args.length spec_doc['tasks']['Observation']['specifications_doc']['duration'] = config["length"]
if args.subband != "": if "subband" in config and config["subband"] != "":
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['SAPs'][0]['subbands'] = subband_list spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['SAPs'][0]['subbands'] = subband_list
n_bf_pipelines = len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines']) n_bf_pipelines = len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'])
...@@ -342,32 +374,115 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -342,32 +374,115 @@ the coordinates, or use --pointing option", action="store_true")
if len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['incoherent']['SAPs']) > 0: if len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['incoherent']['SAPs'][0]['subbands']['list'] = subband_list spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['incoherent']['SAPs'][0]['subbands']['list'] = subband_list
if args.tstart != "": if "stationlist" in config and config["stationlist"] != "":
if "time" in spec_doc['scheduling_constraints_doc']:
spec_doc['scheduling_constraints_doc']['time']['at'] = f'{tstart}'
else:
spec_doc['scheduling_constraints_doc']['time'] = { "at": f'{tstart}' }
spec_doc['scheduling_constraints_doc']['scheduler'] = 'fixed_time'
if args.stationlist != "":
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['station_groups'] = station_groups spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['station_groups'] = station_groups
n_bf_pipelines = len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines']) n_bf_pipelines = len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'])
for ii in range(n_bf_pipelines): for ii in range(n_bf_pipelines):
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['station_groups'] = station_groups spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][ii]['station_groups'] = station_groups
else:
if "Observation" in spec_doc['tasks']:
stationlist = spec_doc['tasks']['Observation']['specifications_doc']['station_configuration']['station_groups'][0]['stations']
if args.mode != "": # Mode - Stokes I / IQUV or XXYY
if "mode" in config and config["mode"] != "":
if "Observation" in spec_doc['tasks']:
# Fly's Eye
if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"enabled" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye'] and \
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['enabled'] == True:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings']['stokes'] = config["mode"]
# Coherent
if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings']['stokes'] = config["mode"]
# Incoherent
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings']['stokes'] = config["mode"]
# Quantisation
if "quantisation" in config:
if "Observation" in spec_doc['tasks']:
# Fly's Eye
if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"enabled" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye'] and \
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['enabled'] == True:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings']['quantisation'] = quantisation
# Coherent
if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings']['quantisation'] = quantisation
# Incoherent
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings']['quantisation'] = quantisation
# Subbands per file
if "subbands_per_file" in config:
if "Observation" in spec_doc['tasks']:
# Fly's Eye
if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"enabled" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye'] and \
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['enabled'] == True:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings']['subbands_per_file'] = config["subbands_per_file"]
# Coherent
if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings']['subbands_per_file'] = config["subbands_per_file"]
# Incoherent
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings']['subbands_per_file'] = config["subbands_per_file"]
# Channels per subband
if "channels_per_subband" in config:
if "Observation" in spec_doc['tasks']: if "Observation" in spec_doc['tasks']:
mode = {"stokes": args.mode, "quantisation": { "bits": 8, "enabled": args.quantisation, "scale_max": 5, "scale_min": -5 }, "subbands_per_file": args.subbands_per_file, "channels_per_subband": args.channels_per_subband, "time_integration_factor": args.downsample } # Fly's Eye
if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]: if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings'] = mode "enabled" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye'] and \
if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]: spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['enabled'] == True:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings'] = mode spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings']['channels_per_subband'] = config["channels_per_subband"]
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]: # Coherent
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings'] = mode if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings']['channels_per_subband'] = config["channels_per_subband"]
# Incoherent
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings']['channels_per_subband'] = config["channels_per_subband"]
# Time integration factor
if "downsample" in config:
if "Observation" in spec_doc['tasks']:
# Fly's Eye
if "flys eye" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"enabled" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye'] and \
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['enabled'] == True:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['flys eye']['settings']['time_integration_factor'] = config["downsample"]
# Coherent
if "coherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['coherent']['settings']['time_integration_factor'] = config["downsample"]
# Incoherent
if "incoherent" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0] and \
"SAPs" in spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent'] and \
len(spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['SAPs']) > 0:
spec_doc['tasks']['Observation']['specifications_doc']['beamformer']['pipelines'][0]['incoherent']['settings']['time_integration_factor'] = config["downsample"]
# Start time
if "tstart" in config and config["tstart"] != "":
if "time" in spec_doc['scheduling_constraints_doc']:
spec_doc['scheduling_constraints_doc']['time']['at'] = f'{tstart}'
else:
spec_doc['scheduling_constraints_doc']['time'] = { "at": f'{tstart}' }
spec_doc['scheduling_constraints_doc']['scheduler'] = 'fixed_time'
# printing out the the updated specs again # printing out the the updated specs again
if args.verbose: if args.verbose:
...@@ -379,10 +494,10 @@ the coordinates, or use --pointing option", action="store_true") ...@@ -379,10 +494,10 @@ the coordinates, or use --pointing option", action="store_true")
sys.exit(0) sys.exit(0)
# Create scheduling unit from JSON specs file # Create scheduling unit from JSON specs file
if args.specfile != "": if "specfile" in config and config["specfile"] != "":
scheduling_unit_draft = client.create_scheduling_unit_draft_from_specifications_doc(args.name, args.descr, set_id, spec_doc) scheduling_unit_draft = client.create_scheduling_unit_draft_from_specifications_doc(args.name, args.descr, set_id, spec_doc)
else: else:
if args.strategy != "": if "strategy" in config and config["strategy"] != "":
# Create scheduling unit from strategy # Create scheduling unit from strategy
scheduling_unit_draft = client.create_scheduling_unit_draft_from_strategy_template(strategy_template['id'], set_id, spec_doc, args.name, args.descr) scheduling_unit_draft = client.create_scheduling_unit_draft_from_strategy_template(strategy_template['id'], set_id, spec_doc, args.name, args.descr)
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment