Skip to content

Commit

Permalink
Replace assert for warning and take only dates newer as existing dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
frandorr committed Feb 15, 2022
1 parent ab9d7d8 commit 962460b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/satextractor/preparer/preparer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import zarr
from loguru import logger
from zarr.errors import ArrayNotFoundError
from zarr.errors import ContainsArrayError
from zarr.errors import ContainsGroupError
Expand Down Expand Up @@ -71,14 +72,17 @@ def create_zarr_patch_structure(
],
)

new_timesteps = np.array(sensing_times)[
~np.isin(sensing_times, existing_timestamps)
]

if new_timesteps.shape[0] > 0:
assert max(existing_timestamps) <= min(
new_timesteps,
), "Sat-Extractor can only append more recent data or overwrite existing data. "
max_existing = max(existing_timestamps)
new_timesteps = np.array(sensing_times)[sensing_times > max_existing]

if new_timesteps.size != sensing_times.size:
logger.warning(
f"""
Sat-Extractor can only append more recent data or overwrite existing data.
Maximum existing date is {max_existing}
and minimum new_timestep is {min(sensing_times)}.
""",
)

# get union of sensing times
timestamps_union = np.union1d(existing_timestamps, sensing_times)
Expand Down

0 comments on commit 962460b

Please sign in to comment.