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
zonnedemo
Commits
c0ba27c4
Commit
c0ba27c4
authored
Aug 23, 2021
by
Tammo Jan Dijkema
Browse files
Add sources, minimum plot, elevation limit
parent
3db4df74
Changes
1
Hide whitespace changes
Inline
Side-by-side
zonnewaarneming.py
View file @
c0ba27c4
...
...
@@ -16,7 +16,7 @@ import re
import
struct
import
numpy
as
np
from
telescope
import
Telescope
from
astropy.coordinates
import
get_sun
,
SkyCoord
,
AltAz
,
EarthLocation
,
Angle
from
astropy.coordinates
import
get_sun
,
get_moon
,
SkyCoord
,
AltAz
,
EarthLocation
,
Angle
from
astropy.time
import
Time
import
astropy.units
as
u
from
matplotlib
import
cm
...
...
@@ -44,7 +44,7 @@ def signal_thread():
global
signal
context
=
zmq
.
Context
()
receiver
=
context
.
socket
(
zmq
.
PULL
)
receiver
.
connect
(
"tcp://127.0.0.1:555
7
"
)
receiver
.
connect
(
"tcp://127.0.0.1:555
8
"
)
while
True
:
buff
=
receiver
.
recv
()
signal
=
np
.
frombuffer
(
buff
,
dtype
=
"float32"
)[
-
1
]
...
...
@@ -53,12 +53,12 @@ s = Thread(target=signal_thread)
s
.
daemon
=
True
s
.
start
()
dt
=
Telescope
(
consoleHost
=
'
localhost
'
)
dt
=
Telescope
(
consoleHost
=
'
console
'
)
dwl
=
EarthLocation
(
lon
=
Angle
(
"6:23:46.21 degrees"
),
lat
=
Angle
(
"52:48:43.27 degrees"
))
sourcenames
=
[
"Cassiopeia A
\n
(supernovarestant)"
,
"Cygnus A
\n
(sterrenstelsel)"
,
"Perseus A
\n
(sterrenstelsel)"
,
"Taurus A (Krabnevel)"
,
"Andromeda (sterrenstelsel)"
,
"Zon"
]
sourcenames
=
[
"Cassiopeia A
\n
(supernovarestant)"
,
"Cygnus A
\n
(sterrenstelsel)"
,
"Taurus A (Krabnevel
, supernovarestant
)"
,
"Andromeda (sterrenstelsel)"
,
"Zon"
,
"Maan"
,
"M42 (Orionnevel)"
]
pattern
=
re
.
compile
(
r
'[ \n]+\(.*\)'
)
def
clean_name
(
prettyname
):
...
...
@@ -68,7 +68,7 @@ def clean_name(prettyname):
sources
=
{}
for
sourcename
in
sourcenames
:
if
sourcename
==
"Zon"
:
if
sourcename
in
[
"Zon"
,
"Maan"
]
:
continue
sources
[
sourcename
]
=
SkyCoord
.
from_name
(
clean_name
(
sourcename
))
...
...
@@ -111,6 +111,7 @@ plt.pause(0.001)
prev_points
=
None
separation
=
None
maxsignal
=
0.
minsignal
=
1.0e8
while
not
stoprequest
:
plt
.
pause
(
0.2
)
...
...
@@ -128,6 +129,7 @@ while not stoprequest:
az
=
Angle
(
az
+
180
*
u
.
deg
)
sources
[
"Zon"
]
=
get_sun
(
Time
.
now
())
sources
[
"Maan"
]
=
get_moon
(
Time
.
now
(),
location
=
dwl
)
color
=
'black'
dwl_altaz
=
AltAz
(
location
=
dwl
,
obstime
=
Time
.
now
())
...
...
@@ -146,31 +148,45 @@ while not stoprequest:
pass
if
separation
>
10
*
u
.
deg
:
print
(
"Separation too big"
)
continue
source_altaz
=
sources
[
closest_source
].
transform_to
(
dwl_altaz
)
separation_az
=
(
az
-
source_altaz
.
az
).
wrap_at
(
180
*
u
.
deg
)
separation_alt
=
(
alt
-
source_altaz
.
alt
)
if
np
.
abs
(
separation_az
)
>
np
.
abs
(
separation_alt
):
if
True
or
np
.
abs
(
separation_az
)
>
np
.
abs
(
separation_alt
):
# TODO: only azimuth
print
(
f
"Separation az:
{
separation_az
.
deg
}
"
)
if
separation_az
<
0
*
u
.
deg
:
separation
=
-
separation
else
:
if
separation_alt
<
0
*
u
.
deg
:
separation
=
-
separation
if
abs
(
dt
.
dist_el
)
>
0.2
*
u
.
deg
:
# Only show values if the elevation is already on source
print
(
f
"Elevation off (
{
separation_alt
}
), continuing"
)
continue
if
dt
.
speed_az
>
0.3
*
u
.
deg
/
u
.
s
:
# Don't show anything if we're slewing very fast
print
(
"Too fast"
)
continue
scatterplot
=
scatterplots
[
closest_source
]
print
(
Time
.
now
(),
separation
,
az
.
to
(
u
.
deg
).
value
,
alt
.
to
(
u
.
deg
).
value
,
signal
,
clean_name
(
closest_source
),
file
=
datafile
,
flush
=
True
,
sep
=
','
)
print
(
Time
.
now
(),
separation
.
deg
,
az
.
to
(
u
.
deg
).
value
,
alt
.
to
(
u
.
deg
).
value
,
signal
,
clean_name
(
closest_source
),
file
=
datafile
,
flush
=
True
,
sep
=
','
)
if
signal
>
maxsignal
:
maxsignal
=
signal
if
signal
<
minsignal
:
minsignal
=
signal
scatter_data
=
scatterplot
.
get_offsets
()
scatter_data
=
np
.
vstack
((
scatter_data
,
[
separation
.
deg
,
signal
]))
scatterplot
.
set_offsets
(
scatter_data
)
prev_points
=
ax
.
scatter
([
separation
.
deg
],
[
signal
],
s
=
50
,
color
=
'red'
)
ax
.
set_ylim
((
2800
,
1.1
*
maxsignal
))
ax
.
set_ylim
((
0.9
*
minsignal
,
1.1
*
maxsignal
))
update_legend
(
ax
,
closest_source
)
...
...
Write
Preview
Supports
Markdown
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