GithubHelp home page GithubHelp logo

rascontrol's People

Contributors

dependabot[bot] avatar gutzbenj avatar jacob-a-brown avatar mikebannis avatar mjb-respec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rascontrol's Issues

Reach code error

Sometimes the reach codes are different in the geometry and output files in HEC-RAS. This will throw an error when accessing the output data because it assigns the incorrect node code to the incorrect reach. In order to fix this you must first grab the reach code using Geometry_GetReaches, assign each reach its appropriate nodes, and then update the reach codes with Output_GetReaches if the two differ. This way, you will be able to read the output file correctly. This was done by amending the River and RasController classes as follows:

River

class River(object):
    def __init__(self, name, code, rc):
        self.name = name  # River name, string
        self.code = code  # River code, int - these start at 1, not 0
        self.rc = rc   # RasController object
        self.reaches = self._get_reaches()  # list of Reach objects
        self._update_reach_codes()

    # TODO -  the reach code should probably be pulled from the rascontller, although i+1 seems to work
    def _get_reaches(self):
        """
        Gets list of reaches for river represented by self
        :return: list of Reach objects
        """
        reaches = []
        reach_names = self.rc.geometry_getreaches(self.code)
        for i, name in enumerate(reach_names):
            new_reach = Reach(name, i+1, self)
            reaches.append(new_reach)
        return reaches

    def _update_reach_codes(self):
        """
        Sometimes the reach codes switch between the geometry and output files. This switches the codes after assigning
        each reach their respective nodes
        """
        
        if self.rc.output_getreaches(self.code)==self.rc.geometry_getreaches(self.code):
            pass
        else:
            new_reach_codes = {}
            new_reach_names = self.rc.output_getreaches(self.code)
            for code, reach in enumerate(new_reach_names):
                new_reach_codes[reach] = code+1
            
            for reach in self.reaches:
                updated_code = new_reach_codes[reach.name]
                reach.code = updated_code
        
    def __repr__(self):
        return 'River name = "'+self.name + '", River code = "' + str(self.code)+'"'

RasController

def geometry_getreaches(self, river_num):
        """
        Returns reach names in river numbered river_num using Geometry_GetReaches
        :param river_num: int
        :return: list of reach names
        """
        
        _, _, reaches = self.com_rc.Geometry_GetReaches(river_num, None, None)
        return reaches
    
def output_getreaches(self, river_num):
        """
        Returns reach names in river numbered river_num using Output_GetReaches
        :param river_num: int
        :return: list of reach names
        """
        
        _, _, reaches = self.com_rc.Output_GetReaches(river_num, None, None)
        return reaches

referencing self in run_orig in RasRunner

If one writes a function to run rascontrol, rather than make a global variable of rascontrol, one runs into a referencing error. In run_orig in RasRunner, I changed

self.full_xs_list = rc.simple_xs_list()
self.rivers = {x.river for x in rr.full_xs_list}
self.xs_by_river = [[x for x in rr.full_xs_list if x.river == riv] for riv in self.rivers]

to

self.full_xs_list = rc.simple_xs_list()
self.rivers = {x.river for x in self.full_xs_list}
self.xs_by_river = [[x for x in self.full_xs_list if x.river == riv] for riv in self.rivers]

to fix the problem.

Incorrect RAS Version

If your version of HEC-RAS is not 4.1, and you do not set the version in RasRunner appropriately, there is an error. Perhaps fix this with a try... catch...? The error comes up in line 232 of rascontrol.py

Cannot import RasController

I installed rascontrol through git and pip as described in the rascontrol homepage. When I run the following code (given in basic usage example), it gives me the error: module 'rascontrol' has no attribute 'RasController'

import rascontrol
rc = rascontrol.RasController(version='507')

I am using Python 3.7.6 and HEC-RAS 5.0.7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.