Python package for the threedigrid administration
Project description
Threedigrid: The 3Di grid admin framework
The Python package for the threedigrid administration.
Free software: BSD license
Documentation: https://threedigrid.readthedocs.io.
Overview
Features
access to the threedicore administration by a single instance of the GridH5Admin object
query the model data by pre-defined subsets and django style filters
export model data to gis formats like shapefile, geopackage
serialize model data as geojson
Quick start
The standard threedigrid distribution is pretty lightweight, installing as little dependencies as possible. If you want to make use of all capabilities threedigrid has to ofter (e.g. spatial operations and command line tools) install like this:
$ pip install threedigrid[geo]
Console scripts
Using the 3digrid_explore shortcut, simply run:
$ 3digrid_explore --grid-file=<path to grid file> --ipy
This will invoke an ipython session with a GridH5Admin instance already loaded.
To get a quick overview of the threedimodels meta data omit the --ipy option or explicitly run:
$ 3digrid_explore --grid-file=<the to grid file> --no-ipy
This will give you output like this:
Overview of model specifics: model slug: v2_bergermeer-v2_bergermeer_bres_maalstop-58-b1f8179f1f3c2333adb08c9e6933fa7b9a8cd163 threedicore version: 0-20180315-3578e9b-1 threedi version: 1.63.dev0 has 1d: True has 2d: True has groundwater: True has levees: True has breaches: True has pumpstations: True
(I)Python shell
Get a grid admin instance:
from threedigrid.admin.gridadmin import GridH5Admin f = 'gridadmin.h5' ga = GridH5Admin(f)
The grid admin directly holds some model specific attributes like whether the model has a 1D or 2D or groundwater section:
In [4]: ga.has_groundwater Out[4]: False In [5]: ga.has_1d Out[5]: True
There are different types of filters but a filter, generally speaking, acts on field. That means you can filter by value. If you have a line model instance you can filter the data by the kcu field:
ga.lines.filter(kcu__in=[100,102])
or by the lik value:
ga.lines.filter(lik__eq=4)
The filtering is lazy, that is, to retrieve data you have to call data explicitly:
ga.lines.filter(lik__eq=4).data # will return an ordered dict
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.4 (2018-04-08)
Changed ResultMixin to dynamically add attributes based on the netcdf variables.
Added basic result proccesing for line/node data.
The filter mask is computed only for array’s affected and before applying it to all array’s
The ‘only’ filter works much faster because the filter mask is only applied on fields that are affected.
The filter mask is cached on the line/node instance after getting the first value. You can thus do something like:
queryset = gridadmin.lines.filter(kcu=2) ids = queryset.id line_coords = queryset.line_coords
and the filter mask will only be computed once.
Add click console scripts 3digrid_explore and 3digrid_export for quick overviews and data exports.
Make ogr/gdal imports optional to avoid breaking parts of the documentation.
Added documentation and setup for sphinx documentation pipeline.
Use linear referencing for embedded channels to keep the original geometry intact when preparing line geometries for visualisation.
Define extra’s to make the standard threedigrid distribution as lightweight as possible.
Convert strings in attrs to numpy.string_ to fix crashes under Windows.
0.1.3 (2018-03-16)
Remove property has_groundwater from GridH5Admin. Should always be provided by the threedicore itself. Gives a warning for backwards compatibility.
0.1.2 (2018-03-12)
Get model extent now always returns a bbox (minX, minY, maxX, maxY)
0.1.1 (2018-03-06)
All imports are absolute.
Added install info using pip.
0.1.0 (2018-03-05)
First release with fullrelease.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for threedigrid-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9352f405c5d0cf546928575f5d23d3a23875f93d755b2019328739737fe7bc31 |
|
MD5 | e6ac4ac263816aa168f82b7ca6d9bc8f |
|
BLAKE2b-256 | 8e0fa8bc7baa99579a528cf7362033fd3ac0d0c843a7d9b294db6c0f5976742e |