Selaa lähdekoodia

bin updated

pull/1/head
Benito Marcote 11 kuukautta sitten
vanhempi
commit
45f6c5da89
  1. 78
      bin/vlbiplanobs

78
bin/vlbiplanobs

@ -9,11 +9,11 @@ and expected thermal noise level for a given EVN observation.
__author__ = "Benito Marcote"
__credits__ = "Benito Marcote"
__license__ = "LGPLv3+"
__date__ = "2020/04/21"
__version__ = "1.0"
__date__ = "2020/10/26"
__version__ = "1.0.1"
__maintainer__ = "Benito Marcote"
__email__ = "marcote@jive.eu"
__status__ = "Development" # Prototype, Development, Production.
__status__ = "Production" # Prototype, Development, Production.
import os
from os import path
@ -35,27 +35,23 @@ from astropy import units as u
## THIS WILL NEED TO GO AWAY IN THE NEW VERSION OF ASTROPY, WHICH IS STILL NOT
## SUPPORTED BY THE CURRENT VERSION OF ASTROPLAN
# 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 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
# TODO: change this, only using for the assets in dash.Dash (line 131)
current_directory = path.dirname(path.realpath(__file__))
if '/' in current_directory:
current_directory = '/'.join(current_directory.split('/')[:-1])
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+
# import vlbiplanobs
from vlbiplanobs import freqsetups as fs
from vlbiplanobs import stations
from vlbiplanobs import observation
@ -94,38 +90,17 @@ default_datarates = {'EVN': 2048, 'e-EVN': 2048, 'eMERLIN': 4096, 'LBA': 1024, '
# 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.keys()
assert a_station in all_antennas.codenames
doc_files = {'About this tool': 'doc-contact.md',
'About the antennas': 'doc-antennas.md',
'Technical background': 'doc-estimations.md'}
# Initial values
# target_source = observation.Source('10h2m3s +50d40m30s', 'Source')
# obs_times = Time('1967-04-17 10:00') + np.arange(0, 600, 15)*u.min
selected_band = None
obs = observation.Observation()
# obs = observation.Observation(target=target_source)
# obs.times = Time('2020-06-15 20:00', scale='utc') + np.arange(0, 1200, 30)*u.min
# obs.band = selected_band
# obs.datarate = 1024
# obs.subbands = 8
# obs.channels = 32
# obs.polarizations = 2
# obs.inttime = 2
# external_stylesheets = ["https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css", "http://jive.eu/~marcote/style.css"]
# external_stylesheets = ["https://bmarcote.github.io/temp/style.css"]
external_stylesheets = []
# n_timestamps = 70 # Number of points (timestamps) for the whole observations.
external_scripts = ["https://kit.fontawesome.com/69c65a0ab5.js"]
#external_scripts = ["""https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js", \
# "https://polyfill.io/v3/polyfill.min.js?features=es6"]
# "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"]
app = dash.Dash(__name__, external_scripts=external_scripts, assets_folder=current_directory + '/assets/')
@ -162,6 +137,8 @@ def get_doc_text():
[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:
@ -177,7 +154,8 @@ def toggle_accordion(*args):
def error_text(an_error):
"""Message written in a modal error window.
"""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."
@ -193,12 +171,12 @@ def convert_colon_coord(colon_coord):
for l in ('h', 'm', 'd', 'm'):
colon_coord = colon_coord.replace(':', l, 1)
return colon_coord.replace(' ', 's ')+'s'
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.
'message' can be either a string or a list with different string/dash components.
"""
if type(message) == str:
return [html.Br(), \
@ -211,7 +189,8 @@ def alert_message(message, title="Warning!"):
def update_sensitivity(obs):
"""Given the observation, it sets the text about all properties of the observation.
"""Given the observation, it sets the text for all summary cards
with information about the observation.
"""
cards = []
# The time card
@ -542,6 +521,8 @@ app.layout = html.Div([
@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}%)"
@ -579,6 +560,12 @@ def select_antennas(selected_band, selected_networks, is_eEVN):
[Input('starttime', 'date'), Input('starthour', 'value'),
Input('endtime', 'date'), Input('endhour', 'value')])
def check_obstime(starttime, starthour, endtime, endhour):
"""Verify the introduced times/dates for correct values.
Once the user has introduced all values for the start and end of the observation,
it guarantees that they have the correct shape:
- the end of the observation is afte the start of the observation.
- The total observing length is less than five days (value chosen for computational reasons).
"""
times = [None, None]
if None not in (starttime, starthour):
times[0] = Time(dt.strptime(f"{starttime} {starthour}", '%Y-%m-%d %H:%M'))
@ -600,12 +587,15 @@ def check_obstime(starttime, starthour, endtime, endhour):
@app.callback(Output('error_source', 'children'),
[Input('source', 'value')])
def get_source(source_coord):
"""Verifies that the introduced source coordinates have a right format.
If they are correct, it does nothing. If they are incorrect, it shows an error label.
"""
if source_coord != 'hh:mm:ss dd:mm:ss' and source_coord != None:
try:
dummy_target = observation.Source(convert_colon_coord(source_coord), 'Source')
return ''
except ValueError as e:
return "Use 'hh:mm:ss dd:mm:ss' format"
return "Use 'hh:mm:ss dd:mm:ss' or 'XXhXXmXXs XXdXXmXXs' format"
else:
return dash.no_update

Ladataan…
Peruuta
Tallenna