Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
L
LOFAR-calculator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Astronomy and Operations
SDC Operations
LOFAR-calculator
Commits
debfa294
Commit
debfa294
authored
Sep 18, 2020
by
Sander ter Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation for calibration parameters
parent
91e1d69b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
backend.py
backend.py
+20
-4
calculator.py
calculator.py
+1
-1
No files found.
backend.py
View file @
debfa294
...
...
@@ -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.
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
):
"""Valid text input supplied by the user: observation time, number of
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,
Return state=True/False accompanied by an error msg
Note: all input parameters are still strings."""
msg
=
''
# Validate the length of the observing time
# Validate the length of the observing time
s
try
:
float
(
obs_t
)
if
float
(
obs_t
)
<
=
0
:
msg
+=
'Observation time cannot be
zero or
negative.
\n
'
if
float
(
obs_t
)
<
0
:
msg
+=
'Observation time cannot be negative.
\n
'
except
ValueError
:
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
if
n_core
<
0
or
n_core
>
24
:
msg
+=
'Number of core stations must be between 0 and 24.
\n
'
...
...
calculator.py
View file @
debfa294
...
...
@@ -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'
if
n_int
is
None
:
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
,
\
src_name
,
coord
,
hba_mode
,
pipe_type
,
\
ateam_names
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment