Skip to main content

Polytope datacube feature extraction library

Project description


Project Maturity ESEE

ci Documentation Status

ConceptInstallationExampleTestingDocumentation

Polytope is a library for extracting complex data from datacubes. It provides an API for non-orthogonal access to data, where the stencil used to extract data from the datacube can be any arbitrary n-dimensional polygon (called a polytope). This can be used to efficiently extract complex features from a datacube, such as polygon regions or spatio-temporal paths.

Polytope is designed to extend different datacube backends:

  • XArray dataarrays
  • FDB object stores (through the GribJump software)

Polytope supports datacubes which have branching, non-uniform indexing, and even cyclic axes. If the datacube backend supports byte-addressability and efficient random access (either in-memory or direct from storage), Polytope can be used to dramatically decrease overall I/O load.

[!IMPORTANT] This software is Incubating and subject to ECMWF's guidelines on Software Maturity.

Concept

Polytope is designed to enable extraction of arbitrary extraction of data from a datacube. Instead of the typical range-based bounding-box approach, Polytope can extract any shape of data from a datacube using a "polytope" (n-dimensional polygon) stencil.

Polytope Concept

The Polytope algorithm can for example be used to extract:

  • 2D cut-outs, such as country cut-outs, from a datacube

    Greece cut-out

  • timeseries from a datacube

    Timeseries

  • more complicated spatio-temporal paths, such as flight paths, from a datacube

    Flight path

  • and many more high-dimensional shapes in arbitrary dimensions...

For more information about the Polytope algorithm, refer to our paper. If this project is useful for your work, please consider citing this paper.

Installation

Install the polytope software with Python 3 (>=3.7) from GitHub directly with the command

python3 -m pip install git+ssh://git@github.com/ecmwf/polytope.git@develop

or from PyPI with the command

python3 -m pip install polytope-python

Example

Here is a step-by-step example of how to use this software.

  1. In this example, we first specify the data which will be in our Xarray datacube. Note that the data here comes from the GRIB file called "winds.grib", which is 3-dimensional with dimensions: step, latitude and longitude.

        import xarray as xr
    
        array = xr.open_dataset("winds.grib", engine="cfgrib")
    

    We then construct the Polytope object, passing in some additional metadata describing properties of the longitude axis.

        options = {"longitude": {"cyclic": [0, 360.0]}}
    
        from polytope_feature.polytope import Polytope
    
        p = Polytope(datacube=array, axis_options=options)
    
  2. Next, we create a request shape to extract from the datacube.
    In this example, we want to extract a simple 2D box in latitude and longitude at step 0. We thus create the two relevant shapes we need to build this 3-dimensional object,

        import numpy as np
        from polytope_feature.shapes import Box, Select
    
        box = Box(["latitude", "longitude"], [0, 0], [1, 1])
        step_point = Select("step", [np.timedelta64(0, "s")])
    

    which we then incorporate into a Polytope request.

        from polytope_feature.polytope import Request
    
        request = Request(box, step_point)
    
  3. Finally, extract the request from the datacube.

        result = p.retrieve(request)
    

    The result is stored as an IndexTree containing the retrieved data organised hierarchically with axis indices for each point.

        result.pprint()
        
    
        Output IndexTree: 
    
            root=None
                step=0 days 00:00:00
                        latitude=0.0
                                longitude=0.0
                                longitude=1.0
                        latitude=1.0
                                longitude=0.0
                                longitude=1.0
    

Testing

Additional Dependencies

The Polytope tests and examples require additional Python packages compared to the main Polytope algorithm. The additional dependencies are provided in the requirements_test.txt and requirements_examples.txt files, which can respectively be found in the tests and examples folders. Moreover, Polytope's tests and examples also require the installation of eccodes and GDAL. It is possible to install both of these dependencies using either a package manager or manually.

Contributing

The main repository is hosted on GitHub; testing, bug reports and contributions are highly welcomed and appreciated. Please see the Contributing document for the best way to help.

Main contributors:

See also the contributors for a more complete list.

License

Copyright 2021 European Centre for Medium-Range Weather Forecasts (ECMWF)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

In applying this licence, ECMWF does not waive the privileges and immunities
granted to it by virtue of its status as an intergovernmental organisation nor
does it submit to any jurisdiction.

Citing

If this software is useful in your work, please consider citing our paper as

Leuridan, M., Hawkes, J., Smart, S., Danovaro, E., & Quintino, T. (2025, November). Polytope: An Algorithm for Efficient Feature Extraction on Hypercubes. In Journal of Big Data (pp. 1-25).

Other papers include:

Leuridan, M., Bradley, C., Hawkes, J., Quintino, T., & Schultz, M. (2025, June). Performance Analysis of an Efficient Algorithm for Feature Extraction from Large Scale Meteorological Data Stores. In Proceedings of the Platform for Advanced Scientific Computing Conference (pp. 1-9).

Acknowledgements

Past and current funding and support for Polytope is listed in the adjoining Acknowledgements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polytope_python-2.1.4.tar.gz (14.3 MB view details)

