Welcome to the RAS Solution › Forums › HECRAS Controller › Working with HECRASController in Python
- This topic has 7 replies, 5,258 voices, and was last updated 9 years, 4 months ago by bb23538.
-
AuthorPosts
-
July 25, 2015 at 1:52 am #8167bb23538Participant
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!
September 3, 2015 at 9:28 pm #13484Mikell WarmsParticipantHey 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!
—
MikellDecember 7, 2016 at 9:20 am #13485rahulParticipantHi
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.December 7, 2016 at 9:39 am #13486AnonymousGuestYou might find the steps given here useful: https://github.com/solomonvimal/PyFloods/blob/master/HEC_RAS_controller.py
HTH,
SolomonDecember 12, 2016 at 11:11 am #13487rahulParticipant– deleted –
December 26, 2016 at 9:36 am #13488rahulParticipantHello Solomon
I want to automate the HEC RAS Software. How Can I Do this?
Please suggest some guidlines.Thanks for your time.
May 24, 2017 at 5:47 pm #13489AnonymousGuestHello 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 🙂March 24, 2020 at 9:54 pm #13490AnonymousGuestHi Anni,
I was wondering to know if you remember how you resolve this issue.
Your help is highly appreciated.Thank you,
AA -
AuthorPosts
- You must be logged in to reply to this topic.