pypest / pyemu

python modules for model-independent uncertainty analyses, data-worth analyses, and interfacing with PEST(++)
BSD 3-Clause "New" or "Revised" License
176 stars 96 forks source link

Modify control data in pst from create from PstFrom object #401

Open RyanConway91 opened 1 year ago

RyanConway91 commented 1 year ago

I want to add stuff to my control_data section. However, when I try the code below:

pst = pf.build_pst()
#add stuff to pass pestchek
d = {pst.control_data.numcom:1}
for k,v in d.items():
    k = v
pst.write(pst_dir+"\\freyberg_mf6_cln.pst")

The new pst file does not have the added "numcom" parameter

jtwhite79 commented 1 year ago

the ControlData class overrides the setters and getters to 0) keep us from having to set all those gory little options as attributes and ii) so that we can type check when someone tries to change one (so you cant pass an str for noptmax, etc). What this means is that you have to assign the values for the control data options by name directly (you cant get a reference to them like in your code because the ControlData instance doesnt have an explicit numcom attribute):

pst.control_data.numcom = 2

RyanConway91 commented 1 year ago

pst.control_data.numcom = 1 does not make it through to the printed .pst. Seems like this might be the same as issue 379? https://github.com/pypest/pyemu/issues/379 Manually adding a few things got the .pst past pestchek, so all good! Thanks