Skip to content

Commit

Permalink
Merge branch '7-patch-extension' of https://github.com/spaceml-org/rs…
Browse files Browse the repository at this point in the history
…_tools into 7-patch-extension
  • Loading branch information
annajungbluth committed Sep 21, 2024
2 parents e1de7e2 + 7c29f8a commit bce8ac3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions rs_tools/_src/geoprocessing/msg/geoprocessor_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ def preprocess_files(self):

for itime in pbar_time:

# TODO: Make it modular whether to overwrite or not
# skip if file already exists
save_filename = Path(self.save_path).joinpath(f"{itime}_msg.nc")
if os.path.exists(save_filename):
logger.info(f"File already exists. Skipping: {save_filename}")
continue

pbar_time.set_description(f"Processing: {itime}")

# get cloud mask file for specific time
Expand All @@ -299,7 +306,7 @@ def preprocess_files(self):
try:
# load cloud mask
cloud_mask = self.preprocess_cloud_mask(files_cloud)
except AssertionError:
except:
logger.error(f"Skipping {itime} due to missing cloud mask")
continue

Expand All @@ -309,7 +316,7 @@ def preprocess_files(self):
try:
# load radiances and attach cloud mask
ds = self.preprocess_radiances(files, cloud_mask=cloud_mask)
except AssertionError:
except:
logger.error(f"Skipping {itime} due to error loading")
continue

Expand All @@ -323,12 +330,6 @@ def preprocess_files(self):
# check if save path exists, and create if not
if not os.path.exists(self.save_path):
os.makedirs(self.save_path)

# remove file if it already exists
save_filename = Path(self.save_path).joinpath(f"{itime}_msg.nc")
if os.path.exists(save_filename):
logger.info(f"File already exists. Overwriting file: {save_filename}")
os.remove(save_filename)

# save to netcdf
ds.to_netcdf(save_filename, engine="netcdf4")
Expand Down

0 comments on commit bce8ac3

Please sign in to comment.