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

Error using soil layer number as constraint to modify soil parameters #32

Closed
jsacerot opened this issue May 4, 2021 · 7 comments
Closed

Comments

@jsacerot
Copy link

jsacerot commented May 4, 2021

Hi @chrisschuerz . I do not know what happened but after the release of the latest version of SWATplusR, an error is returned when using soil layer number as a constraint to modify soil parameters:

Parameters to modify:
par_mod <- c("SOL_AWC.sol|change = relchg|layer = 1", "SOL_K.sol|change = relchg|layer = 1")

Error:
Error in translate_parameter_constraints(par_names, swat_vers) :
The parameter constraints: layer are not valid!

Could you please help us to solve this issue?

Thank you!

@chrisschuerz
Copy link
Owner

Hi sorry for that. For fixing the issue #30 I had to strongly restructure the SWAT2012 input file handling to consider some exceptions in input file structures that I was not aware of. In the restructuring I might have eliminated the layer option. I will try to reintroduce it in the new input file handling.

@jsacerot
Copy link
Author

jsacerot commented May 4, 2021

Thank you, @chrisschuerz!

chrisschuerz added a commit that referenced this issue May 4, 2021
This commit reintroduces the parameter condition 'layer' for sol and chm
files in SWAT2012.
@chrisschuerz
Copy link
Owner

@jsacerot I reintroduced the parameter constrain 'layer' in the new version 0.3.5. If you want to test it please update your SWATplusR version from the masster branch with remotes::install_github('chrisschuerz/SWATplusR')

@jsacerot
Copy link
Author

jsacerot commented May 5, 2021

Hi @chrisschuerz. Now I am getting this error:

Error: nm must be NULL or a character vector the same length as x
Run rlang::last_error() to see where the error occurred.

rlang::last_error()
<error/rlang_error>
nm must be NULL or a character vector the same length as x
Backtrace:

  1. SWATplusR::run_swat2012(...)
  2. purrr::map_df(., ~set_names(.x, par_name))
  3. purrr::map(.x, .f, ...)
  4. SWATplusR:::.f(.x[[i]], ...)
  5. rlang::set_names(.x, par_name)
    Run rlang::last_trace() to see the full context.

Any thoughts about what could be the problem? My code was running before.

Thank you!

@jsacerot
Copy link
Author

jsacerot commented May 5, 2021

@chrisschuerz I performed some tests and discovered that the problem now is with parameters in files *.sub:

               "CH_W1.sub|change = relchg" 
               "CH_S1.sub|change = relchg" 
               "CH_L1.sub|change = relchg" 
               "CH_N1.sub|change = relchg" 
               "CH_K1.sub|change = absval"

@chrisschuerz
Copy link
Owner

chrisschuerz commented May 6, 2021

@jsacerot thanks for looking into it with such detail. It made the search much easier. There was an issue with sub files with different lengths (which is often the case). Version 0.3.5.1 should fix this issue, at least in my tests. Please again update SWATplusR and check if the issues are fixed now.

@jsacerot
Copy link
Author

jsacerot commented May 6, 2021

@chrisschuerz Thank you so much. The issue seems to be fixed, and everything is running without problem.

@jsacerot jsacerot closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants