Flopy rounding BC values #1553
Replies: 7 comments 1 reply
-
Those numbers are very different. I don't think they can be explained by a precision issue. Are you sure there isn't something else wrong? BTW, I moved this to a discussion as it is unclear if there is an issue in the flopy code. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. Bad copy-pasting on my part - the numbers I meant to give are original rch file: 2.076423E-03 Basically, one significant figure is getting rounded off. Interestingly, if the recharge rate has a magnitude of 10e-4 instead of 10e-3, flopy will rewrite the recharge value with greater precision than that in the original file original rch file: 8.225320E-04 See bottom left corner of the attached screenshot. Any ideas why this may be happening? Thank you, |
Beta Was this translation helpful? Give feedback.
-
FYI, the model.rch.rech.array.dtype is 'float32'. Thanks, |
Beta Was this translation helpful? Give feedback.
-
For older MODFLOW versions, flopy writes a two-dimensional np.float32 array (such are recharge) using np.savetxt with fmt=%15.6E". This format is described in detail here. I have to defer to @spaulins-usgs for how the array is written for MODFLOW 6. I thought there were options to control the precision. Any thoughts, @spaulins-usgs? |
Beta Was this translation helpful? Give feedback.
-
In flopy for MODFLOW 6 the precision and the maximum number of characters used to represent a number are set for a simulation. For example,
This example code can be seen in context in tutorial01_mf6_data.py here: https://github.com/modflowpy/flopy/blob/develop/examples/Tutorials/modflow6/tutorial01_mf6.py You can also control the bounds where flopy switches to scientific notation like this:
Based on these settings flopy defines the output strings used to write numbers to a file like this:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your response, @spaulins-usgs. Out of curiosity, what are the values of sim.float_precision and sim.float_characters before set by the user? Those attributes don't seem to exist before I set them. Thanks, |
Beta Was this translation helpful? Give feedback.
-
@jklakovich-INTERA, the default values are: float_precision = 8 |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a model loaded using
m = flopy.mf6.MFSimulation.load(sim_ws=sim_ws, exe_name=exe_name).get_model()
Then I view the recharge and EVT arrays, i.e., using
m.evt.rate.data
m.rch.recharge.data
However, the recharge and EVT values are truncated as compared to original model files. For example, the original recharge file will have a rate of 2.076423E-03 and the numpy array (as well as the new model file when written by flopy) will have the value 0.00267932.
The rounding errors are producing significantly different results in my final head distribution.
I have searched the docs and I do see a way to specify precision in the MFSimulation.load function ... could you please point me in the right direction?
I am using flopy version 3.3.5.
Thank you very much for your help,
Jeff
Beta Was this translation helpful? Give feedback.
All reactions