API Reference¶
-
class
ECHO.observations.
Observation
(lat, lon, frequency=None, description=None)¶ The class object for making observations.
- Parameters
lat (float) – , latitude of receiving antenna (degrees)
lon (float), longitude of receiving antenna (degrees) –
frequency (int) – the reference frequency of the transmitter (MHz)
channel (int) –
description (str) – , text string with information about observation
-
class
Sortie
(sortie_tlog, sortie_ulog, sortie_data, sortie_num, ref_f, sortie_name=None, sortie_title=None)¶ A sortie is created by three files: a ulog, a tlog, and an LWA data file. The data from these files is read and compiled into arrays.
-
apply_bootstart
()¶ Puts drone data on absolute GPS-based time scale.
Uses GPS messages in on-board ulog to calibrate times of positions logged on ground station.
-
flag_endpoints
()¶ Flag data arrays based on mission start/end.
Reads in “global_t” and “waypoint_t” from the tlog data dictionary.
“global_t” contains continuous position data from drone telemetry during the entire sortie. “waypoint_t” contains the position data for each navigational waypoint used to maneuver the drone.
Updates flagged_data and mission_data properties for a sortie
-
flag_waypoints
()¶ Flag data arrays based on waypoint data.
Args:
-
flag_yaws
()¶
-
get_bootstart
()¶ Uses the GPS time to calculate the time at drone boot.
-
get_freq_chans
()¶ Find the channel for our reference frequency.
Args:
Returns:
-
plot
()¶ Creates multiple plots showing position data for sortie.
Tlog X/Y Position, ULog X/Y Position, X Position / Time, Y Position / Time, Z Position / Time:
- Returns
ULog X/Y Position: X Position / Time: Y Position / Time: Z Position / Time:
- Return type
Tlog X/Y Position
-
plot_flags
()¶ Creates a plot showing flagged positions for sortie.
Return:
-
read
()¶ Read in the sortie from associated data files.
The stored tlog, ulog, and receiver datafiles are opened and copied into dictionaries.
- Returns
A dictionary containing info from the sortie tlog u_dict (dict): A dictionary containing info from the sortie ulog data_dict (dict): A dictionary containing info from the sortie receiver datafile
- Return type
t_dict (dict)
-
-
addSortie
(tlog, ulog, data, sortie_name=None, sortie_title=None)¶ Add a sortie to the current observation class.
- Parameters
tlog (file) – txt file for the tlog data
ulog (file) – txt file for the ulog data
data (file) – txt file for the receiver data
sortie_name (str) – unique name for this sortie
sortie_title (str) – display title for this sortie
-
combine_sorties
()¶ Combine our current list of sorties to create a data object for position.
Sorts currently added sorties by timestamp, then aggregates into a single array
- Returns
‘Epoch Time(s), Lat(deg), Lon(deg), Alt(m from ground), Yaw(deg)’ for every sortie
- Return type
dataproduct (array)
-
flagSorties
()¶ Flag the sortie for start and endpoints, as well as waypoints.
-
interpolate_rx
(obsNum, tuning, polarization)¶ Takes position-times of the drone and interpolate the receiver data to the same dimensions as position data.
- Parameters
obsNum (int) – the number of the observation to use
tuning (int) – the number of the tuning to use, 1 or 2
pol (str) – which polarization to use (‘XX’, ‘YY’, ‘YX’, ‘XY’)
- Returns
‘Epoch Time(s), Lat(deg), Lon(deg), Alt(m from ground), Yaw(deg), Radio Spectra’
- Return type
refined_array (array)
-
make_beam
(lat=None, lon=None)¶ Read in the refined array and create a beam.
- Parameters
() (lon) – latitude of the receiver instrument
() – longitude of the receiver instrument
Returns:
-
plot_beam
(fits=False, beamfile=None, countsfile=None)¶ Plot the healpix beam from our observation object.
Optionally plot beams read in from beam files.
- Parameters
fits (bool) –
beamfile (str) –
countsfile (str) –
Returns:
-
plot_grid
(*args, **kwargs)¶ Plot a grid view of the beam.
- Parameters
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
-
plot_isometric
(figsize=5, 5, *args, **kwargs)¶ Plot polar diagrams of the received beam.
- Parameters
figsize (tuple) – figure size for plot
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
-
plot_mollview
(*args, **kwargs)¶ Plot a mollview of the beam using
- Parameters
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
-
plot_polar
(altitude, *args, **kwargs)¶ Plot polar diagrams of the received beam.
- Parameters
altitude – angle from zenith in degrees
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
-
plot_slices
(figsize=None, *args, **kwargs)¶ Plot E and H plane slices of the beam
- Parameters
figsize (tuple) – figure size for plot
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
Returns:
-
read_sorties
()¶ Reads in the data files for a given sortie.
-
sort_sorties
()¶ Sort our current list of sorties by time, using the first entry in each.
At any point we may need to sort the list of sorties by time. It’s preferable to do this rather than sort the data arrays after combining.
- Returns
Sortie object
- Return type
s
-
write_beam
(prefix)¶ Write the beam file out to .fits.
- Parameters
prefix (str) – A string used to name and identify the output files.
Returns:
-
class
ECHO.beams.
Beam
(beam_type, beamfile=None)¶ The Beam class is the container object for various ECHO beams.
A beam can be made using data from the observation object. This will likely use pyuvbeam for stuff.
-
beamlist
¶ List of beams created with this class.
- Type
list
-
efield
¶ numpy array for efield data.
- Type
array, optional
-
power
¶ numpy array for efield data.
- Type
array, optional
-
make_hpx_beam
(data_array, lat=None, lon=None)¶ Read in the refined array and create a beam.
- Parameters
() (lon) – latitude of the receiver instrument
() – longitude of the receiver instrument
Returns:
-
read_cst_beam
(CST_txtfile, beam_type, frequency, telescope_name, feed_name, feed_version, model_name, model_version, feed_pol)¶ Reads in a ASCII formatted CST export file and returns a beam model using pyuvbeam.
- Parameters
CST_txtfile – CST export file
beam_type (str) – ‘efield’ or ‘power’
frequency (float or list of float, Hz) – freq corresponding to CST sim
telescope_name (str) – The instrument name
feed_name (str) – The name of the feed
feed_version (str) – The version of the feed
model_name (str) – Name for the model
model_version (str) – version of the model
feed_pol (str) – polarization of the feed (‘x’,’y’,’xx’,’yy’)
-
write_beam
(beam, rms, counts, prefix)¶ Write the beam file out to .fits.
- Parameters
prefix (str) – A string used to name and identify the output files.
Returns:
-
-
ECHO.plot_utils.
cmap_discretize
(cmap, N)¶ Return a discrete colormap from the continuous colormap cmap.
cmap: colormap instance, eg. cm.jet. N: number of colors.
- Example
x = resize(arange(100), (5,100)) djet = cmap_discretize(cm.jet, 5) imshow(x, cmap=djet)
borrowed from http://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/ColormapTransformations
-
ECHO.plot_utils.
grid_theta_phi_to_healpix
(theta, phi, inbeam)¶ - inputs:
theta (angle down from pixel 0, deg) phi (CW longitude angle, deg) inbeam: input beam values matching the corresponding theta and phi coords
-
ECHO.plot_utils.
grid_to_healpix
(lats, lons, alts, rx, lat0, lon0, nside=8)¶ - input:
lats (deg) lons (deg) alts (m) (relative) rx: power in dB lat0: lat of rx ant (deg) lon0: lon of rx ant nside: of healpix map
-
class
ECHO.plot_utils.
nf
(x=0, /)¶
-
ECHO.plot_utils.
rotate_hpm
(hpm, rot_phi, rot_theta, pol='EW')¶ rotate hpm about phi, then theta (degrees) if pol=EW theta is rotated about the X axis (default) if pol=NS theta is rotated about the Y axis
-
ECHO.plot_utils.
rotate_hpm_old
(hpm, angle, theta_angle=0)¶ rotate hpm angle degrees around the zero pixel (ie around the north pole)
-
ECHO.read_utils.
CST_to_hp
(beamfile, outfile, nside=8, rot=0, zflip=False)¶ Reads in a ASCII formatted CST export file and returns a healpix map. Also saves a .fits file to the current directory. This function is an adaptation of CST_to_healpix.py in the ECHO github. beamfile = CST export file outfile = name of the generated fits file, string nside = number of sides per healpix pixel, must be 2^n int, 8 is typical rot = rotates around the pole by 90deg*rot zflip = inverts the Z axis
-
ECHO.read_utils.
channel_select
(freqs, rxspectrum, channel)¶ - input:
freqs: measured frequences in MHz rxspectrum: power in volt^2 shape(len(times),len(freqs)) channel: give a channel as an int or a float frequency in MHz
- Returns
a single vector ntimes long
-
ECHO.read_utils.
concat_times
(Ts)¶ input a list of astropy time vectors
-
ECHO.read_utils.
flag_angles
(angletimes, angles, sigma=2)¶ - input:
angletimes:astropy.time.Time vector angles: (1,len(angletimes))
sigma: flag values more than this many sigmas above the mean
- Returns
mask times during which angles are bad
-
ECHO.read_utils.
flag_waypoints
(postimes, waypoint_times)¶ - input:
postimes: astropy.time.Time vector matching GPS solutions waypoint_times: astropy.time.Time entries matching times reached wypts
- Returns
flags on the postimes time base (ie matching len(postimes))
-
ECHO.read_utils.
interp_rx
(postimes, rxtimes, rx)¶ - input:
postimes: astropy.Time.Time vector (output points) rxtime: astropy.time.Time vector (input points) Assumes that both position and spectrum data have been properly flagged and that the flags match between the two
- Returns
interpolation of the rx power to the gps times
- Note: this is just a general interpolation function that uses astropy times
and can be used for anything
-
ECHO.read_utils.
mission_endpoint_flagging
(pos_data, wpt_data)¶ Read in position and waypoint array, flag mission endpoints and return valid mission data.
- Parameters
pos_data – the ulog to be converted.
wpt_data –
- Returns
array of flagged data. mission_data: array of valid mission data.
- Return type
flagged_data
-
ECHO.read_utils.
read_CST_puv
(CST_txtfile, beam_type, frequency, telescope_name, feed_name, feed_version, model_name, model_version, feed_pol)¶ Reads in a ASCII formatted CST export file and returns a beam model using pyuvbeam.
- Inputs:
CST_txtfile: CST export file beam_type (str): efield or power frequency (list, Hz): our reference frequency telescope_name (str): The instrument name feed_name (str): The name of the feed feed_version (str): The version of the feed model_name (str): Name for the model model_version (str): version of the model feed_pol (str): polarization of the feed (‘x’,’y’,’xx’,’yy’)
-
ECHO.read_utils.
read_h5
(dataFile)¶ Read in receiver data file, put them into appropriate arrays
- Input:
target_data (HDF5 data file): the datafile for the received power for the target antenna, saved in in h5 format.
- Output:
dataDict: A dictionary containing the observation data. Includes observations, tunings, times, XX and YY polarizations, frequencies
-
ECHO.read_utils.
read_tlog_txt
(tlog)¶ Read in text files converted from tlogs, put them into appropriate arrays.
- Parameters
tlog (int) – the text tlog to be read.
- Returns
waypoints. global_array: global position. local_array: local position. gps_array: gps raw data.
- Return type
wpt_array
-
ECHO.read_utils.
read_ulog
(ulog, output=None, messages='vehicle_global_position,vehicle_local_position,vehicle_gps_position')¶ Read in ulog file, put them into appropriate arrays, then save to .csv
- Input:
ulog (int): the ulog to be converted.
- Output:
global_array: global position. local_array: local position. gps_array: gps raw data.
-
ECHO.read_utils.
write_map
(filename, M)¶ write out a masked healpix map with the correct fill values
-
ECHO.time_utils.
DatetimetoUnix
(data)¶ Function to convert timestamps to unix time through an array.
- Parameters
logged_data (array) – array of data including timestamps in the first column.
- Returns
an array of the same shape as the input array, with timestamps in unix format.
- Return type
timeconv_data