Replies: 2 comments 2 replies
-
In the past 'del hds' at the end has done the trick for me. |
Beta Was this translation helpful? Give feedback.
1 reply
-
The issue is that You could use a "with" statement like this, which will automatically close the file: with HeadFile(hds_file, model = gwf) as hds:
hds # e.g. read, plot, etc.
os.remove(hds_file) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As part of a PEST inversion research, I'm running a sequence of MF6 models that are created, executed, postprocessed and then deleted. I'm loading the head file with:
hds_file = os.path.join(model_folder,root_name + '.hds')
hds = flopy.utils.binaryfile.HeadFile(hds_file, model = gwf)
Each time, after doing the plots I need, I attempt to remove the model folder with shutil. However, sometimes, the process run into an error like the one below, which I think is related to the file system trying to catch up. I have tried using time.sleep() to wait for some time and then perform the deletion and while this has worked, I wonder why this happens only with the hds file and if there is any way to instruct the code to release the file earlier.
Is there anything in flopy that should make the head file hanged? or anything that can be done to ensure it is closed?
Beta Was this translation helpful? Give feedback.
All reactions