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.5.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.5-py3-none-any.whl (181.9 kB view details)

Uploaded Python 3

polytope_python-2.1.5-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.5-cp312-cp312-macosx_11_0_arm64.whl (520.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.5-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.5-cp311-cp311-macosx_11_0_arm64.whl (520.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.5-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.5-cp310-cp310-macosx_11_0_arm64.whl (520.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.5-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.5-cp39-cp39-macosx_11_0_arm64.whl (520.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.5-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.5-cp38-cp38-macosx_11_0_arm64.whl (520.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 d02a5498e4e436fc630548ed30d164ff786282a977eead27c6c3071fa293ab79
MD5 bb6386c751d46a396feb94fa7b98373f
BLAKE2b-256 4738c42b8634bb1e6cfe5a41486bcb174f84c2cdf023134ac22ad9c1e3e34bab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2736035b680e0c39ae285dfc9c978f60a028f2916a79372572485a114f49d1
MD5 e08e81154ddf17d437cb73fb417196cf
BLAKE2b-256 72c834e81b8082d89329cabe9a3a66953782649b2ea32dbf7450d05cae5a8944

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 883d200c53bbe8c18d8399eba4af676c9a7404a2ed2fd6d662aa35a4e7bddb2c
MD5 15c41a01489d9ffebdd2940146a0d9ed
BLAKE2b-256 1f727edef2f58ee5e4f0b7ee4a149f8fb13db9355dde00d3b0b0d8f7c79c1634

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6ddee5ce68513aa6d387543ce1d17dfb602fd71dbe4258afcb65e0059279556
MD5 3b7878460dd495c11b5323c263abe48d
BLAKE2b-256 448e73f9ee2b88daa8ca1cba3413afaed6bfbd5950182396048a09321cfd0b2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f31b5a22014699605d5cbdb547ba9094bb9b2301724b3ed1b4a940c9973db52a
MD5 d70496a119b32aea018926910305df80
BLAKE2b-256 a29dd04797e69d42443e19ec1e983080769c60363175219e132ca7457442f6ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ca4ca6390dcf66bead5e87caecffa974bf8a372457989b2787f4ada8ae725ee
MD5 2ddc1ba4bc1c51f6966f21721c508716
BLAKE2b-256 01c4c9c464139d9bc58ba275c12efec1016b526de7b8807ecbbf30fa1c541a7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9fd28bc733eb47036e5bfdd2d4404091a9ee540dda7223038a9f8d86eac42d7
MD5 cf3cc40f2a4ede8ceef3e88745471243
BLAKE2b-256 26e7c14f6231c8bfe996348cf5838dd1bc0d2a95fe013a6d4e5c6b98e17764fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a02e80530237f2fa06147feeeee9bb6f563cd8a4bbd8369141d25357eb26d2d
MD5 9907de17142ff196c334c78e90caf3aa
BLAKE2b-256 27852bf3519979ff12661be259803a00aadc16e0e7a86b40c956cbdbf1318be8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1c260b0888d07ac692a87cbd91f97b50e2a64d557ef651203e88358cd59ae96
MD5 392bbe991cbffb14e72866faf081ca02
BLAKE2b-256 fbaf74890dcdccaeec606be9108301878995b7175e796c094a2079a4410741e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd1a14d86bedad96c89e0c6578a911495101ba8be47e01ba40374778b7876c43
MD5 f6daa2c520e056d1d8d5b79d1c3b1d5c
BLAKE2b-256 a8c5be43407b5a34cbe558f260dab5c21d943109dec971c82988e10b5dacad5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98f334a425802bf22cf4d96801e822858352f0ed466665ac11beee79c6337cee
MD5 220834d267d3fa21eaa6789c5323e05b
BLAKE2b-256 9b03eebfca42d42052d26ce658bf365ec487154ddc08b36e90ebb97f5463550e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee2c1536e01ebbe8745629fcccb11c9e3b30d124e4da5bd7116a15c07061dbe3
MD5 aa03c0162c48ca6ffd197448621eb38f
BLAKE2b-256 644f8a0ab30e3fd718c8d293e294da11938262ba8fdd7950f4a407f3a7b17bf2

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