Browse Source

Networks now defined in a text file

pull/1/head
Benito Marcote 9 months ago
parent
commit
a1679d5284
  1. 48
      app.py
  2. 68
      vlbiplanobs/stations.py

48
app.py

@ -1269,28 +1269,29 @@ def get_fig_ant_up(obs):
data_fig = []
data_dict = obs.is_visible()
for i,ant in enumerate(data_dict):
data_fig.append({'x': obs.times.datetime[data_dict[ant]],
data_fig.append({'x': np.unwrap(obs.gstimes.value)[data_dict[ant]],
# obs.times.datetime[data_dict[ant]],
'y': np.zeros_like(data_dict[ant][0])-i, 'type': 'scatter',
'hovertemplate': "%{x}",
'mode': 'markers', 'marker_symbol': "41",
'hoverinfo': "skip",
'name': obs.stations[ant].name})
data_fig.append({'x': np.unwrap(obs.gstimes.value), 'y': np.zeros_like(obs.times)-0.5,
data_fig.append({'x': obs.times.datetime, 'y': np.zeros_like(obs.times)-0.5,
'xaxis': 'x2',
'mode': 'lines', 'hoverinfo': 'skip', 'showlegend': False,
'line': {'dash': 'dot', 'opacity': 0.0, 'color': 'white'}})
return {'data': data_fig,
'layout': {'title': 'Source visible during the observation',
'xaxis': {'title': 'Time (UTC)', 'showgrid': False,
'xaxis': {'title': 'Time (GST)', 'showgrid': False,
'ticks': 'inside', 'showline': True, 'mirror': False,
'hovermode': 'closest', 'color': 'black'},
'xaxis2': {'title': {'text': 'Time (GST)', 'standoff': 0},
'xaxis2': {'title': {'text': 'Time (UTC)', 'standoff': 0},
'showgrid': False, 'overlaying': 'x', #'dtick': 1.0,
'tickvals': np.arange(np.ceil(obs.gstimes.value[0]),
np.floor(np.unwrap(obs.gstimes.value)[-1])+1),
'ticktext': np.arange(np.ceil(obs.gstimes.value[0]),
np.floor(np.unwrap(obs.gstimes.value)[-1])+1) % 24,
# 'tickvals': np.arange(np.ceil(obs.gstimes.value[0]),
# np.floor(np.unwrap(obs.gstimes.value)[-1])+1),
# 'ticktext': np.arange(np.ceil(obs.gstimes.value[0]),
# np.floor(np.unwrap(obs.gstimes.value)[-1])+1) % 24,
'ticks': 'inside', 'showline': True, 'mirror': False,
'hovermode': 'closest', 'color': 'black', 'side': 'top'},
'yaxis': {'ticks': '', 'showline': True, 'mirror': True,
@ -1298,6 +1299,37 @@ def get_fig_ant_up(obs):
'showgrid': False, 'hovermode': 'closest',
'startline': False}}}
# data_fig = []
# data_dict = obs.is_visible()
# for i,ant in enumerate(data_dict):
# data_fig.append({'x': obs.times.datetime[data_dict[ant]],
# 'y': np.zeros_like(data_dict[ant][0])-i, 'type': 'scatter',
# 'hovertemplate': "%{x}",
# 'mode': 'markers', 'marker_symbol': "41",
# 'hoverinfo': "skip",
# 'name': obs.stations[ant].name})
#
# data_fig.append({'x': np.unwrap(obs.gstimes.value), 'y': np.zeros_like(obs.times)-0.5,
# 'xaxis': 'x2',
# 'mode': 'lines', 'hoverinfo': 'skip', 'showlegend': False,
# 'line': {'dash': 'dot', 'opacity': 0.0, 'color': 'white'}})
# return {'data': data_fig,
# 'layout': {'title': 'Source visible during the observation',
# 'xaxis': {'title': 'Time (UTC)', 'showgrid': False,
# 'ticks': 'inside', 'showline': True, 'mirror': False,
# 'hovermode': 'closest', 'color': 'black'},
# 'xaxis2': {'title': {'text': 'Time (GST)', 'standoff': 0},
# 'showgrid': False, 'overlaying': 'x', #'dtick': 1.0,
# 'tickvals': np.arange(np.ceil(obs.gstimes.value[0]),
# np.floor(np.unwrap(obs.gstimes.value)[-1])+1),
# 'ticktext': np.arange(np.ceil(obs.gstimes.value[0]),
# np.floor(np.unwrap(obs.gstimes.value)[-1])+1) % 24,
# 'ticks': 'inside', 'showline': True, 'mirror': False,
# 'hovermode': 'closest', 'color': 'black', 'side': 'top'},
# 'yaxis': {'ticks': '', 'showline': True, 'mirror': True,
# 'showticklabels': False, 'zeroline': False,
# 'showgrid': False, 'hovermode': 'closest',
# 'startline': False}}}
def get_fig_uvplane(obs):

68
vlbiplanobs/stations.py

@ -598,6 +598,74 @@ class Stations(object):
return subnetwork
@staticmethod
def get_network_names_from_configfile(filename: str) -> dict:
"""Reads a config file containing the different VLBI networks defined as a config parser file.
Returns a dictionary with the nickname of the VLBI network as keys,
Inputs
- filename : str
Path to the text file containing the information from all stations.
If not provided, it reads the default station catalog file located in
data/stations_catalog.inp
Any other file should contain the same format (standard Python input config files),
with the following fields per station (whose name would be provided as the name of
section).
- station - full name of the station.
- code : codename assigned to the station. It must be unique (typically two letters).
- network - main network to which it belongs to.
- possible_networks - all networks the station can participate in (including 'network')
- country - country where the station is located.
- diameter - free format string with the diameter of the station
(optional more information in case of interferometers).
- position = x, y, z (in meters). Geocentric position of the station.
- min_elevation (in degrees) - minimum elevation the station can observe.
- real_time = yes/no - if the station can participate in real-time observations (e.g. e-EVN).
- SEFD_** - SEFD (in Jy units) of the station at the **cm band. If a given band is not present,
it is assumed that the station cannot observe it.
For example SEFD_21 = 500 means that the SEFD at 21cm is 500 Jy.
- Any other attribute is accepted, but ignored in this code. That would easily allow future
extensions of the code.
- codenames : list
If you only want to select a subset of all stations available in the input file,
here you can pass a list with the codenames of the stations that should be imported.
- name : str
Name to assign to the network of stations that will be created.
Returns
- network : Stations
Returns a Stations object containing the selected stations.
"""
config = configparser.ConfigParser()
if filename is None:
with resources.path("data", "stations_catalog.inp") as stations_catalog_path:
config.read(stations_catalog_path)
else:
# With this approach it raises a FileNotFound exception.
# Otherwise config will run smoothly and provide an empty list.
config.read(open(filename, 'r'))
networks = Stations(name, [])
for stationname in config.sections():
if (codenames is None) or (config[stationname]['code'] in codenames):
temp = [float(i.strip()) for i in config[stationname]['position'].split(',')]
a_loc = coord.EarthLocation(temp[0]*u.m, temp[1]*u.m, temp[2]*u.m)
# Getting the SEFD values for the bands
min_elev = float(config[stationname]['min_elevation'])*u.deg
does_real_time = True if config[stationname]['real_time']=='yes' else False
sefds = {}
for akey in config[stationname].keys():
if 'SEFD_' in akey.upper():
sefds[f"{akey.upper().replace('SEFD_', '').strip()}cm"] = \
float(config[stationname][akey])
new_station = SelectedStation(stationname, config[stationname]['code'],
config[stationname]['network'], a_loc, sefds, min_elev,
config[stationname]['station'], config[stationname]['possible_networks'],
config[stationname]['country'], config[stationname]['diameter'], does_real_time)
networks.add(new_station)
return networks

Loading…
Cancel
Save