Commit debfa294 authored by Sander ter Veen's avatar Sander ter Veen

Add validation for calibration parameters

parent 91e1d69b
...@@ -130,7 +130,7 @@ def calculate_pipe_time(obs_t, cal_t, n_cal, n_sb, n_beams, array_mode, ateam_na ...@@ -130,7 +130,7 @@ def calculate_pipe_time(obs_t, cal_t, n_cal, n_sb, n_beams, array_mode, ateam_na
proc_time /= 3600. proc_time /= 3600.
return proc_time return proc_time
def validate_inputs(obs_t, n_core, n_remote, n_int, n_sb, integ_t, t_avg, def validate_inputs(obs_t, cal_t, n_cal, n_core, n_remote, n_int, n_sb, integ_t, t_avg,
f_avg, src_name, coord, hba_mode, pipe_type, ateam_names): f_avg, src_name, coord, hba_mode, pipe_type, ateam_names):
"""Valid text input supplied by the user: observation time, number of """Valid text input supplied by the user: observation time, number of
subbands, and integration time. Following checks will be performed: subbands, and integration time. Following checks will be performed:
...@@ -150,13 +150,29 @@ def validate_inputs(obs_t, n_core, n_remote, n_int, n_sb, integ_t, t_avg, ...@@ -150,13 +150,29 @@ def validate_inputs(obs_t, n_core, n_remote, n_int, n_sb, integ_t, t_avg,
Return state=True/False accompanied by an error msg Return state=True/False accompanied by an error msg
Note: all input parameters are still strings.""" Note: all input parameters are still strings."""
msg = '' msg = ''
# Validate the length of the observing time # Validate the length of the observing times
try: try:
float(obs_t) float(obs_t)
if float(obs_t) <= 0: if float(obs_t) < 0:
msg += 'Observation time cannot be zero or negative.\n' msg += 'Observation time cannot be negative.\n'
except ValueError: except ValueError:
msg += 'Invalid observation time specified.\n' msg += 'Invalid observation time specified.\n'
try:
float(cal_t)
if float(cal_t) < 0:
msg += 'Calibrator duration cannot be negative.\n'
except ValueError:
msg += 'Invalid calibrator duration specified.\n'
try:
float(cal_t)+float(obs_t)
if float(cal_t)+float(obs_t) <= 0:
msg += 'One of Observation time and Calibration duration must be at least one.\n'
except ValueError:
msg += 'Invalid calibrator duration or observation time specified.\n'
# Validate the number of calibrators
if n_cal < 0:
msg += 'Number of calibrators cannot be negative.\n'
# Validate the number of stations # Validate the number of stations
if n_core < 0 or n_core > 24: if n_core < 0 or n_core > 24:
msg += 'Number of core stations must be between 0 and 24.\n' msg += 'Number of core stations must be between 0 and 24.\n'
......
...@@ -446,7 +446,7 @@ def on_calculate_click(n, n_clicks, obs_t, cal_t, n_cal, n_core, n_remote, n_int ...@@ -446,7 +446,7 @@ def on_calculate_click(n, n_clicks, obs_t, cal_t, n_cal, n_core, n_remote, n_int
n_remote = '0' n_remote = '0'
if n_int is None: if n_int is None:
n_int = '0' n_int = '0'
status, msg = bk.validate_inputs(obs_t, int(n_core), int(n_remote), \ status, msg = bk.validate_inputs(obs_t, cal_t, int(n_cal), int(n_core), int(n_remote), \
int(n_int), n_sb, integ_t, t_avg, f_avg, \ int(n_int), n_sb, integ_t, t_avg, f_avg, \
src_name, coord, hba_mode, pipe_type, \ src_name, coord, hba_mode, pipe_type, \
ateam_names) ateam_names)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment