seasonal water yield code

Anybody can tell me where to find the code of the seasonal water yield code? I want to change two number in the model.I want to let the λimage=0.05(λimage=0.2 in the model)
,but, after installing, I don't know where to find the code to change. Then , I download the code ,but I can't run it successfully.

Comments

  • jdouglassjdouglass Administrator, NatCap Staff
    Hi @wangyao, the source code for InVEST is available from our bitbucket repository (https://bitbucket.org/natcap/invest).  Running InVEST with your changes can be a little tricky, but the installation process (and required dependencies) are documented here: http://invest.readthedocs.io/en/latest/installing.html. ; Once you have your changes installed, you can run InVEST from the command-line.  This is documented here: http://invest.readthedocs.io/en/latest/cli.html
  • Hi jdouglass,Thank you so much .I have done what you told me. But , I ran the seasonal_water_yield.py, I got the error:
    Traceback (most recent call last):
      File "C:\Python2711\Lib\site-packages\natcap\invest\seasonal_water_yield\seasonal_water_yield.py", line 17, in <module>
        from .. import utils
    ValueError: Attempted relative import in non-package

    I don't know how to solve it.Looking forward to your reply.
  • jdouglassjdouglass Administrator, NatCap Staff
    Interesting!  What is the command and/or code you're using to try to run the model?
  • Hi,jdouglass, I have attached the code.
  • jdouglassjdouglass Administrator, NatCap Staff
    OK, so there are a number of issues with this script and how it's being run.  The easiest thing will be for you to work through this tutorial (http://invest.readthedocs.io/en/latest/scripting.html) for getting a function call to an InVEST model working.

    Since you want to make modifications to one of the models, you'll also need to set up a compiler so that you can install your modifications.  You won't be able to use them until you install.  See: http://invest.readthedocs.io/en/latest/installing.html#installing-from-source

    Concretely, there are a number of issues with this script:

    * To define parameters with an InVEST model, use a dictionary mapping string keys to values.  Editing the docstring won't change anything.

    * To run the model, you have to import the python package and call the correct execute function. Calling 'python ./path/to/seasonal_water_yield.py' won't work (You'll get the ValueError mentioned above)

    There's something else worth mentioning, which is that the model doesn't have a documented lambda-image variable ... are you sure you need to edit the source code?  It's kind of a lot of work to get this all up and running, especially if you aren't familiar with python development!
  • RichRich Administrator, NatCap Staff
    Thanks for all this James, and @wangyao, I'm also not sure what the lambda parameter is that you're changing. The code you posted looks like the raw source code of the InVEST model. Maybe there's a different approach we can help you with to get at the solution you need? What is it that you need from the model?
  • Thanks ,jdouglass and Rich.The  lambda parameter is from the formula :QF(i,m)=nm×{(a(i,m)-Si )exp(-(0.2Si)/a(i,m) )+〖Si〗^2/a(i,m) exp((0.8Si)/a(i,m) ) E1 (Si/a(i,m) )}×25.4[mm/in]. I want to change it to QF(i,m)=nm×{(a(i,m)-Si )exp(-(0.05Si)/a(i,m) )+〖Si〗^2/a(i,m) exp((0.95Si)/a(i,m) ) E1 (Si/a(i,m) )}×25.4[mm/in], just it.But ,I don't kown what  to do .I have some trouble with python code.Thank you so much if you have a easier way to  achieve this goal.
  • RichRich Administrator, NatCap Staff
    Hi @wangyao, I made a very custom and untested build of InVEST for you that exposes the "lambda" parameter in the seasonal water yield model. Its value replace the "0.2" in the QF equation. Keep in mind this is something just for you and is otherwise undocumented, unsupported, and won't be in any official release of InVEST. Otherwise I hope it's useful to you for your work! Here's the link: http://data.naturalcapitalproject.org/nightly-build/invest-forks/richsharp/InVEST_richsharp3.4.2.post53+nd45b0603ae4c_x86_Setup.exe

  • Thank you so much for taking the time to help me,Rich. It's very useful to me for my work. 
Sign In or Register to comment.