Browse Source

Command-line approach added. Fixing prev. commit

pull/1/head
Benito Marcote 1 year ago
parent
commit
b155386512
  1. 67
      README.md
  2. 1
      vlbiplanobs/observation.py
  3. 41
      vlbiplanobs/stations.py

67
README.md

@ -41,6 +41,10 @@ The EVN Observation Planner can also be used inside a Python environment or insi
```python
# Packages used in the example:
import numpy as np
from astropy import units as u
import vlbiplanobs
# Two main modules that can also be imported directly
@ -52,17 +56,74 @@ from vlbiplanobs import observation
# You can define the source you want to observe with:
source = observation.Source(coordinates='XXhXXmXXs XXdXXmXXs', name='my_source')
# To can then retrieve the coordinates (as in a astropy.coordinates.angles.Longitude/Latitude object) with:
# To can then retrieve the coordinates with:
# (as in a astropy.coordinates.angles.Longitude/Latitude object)
source.ra
source.dec
# Or retrieve the full astropy.coordinates object as
source.coord
# Then you can set the observation
# You can import all stations that are known by default:
all_stations = stations.Stations.get_stations_from_configfile()
# Note that you can get the codenames with
all_stations.keys()
# Or just a subset of them by selecting manually
# the stations you want from their codenames (e.g.):
my_stations = stations.Stations.get_stations_from_configfile(codenames=('Ef', 'Ys', 'Wb'))
# Where you can also select the antennas that can observe at a given band:
stations18cm = my_stations.stations_with_band('18cm')
# Finally, you can set the observation
obs = observation.Observation(target=source,
times=observation.Time('1967-04-17 10:00') + np.arange(0, 600, 15)*u.min), # list of times covering the observation.
band='18cm' # must be a string with the format XXcm.
datarate=1024, # Mbps
subbands=8, # no. subbands (or IFs).
channels=64, # no. of channels per subband
polarizations=4, # no. of polarizations (1: single, 2: dual, 4: full polarization)
inttime=2, # integration time in seconds (or astropy.Quantity)
ontarget=0.7, # fraction of the total observing time spent in the target source (affects to the estimated noise level)
stations=stations18cm, # add a Stations object containing all stations that will observe
bits=2) # no. of bits used for data recording (2 in typical VLBI observations)
# You can get the wavelength or frequency of the observation
print(obs.wavelength)
print(obs.frequency)
# The total bandwidth of the observation
print(obs.bandwidth)
# Or per subband:
print(obs.bandwidth/obs.subbands)
# Get the times (UTC) in datetime format, or GST:
print(obs.times.datetime)
print(obs.gstimes)
# Obtain the source elevation along the observation for each antenna
obs.elevations() # Returns a dict with the codename of the station as key and an numpy.array with the elevations as value.
# or the altitude/azimuth of the source, following the same approach
obs.altaz()
# If you just want to know at which times the source will be visible per station:
obs.is_visible()
# Obtain the expected thermal rms noise for the whole observation
obs.thermal_noise()
# And the expected synthesized beam (using a neutral weighting of zero)
obs.synthesized_beam() # returns a dict with 'bmaj', 'bmin', 'pa'.
# And some additional useful information as (but not limited to):
obs.longest_baseline() # returning ((antenna1,antenna2), baseline_length)
obs.shortest_baseline()
obs.bandwidth_smearing()
obs.time_smearing()
```

1
vlbiplanobs/observation.py

@ -98,6 +98,7 @@ class Observation(object):
@band.setter
def band(self, new_band):
assert isinstance(new_band, str) and 'cm' in new_band
self._band = new_band
self._uv_baseline = None
self._uv_array = None

41
vlbiplanobs/stations.py

@ -276,8 +276,10 @@ class Stations(object):
return self._stations.__contains__(item)
@staticmethod
def get_stations_from_configfile(filename=None):
"""Retrieves the information concerning all stations available in the 'filename'
def get_stations_from_configfile(filename=None, codenames=None):
"""
codenames : list with the codenames of the stations you want to import
Retrieves the information concerning all stations available in the 'filename'
file. Creates a Stations object containing the stations and the information on it.
The file must have a format readable by the Python ConfigParser.
Each section will be named with the name of the station, and then it must have
@ -306,22 +308,23 @@ class Stations(object):
networks = Stations('network', [])
for stationname in config.sections():
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)
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
@ -334,7 +337,7 @@ class Stations(object):
if output_network_name is None:
output_network_name = f"Stations@{band}"
antennas = stations.Stations(output_network_name, [])
antennas = Stations(output_network_name, [])
for station in self.stations:
if band in station.bands:
antennas.add(station)

Loading…
Cancel
Save