lib_SRT package¶
lib_SRT.Srt module¶
This module contains the main class for VEGA operation. To be instantiated only once by operation session.
The SRT owns the background threads QPing and QTracker. For more about those, see their respective modules.
- class QObsProcess(*args: Any, **kwargs: Any)¶
Bases:
QThread- run()¶
- setOrientation(ra, dec, az, alt)¶
- setParams(repo, name, prefix, dev_args, rf_gain, if_gain, bb_gain, fc, bw, channels, t_sample, duration, overwrite, obs_mode, raw_mode, studentflag)¶
- class Srt(*args: Any, **kwargs: Any)¶
Bases:
QObjectClass that monitors the interface between the user and the VEGA Small Radio Telescope.
The features of the class include :
Slewing the APM in either a simple pointing or tracking motion
Acquiring data from the SDR
Processing data TODO : update the processing pipeline for more control than with virgo
This class is intended to own and communicate with all threads sending commands to the APM. It also owns the SerialPort instance, and as such is the only one to properly speaking communicate with the APM. This is required to prevent multiple access to the Serial port.
- Parameters:
address (str) – Address of the port on which the APM is connected
baud – Baud rate at which data is communicated between SRT and APM
timeout (float) – Timeout duration of the connexion between SRT and APM
- Type:
float
- calibrate_north(value=990000, verbose=False)¶
Defines offset for North position in azimuthal microsteps. The curent estimation is stored in constant NORTH.
- Parameters:
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- connectAPM(water=True)¶
Connects to serial port. Performs the check-in routines :
Unpause the QPing thread
Calibrate the Azimuthal encoder to NORTH
Untangle cables for safety and motor proper activation
By default launch the water evacuation process
Get all current coordinates from encoders
- Parameters:
water (bool) – Flag enabling the water evacuation process launch upon connection
- Returns:
Final feedback from APM
- Return type:
str
- disconnectAPM()¶
Disconnects from serial port. Performs the check-out routines:
Stop all background threads (ping, tracker)
Park the mount
Close connection to serial port
- Returns:
Last feedback from APM
- Return type:
str
- empty_water()¶
Sends command to move the antenna to a position where water can flow out then goes back to parking position after a while. TODO : create constants with coordinates and flowing duration
- Returns:
An IDLE message. Handy for implementation of GUI
- Return type:
str
- getAllCoords()¶
Refreshes all coordinates instance attributes from AzAlt communicated by the APM encoders.
- getAlt()¶
Getter on current Altitude in degrees. In case of error returns -1
- Returns:
Current elevation angle communicated by the APM encoder
- Return type:
float
- getAz()¶
Getter on current Azimuthal angle in degrees. In case of error returns -1.
- Returns:
Current azimuthal angle communicated by the APM encoder
- Return type:
float
- getAzAlt()¶
Getter on current position in AltAz coordinates,
- Returns:
Current azimuthal and elevation angles communicated by the APM encoders
- Return type:
(float, float)
- getDec()¶
Returns current Dec converted from AzAlt communicated by the APM encoders
- Returns:
Current Dec coordinate
- Return type:
float
- getGal()¶
Returns current long/lat in galactic coordinates converted from AzAlt communicated by the APM encoders.
- Returns:
Current galactic longitude and latitude angles
- Return type:
(float, float)
- getPos()¶
Returns current RaDec in degrees converted from AzAlt communicated by the APM encoders.
- Returns:
Current RA and DEC coordinates
- Return type:
(float, float)
- getRA()¶
Returns current RA coordinate converted from AzAlt communicated by the APM encoders.
- Returns:
Current RA coordinate
- Return type:
float
- go_home(verbose=False)¶
Takes SRT to its home position and shuts motors off
- Returns:
Final feedback from APM
- Return type:
str
- obsFinished()¶
Is connected to observing thread ending. :return:
- observe(repo=None, name=None, prefix='', dev_args='hackrf=0,bias=1', rf_gain=48, if_gain=25, bb_gain=18, fc=1420000000.0, bw=2400000.0, channels=2048, t_sample=1, duration=10, overwrite=False, obs_mode=True, raw_mode=False, studentflag=False)¶
Launches a parallelized observation process. All SRT methods are still callable in the meanwhile.
- Parameters:
prefix (str) – added before the folder and file names.
repo (str) – Name of the repository where to store data under DATA_PATH. If None, the name of the repo is by default an auto-generated timestamp
name (str) – Name of the .dat file in which the data is stored. If None, the name of the file is by default an auto-generated timestamp
dev_args (str) – Device string used by GNU-RADIO to activate the SDR with input parameters. Default to ‘hackrf=0,bias=1’ to indicate the SDR is a HackRF, and the bias-tee should be switched on to power the LNA. For more about the acquisition pipeline, refer to VEGA technical documentation
rf_gain (float) – RF gain used by the SDR
if_gain (float) – Intermediate frequency gain used by the SDR
bb_gain (float) – Base-band gain used by the SDR
fc (float) – Central frequency of the observation in MHz. Default set to H21 rest state radiation frequency.
bw (float) – Bandwidth of the observation in MHz. Notice this is the “period” of the Nyquist-Shannon signal to be sampled when measuring a Power Spectral Diagram
channels – Numbers of channels to sample. Default value works fine
t_sample – Sample duration in seconds
duration (float) – Total observation duration in seconds
overwrite (bool) – Flag enabling overwriting of existing observation with same repo and name. If turned off, the new file with overlapping name will be added a suffix ‘_(i)’ to its path with i an integer counter
obs_mode (bool) – Flag enabling processed output to be written to the repo.
raw_mode (bool) – Flag enabling processed output to be written to the repo.
studentflag (bool) – Flag which when enabled changes path to which files are written to student path.
- Type:
float
- Type:
float
- onPingSignal()¶
Slot triggered when the QPing thread sends the signal to process the ping/pong with APM.
- onTrackerSignal(az, alt)¶
Slot triggered when the QTracker thread emits signal to send a slewing command to APM.
Emits the signal trackMotionEnd when the APM has returned, which in turns switches back the QTracker thread on. See QTracker class for more.
- Parameters:
az (float) – Target Azimuth coordinate
alt (float) – Target Altitude coordinate
- pointAzAlt(az, alt, fromTracker=False, verbose=False)¶
Sends the command to slew to Azimuth and Altitude coordinates given in decimal degrees.
- Parameters:
az (float) – Target Azimuth coordinate
alt (float) – Target Altitude coordinate
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- pointGal(long, lat, fromTracker=False, verbose=False)¶
Sends the command to slew to Long Lat galactic coordinates given in decimal hours.
- Parameters:
long (float) – Target longitude coordinate
lat (float) – Target latitude coordinate
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- pointRaDec(ra, dec, fromTracker=False, verbose=False)¶
Sends the command to slew to Ra Dec coordinates given in respectively decimal hour,degrees.
- Parameters:
ra (float) – Target RA coordinate
dec (float) – Target Dec coordinate
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- returnStoredCoords()¶
Getter on all stored current coordinates in all 3 systems : AzAlt, RaDec, Galactic. Handy for e.g. refreshing displayed coordinates on GUI. See mainclient.py for more.
- Returns:
Tuple with all coordinates in all 3 systems
- Return type:
(float, float, float, float, float, float)
- send_APM(msg: str, verbose=False, save=True)¶
Private method monitoring the command transfer to APM via the serial port. This is the only method whatsoever envisioned to directly send commands to the APM.
- Parameters:
msg (str) – Command to send to APM
verbose (bool) – Debugging flag. When on, all transiting commands are printed to console
save (bool) – When this flag is on, the last command sent is saved to the instance attribute self.apmMsg
- Returns:
Feedback from APM
- Return type:
str
- standby(verbose=False)¶
Sends the command to go back to zenith and switch off motors of the mount.
- Parameters:
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- stopObs()¶
Brute force kills the observation process. Be aware this can corrupt the data being acquired.
- stopTracking()¶
Stops the tracking motion by pausing the QTracker thread. Unpauses the QPing thread. See QTracker class for more about the tracking system, QPing class for more about the ping system.
- trackGal(long, b)¶
Starts tracking given coordinates in Galactic mode. See QTracker class for more about the tracking system.
- Parameters:
long (float) – Target longitude coordinate
b (float) – Target latitude coordinate
- trackRaDec(ra, dec)¶
Starts tracking given coordinates in RaDec mode. See QTracker class for more about the tracking system.
- Parameters:
ra (float) – Target RA coordinate
dec (float) – Target Dec coordinate
- trackSat(tle)¶
Starts tracking given a satellite TLE. See QTracker class for more about the tracking system. TODO: Implement satellite tracking
- Parameters:
tle – Target TLE
- untangle(verbose=False)¶
Sends the command to untangle cables of the mount by azimuthal rotation back to initial position.
- Parameters:
verbose (bool) – Flag used by self.send_APM
- Returns:
Last feedback from APM
- Return type:
str
- waitObs()¶
Waits for the running observation to finish. Should only be used in command line; GUI must get rid of this another way round I guess…
- loadTLE(name)¶
Loads TLEs from TLE_PATH
- plotAll(repo, name, calib, n=20, m=35, f_rest=1420405751.7667, vlsr=False, dB=True, meta=False)¶
Plots full display of data using virgo library’s virgo.plot function. Notice the method needs the calibration and the observation data files to be stored in the same repository to work properly. TODO: Implement better method with new acquisition pipeline.
- Parameters:
repo (str) – Name of the repository under which data and params.json files are stored
name (str) – Name of the observation data file
calib (str) – Name of the calibration data file
n (float) – TODO: understand this
m (float) – TODO: understand this
f_rest – Center frequency at which the observation was performed. TODO: use params.json rather
vlsr – TODO: understand this
dB – Scales the calibrated plot in dB
meta – TODO: understand this
- plotAvPSD(path)¶
Plots the averaged PSD of the observation located in path EXPERIMENTAL : work in progress
lib_SRT.QPing module¶
- class QPing(*args: Any, **kwargs: Any)¶
Bases:
QThreadQThread monitoring the recurrent ping handshake with the APM. The APM is programmed to park the radiotelescope automatically after a certain inactivity duration. In order to prevent this parking process to trigger during e.g. a static measurement, or user lasting hesitation, a ping/pong is regularly performed with APM in the background in order to reset its inactivity timer while the SRT object is “connected”.
The rate at which these interactions are executed is fixed by the PING_RATE constant.
Notice the thread is not ypaused during tracking motion : since the QTracker threads sends commands continuously at high rate, the ping is useless in this case, and would only slow down communication with APM. See QTracker for more.
- pause()¶
Pauses the emission of ping signal in the main loop
- run()¶
Main loop of the thread. If the self.on flag is on, the ping signal is emitted for the SRT instance to ping the APM. In any case, PING_RATE seconds are waited before next iteration.
- stop()¶
Allows to kill the thread by switching on the stop flag
- unpause()¶
Enables the emission of ping signal in the main loop
lib_SRT.QTracker module¶
- class QTracker(*args: Any, **kwargs: Any)¶
Bases:
QThreadQThread monitoring the background commands during a track. Envisioned trackable targets are : tuples (a,b) of coordinates in any of the RaDec or Galactic coordinates (More might be added in future), or satellites TLEs (TODO)
Target (a,b) or TLE are given at initialisation of the thread by user input, or modified by call to setTarget. During tracking, current corresponding AzAlt coordinates are regularly refreshed and the slew command to those is sent to APM. The rate at which these commands are sent is fixed by the TRACKING_RATE constant.
TODO: Implement satellite tracking
- SRTreturn()¶
Triggered when SRT returns answer on tracking motion
- onIdle()¶
Slot triggered when SRT is ready for the next tracking motion
- pause()¶
Allows to pause tracking
- refresh_azalt()¶
Refreshes AzAlt coords of target depending on the tracking mode
- run()¶
Main loop of the thread. If the self.on flag is on, the tracking signal is emitted for the SRT instance to send the slew-to-AzAlt command to the APM every TRACKING_RATE seconds, OR as soon as the APM is IDLE.
Notice the self.on flag is turned off after sending a slewing command. This accounts for the time the APM takes to execute the command and return IDLE to the SRT instance. When the IDLE feedback is received, the SRT instance emits a signal which turns the self.on flag back on.
See self.onIdle and SRT class for more.
- sendPointTo¶
alias of
float
- setMode(mode)¶
Sets the tracking mode.
- Parameters:
mode (TrackMode) – Desired mode of tracking (RaDec, Gal or TLE)
- setTarget(*args)¶
Sets target’s coordinates. TODO: Implement TLE, document type of args in this case
- Parameters:
args ((float, float)) – The target to track
- turnOn()¶
Allows to turn on tracking
- class TrackMode(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
EnumTracking modes of SRT. Specifies the coordinate system to use while tracking. For now 3 options are foreseen: RaDec, Galactic coordinates, and TLE (satellites) tracking. TODO: Implement satellite tracking
- GAL = 2¶
- RADEC = 1¶
- TLE = 3¶
lib_SRT.SerialPort module¶
Module containing the private class SerialPort, used by SRT to communicate with APM.
- class SerialPort(address, baud, timeo=None)¶
Bases:
objectClass aimed at monitoring the interaction with the APM serial port using the serial module
- Parameters:
address – address of the serial port (port on the linux machine)
baud – rate of data exchange
timeo – timeout of the communication. Default to None
- connect()¶
Connects to the serial port. TODO: implement security check if an error occurs here
- disconnect()¶
Disconnects the serial port.
- listen()¶
Reads last message from SerialPort with appropriate processing. Messages sent by the APM have format:
{Status}|{Feedback}
where status can either be OK, Warning or Error. Feedback is the actual return value of the APM : either message if status is Warning or Error, or a string containing a value if the status is Success.
Example message : “Success | 33.85” , answer to command “getAz”. The numeric value is thus the current Azimuth angle value assumed by the APM Az encoder.
See APM_embedded_teensy/APM_embedded_teensy_2.ino for more
- Returns:
Message sent by the APM
- Return type:
str
- send_Ser(msg: str)¶
Sends message through the serial port to the APM. Returns answer from SerialPort, following the synchronous philosophy : one command = one feedback. TODO: Make encoders asynchronous to allow multiple commands, command breaks etc (long term)
- Parameters:
msg (str) – Command to send to APM
- Returns:
Feedback from APM after command execution
- Return type:
str
lib_SRT.define module¶
Definition of parameters used when instantiating the SRT object
Module contents¶
Subpackages¶
- lib_SRT.utils package
- lib_SRT.virgo package
- lib_SRT.virgo.run_ftf module
argument_parser()main()run_observationrun_observation.get_bandwidth()run_observation.get_bb_gain()run_observation.get_channels()run_observation.get_custom_window()run_observation.get_dev_args()run_observation.get_duration()run_observation.get_frequency()run_observation.get_if_gain()run_observation.get_obs_file()run_observation.get_raw_file()run_observation.get_rf_gain()run_observation.get_sinc()run_observation.get_sinc_sample_locations()run_observation.get_t_sample()run_observation.set_bandwidth()run_observation.set_bb_gain()run_observation.set_channels()run_observation.set_custom_window()run_observation.set_dev_args()run_observation.set_duration()run_observation.set_frequency()run_observation.set_if_gain()run_observation.set_obs_file()run_observation.set_raw_file()run_observation.set_rf_gain()run_observation.set_sinc()run_observation.set_sinc_sample_locations()run_observation.set_t_sample()
- lib_SRT.virgo.run_wola module
argument_parser()main()run_observationrun_observation.get_bandwidth()run_observation.get_bb_gain()run_observation.get_channels()run_observation.get_custom_window()run_observation.get_dev_args()run_observation.get_duration()run_observation.get_frequency()run_observation.get_if_gain()run_observation.get_obs_file()run_observation.get_raw_file()run_observation.get_rf_gain()run_observation.get_sinc()run_observation.get_sinc_sample_locations()run_observation.get_t_sample()run_observation.set_bandwidth()run_observation.set_bb_gain()run_observation.set_channels()run_observation.set_custom_window()run_observation.set_dev_args()run_observation.set_duration()run_observation.set_frequency()run_observation.set_if_gain()run_observation.set_obs_file()run_observation.set_raw_file()run_observation.set_rf_gain()run_observation.set_sinc()run_observation.set_sinc_sample_locations()run_observation.set_t_sample()
- lib_SRT.virgo.virgo module
- Module contents
- lib_SRT.virgo.run_ftf module