Skip to content

Commit

Permalink
Fix loading of OPERA data.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpf committed Aug 14, 2024
1 parent aa5ef1c commit 6551ab3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chimp/data/opera.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def find_training_files(
"""
pattern = "*????????_??_??.nc"
training_files = sorted(
list((path / "opera").glob(pattern))
list((path / "opera_reflectivity").glob(pattern))
if isinstance(path, Path) else
list(f for f in path if f in list(f.parent.glob("opera" + pattern)))
list(f for f in path if f in list(f.parent.glob("opera_reflectivity" + pattern)))
)
times = np.array(list(map(get_date, training_files)))
return times, training_files
Expand Down
10 changes: 5 additions & 5 deletions chimp/data/training_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __getitem__(self, index):
self.reference_files[sample_index], slices, self.scene_size, rotate=ang, flip=flip
)
except Exception:
LOGGER.exception(
LOGGER.warning(
f"Loading of training sample for '%s'"
"failed. Falling back to another radomly-chosen step.",
self.times[sample_index]
Expand Down Expand Up @@ -532,7 +532,7 @@ def plot_reference_data_availability(
cts[t_ind] = torch.isfinite(data_t).sum()

except Exception:
LOGGER.exception(
LOGGER.warning(
"Encountered an error opening file %s.",
path
)
Expand Down Expand Up @@ -799,7 +799,7 @@ def __getitem__(self, ind: int) -> Tuple[Dict[str, torch.Tensor], Dict[str, torc
return self[new_ind]

except Exception:
LOGGER.exception(
LOGGER.warning(
f"Loading of training sample for '%s'"
"failed. Falling back to another radomly-chosen step.",
self.times[scene_index]
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def __getitem__(self, index):
scene_size=scene_size,
quality_threshold=self.quality_threshold[rd_ind],
)
except Exception:
except Exception as exc:
slices = None
if slices is None:
LOGGER.warning(
Expand Down Expand Up @@ -1133,7 +1133,7 @@ def __getitem__(self, index):
self.reference_files[step_index], slices, self.scene_size, rotate=ang, flip=flip
)
except Exception as exc:
LOGGER.exception(
LOGGER.warning(
"Encountered an error when loading reference data from files '%s'."
"Falling back to another radomly-chosen sample.",
self.reference_files[step_index]
Expand Down

0 comments on commit 6551ab3

Please sign in to comment.