Skip to content

Commit

Permalink
Changed behaviour of start_step=0 to avoid confusion in average compu…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
doc78 committed Sep 25, 2024
1 parent 843188c commit caf9c73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ GRIB File: contains data starting from step 0 to 72 every 6 hours: 0,6,12,18,24,
Day 2: same as Day 1 starting from (24+24)-24=24: the step 24 will have a weight of 3, while steps 30,36 and 42 will be counted 6 times, and finally the step 48 will have a weight of 3.
- if start_step is zero or is not specified, the aggregation will start from 0
- if start_step is zero or is not specified, the aggregation will behave exactly as using start_step=24, so it will start from 1
### Accumulation
For precipitation values, accumulation over 6 or 24 hours is often performed. Here's an example of configuration and execution output in DEBUG mode.
Expand Down
4 changes: 2 additions & 2 deletions src/pyg2p/main/manipulation/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ def _average(self, values):
v_ord = collections.OrderedDict(sorted(dict((k.end_step, v_) for (k, v_) in values.items()).items(), key=lambda k: k))
if self._start == 0 or self._second_t_res:
iter_start = self._start
iter_end = self._end - self._aggregation_step + 2
iter_end = self._end - self._aggregation_step + 2 # CR: TODO: check if +2 instead of +1 is actually needed
else:
iter_start = self._start - self._aggregation_step
iter_end = self._end - self._aggregation_step + 1

for iter_ in range(iter_start, iter_end, self._aggregation_step):
if self._aggregation_halfweights or self._start == 0:
if self._aggregation_halfweights:
iter_from = iter_
iter_to = iter_ + self._aggregation_step + 1
else:
Expand Down

0 comments on commit caf9c73

Please sign in to comment.