RaspyGeo


NameRaspyGeo JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/quantum-dan/RaspyGeo
SummaryAutomated geometry scenario runner (loosely analogous to the Geometry Editor tool) for HEC-RAS
upload_time2023-06-15 22:23:01
maintainer
docs_urlNone
authorDaniel Philippus
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RaspyGeo

Automated geometry scenario runner (loosely analogous to the Geometry Modification tool) for HEC-RAS.  Depends on Raspy (`raspy-auto` on PyPI).  Currently works for steady-state simulations. RaspyGeo is available on PyPI as [RaspyGeo](https://pypi.org/project/RaspyGeo/).

# Updates and Added Features

If additional capabilities would be useful to you, open an Issue and I will check
into it.  Otherwise, I develop updates as I need them.

# Usage

Scenario running is fully automated through `run`.  The HEC-RAS project must
already be set up with a reference (baseline) geometry **and** a new (scenario)
geometry file, and the current plan must be set up to run the scenario geometry.
Then, the user specifies:

- HEC-RAS project path, which needs to be a full path, not relative
- Input (baseline) geometry file, which can be a relative path
- Output (scenario) geometry file, which can be a relative path
- Scenario data output file, which will contain shear, velocity, and depth
for main channel and overbanks
- Data retrieval locations, which is a list of lists: `[[identifier, river, reach, rs]]`, where
`identifier` is the user's name for the spot and the rest are HEC-RAS location
information.
- Number of flow profiles being modeled (steady state)
- Scenario specification
- [Optional] HEC-RAS version (default: "507", for 5.0.7; 6.3.1 would be "631", etc.)

The complicated part is the scenario specification.  This is set up as nested
dictionaries.  The outer dictionary is scenarios, where the key is the name
of the scenario (do not use any commas).  The inner dictionaries have the keys
as `River Name,Reach Name` (no separating spaces, etc), and the values are the
actual geometry specifications.  These are simply functions that take a `Reach`
object (see `hecgeo.py`) and return an updated `Reach`; the user can specify
this however they wish.

The default approach is to design functions that can be passed to
`Reach.adjust_geometry` and to specify datum adjustments with `Reach.adjust_datums`.
Both of these modify any
cross-sections either within a given stretch of the reach or for the whole reach.
Geometry adjustment functions receive coordinates, roughness locations, and bank
stations and return the same.  In the provided coordinates, the low point is zero
elevation and the left edge is station zero; offsets and datums are stored and
added back in before writing.

Coordinates are formatted as `[(station, elevation)]`.  Roughness is, as HEC-RAS
handles it, applied from the left point going rightwards, and formatted as
`[(station, new roughness)]`.  The bank stations are just `[left, right]`.

Specifying geometry modifiers can be quite complicated.  Look at `geofun.py` for
some examples.  Two modifier functions are provided by default: `set_afp` and
`set_lfc`, which are tailored to the developer's use case.  LFC specifies a
low-flow channel, or trapezoidal channel within the main channel.  AFP specifies
an LFC which then has a wider flat floodplain, active floodplain (AFP), around
it.  These are both meant to cut/fill into existing geometry and then daylight.
It would be much more straightforward to design, for example, a constant shape
that ignores the original channel or just adjusts width based on it, etc.  The
complications mainly have to do with connecting the new design with the old.

Using `set_afp`, a full example is included below.  This would work similarly
with the user's own geometry functions.

```
from RaspyGeo import set_afp, run, parse
import matplotlib.pyplot as plt


rpath = r"C:\Users\dphilippus\longpathstuff\TestProj\test.prj"
ingeo = "TestProj/test.g02"
outgeo = "TestProj/test.g01"
outpath = "output.txt"


def buildscen(bwidth, tdatum):
    return lambda geo: geo.adjust_datums(0, tdatum).adjust_geometry(
        set_afp(bwidth, 1, 2, lambda x: 0.5*x, 3, 0.05, 0.05, 0.035, 0.035))


def prepscens(bwidth, tdatum):
    return {
        "RiverOne,Lower": buildscen(bwidth, tdatum),
        "RiverOne,Upper": buildscen(bwidth*0.75, tdatum*2)
        }


scens = {"Width %d Datum %d" % (w, d): prepscens(w, d) for w in range(1, 6)
         for d in [1, 2, 3]}

# [[identifier, river, reach, rs]]
locations = [
    ['R1U', 'RiverOne', 'Upper', '2200'],
    ['R1L', 'RiverOne', 'Lower', '401'],
    ['TH', 'Thingy', 'OnlyOne', '100']
    ]

nprof = 10


def runner():
    run(rpath, ingeo, outgeo, outpath, locations, nprof, scens)
```

# Bugs

Note that HEC-RAS geometry files can have various optional components that I
may not have tested for, and these may produce odd crashes or similar.  If you
are running into such a bug, please attach the relevant geometry input file to
the Issue.

# Summary

The idea is to be able to automatically run through (and retrieve results for) many iterations of some geometry scenario in HEC-RAS.  This can be partially automated (editing the geometry) with the Geometry Editor, but that built-in tool, while very useful, is also quite limited and still requires a manual edit-run-analyze workflow.

The Geometry Editor is the best approach if you have a handful of scenarios, and RaspyGeo does not aim to compete with it.  However, that workflow becomes a major bottleneck when that scales to dozens or hundreds of variations, especially when those require complex modifications to datum, bank stations, etc, followed by exporting and post-processing data.  This project is in response to the developer spending far too much time running geometry scenarios for research.

So the plan is, the user specifies:

- Scenario location (i.e. reach and river stations)
- Data retrieval location
- Datum adjustments at both ends; for now, just linearly interpolate the adjustment
- New geometry
- Slope-to-daylight

RaspyGeo runs the specified scenarios, then retrieves profile data.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/quantum-dan/RaspyGeo",
    "name": "RaspyGeo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Daniel Philippus",
    "author_email": "daniel@dphilippus.com",
    "download_url": "https://files.pythonhosted.org/packages/1f/94/d55ce9b7ec4e3a2cdb5c86b032536fa33a1120ec3211a0b325672a92448b/RaspyGeo-1.0.1.tar.gz",
    "platform": null,
    "description": "# RaspyGeo\r\n\r\nAutomated geometry scenario runner (loosely analogous to the Geometry Modification tool) for HEC-RAS.  Depends on Raspy (`raspy-auto` on PyPI).  Currently works for steady-state simulations. RaspyGeo is available on PyPI as [RaspyGeo](https://pypi.org/project/RaspyGeo/).\r\n\r\n# Updates and Added Features\r\n\r\nIf additional capabilities would be useful to you, open an Issue and I will check\r\ninto it.  Otherwise, I develop updates as I need them.\r\n\r\n# Usage\r\n\r\nScenario running is fully automated through `run`.  The HEC-RAS project must\r\nalready be set up with a reference (baseline) geometry **and** a new (scenario)\r\ngeometry file, and the current plan must be set up to run the scenario geometry.\r\nThen, the user specifies:\r\n\r\n- HEC-RAS project path, which needs to be a full path, not relative\r\n- Input (baseline) geometry file, which can be a relative path\r\n- Output (scenario) geometry file, which can be a relative path\r\n- Scenario data output file, which will contain shear, velocity, and depth\r\nfor main channel and overbanks\r\n- Data retrieval locations, which is a list of lists: `[[identifier, river, reach, rs]]`, where\r\n`identifier` is the user's name for the spot and the rest are HEC-RAS location\r\ninformation.\r\n- Number of flow profiles being modeled (steady state)\r\n- Scenario specification\r\n- [Optional] HEC-RAS version (default: \"507\", for 5.0.7; 6.3.1 would be \"631\", etc.)\r\n\r\nThe complicated part is the scenario specification.  This is set up as nested\r\ndictionaries.  The outer dictionary is scenarios, where the key is the name\r\nof the scenario (do not use any commas).  The inner dictionaries have the keys\r\nas `River Name,Reach Name` (no separating spaces, etc), and the values are the\r\nactual geometry specifications.  These are simply functions that take a `Reach`\r\nobject (see `hecgeo.py`) and return an updated `Reach`; the user can specify\r\nthis however they wish.\r\n\r\nThe default approach is to design functions that can be passed to\r\n`Reach.adjust_geometry` and to specify datum adjustments with `Reach.adjust_datums`.\r\nBoth of these modify any\r\ncross-sections either within a given stretch of the reach or for the whole reach.\r\nGeometry adjustment functions receive coordinates, roughness locations, and bank\r\nstations and return the same.  In the provided coordinates, the low point is zero\r\nelevation and the left edge is station zero; offsets and datums are stored and\r\nadded back in before writing.\r\n\r\nCoordinates are formatted as `[(station, elevation)]`.  Roughness is, as HEC-RAS\r\nhandles it, applied from the left point going rightwards, and formatted as\r\n`[(station, new roughness)]`.  The bank stations are just `[left, right]`.\r\n\r\nSpecifying geometry modifiers can be quite complicated.  Look at `geofun.py` for\r\nsome examples.  Two modifier functions are provided by default: `set_afp` and\r\n`set_lfc`, which are tailored to the developer's use case.  LFC specifies a\r\nlow-flow channel, or trapezoidal channel within the main channel.  AFP specifies\r\nan LFC which then has a wider flat floodplain, active floodplain (AFP), around\r\nit.  These are both meant to cut/fill into existing geometry and then daylight.\r\nIt would be much more straightforward to design, for example, a constant shape\r\nthat ignores the original channel or just adjusts width based on it, etc.  The\r\ncomplications mainly have to do with connecting the new design with the old.\r\n\r\nUsing `set_afp`, a full example is included below.  This would work similarly\r\nwith the user's own geometry functions.\r\n\r\n```\r\nfrom RaspyGeo import set_afp, run, parse\r\nimport matplotlib.pyplot as plt\r\n\r\n\r\nrpath = r\"C:\\Users\\dphilippus\\longpathstuff\\TestProj\\test.prj\"\r\ningeo = \"TestProj/test.g02\"\r\noutgeo = \"TestProj/test.g01\"\r\noutpath = \"output.txt\"\r\n\r\n\r\ndef buildscen(bwidth, tdatum):\r\n    return lambda geo: geo.adjust_datums(0, tdatum).adjust_geometry(\r\n        set_afp(bwidth, 1, 2, lambda x: 0.5*x, 3, 0.05, 0.05, 0.035, 0.035))\r\n\r\n\r\ndef prepscens(bwidth, tdatum):\r\n    return {\r\n        \"RiverOne,Lower\": buildscen(bwidth, tdatum),\r\n        \"RiverOne,Upper\": buildscen(bwidth*0.75, tdatum*2)\r\n        }\r\n\r\n\r\nscens = {\"Width %d Datum %d\" % (w, d): prepscens(w, d) for w in range(1, 6)\r\n         for d in [1, 2, 3]}\r\n\r\n# [[identifier, river, reach, rs]]\r\nlocations = [\r\n    ['R1U', 'RiverOne', 'Upper', '2200'],\r\n    ['R1L', 'RiverOne', 'Lower', '401'],\r\n    ['TH', 'Thingy', 'OnlyOne', '100']\r\n    ]\r\n\r\nnprof = 10\r\n\r\n\r\ndef runner():\r\n    run(rpath, ingeo, outgeo, outpath, locations, nprof, scens)\r\n```\r\n\r\n# Bugs\r\n\r\nNote that HEC-RAS geometry files can have various optional components that I\r\nmay not have tested for, and these may produce odd crashes or similar.  If you\r\nare running into such a bug, please attach the relevant geometry input file to\r\nthe Issue.\r\n\r\n# Summary\r\n\r\nThe idea is to be able to automatically run through (and retrieve results for) many iterations of some geometry scenario in HEC-RAS.  This can be partially automated (editing the geometry) with the Geometry Editor, but that built-in tool, while very useful, is also quite limited and still requires a manual edit-run-analyze workflow.\r\n\r\nThe Geometry Editor is the best approach if you have a handful of scenarios, and RaspyGeo does not aim to compete with it.  However, that workflow becomes a major bottleneck when that scales to dozens or hundreds of variations, especially when those require complex modifications to datum, bank stations, etc, followed by exporting and post-processing data.  This project is in response to the developer spending far too much time running geometry scenarios for research.\r\n\r\nSo the plan is, the user specifies:\r\n\r\n- Scenario location (i.e. reach and river stations)\r\n- Data retrieval location\r\n- Datum adjustments at both ends; for now, just linearly interpolate the adjustment\r\n- New geometry\r\n- Slope-to-daylight\r\n\r\nRaspyGeo runs the specified scenarios, then retrieves profile data.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Automated geometry scenario runner (loosely analogous to the Geometry Editor tool) for HEC-RAS",
    "version": "1.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/quantum-dan/RaspyGeo/issues",
        "Homepage": "https://github.com/quantum-dan/RaspyGeo"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5b5eaacad78e112ae5c6a99032514ed381c4495fe5a736effb9d8c3508fc46a",
                "md5": "250ca3dcfc2b4345d333f69a7ed808de",
                "sha256": "55fdaee50a00149b4f9d091bfa07c6d9c2c2b409f3647ff189658fca839b38c2"
            },
            "downloads": -1,
            "filename": "RaspyGeo-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "250ca3dcfc2b4345d333f69a7ed808de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 32032,
            "upload_time": "2023-06-15T22:23:00",
            "upload_time_iso_8601": "2023-06-15T22:23:00.361086Z",
            "url": "https://files.pythonhosted.org/packages/f5/b5/eaacad78e112ae5c6a99032514ed381c4495fe5a736effb9d8c3508fc46a/RaspyGeo-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f94d55ce9b7ec4e3a2cdb5c86b032536fa33a1120ec3211a0b325672a92448b",
                "md5": "29b20a160ba35e4955fc606152af4745",
                "sha256": "e03cdf2a031df31b4429ba3ae34ec4824f52bf4c10c546a2ab152c7d67874625"
            },
            "downloads": -1,
            "filename": "RaspyGeo-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "29b20a160ba35e4955fc606152af4745",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 31026,
            "upload_time": "2023-06-15T22:23:01",
            "upload_time_iso_8601": "2023-06-15T22:23:01.909390Z",
            "url": "https://files.pythonhosted.org/packages/1f/94/d55ce9b7ec4e3a2cdb5c86b032536fa33a1120ec3211a0b325672a92448b/RaspyGeo-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-15 22:23:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "quantum-dan",
    "github_project": "RaspyGeo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "raspygeo"
}
        
Elapsed time: 0.08838s