Commit 777a3bdd authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add module and class level documentation

parent 1d887dbb
"""HPIB wrappers for devices in the Dwingeloo telescope
This module contains some classes for conveniently working with the devices in the Dwingeloo
Telescope that communicate over GPIB (General Purpuse Interface Bus) or HPIB (presumably the
HP variant of GPIB). Currently, three of these devices exist, on different HPIB addresses:
* Receiver (address 1)
* Local Oscillator (address 28), used for mixing signals to downconvert them
* Clock Generator (address 14), used as the clock for the FPGA
For each of the three devices a class exists. Setting and getting the frequency of these
devices is done by using their `frequency` attribute.
Example:
>>> import camrasdevices
>>> lo = LocalOscillator()
>>> lo.frequency
<Quantity 1.0 GHz>
>>> lo.frequency = 1.1e9
>>> lo.frequency
<Quantity 1.1 GHz>
By default, the setter method of `frequency` checks if setting the device succeeded. This is a
blocking operation, but the HPIB bus is quite fast.
>>> lo.frequency = 1.e18
Traceback (most recent call last):
RuntimeError: Setting frequency failed: tried to set to 1e+18 Hz, it is now 1100000000.0 Hz
This checking can be disabled:
>>> non_checking_lo = camrasdevices.LocalOscillator(check_frequency = False)
>>> non_checking_lo.frequency = 1.e18
>>> non_checking_lo.frequency
<Quantity 1.1 GHz>
The CamrasHpibDevice class spawns one thread (shared with all instances) to perform the HPIB
commands. This is to make sure that instances living in separate threads do not interfere with
each other. The thread is a daemon, so it will be killed on program exit.
On initialization of the first CamrasDevice (or subclass), the command thread is initialized, and
some initialization commands are sent to the HPIB bus to tell it to use the appropriate line
endings etc.
"""
import astropy.units as u
from astropy.units import Quantity
......
"""Implementation of the GPIB protocol for use with serial.threading
This class implements the GPIB (General Purpose Interface Bus) protocol following the example at
https://github.com/pyserial/pyserial/blob/master/examples/at_protocol.py
"""
import serial.threaded
import threading
......
"""Doppler tracking functions by setting the local oscillator frequency over HPIB
"""
from typing import Any, Union
import astropy.units as u
......@@ -13,6 +16,19 @@ freq_hi = 1420.405751 * u.MHz
def doppler_harm(sky_coordinate, time, tracking_frequency, location, variant):
"""Return the doppler frequency by using the executables in Harm's home directory
Args:
sky_coordinate (SkyCoordinate): line of sight
time (Time): Astropy time object with time of the conversion
tracking_frequency (Quantity): frequency to track
location (EarthLocation): position of observatory (typically Dwingeloo)
variant (str): standard to use for the sun's movement: "bl" (IAU, based on Blaauw) for or
"mb" (Mihalas & Binney)
Returns:
Quantity: Doppler frequency
"""
ra = sky_coordinate.ra.to(u.rad).value
dec = sky_coordinate.dec.to(u.rad).value
t = time.unix
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment