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

support for absolute parameters and absparmax(N) #378

Open
hansonmcoombs opened this issue Oct 17, 2022 · 4 comments
Open

support for absolute parameters and absparmax(N) #378

hansonmcoombs opened this issue Oct 17, 2022 · 4 comments
Labels

Comments

@hansonmcoombs
Copy link

From what I can see there is no explict support for setting parameter PARCHGLIM to 'absolute(N)'.

You can manually set the PARCHGLIM field in the parameter data as follows:

pst.parameter_data.loc[idx1, 'parchglim'] = 'absolute(1)'
pst.parameter_data.loc[idx2, 'parchglim'] = 'absolute(2)'

But it does not look like there is a way to set the absparmax(N) values in the control data or write them on line 6 of the pest control file. (e.g. absparmax(1)=0.1 absparmax(2)=0.2)

If I am mistaken, please correct me and maybe add a note somewhere in the documentation.

If I am not mistaken I would suggest implementing:

  1. an absparmax variable in control data with a default value of an implmented as an empty list [] in the dataframe (N by index +1 ) e.g. [N=1, N=2]
  2. alternativley it could be implmented as an empty dictionary and should users need to pass absolute paramter limits they simply call control_data.absparmax[1]=0.1, but this would break the pd.Dataframe object structure
  3. a sanity check that if absparmax is not empty or 'absolute' is in the parameter data, check that the right number of absparmax exist
  4. a modification to the control data.write and write_keyword methods so that the appropriate formatting is written to line 6 of the pst control file (assuming len(control_data.absparmax)!=0)

I'm happy to take a stab at implementing this, but I thought I would check that you all don't have some plan in the works already or that I missed something.

I'm not super familar with the pest control file version 2 style, so a reference to that would help me not mess up :)

@jtwhite79
Copy link
Collaborator

I'm happy for you to have a go at this! Let us know if you get stuck and we can try to help (i don't use these options so might not be very helpful....)

@hansonmcoombs
Copy link
Author

Sounds good I'll put it on my todo list... it may be a min

@wkitlasten
Copy link
Collaborator

I have recently run into this issue. Any progress?

@hansonmcoombs
Copy link
Author

Hi wkitlasten,

I've been too busy to look up from my own work since I started this... The tricky part is the support for multiple absparmax and pyEMU not reallying being set up for this n dimensionality. It's still on my list to tackle, but it might be a while...

The hack I implemented to get my model running was:

# use something like the following to set the parameter to absolute(1):

pst.parameter_data.loc[idx1, 'parchglim'] = 'absolute(1)'


# then after writing the pest control file, but before running the thing call:

def hack_for_absparmax(file, pmax1):
    with open(file, 'r') as f:
        lines = f.readlines()
    lines[6] = lines[6].strip('\n') + f'  absparmax(1)={pmax1}\n'  # keynote ABSPARMAX set here
    with open(file, 'w') as f:
        f.writelines(lines)
    pass


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants