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.2.5 (2018-05-16)

  • Use the custom NumpyEncoder to convert specific numpy types to native python types when calling (geo-)json.dumps().

0.2.4 (2018-05-15)

  • Introducing subset fields that can be used to query results that are collected only for subsets of the model, like the 2D section.

0.2.3 (2018-05-14)

  • Fix lookup_index functionality for composite fields.

  • Make model name property optional. That is, ‘unknown’ will be returned if the name cannot be derived.

  • Changed Depth/width fields on breach-timeseries to breach_depth and breach_width.

0.2.2 (2018-04-30)

  • _get_composite_meta() does not raise an AssertionError anymore if composite field attributes differ. Instead a warning is issued.

0.2.1 (2018-04-26)

  • Bug fix: threedicore_result_version must be a property.

0.2 (2018-04-26)

  • Added additional exporters for

    • 2D_GROUNDWATER

    • 2D_OPEN_WATER

    • 2D_VERTICAL_INFILTRATION

  • Added method get_model_instance_by_field_name to the GridH5ResultAdmin class. This makes it possible to do reverse lookups in situations where you have a field name but do not know which model it belongs to. N.B the field must be unique otherwise an IndexError will be raised.

  • Added property dt_timestamps to the timeseries_mixin module.

  • The version number is added to the __init__ file dynamically using the pkg_resources API.

  • Timestamps of all timeseries fields are shown for aggregation results.

  • Timestamps in the aggregation results are filtered when retrieving subsets of timeseries.

  • Introducing the ModelMeta class. Its main purpose at this moment is to compute all possible combinations of composite_fields and aggregation variables.

  • Fixed return statement of method slice (in class Model) which now takes **new_class_kwargs.

  • Empty or missing datasets are now displayed as np.array(None) instead of raising an error.

0.1.6 (2018-04-18)

  • New release using twine 1.11.

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 Distribution

threedigrid-0.2.5.tar.gz (28.3 MB view details)

Uploaded Source

Built Distribution

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

threedigrid-0.2.5-py2.py3-none-any.whl (86.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file threedigrid-0.2.5.tar.gz.

File metadata

  • Download URL: threedigrid-0.2.5.tar.gz
  • Upload date:
  • Size: 28.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for threedigrid-0.2.5.tar.gz
Algorithm Hash digest
SHA256 6dd0dd99ec0fae9a961170fd33fad4a26bced725203e94cf9905f709dcd94d21
MD5 369592781d8ed9df611b3585acaac4db
BLAKE2b-256 525732b9391a00e839a4720d40af6150cb389dec972e52bcc2f503e598fd6679

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid-0.2.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f0cac0fd22e80c60ae8f8651d59254f41979f952ce12058870e679c12b4288b
MD5 cfc65c5f5b519c816d3b7b3be940f74a
BLAKE2b-256 36cac9ec876d38c30d885c51043d57e711d8ea6fb121bc1abc86440ce345569a

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