From e08f16ea7705301f582b9ce705569a20963e8aef Mon Sep 17 00:00:00 2001 From: David de Meij Date: Tue, 22 Nov 2022 15:49:02 +0000 Subject: [PATCH 1/3] Fix datetime format --- bundle_adjust/ba_timeseries.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundle_adjust/ba_timeseries.py b/bundle_adjust/ba_timeseries.py index da2a74e..d748220 100644 --- a/bundle_adjust/ba_timeseries.py +++ b/bundle_adjust/ba_timeseries.py @@ -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 From d7b45b6888f32396527051d004e348f611b3328e Mon Sep 17 00:00:00 2001 From: David de Meij Date: Tue, 22 Nov 2022 16:03:40 +0000 Subject: [PATCH 2/3] Allow .TIF extension and check if geotiff_paths are found --- bundle_adjust/ba_timeseries.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundle_adjust/ba_timeseries.py b/bundle_adjust/ba_timeseries.py index d748220..260f1bb 100644 --- a/bundle_adjust/ba_timeseries.py +++ b/bundle_adjust/ba_timeseries.py @@ -192,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] From 073c93bc253e7b5bf6169ace6edad86219180218 Mon Sep 17 00:00:00 2001 From: David de Meij Date: Tue, 22 Nov 2022 16:29:14 +0000 Subject: [PATCH 3/3] Fix typo and add assert to make sure the .rpc file exists --- bundle_adjust/ba_timeseries.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundle_adjust/ba_timeseries.py b/bundle_adjust/ba_timeseries.py index 260f1bb..b3f2644 100644 --- a/bundle_adjust/ba_timeseries.py +++ b/bundle_adjust/ba_timeseries.py @@ -192,7 +192,7 @@ def load_scene(self): all_im_rpcs = [] all_im_datetimes = [] - geotiff_paths = sorted(glob.glob(os.path.join(self.geotiff_dir, "**/*.[tT][iI][fF]'"), 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] @@ -209,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 .rpc for RPC files" + rpc = rpcm.rpc_from_rpc_file(rpc_path) else: raise ValueError("Unknown rpc_src value: {}".format(self.rpc_src))