Skip to content

Commit 6c61196

Browse files
authored
Fix no init/valid time support (#1201)
* Fix no init/valid time support Fix #1200 * adapted docstrings
1 parent d7758e3 commit 6c61196

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

mslib/mswms/mss_2D_sections.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,17 @@ def uses_elevation_dimension(self):
135135

136136
def uses_inittime_dimension(self):
137137
"""
138-
Returns whether this layer uses the WMS inittime dimension. If False,
138+
Returns whether this layer uses the inittime dimension. If False,
139139
init_time does not have to be specified to plot_hsection().
140-
141-
Currently redirected to check for valid_time.
142140
"""
143-
return self.driver.uses_validtime_dimension() if self.driver is not None else False
141+
return self.driver.uses_inittime_dimension() if self.driver is not None else False
144142

145143
def uses_validtime_dimension(self):
146144
"""
147-
Returns whether this layer uses the WMS time dimension. If False,
148-
valid_time does not have to be specified to
149-
plot_hsection().
150-
151-
Currently implemented by testing whether the style requires data fields
152-
from the ECMWF forecast.
145+
Returns whether this layer uses the WMS (valid) time dimension. If False,
146+
valid_time does not have to be specified to plot_hsection().
153147
"""
154-
return self.driver.uses_inittime_dimension() if self.driver is not None else False
148+
return self.driver.uses_validtime_dimension() if self.driver is not None else False
155149

156150
def get_elevations(self):
157151
"""

mslib/mswms/mss_plot_driver.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,15 @@ def _set_time(self, init_time, fc_time):
102102
self.vert_units = None
103103
return
104104

105-
if fc_time < init_time:
106-
msg = "Forecast valid time cannot be earlier than " \
107-
"initialisation time."
108-
logging.error(msg)
109-
raise ValueError(msg)
110-
fc_step = fc_time - init_time
111-
fc_step = fc_step.days * 24 + (fc_step.seconds // 3600)
105+
if self.uses_inittime_dimension():
106+
logging.debug("\trequested initialisation time %s", init_time)
107+
if fc_time < init_time:
108+
msg = "Forecast valid time cannot be earlier than " \
109+
"initialisation time."
110+
logging.error(msg)
111+
raise ValueError(msg)
112112
self.fc_time = fc_time
113-
logging.debug("\trequested initialisation time %s", init_time)
114-
logging.debug("\trequested forecast valid time %s (step %s hrs)", fc_time, fc_step)
113+
logging.debug("\trequested forecast valid time %s", fc_time)
115114

116115
# Check if a dataset is open and if it contains the requested times.
117116
# (a dataset will only be open if the used layer has not changed,

0 commit comments

Comments
 (0)