Skip to content

Commit

Permalink
Merge pull request #172 from nsidc/support-both-hemis-ops-cli
Browse files Browse the repository at this point in the history
Support both hemis ops cli
  • Loading branch information
trey-stafford authored Nov 5, 2024
2 parents fe6cb9e + f265b2d commit c5c42d0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
9 changes: 4 additions & 5 deletions doc/operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ as an example.
To create daily data:

```
daily --start-date YYYY-MM-DD --end-date YYYY-MM-DD --hemisphere {north|south}
daily --start-date YYYY-MM-DD --end-date YYYY-MM-DD --hemisphere both
```

Once daily data for a year is available, this data should be aggregated with the
Expand All @@ -110,7 +110,7 @@ There will be one daily aggregate file per year per hemisphere.
When a month's worth of daily data is available, monthly data files can be produced:

```
monthly --year YYYY --month mm --hemisphere {north|south}
monthly --year YYYY --month mm --hemisphere both
```

A range of years/months can also be specified:
Expand All @@ -133,10 +133,9 @@ Each time finalized data is produced, the validation CLI should be run:


```
validate-outputs --hemisphere {north|south} --start-date YYYY-MM-DD --end-date YYYY-MM-DD
validate-outputs --hemisphere both --start-date YYYY-MM-DD --end-date YYYY-MM-DD
```

This produces log files in
`/share/apps/G02202_V5/v05r00_outputs/production/validation/` that should be
published to the production location. TODO: confirm this is accurate. Does not
look like v4 does this.
reviewed by the NOAA@NSIDC project manager responsible for the sea ice CDR.
32 changes: 19 additions & 13 deletions seaice_ecdr/cli/daily.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import datetime as dt
from pathlib import Path
from typing import get_args
from typing import Literal, get_args

import click
from pm_tb_data._types import Hemisphere
Expand Down Expand Up @@ -112,7 +112,7 @@ def make_25km_ecdr(
"-h",
"--hemisphere",
required=True,
type=click.Choice(get_args(Hemisphere)),
type=click.Choice([*get_args(Hemisphere), "both"]),
)
@click.option(
"--base-output-dir",
Expand Down Expand Up @@ -161,7 +161,7 @@ def cli(
*,
date: dt.date,
end_date: dt.date | None,
hemisphere: Hemisphere,
hemisphere: Hemisphere | Literal["both"],
base_output_dir: Path,
no_multiprocessing: bool,
resolution: ECDR_SUPPORTED_RESOLUTIONS,
Expand All @@ -171,16 +171,22 @@ def cli(
if end_date is None:
end_date = copy.copy(date)

make_25km_ecdr(
start_date=date,
end_date=end_date,
hemisphere=hemisphere,
base_output_dir=base_output_dir,
no_multiprocessing=no_multiprocessing,
resolution=resolution,
land_spillover_alg=land_spillover_alg,
ancillary_source=ancillary_source,
)
if hemisphere == "both":
hemispheres: list[Hemisphere] = ["north", "south"]
else:
hemispheres = [hemisphere]

for hemisphere in hemispheres:
make_25km_ecdr(
start_date=date,
end_date=end_date,
hemisphere=hemisphere,
base_output_dir=base_output_dir,
no_multiprocessing=no_multiprocessing,
resolution=resolution,
land_spillover_alg=land_spillover_alg,
ancillary_source=ancillary_source,
)


if __name__ == "__main__":
Expand Down
34 changes: 20 additions & 14 deletions seaice_ecdr/cli/monthly.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime as dt
from pathlib import Path
from typing import get_args
from typing import Literal, get_args

import click
import pandas as pd
Expand Down Expand Up @@ -122,7 +122,7 @@ def make_monthly_25km_ecdr(
"-h",
"--hemisphere",
required=True,
type=click.Choice(get_args(Hemisphere)),
type=click.Choice([*get_args(Hemisphere), "both"]),
)
@click.option(
"--base-output-dir",
Expand Down Expand Up @@ -167,7 +167,7 @@ def cli(
month: int,
end_year: int | None,
end_month: int | None,
hemisphere: Hemisphere,
hemisphere: Hemisphere | Literal["both"],
base_output_dir: Path,
resolution: ECDR_SUPPORTED_RESOLUTIONS,
land_spillover_alg: LAND_SPILL_ALGS,
Expand All @@ -180,17 +180,23 @@ def cli(
if end_month is None:
end_month = month

make_monthly_25km_ecdr(
year=year,
month=month,
end_year=end_year,
end_month=end_month,
hemisphere=hemisphere,
base_output_dir=base_output_dir,
resolution=resolution,
land_spillover_alg=land_spillover_alg,
ancillary_source=ancillary_source,
)
if hemisphere == "both":
hemispheres: list[Hemisphere] = ["north", "south"]
else:
hemispheres = [hemisphere]

for hemisphere in hemispheres:
make_monthly_25km_ecdr(
year=year,
month=month,
end_year=end_year,
end_month=end_month,
hemisphere=hemisphere,
base_output_dir=base_output_dir,
resolution=resolution,
land_spillover_alg=land_spillover_alg,
ancillary_source=ancillary_source,
)


if __name__ == "__main__":
Expand Down

0 comments on commit c5c42d0

Please sign in to comment.