Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3mon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carlo Guidi
km3mon
Commits
e5a32e3f
Commit
e5a32e3f
authored
5 years ago
by
Carlo Guidi
Browse files
Options
Downloads
Patches
Plain Diff
Update acoustics.py
parent
bca09eb3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/acoustics.py
+39
-63
39 additions, 63 deletions
scripts/acoustics.py
with
39 additions
and
63 deletions
scripts/acoustics.py
+
39
−
63
View file @
e5a32e3f
...
...
@@ -8,7 +8,8 @@ Usage:
acoustics.py (-h | --help)
Options:
-d DET_ID Detector ID
-d DET_ID Detector ID
-ndu N_DUS Number of DUs
-o PLOT_DIR The directory to save the plot
-h --help Show this screen.
...
...
@@ -24,30 +25,33 @@ from datetime import datetime
import
km3pipe
as
kp
def
diff
(
first
,
second
):
second
=
set
(
second
)
return
[
item
for
item
in
first
if
item
not
in
second
]
parser
=
argparse
.
ArgumentParser
(
description
=
'
Online_monitoring
'
)
parser
.
add_argument
(
'
-d
'
,
dest
=
'
det_id
'
,
type
=
str
,
nargs
=
1
,
required
=
True
,
help
=
'
The detector ID (e.g. D_ORCA005)
'
)
parser
.
add_argument
(
'
-ndu
'
,
dest
=
'
n_dus
'
,
type
=
int
,
nargs
=
1
,
required
=
True
,
help
=
'
Number of DUs (e.g. 5)
'
)
parser
.
add_argument
(
'
-o
'
,
dest
=
'
plot_dir
'
,
type
=
str
,
nargs
=
1
,
required
=
True
,
help
=
'
Directory in which the plot is saved
'
)
args
=
parser
.
parse_args
()
detid
=
args
.
det_id
[
0
]
directory
=
args
.
plot_dir
[
0
]
N_DUS
=
args
.
n_dus
[
0
]
def
diff
(
first
,
second
):
second
=
set
(
second
)
return
[
item
for
item
in
first
if
item
not
in
second
]
db
=
kp
.
db
.
DBManager
()
sds
=
kp
.
db
.
StreamDS
()
table
=
db
.
run_table
(
detid
)
ACOUSTIC_BEACONS
=
[
12
,
14
,
16
]
N_DOMS
=
18
N_ABS
=
3
DOMS
=
range
(
N_DOMS
+
1
)
N_DUS
=
5
DUS
=
range
(
1
,
N_DUS
+
1
)
TIT
=
600
# Time Interval between Trains of acoustic pulses)
...
...
@@ -56,6 +60,7 @@ SSW = 160 # Signal Security Window (Window size with signal)
check
=
True
while
check
:
table
=
db
.
run_table
(
detid
)
minrun
=
table
[
"
RUN
"
][
len
(
table
[
"
RUN
"
])
-
1
]
ind
,
=
np
.
where
((
table
[
"
RUN
"
]
==
minrun
))
mintime1
=
table
[
'
UNIXSTARTTIME
'
][
ind
]
...
...
@@ -165,40 +170,27 @@ while check:
N_Pulses_Indicator
.
append
(
N_Pulses_Indicator_DU
)
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
)
N_doms
=
18
doms
=
range
(
N_doms
+
1
)
L
=
len
(
doms
)
du1AB1
=
0.9
*
np
.
ones
(
L
)
du1AB2
=
1
*
np
.
ones
(
L
)
du1AB3
=
1.1
*
np
.
ones
(
L
)
du2AB1
=
1.9
*
np
.
ones
(
L
)
du2AB2
=
2
*
np
.
ones
(
L
)
du2AB3
=
2.1
*
np
.
ones
(
L
)
du3AB1
=
2.9
*
np
.
ones
(
L
)
du3AB2
=
3
*
np
.
ones
(
L
)
du3AB3
=
3.1
*
np
.
ones
(
L
)
du4AB1
=
3.9
*
np
.
ones
(
L
)
du4AB2
=
4
*
np
.
ones
(
L
)
du4AB3
=
4.1
*
np
.
ones
(
L
)
du5AB1
=
4.9
*
np
.
ones
(
L
)
du5AB2
=
5
*
np
.
ones
(
L
)
du5AB3
=
5.1
*
np
.
ones
(
L
)
DU1
=
np
.
array
(
N_Pulses_Indicator
[
0
])
DU2
=
np
.
array
(
N_Pulses_Indicator
[
1
])
DU3
=
np
.
array
(
N_Pulses_Indicator
[
2
])
DU4
=
np
.
array
(
N_Pulses_Indicator
[
3
])
DU5
=
np
.
array
(
N_Pulses_Indicator
[
4
])
ind
=
np
.
where
(
DU2
<
1000
)
duab
=
[]
DUs
=
[]
for
du
in
range
(
N_DUS
):
duabdu
=
[]
duab1
=
(
du
+
0.9
)
*
np
.
ones
(
L
)
duab2
=
(
du
+
1
)
*
np
.
ones
(
L
)
duab3
=
(
du
+
1.1
)
*
np
.
ones
(
L
)
duabdu
.
append
(
duab1
)
duabdu
.
append
(
duab2
)
duabdu
.
append
(
duab3
)
duab
.
append
(
duabdu
)
DUs
.
append
(
np
.
array
(
N_Pulses_Indicator
[
du
]))
ind
=
np
.
where
(
DUs
[
1
]
<
1000
)
iAB1
=
np
.
where
(
ind
[
0
]
<
L
)
iAB2_up
=
np
.
where
(
ind
[
0
]
>
(
L
-
1
))
iAB2_down
=
np
.
where
(
ind
[
0
]
<
2
*
L
)
...
...
@@ -209,22 +201,11 @@ while check:
CustomCmap
=
matplotlib
.
colors
.
ListedColormap
(
colorsList
)
bounds
=
[
-
2
,
-
1
,
0
,
1
,
2
]
norma
=
colors
.
BoundaryNorm
(
bounds
,
CustomCmap
.
N
)
color
=
ax
.
scatter
(
du1AB1
,
doms
,
s
=
20
,
c
=
DU1
[
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du1AB2
,
doms
,
s
=
20
,
c
=
DU1
[
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du1AB3
,
doms
,
s
=
20
,
c
=
DU1
[
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du2AB1
,
doms
,
s
=
20
,
c
=
DU2
[
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du2AB2
,
doms
,
s
=
20
,
c
=
DU2
[
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du2AB3
,
doms
,
s
=
20
,
c
=
DU2
[
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du3AB1
,
doms
,
s
=
20
,
c
=
DU3
[
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du3AB2
,
doms
,
s
=
20
,
c
=
DU3
[
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du3AB3
,
doms
,
s
=
20
,
c
=
DU3
[
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du4AB1
,
doms
,
s
=
20
,
c
=
DU4
[
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du4AB2
,
doms
,
s
=
20
,
c
=
DU4
[
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du4AB3
,
doms
,
s
=
20
,
c
=
DU4
[
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du5AB1
,
doms
,
s
=
20
,
c
=
DU5
[
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du5AB2
,
doms
,
s
=
20
,
c
=
DU5
[
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
du5AB3
,
doms
,
s
=
20
,
c
=
DU5
[
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
for
du
in
range
(
N_DUS
):
for
ab
in
range
(
N_ABS
):
color
=
ax
.
scatter
(
duab
[
du
][
ab
],
doms
,
s
=
20
,
c
=
DUs
[
du
][
iAB1
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
duab
[
du
][
ab
],
doms
,
s
=
20
,
c
=
DUs
[
du
][
iAB2
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
color
=
ax
.
scatter
(
duab
[
du
][
ab
],
doms
,
s
=
20
,
c
=
DUs
[
du
][
iAB3
],
norm
=
norma
,
marker
=
'
s
'
,
cmap
=
CustomCmap
);
cbar
=
plt
.
colorbar
(
color
)
cbar
.
ax
.
get_yaxis
().
set_ticks
([])
...
...
@@ -232,30 +213,25 @@ while check:
cbar
.
ax
.
text
(
3.5
,
(
2
*
j
+
1
)
/
8.0
,
lab
,
ha
=
'
center
'
,
va
=
'
center
'
)
cbar
.
ax
.
get_yaxis
().
labelpad
=
18
matplotlib
.
pyplot
.
xticks
(
np
.
arange
(
1
,
6
,
step
=
1
))
matplotlib
.
pyplot
.
xticks
(
np
.
arange
(
1
,
N_DUS
+
1
,
step
=
1
))
matplotlib
.
pyplot
.
yticks
(
np
.
arange
(
0
,
19
,
step
=
1
))
matplotlib
.
pyplot
.
grid
(
color
=
'
k
'
,
linestyle
=
'
-
'
,
linewidth
=
0.2
)
ax
.
set_xlabel
(
'
DUs
'
,
fontsize
=
18
)
ax
.
set_ylabel
(
'
Floors
'
,
fontsize
=
18
)
ts
=
now
+
3600
DATE
=
datetime
.
utcfromtimestamp
(
ts
).
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)
ax
.
set_title
(
r
'
%.16s Detection of the pings emitted by autonomous beacons
'
%
DATE
,
fontsize
=
10
)
# plt.show()
ax
.
set_title
(
r
'
%.16s Detection of the pings emitted by autonomous beacons
'
%
DATE
,
fontsize
=
10
)
my_path
=
os
.
path
.
abspath
(
directory
)
my_file
=
'
Online_Acoustic_Monitoring.png
'
fig
.
savefig
(
os
.
path
.
join
(
my_path
,
my_file
))
print
(
time
.
time
())
check
=
False
check_time
=
time
.
time
()
-
now
print
(
check_time
)
time
.
sleep
(
abs
(
TIT
-
check_time
))
check
=
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment