Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
atdb_plot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nico Vermaas
atdb_plot
Commits
f046e0b4
Commit
f046e0b4
authored
5 years ago
by
Nico Vermaas
Browse files
Options
Downloads
Patches
Plain Diff
adding 'time used' pie chart presentation based on new ATDB query
parent
3b16656d
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
atdb_statistics/atdb_plot.py
+39
-0
39 additions, 0 deletions
atdb_statistics/atdb_plot.py
atdb_stats.py
+35
-0
35 additions, 0 deletions
atdb_stats.py
data/time_used_july_vm.args
+5
-0
5 additions, 0 deletions
data/time_used_july_vm.args
data/time_used_june_vm.args
+5
-0
5 additions, 0 deletions
data/time_used_june_vm.args
with
84 additions
and
0 deletions
atdb_statistics/atdb_plot.py
+
39
−
0
View file @
f046e0b4
...
@@ -397,3 +397,42 @@ def do_speeds_plot(title, y_axis_title, subtitle, annotate, datapoints):
...
@@ -397,3 +397,42 @@ def do_speeds_plot(title, y_axis_title, subtitle, annotate, datapoints):
plt
.
legend
(
loc
=
'
upper right
'
)
plt
.
legend
(
loc
=
'
upper right
'
)
plt
.
show
()
plt
.
show
()
def
do_time_used_plot
(
title
,
subtitle
,
data
):
"""
:param title: Title of Plot
:param x: dict with data for x-axis (time)
:param y: dict with data for y_axix (usage)
:return:
"""
total_minutes
=
data
[
'
total_minutes
'
]
time_on_sky
=
data
[
'
time-on-sky-overview
'
][
'
was_archived
'
]
imaging_minutes
=
time_on_sky
[
'
imaging_minutes
'
]
arts_minutes
=
time_on_sky
[
'
arts_minutes
'
]
system_minutes
=
time_on_sky
[
'
system_minutes
'
]
imaging_fraction
=
int
(
imaging_minutes
/
total_minutes
*
100
)
arts_fraction
=
int
(
arts_minutes
/
total_minutes
*
100
)
system_fraction
=
int
(
system_minutes
/
total_minutes
*
100
)
idle_fraction
=
100
-
(
imaging_fraction
+
arts_fraction
+
system_fraction
)
# Pie chart, where the slices will be ordered and plotted counter-clockwise:
fig
=
plt
.
figure
(
figsize
=
(
12
,
6
))
labels
=
'
Imaging (archived)
'
,
'
ARTS (archived)
'
,
'
other
'
,
'
system
'
sizes
=
[
imaging_fraction
,
arts_fraction
,
idle_fraction
,
system_fraction
]
explode
=
(
0.1
,
0.1
,
0
,
0
)
# only "explode" the 2nd slice (i.e. 'Hogs')
#fig1, ax1 = plt.subplots()
plt
.
pie
(
sizes
,
explode
=
explode
,
labels
=
labels
,
autopct
=
'
%1.1f%%
'
,
shadow
=
True
,
startangle
=
90
)
plt
.
axis
(
'
equal
'
)
# Equal aspect ratio ensures that pie is drawn as a circle.
plt
.
title
(
title
)
plt
.
grid
(
True
,
alpha
=
0.3
)
plt
.
legend
(
loc
=
'
upper right
'
)
plt
.
show
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
atdb_stats.py
+
35
−
0
View file @
f046e0b4
...
@@ -370,6 +370,38 @@ def do_speeds(args):
...
@@ -370,6 +370,38 @@ def do_speeds(args):
atdb_plot
.
do_speeds_plot
(
args
.
title
,
args
.
y_axis_title
,
args
.
subtitle
,
args
.
annotate
,
datapoints
)
atdb_plot
.
do_speeds_plot
(
args
.
title
,
args
.
y_axis_title
,
args
.
subtitle
,
args
.
annotate
,
datapoints
)
@timeit
def
do_time_used
(
args
):
# The request header
ATDB_HEADER
=
{
'
content-type
'
:
"
application/json
"
,
'
cache-control
'
:
"
no-cache
"
,
'
authorization
'
:
"
Basic YWRtaW46YWRtaW4=
"
}
# input parameters
url
=
args
.
atdb_host
+
"
/time-used?
"
+
str
(
args
.
query
)
# do the request to the ATDB backend
print
(
'
request to
'
+
url
)
response
=
requests
.
request
(
"
GET
"
,
url
,
headers
=
ATDB_HEADER
)
# parse the response
try
:
json_response
=
json
.
loads
(
response
.
text
)
time_used_data
=
json_response
[
"
time_used_data
"
]
except
Exception
as
err
:
print
(
"
Exception :
"
+
str
(
err
))
raise
(
Exception
(
"
ERROR:
"
+
str
(
response
.
status_code
)
+
"
,
"
+
str
(
response
.
reason
)
+
'
,
'
+
str
(
response
.
content
)))
# plot the results
atdb_plot
.
do_time_used_plot
(
args
.
title
,
args
.
y_axis_title
,
time_used_data
)
def
get_arguments
(
parser
):
def
get_arguments
(
parser
):
"""
"""
Gets the arguments with which this application is called and returns the parsed arguments.
Gets the arguments with which this application is called and returns the parsed arguments.
...
@@ -563,6 +595,9 @@ def main():
...
@@ -563,6 +595,9 @@ def main():
elif
presentation
==
"
speeds
"
:
elif
presentation
==
"
speeds
"
:
do_speeds
(
args
)
do_speeds
(
args
)
elif
presentation
==
"
time_used
"
:
do_time_used
(
args
)
if
args
.
remote_post_command
!=
None
:
if
args
.
remote_post_command
!=
None
:
execute_remote_command
(
args
.
atdb_host
,
args
.
remote_post_command
)
execute_remote_command
(
args
.
atdb_host
,
args
.
remote_post_command
)
...
...
This diff is collapsed.
Click to expand it.
data/time_used_july_vm.args
0 → 100644
+
5
−
0
View file @
f046e0b4
--presentation=time_used
--atdb_host=http://192.168.22.22/atdb
--title=APERTIF On Sky - July 2019
--subtitle=July 2019
--query=from=2019-07-01&to=2019-07-30
\ No newline at end of file
This diff is collapsed.
Click to expand it.
data/time_used_june_vm.args
0 → 100644
+
5
−
0
View file @
f046e0b4
--presentation=time_used
--atdb_host=http://192.168.22.22/atdb
--title=APERTIF Observing Times - June 2019
--subtitle=June 2019
--query=from=2019-06-01&to=2019-06-30
\ No newline at end of file
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