Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
HPIB
Commits
a86caf22
Commit
a86caf22
authored
Apr 23, 2018
by
Tammo Jan Dijkema
Browse files
Use astropy time in function template, nicer test
parent
9dbda9d2
Changes
3
Show whitespace changes
Inline
Side-by-side
test/test_track_doppler.py
View file @
a86caf22
import
track_doppler
import
unittest
from
mock
import
call
,
patch
import
astropy.units
as
u
from
vlsr
import
doppler_frequency
from
astropy.coordinates
import
SkyCoord
import
astropy.units
as
u
...
...
@@ -40,9 +43,9 @@ class DummyLocalOscillator(object):
@
frequency
.
setter
def
frequency
(
self
,
freq
):
self
.
_frequency
=
freq
print
(
"Dummy LO set to
{
}"
.
format
(
self
.
_frequency
))
print
(
"Dummy LO set to
1GHz {:+.3f
}"
.
format
(
(
self
.
_frequency
-
1
*
u
.
GHz
).
to
(
u
.
kHz
)
))
track_doppler
.
track_doppler
(
lo
=
DummyLocalOscillator
(),
dt
=
DummyTelescope
())
track_doppler
.
track_doppler
(
lo
=
DummyLocalOscillator
(),
dt
=
DummyTelescope
()
,
doppler_function
=
doppler_frequency
)
if
__name__
==
'__main__'
:
unittest
.
main
()
track_doppler.py
View file @
a86caf22
import
astropy.units
as
u
from
astropy.coordinates
import
SkyCoord
,
EarthLocation
from
astropy.time
import
Time
import
numpy
as
np
import
argparse
...
...
@@ -16,10 +18,14 @@ freq_hi = 1420.405751 * u.MHz
def
doppler_harm
(
sky_coordinate
,
time
,
tracking_frequency
,
location
):
ra
=
sky_coordinate
.
ra
.
to
(
u
.
rad
).
value
dec
=
sky_coordinate
.
dec
.
to
(
u
.
rad
).
value
t
=
time
.
unix
dt_lat
=
location
.
lat
.
to
(
u
.
rad
).
value
dt_lon
=
location
.
lon
.
to
(
u
.
rad
).
value
dt_alt
=
location
.
height
.
to
(
u
.
m
).
value
argstring
=
"{ra} {dec} 2000 {time} {dt_lat} {dt_lon} {dt_alt}"
.
format
(
ra
=
ra
,
dec
=
dec
,
time
=
t
ime
,
dt_lat
=
dt_lat
,
dt_lon
=
dt_lon
,
dt_alt
=
dt_alt
)
ra
=
ra
,
dec
=
dec
,
time
=
t
,
dt_lat
=
dt_lat
,
dt_lon
=
dt_lon
,
dt_alt
=
dt_alt
)
doppler_executable
=
"/home/harm/bin/doppler_
m
b"
doppler_executable
=
"/home/harm/bin/doppler_b
l
"
doppler_cmd
=
doppler_executable
+
" "
+
argstring
+
" "
+
str
(
tracking_frequency
.
to
(
u
.
MHz
).
value
)
freq_doppler
=
float
(
subprocess
.
Popen
(
doppler_cmd
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
).
stdout
.
read
())
...
...
@@ -55,7 +61,7 @@ def track_doppler(lo=None, dt=None,
while
not
exit_event
.
is_set
():
sky_coordinate
=
dt
.
radec
freq_doppler
=
doppler_function
(
sky_coordinate
,
t
ime
.
time
(),
tracking_frequency
,
dt_loc
)
freq_doppler
=
doppler_function
(
sky_coordinate
,
T
ime
.
now
(),
tracking_frequency
,
dt_loc
)
dfreq
=
1
*
u
.
GHz
+
tracking_frequency
-
freq_doppler
lo
.
frequency
=
dfreq
exit_event
.
wait
(
timeout
=
0.5
)
vlsr.py
View file @
a86caf22
...
...
@@ -4,7 +4,6 @@ from astropy.coordinates import SkyCoord, EarthLocation
import
astropy.units
as
u
from
astropy.units
import
Quantity
import
astropy.constants
from
typing
import
Union
import
numpy
as
np
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment