EVN Observation Planner. Helps you to plan a VLBI observation. Given a date, source coordinates, and a VLBI array, it will tell you when the source can be observed by each antenna, the reached rms noise level and resolution, among other details.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1107 lines
60 KiB

#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""EVN Observation Planner.
Program to compute the source elevation visibility
and expected thermal noise level for a given EVN observation.
__author__ = "Benito Marcote"
__credits__ = "Benito Marcote"
__license__ = "LGPLv3+"
__date__ = "2020/10/26"
__version__ = "1.0.1"
__maintainer__ = "Benito Marcote"
__email__ = "marcote@jive.eu"
__status__ = "Production" # Prototype, Development, Production.
import os
from os import path
from time import sleep
import itertools
from importlib import resources
from datetime import datetime as dt
import numpy as np
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import plotly.graph_objs as go
from astropy.time import Time
from astropy import coordinates as coord
from astropy import units as u
# Tweak to not let astroplan crashing...
# from astropy.utils.data import clear_download_cache
# from astropy.utils import iers
# clear_download_cache() # to be sure it is really working
# iers.conf.auto_download = False
# iers.conf.iers_auto_url = None
# iers.conf.auto_max_age = None
# iers.conf.remote_timeout = 100.0
# iers.conf.download_cache_lock_attempts = 10
from astroplan import FixedTarget
current_directory = path.dirname(path.realpath(__file__))
if path.isfile(current_directory + '/.astropy/cache/download/py3/lock'):
os.remove(current_directory + '/.astropy/cache/download/py3/lock')
######### All the previous part will be removed with astropy 4.1+ and astroplan 0.7+
from vlbiplanobs import freqsetups as fs
from vlbiplanobs import stations
from vlbiplanobs import observation
from vlbiplanobs import graphical_elements as ge
# adding the possibility of disabled. Will be implemented in a future version of dash_bootstrap_components
from vlbiplanobs.Checkbox import Checkbox
all_antennas = stations.Stations.get_stations_from_configfile()
sorted_networks = {'EVN': 'EVN: European VLBI Network', 'eMERLIN': 'eMERLIN (out-stations)',
'VLBA': 'VLBA: Very Long Baseline Array',
'LBA': 'LBA: Australian Long Baseline Array',
'KVN': 'KVN: Korean VLBI Network',
'Other': 'Other antennas',
'Decom': 'Decommissioned antennas'}
default_arrays = {'EVN': ['Ef', 'Hh', 'Jb2', 'Mc', 'Nt', 'Ur', 'On', 'Sr', 'T6', 'Tr',
'Ys', 'Wb', 'Bd', 'Sv', 'Zc', 'Ir'],
'e-EVN': ['Ef', 'Hh', 'Jb2', 'Mc', 'Nt', 'On', 'T6', 'Tr', 'Ys', 'Wb',
'Bd', 'Sv', 'Zc', 'Ir', 'Sr'],
'eMERLIN': ['Cm', 'Kn', 'Pi', 'Da', 'De', 'Jb2'],
'LBA': ['ATCA', 'Pa', 'Mo', 'Ho', 'Cd', 'Td', 'Ww'],
'VLBA': ['Br', 'Fd', 'Hn', 'Kp', 'La', 'Mk', 'Nl', 'Ov', 'Pt', 'Sc'],
'KVN': ['Ky', 'Ku', 'Kt'],
'Global VLBI': ['Ef', 'Hh', 'Jb2', 'Mc', 'Nt', 'Ur', 'On', 'Sr', 'T6',
'Tr', 'Ys', 'Wb', 'Bd', 'Sv', 'Zc', 'Ir', 'Br', 'Fd', 'Hn',
'Kp', 'La', 'Mk', 'Nl', 'Ov', 'Pt', 'Sc'],
'HSA': ['Br', 'Fd', 'Hn', 'Kp', 'La', 'Mk', 'Nl', 'Ov', 'Pt', 'Sc', 'Ef', #'Ar',
'Gb', 'Y27'],
'GMVA': ['Ef', 'Mh', 'On', 'Ys', 'Pv', 'PdB', 'Br', 'Fd', 'Kp', 'La', 'Mk', 'Nl',
'Ov', 'Pt', 'Gb'],
'EHT': ['ALMA', 'Pv', 'LMT', 'PdB', 'SMA', 'JCMT', 'APEX', 'SMT', 'SPT']}
vlbi_networks_names = {'EVN': 'EVN: European VLBI Network',
'LBA': 'LBA: Australian Long Baseline Array',
'VLBA': 'VLBA: Very Long Baseline Array',
'KVN': 'KVN: Korean VLBI Network',
# 'Global VLBI': 'Global VLBI (VLBA+EVN)',
'HSA': 'HSA: High Sensitivity Array',
'GMVA': 'GMVA: Global mm-VLBI Array',
'EHT': 'EHT: Event Horizon Telescope'}
#TODO: this will be included per station (but maybe it needs to remain):
default_datarates = {'EVN': 2048, 'e-EVN': 2048, 'eMERLIN': 4096, 'LBA': 1024, 'VLBA': 4096, 'KVN': 4096,
'Global VLBI': 2048, 'HSA': 2048, 'GMVA': 4096, 'EHT': 2**15}
# Safety check that all these antennas are available in the file
for a_array in default_arrays:
for a_station in default_arrays[a_array]:
assert a_station in all_antennas.codenames
doc_files = {'About the EVN Observation Planner': 'doc-contact.md',
'About the antennas': 'doc-antennas.md',
'Technical background': 'doc-estimations.md'}
selected_band = None
obs = observation.Observation()
external_stylesheets = []
external_scripts = ["https://kit.fontawesome.com/69c65a0ab5.js"]
app = dash.Dash(__name__, title='EVN Observation Planner', external_scripts=external_scripts,
app.config.suppress_callback_exceptions = True # Avoids error messages for id's that haven't been loaded yet
server = app.server
def get_doc_text():
"""Reads the doc files and returns it as a Div object.
temp = []
for i,a_topic in enumerate(doc_files):
with resources.open_text("doc", doc_files[a_topic]) as f:
# Some files will have references to images/files in the form '{src:filename}'
# We parse this
parsed_text = f.read()
while '{src:' in parsed_text:
i0 = parsed_text.index('{src:')
i1 = i0 + parsed_text[i0:].index('}')
filename = parsed_text[i0+5:i1]
parsed_text = parsed_text.replace( parsed_text[i0:i1+1],
app.get_asset_url(filename) )
if a_topic == 'About the antennas':
temp += [ge.create_accordion_card(a_topic,
1 year ago
[dcc.Markdown(parsed_text), ge.antenna_cards(app, all_antennas)], id=str(i), is_open=False)]
temp += [ge.create_accordion_card(a_topic, dcc.Markdown(parsed_text),
1 year ago
id=str(i), is_open=False)]
return html.Div(temp, className='col-12 accordion')
@app.callback([Output(f"collapse-{i}", "is_open") for i in range(len(doc_files))],
[Input(f"group-{i}-toggle", "n_clicks") for i in range(len(doc_files))],
[State(f"collapse-{i}", "is_open") for i in range(len(doc_files))])
def toggle_accordion(*args):
"""Allows the expansion/collapse of an HTML accordion block.
defaults = list(args[len(doc_files):])
ctx = dash.callback_context
if not ctx.triggered:
return [dash.no_update]*len(doc_files)
button_id = ctx.triggered[0]["prop_id"].split(".")[0]
for i in range(len(doc_files)):
if (button_id == f"group-{i}-toggle") and (args[i] is not None):
defaults[i] = not defaults[i]
return defaults
def error_text(an_error):
"""Standard error message written in a modal error window.
It returns a str mentioning 'an_error' and the contact details to report it.
return f"An error occured.\n{an_error}.\nPlease report to marcote@jive.eu " \
"or in https://github.com/bmarcote/vlbi_calculator."
def convert_colon_coord(colon_coord):
"""Converts some coordinates given in a str format 'HH:MM:SS DD:MM:SS' to
If ':' are not present in colon_coord, then it returns the same str.
if ':' not in colon_coord:
return colon_coord
for l in ('h', 'm', 'd', 'm'):
colon_coord = colon_coord.replace(':', l, 1)
return ' '.join([f"{s}s" for s in colon_coord.split()])
def alert_message(message, title="Warning!"):
"""Produces an alert-warning message.
'message' can be either a string or a list with different string/dash components.
if type(message) == str:
return [html.Br(), \
dbc.Alert([html.H4(title, className='alert-heading'), message], \
color='warning', dismissable=True)]
return [html.Br(), \
dbc.Alert([html.H4(title, className='alert-heading'), *message], \
color='warning', dismissable=True)]
def update_sensitivity(obs):
"""Given the observation, it sets the text for all summary cards
with information about the observation.
cards = []
# The time card
cards += ge.summary_card_times(app, obs)
cards += ge.summary_card_frequency(app, obs)
cards += ge.summary_card_antennas(app, obs)
cards += ge.summary_card_beam(app, obs)
cards += ge.summary_card_rms(app, obs)
cards += ge.summary_card_fov(app, obs)
return [html.Div(className='card-deck col-12 justify-content-center', children=cards)]
def arrays_with_band(arrays, a_band):
"""Returns the arrays that can observe the given band with at least two antennas.
It excludes e-EVN if it is included in arrays.
Note that hardcoded is the detection of GMVA and EHT (only available at a given frequency).
- arrays : dict
The keys are the name of the array and the values must be a list with the codenames
of the antennas in the array.
- a_band : str
The band to be observed, following the criteria in fs.bands.
- arrays_with_band : str
Comma-separated list of the arrays that can observe the given band.
tmp = [] # the list of arrays that can observe the given band
for an_array in arrays:
if an_array != 'e-EVN':
if np.sum([all_antennas[a_station].has_band(a_band) for a_station in arrays[an_array]]) > 1:
if an_array == 'GMVA':
if a_band == '0.3cm':
elif an_array == 'EHT':
if (a_band == '0.1cm') or (a_band == '0.3cm'):
elif (an_array == 'EVN') or (an_array == 'Global VLBI'):
if float(a_band.replace('cm', '')) > 0.5:
if len(tmp) == 0:
return 'none'
elif len(tmp) == 2:
return ' and '.join(tmp)
elif len(tmp) in (1, 3):
return ', '.join(tmp)
else: # >= 4
return ', '.join(tmp[:-1]) + ' and ' + tmp[-1]
@app.callback(Output('initial-pickband-label', 'children'),
[Input('initial-band', 'value')])
def update_pickband_tooltip(a_wavelength):
a_band = tuple(fs.bands)[a_wavelength]
return [dbc.Card(dbc.CardBody([
src=app.get_asset_url(f"waves-{a_band.replace('.', '_')}.svg"),
alt='Band: ', className='d-inline-block'),
style={'float': 'right'})
], className="card-title"),
html.P([html.Span("Wavelength: ", style={'color': '#888888'}),
html.Span("Frequency: ", style={'color': '#888888'}),
f"{fs.bands[a_band].split('(')[1].split('or')[1].replace(')', '').strip()}.",
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")
@app.callback([Output('initial-timeselection-div-guess', 'hidden'),
Output('initial-timeselection-div-epoch', 'hidden')],
[Input('initial-timeselection', 'value')])
def type_time_selection(time_selection_selected):
"""Modifies the hidden message related to the two options about how to pick the observing time.
return [time_selection_selected, not time_selection_selected]
@app.callback(Output('main-window', 'children'),
[Input('button-initial-wizard', 'n_clicks'),
Input('button-initial-expert', 'n_clicks'),
Input('button-pickband', 'n_clicks'),
Input('button-picknetwork', 'n_clicks'),
Input('button-picktimes', 'n_clicks'),
Input('button-mode-continuum', 'n_clicks'),
Input('button-mode-line', 'n_clicks')],
[State('initial-band', 'value'),
State('initial-array', 'value'),
State('initial-timeselection', 'value'), # True if date are provided, False if guessing
State('starttime', 'date'),
State('starthour', 'value'),
State('duration', 'value')
def skip_intro_choices(clicks_wizard, clicks_expert, clicks_pickband, clicks_picknetwork, clicks_picktimes,
clicks_continuum, clicks_line,
a_wavelength, a_array, time_selection, starttime, starthour, obs_duration):
if clicks_expert is not None:
return main_page(None)
elif clicks_wizard is not None:
return initial_page('band')
elif clicks_pickband is not None:
return initial_page('network')
elif clicks_picknetwork is not None:
return initial_page('time')
elif clicks_picktimes is not None:
#TODO: if dates are provided, all date/time/dur must be provided
return initial_page('mode')
elif clicks_continuum is not None:
return compute_observation(n_clicks, band, starttime, starthour, duration, source, onsourcetime,
datarate, subbands, channels, pols, inttime, guest_time, selected_tab, *ants)
elif clicks_line is not None:
return dash.no_update
return dash.no_update
def initial_page(choice_card):
"""Initial window with the introduction to the EVN Observation Planner and the band selection.
return [
html.Div(className='row justify-content-center',
children=html.Div(className='col-sm-6 justify-content-center',
html.P(["The EVN Observation Planner allows you to plan observations with the ",
html.A(href="https://www.evlbi.org", children="European VLBI Network"),
" (EVN) and other Very Long Baseline Interferometry (VLBI) networks. "
"The EVN Observation Planner helps you to determine when your source "
"can be observed by the different antennas, and provides the expected "
"outcome of these observations, like the expected sensitivity or resolution."]),
html.Div(hidden=False if choice_card == 'choice' else True,
html.Div(hidden=False if choice_card == 'band' else True,
html.Div(hidden=False if choice_card == 'network' else True,
html.Div(hidden=False if choice_card == 'time' else True,
html.Div(hidden=False if choice_card == 'mode' else True,
], style={'text:align': 'justify !important'})
)] #, *main_page(None, True)]
def main_page(a_wavelength):
a_band = tuple(fs.bands)[a_wavelength] if a_wavelength is not None else None
return [
# First row containing all buttons/options, list of telescopes, and button with text output
dcc.ConfirmDialog(id='global-error', message=''),
# Elements in second column (checkboxes with all stations)
html.Div(className='container-fluid', children=[
html.Div(className='row justify-content-center', children=[
html.Div(className='col-sm-3', style={'max-width': '350px','float': 'left',
1 year ago
'min-width': '17rem'}, children=[
html.Div(className='form-group', children=[
html.Div('', style={'height': '70px'}),
dcc.Loading(id="loading2", children=[html.Div(id="loading-output2")],
1 year ago
html.Div(id='div-antenna-selection-button2', children=[]),
html.Label('Your observing Band'),
message="This will update the "
"antenna list showing the ones that can observe "
"at that given frequency."),
dcc.Dropdown(id='band', persistence=True, value=a_band,
options=[{'label': fs.bands[b], 'value': b} for b \
# in fs.bands], value='18cm'),
in fs.bands], placeholder='Select observing band...')
html.Div(className='input-group-prepend', children=[
dbc.Checklist(id='e-EVN', className='checkbox', persistence=True,
options=[{'label': ' e-EVN (real-time) mode',
'value': 'e-EVN'}], value=[]),
message="Only available for the EVN: real-time correlation mode.")
html.Div(className='form-group', children=[
html.Label('Source (name or coordinates)'),
message="Source name or coordinates. " \
"You may see an error if the given name is not properly resolved. "
"J2000 coordinates are assumed in both forms: 00:00:00 00:00:00 or " \
"00h00m00s 00d00m00s."),
# dcc.Input(id='source', value='12:29:06.7 +02:03:08.6', type='text',
dcc.Input(id='source', value=None, type='text',
className='form-control', placeholder="hh:mm:ss dd:mm:ss",
html.Small(id='error_source', style={'color': '#999999'},
dbc.Tab(label='Pick Epoch', id='tab-pick-epoch', tabClassName='tab-for-card', children=[
html.Div(className='form-group', children=[
dbc.Card(className='card-no-left-border', children=dbc.CardBody([
html.Label('Start of observation (UTC)'),
*ge.tooltip(idname='popover-startime', message="Select the date and "
"time of the start of the observation (Universal, UTC, "
"time). You will also see the day of the year (DOY) in "
"brackets once the date is selected."),
dcc.DatePickerSingle(id='starttime', date=None, min_date_allowed=dt(1900, 1, 1),
max_date_allowed=dt(2100, 1, 1),
display_format='DD-MM-YYYY (DDD)',
placeholder='Start date',
dcc.Dropdown(id='starthour', placeholder="Start time", value=None,
options=[{'label': f"{hm//60:02n}:{hm % 60:02n}", \
'value': f"{hm//60:02n}:{hm % 60:02n}"} \
for hm in range(0, 24*60, 15)],
persistence=True, className='form-hour'),
html.Small(id='error_starttime', style={'color': 'red'},
className='form-text text-muted'),
html.Div(className='form-group', children=[
html.Label('Duration of the observation (hours)'),
*ge.tooltip(idname='popover-duration', message="Select the total duration of the "
"observation (provided in hours)."),
dcc.Input(id='duration', value=None, type='number', className='form-control',
placeholder="In hours", persistence=True, inputMode='numeric'),
html.Small(id='error_duration', style={'color': 'red'}, className='form-text text-muted')
dbc.Tab(label='Guess Times', id='tab-guess-times', tabClassName='tab-for-card', children=[
html.Div(className='form-group', children=[
dbc.Card(className='card-no-left-border', children=dbc.CardBody([
html.P("Choose this option if you just want to find out when your source "
"will be visible. It will pick the time range when more than 3 antennas "
"can observe."),
dbc.Checklist(id='guest-times', className='checkbox', persistence=True,
options=[{'label': " I don't have preferred times",
'value': 'guest-times'}], value=[]),
html.Small("Note that this option may not provide the wished results if "
"different networks far apart (e.g. LBA + EVN) are selected.",
style={'color': '#999999'})
html.Div(className='form-group', children=[
children='% of on-target time'),
message="Assumes that you will only spend this amount of the total " \
"observing time on the given target source. It affects the " \
"expected sensitivity."),
dcc.Slider(id='onsourcetime', min=20, max=100, step=5, value=70,
marks= {i: str(i) for i in range(20, 101, 10)},
html.H4("Advanced setup"),
html.Div(className='form-group', children=[
html.Label('Datarate per station'),
message=["Expected datarate for each station, assuming all " \
"of them run at the same rate.",
html.Li("The EVN can run typically at up to 2 Gbps (1 Gbps at L band), " \
"although a few antennas may observe at lower datarates."),
html.Li("The VLBA can now observe up to 4 Gbps."),
html.Li("The LBA typically runs at 512 Mbps but can reach up to 1 Gbps."),
html.Li("Check the documentation from other networks to be " \
"sure about their capabilities.")])]),
placeholder="Select the data rate...",
options=[{'label': fs.data_rates[dr], 'value': dr} \
for dr in fs.data_rates], value=2048, persistence=True),
html.Div(className='form-group', children=[
html.Label('Number of subbands'),
message="Number of subbands to split the total observed bandwidth "
" during correlation (IFs in AIPS)."),
dcc.Dropdown(id='subbands', placeholder="Select no. subbands...",
options=[{'label': fs.subbands[sb], 'value': sb} \
for sb in fs.subbands], value=8, persistence=True),
html.Div(className='form-group', children=[
html.Label('Number of spectral channels'),
message="How many channels per subband will be produced "
"during correlation."),
dcc.Dropdown(id='channels', placeholder="Select no. channels...",
options=[{'label': fs.channels[ch],
'value': ch} \
for ch in fs.channels], value=32, persistence=True),
html.Div(className='form-group', children=[
html.Label('Number of polarizations'),
message="Number of polarizations to correlate. Note that VLBI uses circular " \
"polarizations. Full polarization implies the four stokes: RR, LL, RL, LR; " \
"while dual polarization implies RR and LL only."),
dcc.Dropdown(id='pols', placeholder="Select polarizations...",
options=[{'label': fs.polarizations[p], 'value': p} \
for p in fs.polarizations], value=4, persistence=True),
html.Div(className='form-group', children=[
html.Label('Integration time (s)'),
message="Integration time to compute each visibility. Note that for continuum " \
"observations values of 1-2 seconds are typical."),
dcc.Dropdown(id='inttime', placeholder="Select integration time...",
options=[{'label': fs.inttimes[it], 'value': it} \
for it in fs.inttimes], value=2, persistence=True),
1 year ago
dcc.Tabs(parent_className='custom-tabs col', className='custom-tabs-container', id='tabs',
value='tab-setup', children=[
dcc.Tab(label='Observation Setup', className='custom-tab', value='tab-setup',
selected_className='custom-tab--selected', children=[
# Elements in first column ()
html.Div(className='row justify-content-center', children=[
html.Div(className='col-9', children=[
html.Div(id='first-advise', className='col-sm-9', children=[
html.P(["Here you can set up your observation.", html.Br(),
"Please select which network (or networks) you want to use in your "
"observations, or select a customized array of antennas. "
"On the left panel you can set the basic information from your observations: "
"times of the observations and target source to observe. ", html.Br(),
"Optionally, you can customize the configuration and correlation parameters "
"under 'advance setup'. Otherwise, default values based on your selection "
"will be used.", html.Br(),
"Once you are ready, press the big red ", html.B("'compute observation'"),
" button. You will get a detailed "
"summary of the planned observation and expected outcomes in the different "
html.P(["Note that only antennas that can observe at the selected band "
"will be clickable."])
], 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=[
html.Label('Select default VLBI Network(s)',
style={'color': '#a01d26'}),
*ge.tooltip(idname='popover-network', message="Automatically selects "
"the default participating antennas for the selected VLBI network(s)."),
dcc.Dropdown(id='array', options=[{'label': n, 'value': n} \
for n in default_arrays if n != 'e-EVN'], value=[],
persistence=True, multi=True),
1 year ago
html.Div(id='div-antenna-selection-button', className='col-sm-3', children=[
html.Button('Compute Observation', id='antenna-selection-button',
className='btn btn-primary btn-lg'),
html.Div(className='col-9 text-center justify-content-center', children=[
dcc.Loading(id="loading", children=[html.Div(id="loading-output")],
html.Div([dbc.Tooltip(ge.antenna_card(app, s), placement='right',
hide_arrow=True, target=f"_input_{s.codename}",
innerClassName='tooltip-card-inner') for s in all_antennas
html.Div(id='antennas-div', className='container', children=[
html.Div(className='antcheck', children=[html.Br(), html.Br(),
style={'width': '100%'}),
html.Div(className='antcheck', children=[
Checkbox(id=f"check_{s.codename}", persistence=True,
disabled=not s.has_band(selected_band)),
dbc.Label(s.name, html_for=f"check_{s.codename}",
className='custom-control-label form-check-label')
], check=True, inline=True, className="form-check-input "
"custom-checkbox custom-control custom-control-inline")
for s in all_antennas if s.network == an_array
]) for an_array in sorted_networks
html.Div(style={'height': '15rem'})
# html.Div(className='col-sm-2', style={'float': 'left'}, children=[
# ])
1 year ago
dcc.Tab(label='Summary', className='custom-tab', value='tab-summary',
selected_className='custom-tab--selected', children=[
html.Div(className='row justify-content-center', children=[
html.Div(className='col-10 justify-content-center',
children=[html.Div(className='col-md-6', children=[
html.Br(), html.Br(), html.H2("Set the observation first"),
html.P("Here you will see a summary of your observation, "
"with information about all participating stations, longest and "
"shortest baseline, expected size of the data once is correlated, "
"reached resolution and sensitivity, and the limitations in your "
"field of view due to time and frequency smearing.")])
1 year ago
dcc.Tab(label='Elevations', className='custom-tab', value='tab-elevation',
selected_className='custom-tab--selected', children=[
html.Div(className='row justify-content-center', children=[
html.Div(className='col-md-8 justify-content-center', children=[
# Elevation VS time
html.H4("When is your source visible?"),
dbc.Alert([html.H4("Info on plots", className='alert-heading'),
html.P("A single click on one station in the legend will "
"hide/show it. Double-click will hide/show "
"all other antennas. You can also save the plot "
"as png."),
], color='info', dismissable=True),
html.P("The following plot shows the source elevation for the "
"different antennas during the proposed observation. The horizontal "
"solid and dashed lines represent the elevation of 20 and 10 degrees, "
html.P("""The following plot shows when the source may be observed
for the different antennas, assuming a minimum elevation of 10 degrees
for most antennas (except e.g. Arecibo). Note that some antennas may
have additional constraints for particular azimuth or elevation
angles that are not considered here.
1 year ago
dcc.Tab(label='UV Coverage', className='custom-tab', value='tab-uv',
selected_className='custom-tab--selected', children=[
# Images
html.Div(className='row justify-content-center', children=[
html.Div(className='col-md-8 justify-content-center', children=[
# dcc.Markdown(children="""To be implemented.
# The uv coverage and expected dirty images will go here.""")
html.H4("Resulting (u,v) coverage"),
html.Div(children=[dcc.Graph(id='fig-uvplane')], className='tex2jax_ignore')
1 year ago
dcc.Tab(label='Documentation', className='custom-tab', value='tab-doc',
selected_className='custom-tab--selected', children=[
# Documentation
html.Div(className='row justify-content-center', children=[
html.Div([html.Br(), html.Br()]),
html.Div(className='col-md-8', children=get_doc_text())
html.Div(className='container-fluid', children=[html.Br(), html.Br()])
@app.callback([Output('tab-pick-epoch', 'label'),
Output('tab-guess-times', 'label')],
[Input('guest-times', 'value')])
def update_tab_time_labels(guest_time):
"""Updates the labels in the tabs where the user can either pick a specific observing
time or let the app to guest the correct times.
It will add a green tick or red cross to the option that is currently selected.
if guest_time:
return "Pick Epoch ", "Guest Times ✔️"
return "Pick Epoch ✔️", "Guest Times ❌"
1 year ago
@app.callback([Output('div-antenna-selection-button', 'children'),
Output('div-antenna-selection-button2', 'children')],
[Input('tabs', 'value')])
def move_compute_button(selected_tab):
"""Depending on which tab is selected, it will show the button to compute the observation
in one place or another, so it is always visible and clickable.
if selected_tab == 'tab-setup' or selected_tab == 'tab-doc':
1 year ago
return html.Button('Compute Observation', id='antenna-selection-button',
className='btn btn-primary btn-lg'), html.Div('', style={'height': '2.3rem'})
return html.Div('', style={'height': '2.3rem'}), html.Button('Compute again',
id='antenna-selection-button', className='btn btn-primary btn-lg',
style={'width': '100%', 'margin-bottom': '1rem'}),
@app.callback(Output('onsourcetime-label', 'children'),
[Input('onsourcetime', 'value')])
def update_onsourcetime_label(onsourcetime):
"""Keeps the on-source time label updated with the value selected by the user.
return f"% of on-target time ({onsourcetime}%)"
@app.callback([Output(f"check_{s.codename}", 'checked') for s in all_antennas] + \
[Output(f"check_{s.codename}", 'disabled') for s in all_antennas] + \
[Output('datarate', 'value')],
[Input('band', 'value'), Input('array', 'value'), Input('e-EVN', 'value')])
def select_antennas(selected_band, selected_networks, is_eEVN):
"""Given a selected band and selected default networks, it selects the associated
antennas from the antenna list.
print(selected_band, selected_networks, is_eEVN)
selected_antennas = []
if is_eEVN:
selected_antennas = [ant for ant in default_arrays['e-EVN'] \
if all_antennas[ant].has_band(selected_band)]
datarate = default_datarates['e-EVN'] if selected_band not in ('18cm', '21cm') else 1024
return [True if s.codename in selected_antennas else False for s in all_antennas] + \
[False if (s.has_band(selected_band) and s.real_time) else True \
for s in all_antennas] + [datarate]
datarate = -1
for an_array in selected_networks:
selected_antennas += [ant for ant in default_arrays[an_array] \
if all_antennas[ant].has_band(selected_band)]
datarate = max(datarate, default_datarates[an_array] if not ((an_array == 'EVN') and \
(selected_band in ('18cm', '21cm'))) else 1024)