Skip to content

Commit d208092

Browse files
dtpcDave Cole
andauthored
Add support for monthly statistics (#189)
Co-authored-by: Dave Cole <david.cole@csiro.au>
1 parent 5d74c94 commit d208092

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

odc/stats/_cli_save_tasks.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@
2121
"optional_products",
2222
]
2323

24+
SUPPORTED_FREQUENCY = [
25+
"annual",
26+
"annual-fy",
27+
"semiannual",
28+
"seasonal",
29+
"quartely",
30+
"3month-seasons",
31+
"rolling-3months",
32+
"nov-mar",
33+
"apr-oct",
34+
"monthly",
35+
"all",
36+
]
37+
2438

2539
@main.command("save-tasks")
2640
@click.option(
@@ -51,10 +65,7 @@
5165
@click.option(
5266
"--frequency",
5367
type=str,
54-
help=(
55-
"Specify temporal binning: "
56-
"annual|annual-fy|semiannual|seasonal|quartely|3month-seasons|rolling-3months|nov-mar|apr-oct|all"
57-
),
68+
help=f"Specify temporal binning: {'|'.join(SUPPORTED_FREQUENCY)}",
5869
)
5970
@click.option("--env", "-E", type=str, help="Datacube environment name")
6071
@click.option(
@@ -198,21 +209,9 @@ def save_tasks(
198209
sys.exit(1)
199210

200211
if _cfg.get("frequency") is not None:
201-
if _cfg.get("frequency") not in (
202-
"annual",
203-
"annual-fy",
204-
"semiannual",
205-
"seasonal",
206-
"quartely",
207-
"3month-seasons",
208-
"rolling-3months",
209-
"nov-mar",
210-
"apr-oct",
211-
"all",
212-
):
212+
if _cfg.get("frequency") not in SUPPORTED_FREQUENCY:
213213
print(
214-
f"""Frequency must be one of annual|annual-fy|semiannual|seasonal|
215-
quartely|3month-seasons|rolling-3months|nov-mar|apr-oct|all
214+
f"""Frequency must be one of {'|'.join(SUPPORTED_FREQUENCY)}
216215
and not '{frequency}'""",
217216
file=sys.stderr,
218217
)

odc/stats/tasks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ def msg_default(msg):
616616
tasks = bin_seasonal(cells, months=12, anchor=7)
617617
elif self._frequency == "annual":
618618
tasks = bin_annual(cells)
619+
elif self._frequency == "monthly":
620+
tasks = bin_seasonal(cells, months=1, anchor=1)
619621
elif temporal_range is not None:
620622
tasks = bin_generic(cells, [temporal_range])
621623
else:

0 commit comments

Comments
 (0)