Skip to main content

Python package for the threedigrid administration

Project description

Threedigrid: The 3Di grid admin framework

The Python package for the threedigrid administration.

https://travis-ci.org/nens/threedigrid.svg?branch=master Documentation Status

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.5 (2018-04-18)

  • Added support for composite fields which can be used to fetch data from multiple source variables as a single field. Like this result_3di netcdfs can be queried the same way as gridadmin files.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

threedigrid-0.1.5-py2.py3-none-any.whl (79.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file threedigrid-0.1.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for threedigrid-0.1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8ff5cea10f4d805761ac77a6a33359a1b6c95a1442187f8c781a2396ab75a1b2
MD5 31e42e69c6b008aeb554e6833cea5e00
BLAKE2b-256 81e6d08789d05dfddfa80387697e0c214e7cde88ca95798f7a0972569d5b7600

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page