Skip to content

Commit 11f0ed4

Browse files
committed
Forcing thumbnail location save
1 parent 0860bc9 commit 11f0ed4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/psup_stac_converter/omega/_base.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime as dt
22
import json
33
import logging
4+
from pathlib import Path
45
from typing import Any, Literal, cast
56
from zoneinfo import ZoneInfo
67

@@ -518,6 +519,7 @@ def create_stac_item(self, orbit_cube_idx: str, **kwargs) -> pystac.Item:
518519
orbit_cube_idx=orbit_cube_idx,
519520
data=select_rgb_from_xarr(nc_data),
520521
dims=self.thumbnail_dims,
522+
thumbnail_location=thumbnail_location,
521523
)
522524

523525
# Thumbnail
@@ -759,6 +761,7 @@ def make_thumbnail(
759761
mode: Literal["L", "RGB", "RGBA"] = "RGB",
760762
cmap: str | None = None, # left at none for composite
761763
fmt: str = "png",
764+
thumbnail_location: Path | None = None,
762765
):
763766
"""Creates a thumbnail for a datacube out of one of its 2D data arrays.
764767
@@ -774,7 +777,14 @@ def make_thumbnail(
774777
thumbnail = convert_arr_to_thumbnail(
775778
data=data, resize_dims=dims, mode=mode, cmap=cmap
776779
)
777-
self.log.debug(f"""Saving as {orbit_cube_idx}_{dims[0]}x{dims[1]}.{fmt}""")
778-
thumbnail.save(
779-
self.thumbnail_folder / f"{orbit_cube_idx}_{dims[0]}x{dims[1]}.{fmt}"
780-
)
780+
781+
if thumbnail_location is None:
782+
thumbnail_location = (
783+
self.thumbnail_folder / f"{orbit_cube_idx}_{dims[0]}x{dims[1]}.{fmt}"
784+
)
785+
self.log.debug(
786+
f"`thumbnail_location` not defined. Saving at {thumbnail_location.resolve()}"
787+
)
788+
789+
self.log.debug(f"""Saving as {thumbnail_location.resolve()}""")
790+
thumbnail.save(thumbnail_location)

0 commit comments

Comments
 (0)