Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bundle_adjust/ba_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def get_acquisition_date(geotiff_path):
with rasterio.open(geotiff_path) as src:
if "TIFFTAG_DATETIME" in src.tags().keys():
date_string = src.tags()["TIFFTAG_DATETIME"]
dt = datetime.datetime.strptime(date_string, "%Y:%m:%d %H:%M:%S")
try:
dt = datetime.datetime.strptime(date_string, "%Y:%m:%d %H:%M:%S")
except:
dt = datetime.datetime.strptime(date_string, "%Y:%m:%dT%H:%M:%S")
else:
# temporary fix in case the previous tag is missing
# get datetime from skysat geotiff identifier
Expand Down Expand Up @@ -189,7 +192,8 @@ def load_scene(self):
all_im_rpcs = []
all_im_datetimes = []

geotiff_paths = sorted(glob.glob(os.path.join(self.geotiff_dir, "**/*.tif"), recursive=True))
geotiff_paths = sorted(glob.glob(os.path.join(self.geotiff_dir, "**/*.[tT][iI][fF]"), recursive=True))
assert len(geotiff_paths) > 0, f"No GeoTiffs found in {self.geotiff_dir}."
if self.geotiff_label is not None:
geotiff_paths = [os.path.basename(fn) for fn in geotiff_paths if self.geotiff_label in fn]

Expand All @@ -205,7 +209,9 @@ def load_scene(self):
d = json.load(f)
rpc = rpcm.RPCModel(d, dict_format="rpcm")
elif self.rpc_src == "txt":
rpc = rpcm.rpc_from_rpc_file(os.path.join(self.rpc_dir, f_id + ".rpc"))
rpc_path = os.path.join(self.rpc_dir, f_id + ".rpc")
assert os.path.exists(rpc_path), f"{rpc_path} does not exist, make sure to use the <image name>.rpc for RPC files"
rpc = rpcm.rpc_from_rpc_file(rpc_path)
else:
raise ValueError("Unknown rpc_src value: {}".format(self.rpc_src))

Expand Down