Skip to content

Commit 85f64eb

Browse files
committed
Select/deselect stations before looping over entire list
This clears up log.
1 parent 938aa3f commit 85f64eb

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

schimpy/batch_metrics.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,21 @@ def plot(self):
463463
"station, RMSE, lag, bias, NSE, Willmott_skill, Correlation\n"
464464
)
465465

466+
if selected_stations is not None:
467+
idx = pd.IndexSlice
468+
sim_outputs[0] = sim_outputs[0].loc[:, idx[selected_stations, :]]
469+
self.logger.info("==================================================")
470+
self.logger.info("'selected_stations' enabled. Only following will be processed.")
471+
for station_id in selected_stations:
472+
self.logger.info(" {}".format(station_id))
473+
474+
if excluded_stations is not None:
475+
sim_outputs[0] = sim_outputs[0].loc[:, idx[~sim_outputs[0].columns.get_level_values(0).isin(excluded_stations), :]]
476+
self.logger.info("==================================================")
477+
self.logger.info("'excluded_stations' enabled. Following will be skipped.")
478+
for station_id in excluded_stations:
479+
self.logger.info(" {}".format(station_id))
480+
466481
# Iterate through the stations in the first simulation outputs
467482
for stn in sim_outputs[0].columns:
468483
station_id = stn[0].lower() if type(stn) == tuple else stn.lower()
@@ -471,21 +486,6 @@ def plot(self):
471486

472487
self.logger.info("Start processing station: {}".format(station_id))
473488

474-
if selected_stations is not None:
475-
if station_id not in selected_stations:
476-
self.logger.info(
477-
"Skipping..." " Not in the list of the selected stations: %s",
478-
station_id,
479-
)
480-
continue
481-
if excluded_stations is not None:
482-
if station_id in excluded_stations:
483-
self.logger.info(
484-
"Skipping... " "In the list of the excluded stations: %s",
485-
station_id,
486-
)
487-
continue
488-
489489
if not station_id.lower() in db_stations.index:
490490
self.logger.warning(
491491
"Station id {} not found in station listings ({})".format(

0 commit comments

Comments
 (0)