Skip to content

Commit

Permalink
fix(l3): fix missing crs in build_dataset return
Browse files Browse the repository at this point in the history
  • Loading branch information
j-haacker committed Sep 9, 2024
1 parent 2af9c16 commit 8ccf6dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cryoswath/l3.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ def local_closure(roll_iteration):
del l3_data
tmp = previously_processed_l3.to_xarray().sortby("x").sortby("y")
del previously_processed_l3
previously_processed_l3 = fill_missing_coords(tmp)
previously_processed_l3 = fill_missing_coords(tmp).rio.write_crs(crs)
tmp.close()
# save/backup result
tmp_path = os.path.join(data_path, "tmp", f"{region_id}_l3")
# try to write new data to file. if anything goes wrong, restore. is this sufficiently safe?
try:
if os.path.isfile(outfilepath):
shutil.move(outfilepath, tmp_path)
previously_processed_l3.rio.write_crs(crs).to_netcdf(outfilepath)
previously_processed_l3.to_netcdf(outfilepath)
except Exception as err:
shutil.move(tmp_path, outfilepath)
print("\n")
Expand All @@ -326,7 +326,7 @@ def local_closure(roll_iteration):
+ "message below and continuing. Attempting to save to temporary file.")
try:
safety_net_tmp_file_path = os.path.join(tmp_path, f"tmp_l3_state__{datetime.datetime.strftime('%dT%H%M%S')}.nc")
previously_processed_l3.rio.write_crs(crs).to_netcdf(safety_net_tmp_file_path)
previously_processed_l3.to_netcdf(safety_net_tmp_file_path)
except Exception as err_inner:
print("\n")
warnings.warn(
Expand Down

0 comments on commit 8ccf6dc

Please sign in to comment.