Skip to main content

NCFTOOLS

A collection of Python tools for working with NetCDF files.

Installation

pip install -e .

Features

  • meshinfo: Display mesh information from FlowFM NetCDF files (node/face/edge counts, element types, spatial extent)
  • nc2shp: Convert a UGRID-compliant NetCDF mesh file to ESRI Shapefiles
  • shp2nc: Rebuild a UGRID mesh NetCDF (D-Flow FM net file) from a cell-polygon shapefile
  • transzone1: Build a transition zone from triangle mesh faces and select all intersecting faces
  • transzone2: Extract the core transition zone — faces fully within the shrunk zone
  • setncrain: Point a D-Flow FM model (.ext / .mdu) at a NetCDF rainfall forcing file
  • rnxml: Rename dimr.xml to dimr_config.xml

Usage

Check version

ncftools --version

List all available commands

ncftools-info

meshinfo

Display mesh information from a FlowFM NetCDF file. UGRID (Mesh2d_*), D-Flow FM 2D3D (mesh2d_*, e.g. from RGFGRID) and old-format (NetNode/NetLink) net files are detected automatically.

meshinfo FlowFM_net.nc
meshinfo -h

nc2shp

Convert a NetCDF mesh file to ESRI Shapefiles. Outputs {stem}_faces.shp in the output directory. Pass -d/--dissolve to additionally write {stem}_dissolved.shp, a single polygon dissolved from all mesh faces (slower on large meshes).

nc2shp FlowFM_net.nc
nc2shp mesh.nc -d
nc2shp mesh.nc -o output --crs EPSG:4326
nc2shp mesh.nc -q

shp2nc

Rebuild a D-Flow FM 2D net file (UGRID, mesh2d_* variables) from a polygon shapefile in which every polygon is one mesh cell — the reverse of nc2shp. Vertices shared by neighbouring cells are merged into one node (within --tol, default 0.001 map units), cells are made counter-clockwise, and edges and face centres are derived. Numeric shapefile attributes are kept as face variables. The CRS comes from the .prj; --crs is used only when it is missing. Writes {stem}_net.nc unless -o is given.

shp2nc mesh.shp
shp2nc mesh.shp -o FlowFM_net.nc
shp2nc mesh.shp --tol 0.01 --node-z -5.0
shp2nc mesh.shp -q

transzone1

Buffer triangle mesh faces by +1 m to form a transition zone, then select all faces that intersect it. Outputs trans_zone.shp and trans_zone_extend.shp.

Triangles are identified from the type attribute column when present; otherwise they are detected automatically by vertex count (closed rings with 3 unique vertices).

transzone1 SHP_NC/FlowFM_net_faces.shp
transzone1 SHP_NC/FlowFM_net_faces.shp -o SHP_TRANS
transzone1 SHP_NC/FlowFM_net_faces.shp -q

transzone2

Shrink trans_zone_extend.shp (output of transzone1) by −1 m and select faces fully within the core zone. Outputs trans_zone_core.shp.

transzone2 SHP_NC/FlowFM_net_faces.shp -z SHP_TRANS/trans_zone_extend.shp
transzone2 SHP_NC/FlowFM_net_faces.shp -z SHP_TRANS/trans_zone_extend.shp -o SHP_TRANS
transzone2 SHP_NC/FlowFM_net_faces.shp -z SHP_TRANS/trans_zone_extend.shp -q

setncrain

Point a D-Flow FM model at a NetCDF rainfall forcing file.

Every [Meteo] block in the .ext file is rewritten to quantity=rainfall, forcingFile=<your .nc>, forcingFileType=netcdf. If the .ext file does not exist it is created from a built-in template and registered in the .mdu as ExtForceFileNew.

The NetCDF time axis is read and the model times in the .mdu are set to match it (expressed in the model's Tunit):

Key Value
RefDate midnight of the first time stamp
TStart offset of the first time stamp from RefDate
TStop offset of the last time stamp from RefDate

The forcingFile path is written relative to the .ext file (D-Flow FM resolves it that way); use --as-given to write it exactly as typed. .bak copies of the modified files are written unless --no-backup is given.

setncrain -i May28_Event.nc
setncrain -i data/May28_Event.nc --ext dflowfm/FM_model_bnd.ext
setncrain -i May28_Event.nc --mdu dflowfm/FM_model.mdu --no-time
setncrain -i May28_Event.nc --no-backup --as-given
setncrain -i May28_Event.nc -q

rnxml

Rename dimr.xml to dimr_config.xml, the name the DIMR runner expects. The file stays in its folder and its contents are not touched.

If dimr_config.xml already exists the rename is refused; pass --force to overwrite it (a .bak copy of the old target is kept unless --no-backup).

rnxml
rnxml model/dimr.xml
rnxml dimr.xml -o dimr_config.xml --force
rnxml dimr.xml -q

Python API

from ncftools import meshinfo

meshinfo.show_mesh_info("FlowFM_net.nc")

Metadata

Release files for ncftools 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ncftools 0.12.0
File Size Uploaded Provenance Actions
ncftools-0.12.0.tar.gz 24.6 kB With provenance Details for ncftools-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ncftools 0.12.0
File Interpreter ABI Platform Actions
ncftools-0.12.0-py3-none-any.whl Python 3 none any Details for ncftools-0.12.0-py3-none-any.whl

Total release size: 54.4 kB

Release files / ncftools-0.12.0.tar.gz

Download URL ncftools-0.12.0.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
18ddaad93c5524db66b9b5d64826f102f600e5954603137b49d6f319f5bffa43
BLAKE2b-256 checksum
How to use checksums
ec1e45f2c8ae5becb9440cabfc090ddc3df0d3efd7bfed13a36b233c409697de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / ncftools-0.12.0-py3-none-any.whl

Download URL ncftools-0.12.0-py3-none-any.whl
Size 29.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdfb34937f85200752fe34bb5964400cc3765b20a2321f5663b695cb7e4e6b4d
BLAKE2b-256 checksum
How to use checksums
8779376f1af6bb9478aeadfc332fd2edc8a4cb7389fabb4979184632195f9c25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for ncftools 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ncftools-0.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page