Browse Source

Verifies inserted data before continue in Wizard

pull/1/head
Benito Marcote 9 months ago
parent
commit
e5c28a896b
  1. 65
      app.py
  2. 4
      vlbiplanobs/graphical_elements.py

65
app.py

@ -381,6 +381,47 @@ def line_cont_setup(is_line_exp):
return 8, 32, 4, 2
@app.callback(Output('button-picknetwork', 'disabled'),
[Input(f'network-{network.lower()}', 'value') for network in vlbi_networks_names])
def continue_from_networks(*networks):
"""Verifies that the user has selected at least one VLBI network during the wizard screen
"""
for n in networks:
if True in n:
return False
return True
# len([True for n in networks if True in n]) > 0 % Slower
@app.callback(Output('button-picktimes', 'disabled'),
[Input('initial-timeselection', 'value'),
Input('initial-starttime', 'date'),
Input('initial-starthour', 'value'),
Input('initial-duration', 'value'),
Input('initial-source', 'value')])
def continue_from_times(time_selection, time_date, time_hour, time_duration, source):
"""Verifies that the user has selected and introduced the required data before continue.
"""
if source is None:
return True
if not verify_recognized_source(source):
return True
if time_selection:
if (time_date is not None) and (time_hour is not None) and (time_duration is not None):
try:
dummy = float(time_duration)
return dummy <= 0
except:
return True
else:
return True
return False
@app.callback(Output('main-window2', 'children'),
Output('is_line', 'value'),
@ -964,6 +1005,30 @@ def get_initial_source(source_coord):
return '', dash.no_update
def verify_recognized_source(a_source):
"""Equivalent to the previous function, but returns a bool for when a source name/coordinates
have been introduced correctly or not.
"""
if a_source is None:
return False
if len(a_source) > 30:
return False
try:
dummy_target = observation.Source(convert_colon_coord(a_source), 'Source')
return True
except ValueError as e:
try:
dummy_target = coord.get_icrs_coordinates(a_source)
return True
except coord.name_resolve.NameResolveError as e:
return False
return False
@app.callback([Output('error_source', 'children'),
Output('error_source', 'className')],
[Input('source', 'value')])

4
vlbiplanobs/graphical_elements.py

@ -491,7 +491,7 @@ def initial_window_pick_network(app, vlbi_networks):
html.Br(),
html.Div(className='row justify-content-center',
children=html.Button('Continue', id='button-picknetwork',
className='btn btn-primary btn-lg')),
disabled=True, className='btn btn-primary btn-lg')),
# html.Div(hidden=True, children=[
# dcc.Dropdown(id='initial-array', options=[{'label': n, 'value': n} \
# for n in vlbi_networks if n != 'e-EVN'], value=[],
@ -633,7 +633,7 @@ def initial_window_final():
"You will also be able to change the setup and re-compute it."]),
html.Br(),
]),
html.Span(style={'height': '5rem'}),
html.Div(style={'height': '7rem'}),
html.Div(className='row justify-content-center',
children=html.Button('Compute', id='antenna-selection-button',
className='btn btn-primary btn-lg')),

Loading…
Cancel
Save