diff --git a/earthdiagnostics/datafile.py b/earthdiagnostics/datafile.py index 4cbc5808dfacb9d021d5e03d04a938efdd76ebbe..1390a97345b9ab444f6f92ee39113290a581ffe5 100644 --- a/earthdiagnostics/datafile.py +++ b/earthdiagnostics/datafile.py @@ -192,6 +192,11 @@ class DataFile(Publisher): remote_diags_file = remote_diags_file.replace("/original_files/", "/") return remote_diags_file + @property + def remote_cmor_file(self): + remote_cmor_file = self.remote_file.replace("/original_files/", "/") + return remote_cmor_file + @property def local_status(self): """Get local storage status""" @@ -442,14 +447,18 @@ class DataFile(Publisher): cube.coord("region") except iris.exceptions.CoordinateNotFoundError: return - try: - old_cube = iris.load_cube(self.remote_diags_file) - except Exception: + old_cube = None + for path in (self.remote_diags_file, self.remote_file, + self.remote_cmor_file): try: - old_cube = iris.load_cube(self.remote_file) + old_cube = iris.load_cube(path) except Exception: - # Bad data, overwrite - return + pass + else: + break + if old_cube is None: + return + new_data = {} for region_slice in cube.slices_over("region"): Log.debug(region_slice.coord("region").points[0]) @@ -674,6 +683,7 @@ class NetCDFFile(DataFile): for path in ( self.remote_diags_file, self.remote_file, + self.remote_cmor_file, ): if os.path.isfile(path): try: @@ -721,6 +731,7 @@ class NetCDFFile(DataFile): def check_is_in_storage(self, update_status=True): for path in ( self.remote_file, + self.remote_cmor_file, self.remote_diags_file ): if os.path.isfile(path):