Skip to content

Commit a9d14da

Browse files
committed
Merge branch 'main' into Feature/ras_1d
2 parents 61a1a7c + 025cf0e commit a9d14da

24 files changed

+436
-107
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
os: ["ubuntu-latest"]
2727

2828
runs-on: ${{ matrix.os }}
29+
environment: ci-env
2930

3031
steps:
3132
- uses: actions/checkout@v4
@@ -45,6 +46,15 @@ jobs:
4546
ruff check
4647
ruff format --check
4748
48-
- name: Test with pytest
49+
- name: Run tests with coverage
4950
run: |
50-
pytest
51+
pytest --cov=src --cov-report term-missing
52+
53+
- name: Run coverage
54+
run: |
55+
coverage xml
56+
57+
- name: Upload coverage reports to Codecov
58+
uses: codecov/[email protected]
59+
with:
60+
token: ${{ secrets.CODECOV_TOKEN }}

.readthedocs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: mambaforge-latest
13+
14+
# Build documentation in the "docs/" directory with Sphinx
15+
sphinx:
16+
configuration: docs/source/conf.py
17+
18+
# Optionally build your docs in additional formats such as PDF and ePub
19+
# formats:
20+
# - pdf
21+
# - epub
22+
23+
# Optional but recommended, declare the Python requirements required
24+
# to build your documentation
25+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
26+
conda:
27+
environment: docs/environment.yml

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
[![CI](https://github.com/fema-ffrd/rashdf/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/fema-ffrd/rashdf/actions/workflows/continuous-integration.yml)
33
[![Release](https://github.com/fema-ffrd/rashdf/actions/workflows/release.yml/badge.svg)](https://github.com/fema-ffrd/rashdf/actions/workflows/release.yml)
44
[![PyPI version](https://badge.fury.io/py/rashdf.svg)](https://badge.fury.io/py/rashdf)
5+
[![codecov](https://codecov.io/gh/fema-ffrd/rashdf/graph/badge.svg?token=CTIIONEHV1)](https://codecov.io/gh/fema-ffrd/rashdf)
6+
[![Documentation Status](https://readthedocs.org/projects/rashdf/badge/?version=latest)](https://rashdf.readthedocs.io/en/latest/?badge=latest)
57

68
Read data from [HEC-RAS](https://www.hec.usace.army.mil/software/hec-ras/) [HDF](https://github.com/HDFGroup/hdf5) files.
79

810
*Pronunciation: `raz·aitch·dee·eff`*
911

12+
## Documentation
13+
[rashdf on ReadTheDocs](http://rashdf.readthedocs.io/)
14+
1015
## Install
1116
```bash
1217
$ pip install rashdf
@@ -97,9 +102,6 @@ Example: write structures GeoJSON to `stdout`:
97102
$ rashdf structures Potomac.p01.hdf
98103
```
99104

100-
## Documentation
101-
Coming soon.
102-
103105
## Developer Setup
104106
Create a virtual environment in the project directory:
105107
```

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: rashdf-docs
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- python=3.9
7+
- pip
8+
- pip:
9+
- -e ../[docs]

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/RasGeomHdf.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
RasGeomHdf
2+
==========
3+
.. currentmodule:: rashdf
4+
.. autoclass:: RasGeomHdf
5+
:show-inheritance:
6+
:members: projection,
7+
mesh_area_names,
8+
mesh_areas,
9+
mesh_cell_polygons,
10+
mesh_cell_points,
11+
mesh_cell_faces,
12+
bc_lines,
13+
breaklines,
14+
refinement_regions,
15+
structures,
16+
get_geom_attrs,
17+
get_geom_structures_attrs,
18+
get_geom_2d_flow_area_attrs

docs/source/RasHdf.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
RasHdf
2+
======
3+
.. currentmodule:: rashdf
4+
.. autoclass:: RasHdf
5+
:show-inheritance:
6+
:special-members: __init__,
7+
open_uri

docs/source/RasPlanHdf.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
RasPlanHdf
2+
==========
3+
.. currentmodule:: rashdf
4+
.. autoclass:: RasPlanHdf
5+
:show-inheritance:
6+
:members: get_plan_info_attrs,
7+
get_plan_param_attrs,
8+
get_meteorology_precip_attrs,
9+
get_results_unsteady_attrs,
10+
get_results_unsteady_summary_attrs,
11+
get_results_volume_accounting_attrs

docs/source/_static/.gitkeep

Whitespace-only changes.

docs/source/_templates/.gitkeep

Whitespace-only changes.

docs/source/conf.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
import sys
7+
8+
sys.path.insert(0, "src")
9+
10+
# -- Project information -----------------------------------------------------
11+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
12+
13+
project = "rashdf"
14+
copyright = "2024, fema-ffrd"
15+
author = "fema-ffrd"
16+
release = "0.2.1"
17+
18+
# -- General configuration ---------------------------------------------------
19+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20+
21+
extensions = [
22+
"sphinx.ext.autodoc",
23+
"sphinx.ext.autosummary",
24+
"sphinx_rtd_theme",
25+
"numpydoc",
26+
]
27+
28+
numpydoc_show_class_members = False
29+
30+
templates_path = ["_templates"]
31+
exclude_patterns = []
32+
33+
34+
# -- Options for HTML output -------------------------------------------------
35+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
36+
37+
# html_theme = "alabaster"
38+
html_theme = "sphinx_rtd_theme"
39+
html_static_path = ["_static"]

docs/source/index.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
.. rashdf documentation master file, created by
2+
sphinx-quickstart on Mon Jun 3 15:55:12 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
7+
rashdf Documentation
8+
====================
9+
:code:`rashdf` is a library for reading data from `HEC-RAS <https://www.hec.usace.army.mil/software/hec-ras/>`_
10+
HDF5 files. It is a wrapper around the :code:`h5py` library, and provides an interface with
11+
convenience functions for reading key HEC-RAS geometry data, output data,
12+
and metadata.
13+
14+
Installation
15+
============
16+
With :code:`pip`::
17+
18+
pip install rashdf
19+
20+
21+
Quickstart
22+
==========
23+
Reading geometry from a HEC-RAS geometry HDF file::
24+
25+
>>> from rashdf import RasGeomHdf
26+
>>> with RasGeomHdf('Muncie.g05.hdf') as geom_hdf:
27+
... projection = geom_hdf.projection()
28+
... mesh_area_names = geom_hdf.mesh_area_names()
29+
... mesh_areas = geom_hdf.mesh_areas()
30+
... mesh_cell_points = geom_hdf.mesh_cell_points()
31+
>>> projection
32+
<Projected CRS: EPSG:2965>
33+
Name: NAD83 / Indiana East (ftUS)
34+
Axis Info [cartesian]:
35+
- E[east]: Easting (US survey foot)
36+
- N[north]: Northing (US survey foot)
37+
Area of Use:
38+
- undefined
39+
Coordinate Operation:
40+
- name: unnamed
41+
- method: Transverse Mercator
42+
Datum: North American Datum 1983
43+
- Ellipsoid: GRS 1980
44+
- Prime Meridian: Greenwich
45+
>>> mesh_area_names
46+
['2D Interior Area', 'Perimeter_NW']
47+
>>> mesh_areas
48+
mesh_name geometry
49+
0 2D Interior Area POLYGON ((409537.180 1802597.310, 409426.140 1...
50+
1 Perimeter_NW POLYGON ((403914.470 1804971.220, 403008.310 1...
51+
>>> mesh_cell_points
52+
mesh_name cell_id geometry
53+
0 2D Interior Area 0 POINT (406000.000 1805000.000)
54+
1 2D Interior Area 1 POINT (406050.000 1805000.000)
55+
2 2D Interior Area 2 POINT (406100.000 1805000.000)
56+
3 2D Interior Area 3 POINT (406150.000 1805000.000)
57+
4 2D Interior Area 4 POINT (406200.000 1805000.000)
58+
... ... ... ...
59+
5785 Perimeter_NW 514 POINT (403731.575 1804124.860)
60+
5786 Perimeter_NW 515 POINT (403650.619 1804121.731)
61+
5787 Perimeter_NW 516 POINT (403585.667 1804141.139)
62+
5788 Perimeter_NW 517 POINT (403534.818 1804186.902)
63+
5789 Perimeter_NW 518 POINT (403632.837 1804235.708)
64+
65+
Reading plan data from a HEC-RAS plan HDF file hosted on AWS S3
66+
(note, this requires installation of the optional :code:`fsspec`
67+
and :code:`s3fs` libraries as well as configuration of S3
68+
credentials)::
69+
70+
>>> from rashdf import RasPlanHdf
71+
>>> with RasPlanHdf.open_uri('s3://bucket/ElkMiddle.p01.hdf') as plan_hdf:
72+
... plan_info = plan_hdf.get_plan_info_attrs()
73+
>>> plan_info
74+
{'Base Output Interval': '1HOUR', 'Computation Time Step Base': '1MIN',
75+
'Flow Filename': 'ElkMiddle.u01', 'Flow Title': 'Jan_1996',
76+
'Geometry Filename': 'ElkMiddle.g01', 'Geometry Title': 'ElkMiddle',
77+
'Plan Filename': 'ElkMiddle.p01', 'Plan Name': 'Jan_1996',
78+
'Plan ShortID': 'Jan_1996', 'Plan Title': 'Jan_1996',
79+
'Project Filename': 'g:\\Jan1996_Kanawha_CloudPrep\\Elk Middle\\ElkMiddle.prj',
80+
'Project Title': 'ElkMiddle',
81+
'Simulation End Time': datetime.datetime(1996, 2, 7, 12, 0),
82+
'Simulation Start Time': datetime.datetime(1996, 1, 14, 12, 0),
83+
'Time Window': [datetime.datetime(1996, 1, 14, 12, 0),
84+
datetime.datetime(1996, 2, 7, 12, 0)]}
85+
86+
87+
API
88+
===
89+
.. toctree::
90+
:maxdepth: 1
91+
92+
RasGeomHdf
93+
RasPlanHdf
94+
RasHdf
95+
96+
:code:`rashdf` provides two primary classes for reading data from
97+
HEC-RAS geometry and plan HDF files: :code:`RasGeomHdf` and :code:`RasPlanHdf`.
98+
Both of these classes inherit from the :code:`RasHdf` base class, which
99+
inherits from the :code:`h5py.File` class.
100+
101+
Note that :code:`RasPlanHdf` inherits from :code:`RasGeomHdf`, so all of the
102+
methods available in :code:`RasGeomHdf` are also available in :code:`RasPlanHdf`.

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ classifiers = [
1212
"Programming Language :: Python :: 3.11",
1313
"Programming Language :: Python :: 3.12",
1414
]
15-
version = "0.2.1"
15+
version = "0.2.2"
1616
dependencies = ["h5py", "geopandas", "pyarrow"]
1717

1818
[project.optional-dependencies]
19-
dev = ["pre-commit", "ruff", "pytest"]
19+
dev = ["pre-commit", "ruff", "pytest", "pytest-cov"]
20+
docs = ["sphinx", "numpydoc", "sphinx_rtd_theme"]
2021

2122
[project.urls]
2223
repository = "https://github.com/fema-ffrd/rashdf"
@@ -28,10 +29,12 @@ rashdf = "cli:main"
2829
pythonpath = "src"
2930
testpaths = "tests"
3031

31-
# TODO: linting for docstrings.
32-
# https://github.com/fema-ffrd/rashdf/issues/15
33-
# [tool.ruff.lint]
34-
# select = ["D"]
32+
[tool.ruff.lint]
33+
select = ["D"]
3534

36-
# [tool.ruff.lint.pydocstyle]
37-
# convention = "numpy"
35+
[tool.ruff.lint.pydocstyle]
36+
convention = "numpy"
37+
38+
[tool.ruff.lint.per-file-ignores]
39+
"tests/**" = ["D"]
40+
"docs/**" = ["D"]

requirements.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)