Uploaded Source

Built Distributions

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

polytope_python-2.1.4-py3-none-any.whl (181.9 kB view details)

Uploaded Python 3

polytope_python-2.1.4-cp312-cp312-manylinux_2_28_x86_64.whl (573.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.4-cp312-cp312-macosx_11_0_arm64.whl (520.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.4-cp311-cp311-manylinux_2_28_x86_64.whl (574.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.4-cp311-cp311-macosx_11_0_arm64.whl (520.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.4-cp310-cp310-manylinux_2_28_x86_64.whl (574.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.4-cp310-cp310-macosx_11_0_arm64.whl (520.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.4-cp39-cp39-manylinux_2_28_x86_64.whl (574.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.4-cp39-cp39-macosx_11_0_arm64.whl (520.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.4-cp38-cp38-manylinux_2_28_x86_64.whl (574.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.4-cp38-cp38-macosx_11_0_arm64.whl (520.1 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file polytope_python-2.1.4.tar.gz.

File metadata

  • Download URL: polytope_python-2.1.4.tar.gz
  • Upload date:
  • Size: 14.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for polytope_python-2.1.4.tar.gz
Algorithm Hash digest
SHA256 464dd3ec5bd29d5d1a27a0cbbe271f1307c34d7a4d1a249fbcefb22eb67a4490
MD5 7e006c3681dad970d95f5e3258ace562
BLAKE2b-256 3777ff897d0699e0649989ad03a4847f6446632ad811814dbd9d8ca003db855b

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a996a6825b396ea84613b338d2158efc5158b0ac54b255fe56646ffc02cd63a7
MD5 fbf3916023f525f91002298e17d11d66
BLAKE2b-256 568333bb92a39cc9c2b3f1eb9acc1079fe8a42ba014c5034d6dbe896aa770dbd

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 23c93c61ceac97110742b000cfef6787a2a557fdf5f35d5285b270e07f96ca61
MD5 d971389f0b577896d62b84fade8b45fc
BLAKE2b-256 b5e1e12db94d17c8aa213ab63b801c319c8cde245f2ee9e3a9b8ad2aa8c00f77

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56e4fef2a3986916d2184a32c81875c06aed2f826325bf0f94812816257451ea
MD5 e2b558cce6e9c9b34e832a9c5669c551
BLAKE2b-256 d0c408dcd51bba6d743b08ff42369c28c108bc2098bc5cda495bace61a9fee8b

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 837ddf27113f4edde2e0f98c4e9223cd40b7a9746527166055be4a100c841e82
MD5 c3bdab0ca27a2226fa9b353581329ca4
BLAKE2b-256 e96a31d8c1cdc35d32a7abdb5f9ffcbcf23e478bcd96b9f0b58fa136f0cee8b2

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97c837f98ece3b99808bb970d220b0316c088e065a5b5b06e6341edaa0afdb28
MD5 af017063f5dbfe76cdb38c82d1ef3b9d
BLAKE2b-256 26231a30bfce3116182fe8ae407dcddc5a0e56517ea53af4df98f448857aef2a

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66be796dd863ccbecfd8876ec3d2cf3d59120423f310616f2091a444304f0b54
MD5 e698134889b5352aec95216edb3375c2
BLAKE2b-256 ac3662924732752919631308768feffe4bd461a6661091c315f0ab914f0392bc

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06714b10d90873a70684c5d2044a69b7661afbc07fdecc3ba6904feb1880e8ad
MD5 e4de22da60422a63619105e024ad879c
BLAKE2b-256 749cfecd98cc9de820a66fd5feb8d52204581e41aa42b31c727b2c2fce907515

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0df7322a1a177325da4b4a5cb870a97f5113f4a812fdfdcd33100e88d29f5ea3
MD5 6b6600c0a53e8805535b37fa186a5950
BLAKE2b-256 2aaf141f2b349f71e8b9048731f75b0d20a99f9bf7988d3fc5e470a1672cc26c

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37234896ec0c9c0f21c95f8d616e07a17549a0dbba33934430832f87193727f1
MD5 5c70791e90337cfa6c410903a714d599
BLAKE2b-256 928f16f9c2b8dbfb2322237e0b73b41657321222bf241b97cca141c86ee2f6df

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 569937e26822cf14a8a6630d3533f971ceb4a62ca63381b1f054e9f15127a9f1
MD5 5ef5789a3e6eeaa91651fb18e4ba4794
BLAKE2b-256 62201213438086ca77e95f28d847f9b290d3b8aca5aa72a185539d9960052bb8

See more details on using hashes here.

File details

Details for the file polytope_python-2.1.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polytope_python-2.1.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5cd22fad42524e4094d9af6797e316951cc2a64dc51ac39dcf6bf7b12865a86
MD5 5a26df84b8e29f75b04f5fba1f447cfe
BLAKE2b-256 31e7c20f7088f1ec20bf8a8d8161f3bfebdce79357edaa1f13536dacf3171256

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