Welcome to the RAS Solution Forums HECRAS Controller Working with HECRASController in Python

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #8167
    bb23538
    Participant

    I’m interested in programming in python using classes from the HEC-RAS API. It seems as though the only method to loading / accessing the HECRASController Classes in Python is using a PyRAS module (https://pypi.python.org/pypi/PyRAS/). If any one has had any luck using the PyRAS module or any other method to accessing the HEC-RAS API in Python can you provide general feedback / insight on your experiences?

    Thank you!

    #13484
    Mikell Warms
    Participant

    Hey BB,

    I am a python user, and was interested in this same question a few months ago. Having spent a few hours (not long) looking into PyRAS, I decided it would probably be a bit easier to try something a little different. I guess it really depends on what you are trying to do with the API. In my case, I was interested in automation of sensitivity and statistical analyses.

    My workaround has been to use python to modify/create the text input files for RAS (specifically the flow and plan files) to create hundreds/thousands of runs. I then would open up RAS and use the “Run Multiple Plans…” option and allow it to work its way through them all.

    Once all of the runs are finished (I let this finish overnight, typically), I run a separate python script to read from the HDF output files for each plan, then perform whatever analysis on the data I would like. Specifically a combination of h5py (for some reason HDFStore in Pandas doesn’t work with the RAS HDF files), pandas, and scipy modules has worked well for me.

    I guess if you absolutely needed the API, you could write the code in VBA and then call a python script from VBA, or vice versa.

    Good luck!

    Mikell

    #13485
    rahul
    Participant

    Hi
    I am Rahul. I also want to work on the Py-RAS. I am just new user of that. I want to know some basics steps regarding how to call function of Hec-Ras in python interface.
    There will be no documentation available for How to use the Py-RAS.
    Please suggest some steps. So that I can follows those steps.

    #13486
    Anonymous
    Guest

    You might find the steps given here useful: https://github.com/solomonvimal/PyFloods/blob/master/HEC_RAS_controller.py

    HTH,
    Solomon

    #13487
    rahul
    Participant

    – deleted –

    #13488
    rahul
    Participant

    Hello Solomon

    I want to automate the HEC RAS Software. How Can I Do this?
    Please suggest some guidlines.

    Thanks for your time.

    #13489
    Anonymous
    Guest

    Hello everyone,

    I am trying to use the HecrasController in Python. Till now everything worked well with starting HecRas, computing the current plan and reading the results.
    But now I want to use a restart file and compute one timestep, write a new restart file, compute the next timestep with the new restart file, write again a new restart file,…

    I am using this Code to compute the plan:

    nmsg = None
    msg = None
    RC = win32com.client.Dispatch(‘RAS503.HECRASCONTROLLER’)
    RC.Project_Open(hec_prj)
    RC.Compute_CurrentPlan(nmsg,msg)
    RC.Project_Close()
    RC.QuitRas()

    I get the following error message in the HecRas Computation Window:
    “Could not find Restart File
    It may need to be recreated
    Unsteady flow encountered an error.
    ERROR with Restart File
    An error occurred while reading the restart file
    Re-creating the restart file might help.
    Writing Results to DSS
    Reading Data for Post Process”

    I checked the created boundary condition file. The restart file listed there is the one that I want to use and it definitely exists.
    The strange thing is, when I open HecRas and run the current Plan manually, it works perfectly well with the restart file.

    Does anybody have any experience with restart files and the Hecras controller and is able to help me?
    I am thankful for every hint 🙂

    #13490
    Anonymous
    Guest

    Hi Anni,

    I was wondering to know if you remember how you resolve this issue.
    Your help is highly appreciated.

    Thank you,
    AA

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.