Browse Source

Fix bug and working (still to improve) version

pull/1/head
Benito Marcote 9 months ago
parent
commit
cb84638d66
  1. 11
      app.py
  2. 3
      vlbiplanobs/graphical_elements.py
  3. 37
      vlbiplanobs/observation.py

11
app.py

@ -282,7 +282,7 @@ def update_pickband_tooltip(a_wavelength):
html.Span(html.Small(f"Can be observed with the {arrays_with_band(default_arrays, a_band)}."),
style={'color': '#888888'})
], className="card-text"),
]), className="col-sm-3 my-2 shadow-1-strong border border-primary")
]), className="col-sm-3 my-2 shadow-1-strong")
]
@ -446,11 +446,12 @@ def initial_page():
def choice_for_setup(do_wizard, do_expert):
if (do_expert is not None) or (do_wizard is not None):
return [
html.Div(id='main-window', hidden=do_expert is None,
children=main_page(show_compute_button=do_expert is not None)),
# order inverted to improve loading times
html.Div(id='main-window2', hidden=do_expert is not None,
children=[dbc.Checklist(id='is_line', options=[{'label': 'line obs', 'value': False}],
value=[])] if do_expert is not None else choice_page('band'))
value=[])] if do_expert is not None else choice_page('band')),
html.Div(id='main-window', hidden=do_expert is None,
children=main_page(show_compute_button=do_expert is not None))
]
else:
return dash.no_update
@ -699,7 +700,7 @@ def main_page(results_visible=False, summary_output=None, fig_elev_output=None,
"summary of the planned observation and expected outcome in the different "
"tabs."]),
html.P(html.Em(["Note that only antennas that can observe at the selected band "
"will be clickable."]))
"will be clickable."], className='form-text text-warning'))
], style={'margin-top': '2rem', 'margin-bottom': '2rem'}),
html.Div(className='col-9 form-group row align-items-end', children=[
html.Div(className='col-md-6', children=[

3
vlbiplanobs/graphical_elements.py

@ -184,6 +184,7 @@ def summary_card_beam(app, obs):
"on the weighting used during imaging (null weighting assumed here).")]
return create_sensitivity_card('Resolution', temp_msg)
def summary_card_times(app, obs):
"""Creates a summary card showing the observing times, and the resulting data size.
"""
@ -434,7 +435,7 @@ def initial_window_pick_band():
marks={i: fq for i,fq in enumerate(fs.bands)},
persistence=True, # tooltip={'always_visible': True, 'placement': 'top'},
updatemode='drag', included=False)), html.Br(), #html.Br(),
html.Div(id='initial-pickband-label', className='row justify-content-center', children='Hello'),
html.Div(id='initial-pickband-label', className='row justify-content-center', children=''),
html.Br(),
html.Div(className='row text-center',
children=html.Button('Continue', id='button-pickband',

37
vlbiplanobs/observation.py

@ -548,17 +548,20 @@ class Observation(object):
indexes = 0 if n_onsource[0] >= 3 else 1
# Special case: first element
if indexes == 0:
n_max = [-1, 0, np.max([n_onsource[vis_ranges[-1]:].max(), n_onsource[:vis_ranges[0]].max()])]
for i in range(1-indexes, len(vis_ranges)-1, 2):
print(vis_ranges)
print(n_onsource)
if n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max() > n_max[2]:
n_max = [i-1+indexes, i+indexes, n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max()]
elif (n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max() == n_max[2]) and \
(vis_ranges[i+indexes]-vis_ranges[i-1+indexes] > n_max[1]-n_max[0]):
n_max = [i-1+indexes, i+indexes, n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max()]
try:
if indexes == 0:
n_max = [-1, 0, np.max([n_onsource[vis_ranges[-1]:].max(), n_onsource[:vis_ranges[0]].max()])]
for i in range(1-indexes, len(vis_ranges)-1, 2):
if n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max() > n_max[2]:
n_max = [i-1+indexes, i+indexes, \
n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max()]
elif (n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max() == n_max[2]) and \
(vis_ranges[i+indexes]-vis_ranges[i-1+indexes] > n_max[1]-n_max[0]):
n_max = [i-1+indexes, i+indexes, \
n_onsource[vis_ranges[i-1+indexes]:vis_ranges[i+indexes]+1].max()]
except IndexError: # because vis_ranges is an empty list. Got it in the following
pass
if None in (n_max[0], n_max[1]):
# Either the source is visible all the time or never
@ -851,14 +854,16 @@ class Observation(object):
# i += uvdata[bl_name].shape[0]
def print_obs_times(self, date_format='%d %b %Y'):
def print_obs_times(self, date_format='%d %B %Y'):
"""Returns the time range (starttime-to-endtime) of the observation in a smart way.
If the observation lasts for less than one day it omits the end date:
20 January 1971 10:00-20:00 UTC
20 January 1971
10:00-20:00 UTC
GST range: 05:00-15:00
If the observation ends the day after, then it returns:
20 January 1971 10:00-20:00 UTC (+1d)
20 January 1971
10:00-20:00 UTC (+1d)
GST range: 05:00-15:00
If the observation is longer, then it returns
@ -878,11 +883,11 @@ class Observation(object):
(self.gstimes[-1].hour*60) // 60,
(self.gstimes[0].hour*60) % 60)
if self.times[0].datetime.date() == self.times[-1].datetime.date():
return "{} {}-{} UTC\nGST range: {}".format(self.times[0].datetime.strftime(date_format),
return "{}\n{}-{} UTC\nGST range: {}".format(self.times[0].datetime.strftime(date_format),
self.times[0].datetime.strftime('%H:%M'),
self.times[-1].datetime.strftime('%H:%M'), gsttext)
elif (self.times[-1] - self.times[0]) < 24*u.h:
return "{} {}-{} UTC (+1d)\nGST range: {}".format(
return "{}\n{}-{} UTC (+1d)\nGST range: {}".format(
self.times[0].datetime.strftime(date_format),
self.times[0].datetime.strftime('%H:%M'),
self.times[-1].datetime.strftime('%H:%M'), gsttext)

Loading…
Cancel
Save