-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from nsidc/nrt-like-v4
NRT Processing updates for G10016
- Loading branch information
Showing
19 changed files
with
404 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"""Wrapper around the nrt CLI to override platform start dates config | ||
This is a hack, and should be unnecessary once the code is refactored to make it | ||
easier to configure the platform start dates. | ||
""" | ||
|
||
import copy | ||
import datetime as dt | ||
from pathlib import Path | ||
from typing import get_args | ||
|
||
import click | ||
from pm_tb_data._types import Hemisphere | ||
|
||
from seaice_ecdr.cli.util import CLI_EXE_PATH, datetime_to_date, run_cmd | ||
from seaice_ecdr.constants import DEFAULT_BASE_NRT_OUTPUT_DIR | ||
from seaice_ecdr.platforms.config import NRT_PLATFORM_START_DATES_CONFIG_FILEPATH | ||
|
||
|
||
@click.command(name="daily-nrt") | ||
@click.option( | ||
"-d", | ||
"--date", | ||
required=True, | ||
type=click.DateTime(formats=("%Y-%m-%d", "%Y%m%d", "%Y.%m.%d")), | ||
callback=datetime_to_date, | ||
) | ||
@click.option( | ||
"--end-date", | ||
required=False, | ||
type=click.DateTime( | ||
formats=( | ||
"%Y-%m-%d", | ||
"%Y%m%d", | ||
"%Y.%m.%d", | ||
) | ||
), | ||
# Like `datetime_to_date` but allows `None`. | ||
callback=lambda _ctx, _param, value: value if value is None else value.date(), | ||
default=None, | ||
help="If given, run temporal composite for `--date` through this end date.", | ||
) | ||
@click.option( | ||
"-h", | ||
"--hemisphere", | ||
required=True, | ||
type=click.Choice(get_args(Hemisphere)), | ||
) | ||
@click.option( | ||
"--base-output-dir", | ||
required=True, | ||
type=click.Path( | ||
exists=True, | ||
file_okay=False, | ||
dir_okay=True, | ||
writable=True, | ||
resolve_path=True, | ||
path_type=Path, | ||
), | ||
default=DEFAULT_BASE_NRT_OUTPUT_DIR, | ||
help=( | ||
"Base output directory for NRT ECDR outputs." | ||
" Subdirectories are created for outputs of" | ||
" different stages of processing." | ||
), | ||
show_default=True, | ||
) | ||
@click.option( | ||
"--overwrite", | ||
is_flag=True, | ||
help=("Overwrite intermediate and final outputs."), | ||
) | ||
def cli( | ||
*, | ||
date: dt.date, | ||
end_date: dt.date | None, | ||
hemisphere: Hemisphere, | ||
base_output_dir: Path, | ||
overwrite: bool, | ||
): | ||
if end_date is None: | ||
end_date = copy.copy(date) | ||
|
||
overwrite_str = " --overwrite" if overwrite else "" | ||
|
||
run_cmd( | ||
f"export PLATFORM_START_DATES_CONFIG_FILEPATH={NRT_PLATFORM_START_DATES_CONFIG_FILEPATH} &&" | ||
f"{CLI_EXE_PATH} nrt" | ||
f" --hemisphere {hemisphere}" | ||
f" --base-output-dir {base_output_dir}" | ||
f" --date {date:%Y-%m-%d}" | ||
f" --end-date {end_date:%Y-%m-%d}" + overwrite_str | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cdr_platform_start_dates: | ||
# We only use F18 for NRT. | ||
- platform_id: "F18" | ||
# This appears to be the first date of data in NSIDC0080. | ||
start_date: "2021-11-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.