surface-water-network

A Python package to create and analyze surface water networks.

https://github.com/mwtoews/surface-water-network

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.4%) to scientific vocabulary

Keywords

hydrology modflow python surface-water

Keywords from Contributors

geoscience uncertainty-analysis ode mesh open-science vtk energy-system-model
Last synced: 6 months ago · JSON representation ·

Repository

A Python package to create and analyze surface water networks.

Basic Info
Statistics
  • Stars: 29
  • Watchers: 6
  • Forks: 6
  • Open Issues: 13
  • Releases: 5
Topics
hydrology modflow python surface-water
Created almost 7 years ago · Last pushed 8 months ago
Metadata Files
Readme License Citation

README.md

Surface water network

DOI Codacy Codcov CI

A Python package to create and analyze surface water networks.

Python packages

Python 3.10+ is required.

Required

  • geopandas - process spatial data similar to pandas
  • packaging - used to check package versions
  • pandas - tabular data analysis
  • pyproj - spatial projection support
  • rtree - spatial index support

Optional

  • flopy >=3.3.6 - read/write MODFLOW models
  • netCDF4 - used to read TopNet files

Testing

Run pytest -v or python3 -m pytest -v

For faster multi-core pytest -v -n 2 (with pytest-xdist)

To run doctests pytest -v swn --doctest-modules

Examples

python import geopandas import pandas as pd import swn

Read from Shapefile: python shp_srs = "tests/data/DN2_Coastal_strahler1z_stream_vf.shp" lines = geopandas.read_file(shp_srs) lines.set_index("nzsegment", inplace=True, verify_integrity=True) # optional

Or, read from PostGIS: ```python from sqlalchemy import create_engine, engine

conurl = engine.url.URL(drivername="postgresql", database="scigen") con = createengine(conurl) sql = "SELECT * FROM wrc.rec2riverlinescoastal" lines = geopandas.readpostgis(sql, con) lines.setindex("nzsegment", inplace=True, verifyintegrity=True) # optional ```

Initialise and create network: ```python n = swn.SurfaceWaterNetwork.from_lines(lines.geometry) print(n)

<SurfaceWaterNetwork: with Z coordinates

304 segments: [3046409, 3046455, ..., 3050338, 3050418]

154 headwater: [3046409, 3046542, ..., 3050338, 3050418]

3 outlets: [3046700, 3046737, 3046736]

no diversions />

```

Plot the network, write a Shapefile, write and read a SurfaceWaterNetwork file: ```python n.plot()

swn.file.gdftoshapefile(n.segments, "segments.shp")

n.topickle("network.pkl") n = swn.SurfaceWaterNetwork.frompickle("network.pkl") ```

Remove segments that meet a condition (stream order), or that are upstream/downstream from certain locations: python n.remove( n.segments.stream_order == 1, segnums=n.gather_segnums(upstream=3047927))

Read flow data from a TopNet netCDF file, convert from m3/s to m3/day: ```python

ncpath = "tests/data/streamq2017011520170128topnet03046727strahler1.nc" flow = swn.file.topnet2ts(ncpath, "modflow", 86400)

remove time and truncate to closest day

flow.index = flow.index.floor("d")

7-day mean

flow7d = flow.resample("7D").mean()

full mean

flow_m = pd.DataFrame(flow.mean(0)).T ```

Process a MODFLOW/flopy model: ```python import flopy

m = flopy.modflow.Modflow.load("h.nam", modelws="tests/data", check=False) nm = swn.SwnModflow.fromswnflopy(n, m) nm.defaultsegmentdata() nm.setsegmentdatainflow(flowm) nm.plot() nm.topickle("sfrnetwork.pkl") nm = swn.SwnModflow.frompickle("sfrnetwork.pkl", n, m) nm.setsfrobj() m.sfr.writefile("file.sfr") nm.gridcells.tofile("gridcells.shp") nm.reaches.tofile("reaches.shp") ```

Citation

Toews, M. W.; Hemmings, B. 2019. A surface water network method for generalising streams and rapid groundwater model development. In: New Zealand Hydrological Society Conference, Rotorua, 3-6 December, 2019. p. 166-169.

Owner

  • Name: Mike Taves
  • Login: mwtoews
  • Kind: user
  • Location: Wellington, New Zealand
  • Company: GNS Science

Hydrogeologist, numerical modeller, GIS guru. Last name is also Toews.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "Please cite this software using these metadata."
type: software
title: "Surface water network"
version: "0.8"
date-released: "2024-07-03"
doi: 10.5281/zenodo.6866082
abstract: "A Python package to create and analyze surface water networks."
repository-artifact: https://pypi.org/project/surface-water-network
repository-code: https://github.com/mwtoews/surface-water-network
license: "BSD-3-Clause"
authors:
  - given-names: "Mike W."
    family-names: Taves
    email: mwtoews@gmail.com
    affiliation: "GNS Science"
    orcid: "https://orcid.org/0000-0003-3657-7963"
  - given-names: Brioch
    family-names: Hemmings
    email: briochh@gmail.com
    affiliation: "GNS Science"
    orcid: "https://orcid.org/0000-0001-6311-8450"
keywords:
  - "surface water"
  - groundwater
  - MODFLOW
  - flopy

GitHub Events

Total
  • Issues event: 3
  • Watch event: 1
  • Delete event: 7
  • Push event: 16
  • Pull request review event: 1
  • Pull request event: 15
  • Create event: 7
Last Year
  • Issues event: 3
  • Watch event: 1
  • Delete event: 7
  • Push event: 16
  • Pull request review event: 1
  • Pull request event: 15
  • Create event: 7

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 317
  • Total Committers: 5
  • Avg Commits per committer: 63.4
  • Development Distribution Score (DDS): 0.117
Past Year
  • Commits: 20
  • Committers: 2
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.2
Top Committers
Name Email Commits
Mike Taves m****s@g****m 280
Briochh b****h@g****m 23
pre-commit-ci[bot] 6****] 12
Codacy Badger b****r@c****m 1
Brioch Hemmings b****s@g****z 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 25
  • Total pull requests: 97
  • Average time to close issues: 11 months
  • Average time to close pull requests: 14 days
  • Total issue authors: 4
  • Total pull request authors: 5
  • Average comments per issue: 0.72
  • Average comments per pull request: 0.28
  • Merged pull requests: 84
  • Bot issues: 0
  • Bot pull requests: 17
Past Year
  • Issues: 3
  • Pull requests: 16
  • Average time to close issues: N/A
  • Average time to close pull requests: about 7 hours
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • wkitlasten (14)
  • mwtoews (8)
  • briochh (3)
  • izarikos (1)
Pull Request Authors
  • mwtoews (74)
  • pre-commit-ci[bot] (20)
  • wkitlasten (9)
  • briochh (3)
  • codacy-badger (1)
Top Labels
Issue Labels
task (3) enhancement (2)
Pull Request Labels
enhancement (4) potentially breaking (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 25 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 7
  • Total maintainers: 1
pypi.org: surface-water-network

Surface water network

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 25 Last month
Rankings
Dependent packages count: 7.3%
Stargazers count: 12.5%
Forks count: 13.3%
Average: 21.6%
Dependent repos count: 22.1%
Downloads: 52.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/pages.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
  • geopandas >=0.9
  • packaging *
  • pandas >=1.2
  • pyproj >=2.2
  • rtree *
  • shapely *
setup.py pypi