diff --git a/bundle_adjust/ba_timeseries.py b/bundle_adjust/ba_timeseries.py index da2a74e..b3f2644 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 @@ -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] @@ -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 .rpc for RPC files" + rpc = rpcm.rpc_from_rpc_file(rpc_path) else: raise ValueError("Unknown rpc_src value: {}".format(self.rpc_src))