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
066257d4
Unverified
Commit
066257d4
authored
7 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Add wind direction specific plot maker and other fixes
parent
6ac0019f
No related branches found
Branches containing commit
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
+44
-13
44 additions, 13 deletions
aosstower/tower_quicklooks/create_quicklook.py
with
44 additions
and
13 deletions
aosstower/tower_quicklooks/create_quicklook.py
+
44
−
13
View file @
066257d4
...
@@ -10,6 +10,7 @@ import matplotlib.dates as md
...
@@ -10,6 +10,7 @@ import matplotlib.dates as md
import
math
import
math
LOG
=
logging
.
getLogger
(
__name__
)
LOG
=
logging
.
getLogger
(
__name__
)
FIGURE_TITLE_SIZE
=
13
# names of the plots used in title (default is `.title()` of plot name)
# names of the plots used in title (default is `.title()` of plot name)
TITLES
=
{
TITLES
=
{
...
@@ -86,10 +87,11 @@ class PlotMaker(object):
...
@@ -86,10 +87,11 @@ class PlotMaker(object):
def
_set_ylim
(
self
,
frame
,
ax
):
def
_set_ylim
(
self
,
frame
,
ax
):
ymin
=
np
.
floor
(
frame
.
min
().
min
())
ymin
=
np
.
floor
(
frame
.
min
().
min
())
ymax
=
np
.
ceil
(
frame
.
max
().
max
())
ymax
=
np
.
ceil
(
frame
.
max
().
max
())
delta
=
ymax
-
ymin
if
ymin
==
ymax
:
if
ymin
==
ymax
:
ax
.
set_ylim
(
ymin
,
ymax
+
0.1
)
ax
.
set_ylim
(
ymin
-
0.1
,
ymax
+
0.1
)
else
:
else
:
ax
.
set_ylim
(
ymin
,
ymax
)
ax
.
set_ylim
(
ymin
-
delta
*
0.2
,
ymax
+
delta
*
0.2
)
return
ymin
,
ymax
return
ymin
,
ymax
def
_set_title
(
self
,
frame
,
fig
,
ax
,
start_time
=
None
,
end_time
=
None
,
title
=
None
,
is_subplot
=
None
):
def
_set_title
(
self
,
frame
,
fig
,
ax
,
start_time
=
None
,
end_time
=
None
,
title
=
None
,
is_subplot
=
None
):
...
@@ -103,7 +105,7 @@ class PlotMaker(object):
...
@@ -103,7 +105,7 @@ class PlotMaker(object):
if
is_subplot
:
if
is_subplot
:
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
:
fig
.
suptitle
(
title
,
fontsize
=
13
)
fig
.
suptitle
(
title
,
fontsize
=
FIGURE_TITLE_SIZE
)
def
_get_axes
(
self
,
fig
,
is_subplot
,
shared_x
=
None
):
def
_get_axes
(
self
,
fig
,
is_subplot
,
shared_x
=
None
):
if
is_subplot
:
if
is_subplot
:
...
@@ -120,7 +122,7 @@ class PlotMaker(object):
...
@@ -120,7 +122,7 @@ class PlotMaker(object):
def
_set_yticks
(
self
,
ax
,
ymin
,
ymax
,
is_subplot
):
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.yaxis.get_major_ticks()[-1].set_visible(False)
ax
.
set_yticks
(
new_ticks
)
ax
.
set_yticks
(
new_ticks
)
def
create_plot
(
self
,
frame
,
fig
,
start_time
=
None
,
end_time
=
None
,
def
create_plot
(
self
,
frame
,
fig
,
start_time
=
None
,
end_time
=
None
,
...
@@ -140,6 +142,8 @@ class PlotMaker(object):
...
@@ -140,6 +142,8 @@ class PlotMaker(object):
# get the min for each column then combine them assuming we can
# 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
]]
specific_frame
=
frame
[[
x
for
x
in
frame
.
columns
if
x
in
self
.
deps
]]
# make ticks show up on top and bottom inside and out of the axis line
ax
.
xaxis
.
set_tick_params
(
left
=
True
,
right
=
True
,
direction
=
'
inout
'
)
lines
=
self
.
_call_plot
(
specific_frame
,
ax
)
lines
=
self
.
_call_plot
(
specific_frame
,
ax
)
ymin
,
ymax
=
self
.
_set_ylim
(
specific_frame
,
ax
)
ymin
,
ymax
=
self
.
_set_ylim
(
specific_frame
,
ax
)
...
@@ -150,11 +154,36 @@ class PlotMaker(object):
...
@@ -150,11 +154,36 @@ class PlotMaker(object):
return
ax
return
ax
class
PrecipPlotMaker
(
PlotMaker
):
def
_set_ylim
(
self
,
frame
,
ax
):
ymin
=
0
ymax
=
np
.
ceil
(
frame
.
max
().
max
())
delta
=
ymax
-
ymin
# 0 is the minimum y-min we want
if
ymin
==
ymax
:
ax
.
set_ylim
(
ymin
,
ymax
+
0.2
)
else
:
ax
.
set_ylim
(
ymin
,
ymax
+
delta
*
0.2
)
return
ymin
,
ymax
class
TDPlotMaker
(
PlotMaker
):
class
TDPlotMaker
(
PlotMaker
):
def
_call_plot
(
self
,
frame
,
ax
):
def
_call_plot
(
self
,
frame
,
ax
):
air_temp
=
self
.
deps
[
0
]
air_temp
=
self
.
deps
[
0
]
dewpoint
=
self
.
deps
[
1
]
dewpoint
=
self
.
deps
[
1
]
ax
.
plot
(
frame
.
index
,
frame
[
air_temp
],
'
r
'
,
frame
.
index
,
frame
[
dewpoint
],
'
g
'
)
return
ax
.
plot
(
frame
.
index
,
frame
[
air_temp
],
'
r
'
,
frame
.
index
,
frame
[
dewpoint
],
'
g
'
)
class
WindDirPlotMaker
(
PlotMaker
):
def
_set_ylim
(
self
,
frame
,
ax
):
return
0
,
360
def
_set_yticks
(
self
,
ax
,
ymin
,
ymax
,
is_subplot
):
ax
.
yaxis
.
set_ticks
([
0
,
90
,
180
,
270
])
def
_call_plot
(
self
,
frame
,
ax
):
lines
=
ax
.
plot
(
frame
.
index
,
frame
,
'
k.
'
,
markersize
=
3
,
linewidth
=
0
)
return
lines
class
MeteorogramPlotMaker
(
PlotMaker
):
class
MeteorogramPlotMaker
(
PlotMaker
):
...
@@ -173,7 +202,7 @@ class MeteorogramPlotMaker(PlotMaker):
...
@@ -173,7 +202,7 @@ class MeteorogramPlotMaker(PlotMaker):
end_time
=
frame
.
index
[
-
1
].
to_pydatetime
()
end_time
=
frame
.
index
[
-
1
].
to_pydatetime
()
if
title
is
None
:
if
title
is
None
:
title
=
self
.
get_title
(
frame
,
False
,
start_time
,
end_time
)
title
=
self
.
get_title
(
frame
,
False
,
start_time
,
end_time
)
fig
.
suptitle
(
title
,
fontsize
=
13
)
fig
.
suptitle
(
title
,
fontsize
=
FIGURE_TITLE_SIZE
)
num_plots
=
len
(
self
.
plot_deps
)
num_plots
=
len
(
self
.
plot_deps
)
shared_x
=
None
shared_x
=
None
...
@@ -187,11 +216,13 @@ class MeteorogramPlotMaker(PlotMaker):
...
@@ -187,11 +216,13 @@ 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
.
set_xticklabels
([
''
]
*
len
(
ax
.
get_xticklabels
()))
kwargs
=
{
'
visible
'
:
False
}
# ax.get_xaxis().get_major_ticks()[-1].set_visible(False)
for
l
in
ax
.
get_xticklabels
():
# ax.get_xaxis().get_major_ticks()[0].set_visible(False)
l
.
update
(
kwargs
)
# make the top y-tick label invisible
# ax.yaxis.get_major_ticks()[-1].label1.update({'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
)
...
@@ -204,13 +235,13 @@ PLOT_TYPES = {
...
@@ -204,13 +235,13 @@ PLOT_TYPES = {
(
'
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
'
:
TDPlotMaker
(
'
td
'
,
(
'
air_temp
'
,
'
dewpoint
'
),
units
=
"
°C
"
),
# air_temp and dewpoint in one plot
'
td
'
:
TDPlotMaker
(
'
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
'
:
WindDir
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
'
),
'
pressure
'
:
PlotMaker
(
'
pressure
'
,
(
'
pressure
'
,),
units
=
'
hpa
'
),
'
pressure
'
:
PlotMaker
(
'
pressure
'
,
(
'
pressure
'
,),
units
=
'
hpa
'
),
'
dewpoint
'
:
PlotMaker
(
'
dewpoint
'
,
(
'
air_temp
'
,),
units
=
'
°C
'
),
'
dewpoint
'
:
PlotMaker
(
'
dewpoint
'
,
(
'
air_temp
'
,),
units
=
'
°C
'
),
'
wind_speed
'
:
PlotMaker
(
'
wind_speed
'
,
(
'
wind_speed
'
,),
units
=
'
m/s
'
),
'
wind_speed
'
:
PlotMaker
(
'
wind_speed
'
,
(
'
wind_speed
'
,),
units
=
'
m/s
'
),
'
accum_precip
'
:
PlotMaker
(
'
accum_precip
'
,
(
'
accum_precip
'
,),
units
=
'
mm
'
),
'
accum_precip
'
:
Precip
PlotMaker
(
'
accum_precip
'
,
(
'
accum_precip
'
,),
units
=
'
mm
'
),
'
solar_flux
'
:
PlotMaker
(
'
solar_flux
'
,
(
'
solar_flux
'
,),
units
=
'
W/m^2
'
),
'
solar_flux
'
:
PlotMaker
(
'
solar_flux
'
,
(
'
solar_flux
'
,),
units
=
'
W/m^2
'
),
}
}
...
@@ -488,7 +519,7 @@ def full_plot(fig, axes, dates, data, ymin, ymax,
...
@@ -488,7 +519,7 @@ def full_plot(fig, axes, dates, data, ymin, ymax,
# @param numSubPlots - number of subplots
# @param numSubPlots - number of subplots
# @return y-coordinate of subtitle
# @return y-coordinate of subtitle
def
get_subtitle_location
(
numSubPlots
):
def
get_subtitle_location
(
numSubPlots
):
return
1
-
0.05
*
numSubPlots
return
1
-
0.05
5
*
numSubPlots
def
create_full_plot
(
plot_names
,
frame
,
output
,
start_time
=
None
,
end_time
=
None
):
def
create_full_plot
(
plot_names
,
frame
,
output
,
start_time
=
None
,
end_time
=
None
):
...
...
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