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

Uploaded Python 3

polytope_python-2.1.10-cp312-cp312-manylinux_2_28_x86_64.whl (575.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.10-cp312-cp312-macosx_11_0_arm64.whl (521.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.10-cp311-cp311-manylinux_2_28_x86_64.whl (577.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.10-cp311-cp311-macosx_11_0_arm64.whl (522.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.10-cp310-cp310-manylinux_2_28_x86_64.whl (577.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.10-cp310-cp310-macosx_11_0_arm64.whl (522.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.10-cp39-cp39-manylinux_2_28_x86_64.whl (577.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.10-cp39-cp39-macosx_11_0_arm64.whl (522.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.10-cp38-cp38-manylinux_2_28_x86_64.whl (577.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.10-cp38-cp38-macosx_11_0_arm64.whl (521.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for polytope_python-2.1.10.tar.gz
Algorithm Hash digest
SHA256 e206a272af8a03840451b5a9401f5e201a49c789b200994231e331a0ddc0759c
MD5 07c73db62f34f8a7f7b3fbaefa4fb77d
BLAKE2b-256 947d1c82d820b2c289a73f05aa598fedc5b00715a212336611f3caf43f25445a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 26c533ed339e8236db5b55bf6027fa0eb2eced94111fb43aafdb4d7f2015116f
MD5 0a2bf0902a3d257a9456db092ef0a94e
BLAKE2b-256 748ab6cf8cd7bc20ae0427885eb6b8ad9a018af0b9a0eca99ecc74d9210d4b8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 975b8b7e7e6bae9566777b5808501dd8aebe00f7a3e0595629526df1bf868270
MD5 e79fa37bb51333b51181227d071ad63e
BLAKE2b-256 e840a7f126ac0e30d64a3fa3ff94f9b3177e0cf6a8da4e8c08b6140ad35a9e85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42e4fdbb25703fbe3b9e05ca7bd705ee972d3345cf1ca07df3e4dfd689d31f02
MD5 b5b7f3a1dec08ded32a10e1d0a81033b
BLAKE2b-256 343db0f626a29095b754ddb2ae37298fa46e031e5b13171a5b4d7fd3bf02f98a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 448e1de1e0596a5beb90dd4dc7d4e550dbb82975a5ba7e0f46f0102c21686d3e
MD5 6f15b1f6ec9cbb4f12a35c9c305b4df3
BLAKE2b-256 6783b32565a896acc3a196d67ac376f3080d1af7ef2aa8530a9a49b1f024a465

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b075f6bb1f4a2e772a77281c01b479671646b8a4fe2f937d4c7aa2115a03a244
MD5 544243f4b7bdf7dd5374b03835de2c40
BLAKE2b-256 6ea68e150775262a5483cd5c721b9479d1a74e66f50bb6fa918589e2171f4c76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1674d6cc22b417c52c44cad813ec47a5f47d17f8f961f199afeaf106407e31f1
MD5 b8819d1a352917767d44dd54f00a1cb7
BLAKE2b-256 5b9b70eac0fd482ebbc9db6aa6f03ebb715079fe57f251068987986d4b2cd5b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1add623ea2ecf29e0d9903a8e0b8ffe3349b37d633b44a31ad7d53afed09652f
MD5 c9690e6242e6c7ce71ceca871886fe9b
BLAKE2b-256 8dff397750319536089a255485d41f6e8841801b87a8b0745dbe6780bb879e0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d02528f7a2ce591e465db988d3b1feab982a72aadc640721bea5787e93ba8af6
MD5 de634bb3c6929513da3edb98db582818
BLAKE2b-256 67e2accee25a5384121799ab0ca891dc0a61034eeb22250d8f5692181260f40b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f359ff425750c81896f74a406173c1dc99377d4c2f7b7676d6455b378e3de39
MD5 5feafd679d7541f187ff92f4a46220cd
BLAKE2b-256 188aa276676f0d6a2d925f9a0455ecfa39998e28bc6c59d6ed9fdf563e3b2935

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a94a8d6fa4f8be3983d4c108a2f304add53da0d8fa431f52c8f31ef8a8c0b6d
MD5 a98199600a93258e9e15d2b1f306b732
BLAKE2b-256 46ff787ab237b11eda035d12b678d230ea20198f641f5425374251a2867b97e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.10-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88c9def7eadaa89b19b168de5ff470e7288f300d08a18be5e3d32c54f7186006
MD5 97d6ea2b79652a00866801d6d29d2987
BLAKE2b-256 166b38c9718885d8791d63a76ece9dac9ec14bde86972d8466db0085e502dd70

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