Skip to content

Commit

Permalink
fix(sat): Update script to match VM (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
devsjc authored Dec 6, 2024
1 parent 5ba02bc commit 0af82d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
1 change: 1 addition & 0 deletions containers/sat/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ COPY --from=install-reqs /venv /venv
COPY . /app
WORKDIR /app
ENTRYPOINT ["/venv/bin/python3", "download_process_sat.py"]
VOLUME /mnt/disks/sat

30 changes: 8 additions & 22 deletions containers/sat/download_process_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,18 +603,12 @@ def _rewrite_zarr_times(output_name: str) -> None:
default="/mnt/disks/sat",
type=pathlib.Path,
)
range_group = parser.add_mutually_exclusive_group(
required=True,
)
range_group.add_argument(
parser.add_argument(
"--month", "-m",
help="Month to download data for (YYYY-MM)",
type=str,
)
range_group.add_argument(
"--day", "-d",
help="Day to download data for (YYYY-MM-DD)",
type=str,
required=True,
default=str(dt.datetime.now(tz=dt.UTC).strftime("%Y-%m")),
)
parser.add_argument(
"--delete_raw", "--rm",
Expand All @@ -635,19 +629,11 @@ def run(args: argparse.Namespace) -> None:
sat_config = CONFIGS[args.sat]

# Get start and end times for run
if args.month:
start: dt.datetime = dt.datetime.strptime(args.month, "%Y-%m")
end: dt.datetime = \
start.replace(month=start.month + 1) if start.month < 12 \
else start.replace(year=start.year + 1, month=1) \
- dt.timedelta(days=1)
elif args.day:
start = dt.datetime.strptime(args.day, "%Y-%m-%d")
end = start + dt.timedelta(days=1)
else:
log.error("Invalid args.")
return

start: dt.datetime = dt.datetime.strptime(args.month, "%Y-%m")
end: dt.datetime = \
start.replace(month=start.month + 1) if start.month < 12 \
else start.replace(year=start.year + 1, month=1) \
- dt.timedelta(days=1)
scan_times: list[pd.Timestamp] = pd.date_range(
start=start,
end=end,
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ dependencies = [
[project.optional-dependencies]
dev = [
"mypy == 1.7.1",
"types-PyYAML",
"types-pytz",
"types-requests",
"ruff == 0.1.7",
"unittest-xml-reporting == 3.2.0",
"pytest >= 7.4.1",
Expand Down

0 comments on commit 0af82d3

Please sign in to comment.