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

now several start times can be specified, either as a comma-separated string...

now several start times can be specified, either as a comma-separated string in --tstart option or in config file also as comma-separated string, or list of strings
parent bb55000f
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ the coordinates, or use --pointing option", action="store_true")
default=0, type=int)
parser.add_argument("--quantisation" , help="Enable quantisation to 8 bits for the raw data [default - False (without this option)]",
action="store_true")
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]",
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 (incremental index will be added in front of the name if several start times are given). The \"now\" string can not be combined with other start times [str[,str,[str]]]",
default="", type=str)
parser.add_argument("--length", help="Observation length (s) [int]",
default=0, type=int)
......@@ -252,15 +252,28 @@ the coordinates, or use --pointing option", action="store_true")
config["downsample"] = 16
# Start time
if args.tstart != "": config["tstart"] = args.tstart
if "tstart" in config and config["tstart"] != "":
if config["tstart"] == "now":
start_times = []
if "tstart" in config and args.tstart == "":
if type(config["tstart"]) is list:
args.tstart = ",".join(config["tstart"])
else:
args.tstart = config["tstart"]
if args.tstart != "":
if "now" in args.tstart:
# Round to start of minute
tstart = datetime.now(timezone.utc) + timedelta(seconds=args.delay)
tstart = tstart.strftime("%Y-%m-%dT%H:%M:00")
start_times.append(tstart)
else:
tstart = datetime.strptime(config["tstart"], "%Y-%m-%dT%H:%M:%S")
if "," in args.tstart:
parts = [part for part in args.tstart.split(",")]
for part in parts:
tstart = datetime.strptime(part, "%Y-%m-%dT%H:%M:%S")
tstart = tstart.strftime("%Y-%m-%dT%H:%M:%S")
start_times.append(tstart)
else:
tstart = datetime.strptime(args.tstart, "%Y-%m-%dT%H:%M:%S")
start_times.append(tstart.strftime("%Y-%m-%dT%H:%M:%S"))
if args.length > 0: config["length"] = args.length
# Station groups for Fly's Eye observations
......@@ -510,7 +523,7 @@ the coordinates, or use --pointing option", action="store_true")
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"] != "":
for (ii, tstart) in zip(list(range(1, 1+len(start_times))), start_times):
if "time" in spec_doc['scheduling_constraints_doc']:
spec_doc['scheduling_constraints_doc']['time']['at'] = f'{tstart}'
else:
......@@ -524,15 +537,20 @@ the coordinates, or use --pointing option", action="store_true")
# Skip if not uploaded
if not args.upload:
print("No scheduling units uploaded to TMSS\n")
sys.exit(0)
else:
# Create scheduling unit from JSON specs file
if len(start_times) > 1:
suname = f"{ii}. {args.name}"
else:
suname = args.name
print (f"{suname} | {args.descr}")
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(suname, args.descr, set_id, spec_doc)
else:
if "strategy" in config and config["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, suname, args.descr)
else:
print ("Error: you should not be able to get to this point. (double) weird...")
sys.exit(1)
......@@ -541,8 +559,7 @@ the coordinates, or use --pointing option", action="store_true")
# Skip if not blueprinted
if not args.blueprint:
print("No scheduling units blueprinted\n")
sys.exit(0)
else:
# Blueprint SU
scheduling_unit_blueprint = client.create_scheduling_unit_blueprint_and_tasks_and_subtasks_tree(scheduling_unit_draft['id'])
print(f"Created SU blueprint {scheduling_unit_blueprint['id']} for {scheduling_unit_blueprint['name']} at {scheduling_unit_blueprint['url']}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment