Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
MetObs
AossTower
Commits
6ac0019f
Unverified
Commit
6ac0019f
authored
7 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Add temperature and dewpoint specific plot maker
parent
02227946
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
aosstower/tower_quicklooks/create_quicklook.py
+66
-30
66 additions, 30 deletions
aosstower/tower_quicklooks/create_quicklook.py
with
66 additions
and
30 deletions
aosstower/tower_quicklooks/create_quicklook.py
+
66
−
30
View file @
6ac0019f
...
@@ -66,7 +66,7 @@ class PlotMaker(object):
...
@@ -66,7 +66,7 @@ class PlotMaker(object):
new_ticks
=
np
.
arange
(
ymin
,
(
ymin
+
delta
*
num_plots
),
delta
)
new_ticks
=
np
.
arange
(
ymin
,
(
ymin
+
delta
*
num_plots
),
delta
)
return
new_ticks
return
new_ticks
def
get_ylabel
(
self
,
is_subplot
=
False
):
def
_
get_ylabel
(
self
,
is_subplot
=
False
):
y_label
=
TITLES
.
get
(
self
.
name
,
self
.
name
.
replace
(
'
_
'
,
'
'
).
title
())
y_label
=
TITLES
.
get
(
self
.
name
,
self
.
name
.
replace
(
'
_
'
,
'
'
).
title
())
if
is_subplot
:
if
is_subplot
:
return
None
return
None
...
@@ -74,16 +74,25 @@ class PlotMaker(object):
...
@@ -74,16 +74,25 @@ class PlotMaker(object):
return
"
{} ({})
"
.
format
(
y_label
,
self
.
units
)
return
"
{} ({})
"
.
format
(
y_label
,
self
.
units
)
return
y_label
return
y_label
def
create_plot
(
self
,
frame
,
fig
,
start_time
=
None
,
end_time
=
None
,
def
_set_ylabel
(
self
,
ax
,
is_subplot
=
False
):
is_subplot
=
None
,
shared_x
=
None
,
title
=
None
):
y_label
=
self
.
_get_ylabel
(
is_subplot
)
"""
if
y_label
and
not
is_subplot
:
ax
.
set_ylabel
(
y_label
)
:param frame:
def
_call_plot
(
self
,
frame
,
ax
):
:param fig:
lines
=
ax
.
plot
(
frame
.
index
,
frame
,
'
k
'
)
:param is_subplot: None or (num plots, num columns, num_rows)
return
lines
:param shared_x:
:return:
def
_set_ylim
(
self
,
frame
,
ax
):
"""
ymin
=
np
.
floor
(
frame
.
min
().
min
())
ymax
=
np
.
ceil
(
frame
.
max
().
max
())
if
ymin
==
ymax
:
ax
.
set_ylim
(
ymin
,
ymax
+
0.1
)
else
:
ax
.
set_ylim
(
ymin
,
ymax
)
return
ymin
,
ymax
def
_set_title
(
self
,
frame
,
fig
,
ax
,
start_time
=
None
,
end_time
=
None
,
title
=
None
,
is_subplot
=
None
):
if
start_time
is
None
:
if
start_time
is
None
:
start_time
=
frame
.
index
[
0
].
to_pydatetime
()
start_time
=
frame
.
index
[
0
].
to_pydatetime
()
if
end_time
is
None
:
if
end_time
is
None
:
...
@@ -92,37 +101,62 @@ class PlotMaker(object):
...
@@ -92,37 +101,62 @@ class PlotMaker(object):
title
=
self
.
get_title
(
frame
,
is_subplot
,
start_time
,
end_time
)
title
=
self
.
get_title
(
frame
,
is_subplot
,
start_time
,
end_time
)
if
is_subplot
:
if
is_subplot
:
ax
=
fig
.
add_subplot
(
*
is_subplot
,
sharex
=
shared_x
)
ax
.
set_title
(
title
,
x
=
0.5
,
y
=
get_subtitle_location
(
is_subplot
[
0
]),
fontsize
=
8
)
ax
.
set_title
(
title
,
x
=
0.5
,
y
=
get_subtitle_location
(
is_subplot
[
0
]),
fontsize
=
8
)
else
:
else
:
ax
=
fig
.
add_subplot
(
111
,
sharex
=
shared_x
)
fig
.
suptitle
(
title
,
fontsize
=
13
)
fig
.
suptitle
(
title
,
fontsize
=
13
)
y_label
=
self
.
get_ylabel
(
is_subplot
)
if
y_label
:
ax
.
set_ylabel
(
y_label
)
plt
.
sca
(
ax
)
# get the min for each column then combine them assuming we can
specific_frame
=
frame
[[
x
for
x
in
frame
.
columns
if
x
in
self
.
deps
]]
ymin
=
np
.
floor
(
specific_frame
.
min
().
min
())
ymax
=
np
.
ceil
(
specific_frame
.
max
().
max
())
ax
.
plot
(
specific_frame
.
index
,
specific_frame
,
'
k
'
)
def
_get_axes
(
self
,
fig
,
is_subplot
,
shared_x
=
None
):
if
ymin
==
ymax
:
if
is_subplot
:
ax
.
set_ylim
(
ymin
,
ymax
+
0.1
)
ax
=
fig
.
add_subplot
(
*
is_subplot
,
sharex
=
shared_x
)
else
:
else
:
ax
.
set_ylim
(
ymin
,
ymax
)
ax
=
fig
.
add_subplot
(
111
,
sharex
=
shared_x
)
plt
.
sca
(
ax
)
return
ax
def
_set_xlabel
(
self
,
ax
,
is_subplot
):
if
not
is_subplot
:
ax
.
set_xlabel
(
'
Time (UTC)
'
)
def
_set_yticks
(
self
,
ax
,
ymin
,
ymax
,
is_subplot
):
if
is_subplot
:
if
is_subplot
:
new_ticks
=
self
.
get_yticks
(
ymin
,
ymax
,
is_subplot
[
0
])
new_ticks
=
self
.
get_yticks
(
ymin
,
ymax
,
is_subplot
[
0
])
ax
.
get_yaxis
().
get_major_ticks
()[
-
1
].
set_visible
(
False
)
ax
.
get_yaxis
().
get_major_ticks
()[
-
1
].
set_visible
(
False
)
ax
.
set_yticks
(
new_ticks
)
ax
.
set_yticks
(
new_ticks
)
else
:
ax
.
set_xlabel
(
'
Time (UTC)
'
)
def
create_plot
(
self
,
frame
,
fig
,
start_time
=
None
,
end_time
=
None
,
is_subplot
=
None
,
shared_x
=
None
,
title
=
None
):
"""
:param frame:
:param fig:
:param is_subplot: None or (num plots, num columns, num_rows)
:param shared_x:
:return:
"""
ax
=
self
.
_get_axes
(
fig
,
is_subplot
,
shared_x
)
self
.
_set_title
(
frame
,
fig
,
ax
,
start_time
=
start_time
,
end_time
=
end_time
,
title
=
title
,
is_subplot
=
is_subplot
)
# get the min for each column then combine them assuming we can
specific_frame
=
frame
[[
x
for
x
in
frame
.
columns
if
x
in
self
.
deps
]]
lines
=
self
.
_call_plot
(
specific_frame
,
ax
)
ymin
,
ymax
=
self
.
_set_ylim
(
specific_frame
,
ax
)
self
.
_set_yticks
(
ax
,
ymin
,
ymax
,
is_subplot
)
self
.
_set_xlabel
(
ax
,
is_subplot
)
self
.
_set_ylabel
(
ax
,
is_subplot
)
return
ax
return
ax
class
TDPlotMaker
(
PlotMaker
):
def
_call_plot
(
self
,
frame
,
ax
):
air_temp
=
self
.
deps
[
0
]
dewpoint
=
self
.
deps
[
1
]
ax
.
plot
(
frame
.
index
,
frame
[
air_temp
],
'
r
'
,
frame
.
index
,
frame
[
dewpoint
],
'
g
'
)
class
MeteorogramPlotMaker
(
PlotMaker
):
class
MeteorogramPlotMaker
(
PlotMaker
):
def
__init__
(
self
,
name
,
dependencies
,
plot_deps
=
None
,
title
=
None
):
def
__init__
(
self
,
name
,
dependencies
,
plot_deps
=
None
,
title
=
None
):
self
.
plot_deps
=
plot_deps
self
.
plot_deps
=
plot_deps
...
@@ -153,9 +187,11 @@ class MeteorogramPlotMaker(PlotMaker):
...
@@ -153,9 +187,11 @@ class MeteorogramPlotMaker(PlotMaker):
if
idx
==
0
:
if
idx
==
0
:
shared_x
=
ax
shared_x
=
ax
if
idx
!=
num_plots
-
1
:
if
idx
!=
num_plots
-
1
:
print
(
"
Disabling
"
)
# Disable the x-axis ticks so we don't interfere with other subplots
# Disable the x-axis ticks so we don't interfere with other subplots
ax
.
get_xaxis
().
get_major_ticks
()[
-
1
].
set_visible
(
False
)
ax
.
set_xticklabels
([
''
]
*
len
(
ax
.
get_xticklabels
()))
ax
.
get_xaxis
().
get_major_ticks
()[
0
].
set_visible
(
False
)
# ax.get_xaxis().get_major_ticks()[-1].set_visible(False)
# ax.get_xaxis().get_major_ticks()[0].set_visible(False)
ax
.
set_xlabel
(
'
Time (UTC)
'
)
ax
.
set_xlabel
(
'
Time (UTC)
'
)
fig
.
subplots_adjust
(
hspace
=
0
,
bottom
=
0.125
)
fig
.
subplots_adjust
(
hspace
=
0
,
bottom
=
0.125
)
...
@@ -167,7 +203,7 @@ PLOT_TYPES = {
...
@@ -167,7 +203,7 @@ PLOT_TYPES = {
'
meteorogram
'
:
MeteorogramPlotMaker
(
'
meteorogram
'
,
'
meteorogram
'
:
MeteorogramPlotMaker
(
'
meteorogram
'
,
(
'
air_temp
'
,
'
dewpoint
'
,
'
rh
'
,
'
wind_speed
'
,
'
wind_dir
'
,
'
accum_precip
'
),
(
'
air_temp
'
,
'
dewpoint
'
,
'
rh
'
,
'
wind_speed
'
,
'
wind_dir
'
,
'
accum_precip
'
),
(
'
td
'
,
'
rh
'
,
'
wind_speed
'
,
'
wind_dir
'
,
'
accum_precip
'
)),
(
'
td
'
,
'
rh
'
,
'
wind_speed
'
,
'
wind_dir
'
,
'
accum_precip
'
)),
'
td
'
:
PlotMaker
(
'
td
'
,
(
'
air_temp
'
,
'
dewpoint
'
),
units
=
"
°C
"
),
# air_temp and dewpoint in one plot
'
td
'
:
TD
PlotMaker
(
'
td
'
,
(
'
air_temp
'
,
'
dewpoint
'
),
units
=
"
°C
"
),
# air_temp and dewpoint in one plot
'
wind_dir
'
:
PlotMaker
(
'
wind_dir
'
,
(
'
wind_dir
'
,),
units
=
'
°
'
),
# special tick labels
'
wind_dir
'
:
PlotMaker
(
'
wind_dir
'
,
(
'
wind_dir
'
,),
units
=
'
°
'
),
# special tick labels
'
rh
'
:
PlotMaker
(
'
rh
'
,
(
'
rh
'
,),
units
=
'
%
'
),
'
rh
'
:
PlotMaker
(
'
rh
'
,
(
'
rh
'
,),
units
=
'
%
'
),
'
air_temp
'
:
PlotMaker
(
'
air_temp
'
,
(
'
air_temp
'
,),
units
=
'
°C
'
),
'
air_temp
'
:
PlotMaker
(
'
air_temp
'
,
(
'
air_temp
'
,),
units
=
'
°C
'
),
...
...
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