Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM1.5 conversion driver, delete inputs upon successful conversion #77

Merged
merged 13 commits into from
Aug 20, 2024

Conversation

blimlim
Copy link
Collaborator

@blimlim blimlim commented Aug 19, 2024

This pull request would close #49.

In most simulations of ESM1.5, the original fields files aren't very useful once they've been converted to NetCDF. This pull request adds a command line flag --delete_ff, -d, to the conversion driver. When included, the conversion driver will delete the input fields files when they are converted.

I've implemented this by adding the deletion as close as possible to the actual conversion:

try:
um2netcdf4.process(fields_file_path, nc_write_path, ARG_VALS)
succeeded.append((fields_file_path, nc_write_path))
if delete_ff:
os.remove(fields_file_path)

This does bury a bit more I/O in the convert_fields_file_list, but I think it seems safe to have it there to try and ensure that the only way a file can be deleted is if the conversion runs without any errors.

I also modified the convert_fields_file_list tests to check that file deletion is run when requested, and is not run when it is not requested or if there are any errors.

Let me know if these changes look ok, any feedback/suggestions are welcome!

@truth-quark truth-quark self-requested a review August 20, 2024 07:07
Copy link
Collaborator

@truth-quark truth-quark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go!

umpost/conversion_driver_esm1p5.py Outdated Show resolved Hide resolved
umpost/conversion_driver_esm1p5.py Show resolved Hide resolved
@blimlim blimlim merged commit 8aa708d into develop Aug 20, 2024
4 checks passed
@blimlim blimlim deleted the 49/esm1.5-driver-delete-inputs branch September 11, 2024 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Driver script - fields file deletion upon successful conversion
2 participants