modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

Setters and getters #19

Closed jdhughes-usgs closed 9 years ago

jdhughes-usgs commented 9 years ago

It might be time to consider including set and get methods to redefine variables now that the load methods are working.

jtwhite79 commented 9 years ago

I had some people asking about this too. I added a generic Package__setattr__() to help with resetting util_3d, util_2d, transient_2d and mflist attributes. For example:

lpf = ModflowLpf(model,hk=1.0)

To reset the util_3d attribute named hk, you just access as you normally would:

lpf.hk = 2.0

and __setattr__() finds an existing attribute named hk and uses it to instantiate a new util_3d object and resets the hk attribute with it. Note that this will not help users reset more complex attributes like the SWI2's zeta.

jdhughes-usgs commented 9 years ago

Added logic to work with lists composed of util_2d and util_3d objects. So __setattr__() now works with SWI2's zeta.

mbakker7 commented 9 years ago

Those setters and getters are pretty cool, guys.

It feels like the next MODFLOW conference (not the one coming up) it may be time to teach a FloPy course. Just a thought. For whomever has time. Or a strong urge.

Mark

On Mon, Mar 23, 2015 at 10:54 PM, Hughes, J.D. notifications@github.com wrote:

Closed #19 https://github.com/modflowpy/flopy/issues/19.

— Reply to this email directly or view it on GitHub https://github.com/modflowpy/flopy/issues/19#event-262867859.