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

Uploaded Python 3

polytope_python-2.1.7-cp312-cp312-manylinux_2_28_x86_64.whl (576.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.7-cp312-cp312-macosx_11_0_arm64.whl (520.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.7-cp311-cp311-manylinux_2_28_x86_64.whl (577.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.7-cp311-cp311-macosx_11_0_arm64.whl (521.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.7-cp310-cp310-manylinux_2_28_x86_64.whl (577.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.7-cp310-cp310-macosx_11_0_arm64.whl (521.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.7-cp39-cp39-manylinux_2_28_x86_64.whl (577.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.7-cp39-cp39-macosx_11_0_arm64.whl (522.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.7-cp38-cp38-manylinux_2_28_x86_64.whl (577.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.7-cp38-cp38-macosx_11_0_arm64.whl (521.4 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 c926e126d573749c513c92d32560d701c2e75cf2746760e6f46822eff29be444
MD5 565e6abfe55de2e4b013742c6ac989d7
BLAKE2b-256 b7aa6458c622d29546ac50fec2bb650d96812a73781edb814fa7ef8387d0af29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a3ec50b2e6485a289e017e91645a5d646557615d860b90b11198a5e47f22bbc4
MD5 6180d18581b5f09a0199f2189fbfd8e6
BLAKE2b-256 db1b1a2f6f1421c86f0da4bf1e20d54f8f23c72d0e03931356280022cd006a56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af9476ab4b1461c1c9f5027b1d8b019d7f0312a18d062d26a21e46913858d271
MD5 9a8e3e312a9051653455cf9c26010197
BLAKE2b-256 eec2dc8c535a784c64eb6bb4bcfedf4e3943bb0876caa2784fc2efdec0028cf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 535f544e39112e06b30ba3356425fdf494e26294d0fa3c289584f367b0fa5050
MD5 d1d12df17fa3f3aab274e8e1eb5c18f1
BLAKE2b-256 72a24dac6dd1e73b878cfe1ee93ddce62adc8a078980de53105f4d27132f3b59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d822f85a539a3c85094005be17ac139613a4a41c456950304ea0a41089492722
MD5 6c0d6e9739dd86529c26ad8b2768dd89
BLAKE2b-256 11f39c2c175fc68a93a132309a3d3c8ce682647d6f401abfd0ae46fbb04ac8bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfb3c4cad3c495ca535e2d055c08ab3afe992742a7f5dcd71d9c9d78ba8fb14b
MD5 771a711e149843f8548110e16188acf8
BLAKE2b-256 22591b2fd64298b278faaa4389789d25425beba380fc0463f0855fac143d4240

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 592a3cb2cdd86510e9be872df5f10d3c4d972aae63680256de68bed6f5fc86d8
MD5 7d1a964831c28ae208b71f491a075f9a
BLAKE2b-256 9da629ca2985f262c3f46fc6dad5b39b67d9516f705c5b764e972fcdd6cef61d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a351421b7b8a5f98df565eea095f4718e86fecffbbd277b9585b72c4313a39ef
MD5 16d1712af56c5e7bde86fe4e9cd3eadd
BLAKE2b-256 41d510ccbc052d5fb2cd13c65a303f749e0d2062eb10e71cae65b7cd499c792d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 27787d4ddc833137b653fd56bb825e92a3b816d0565542597a100050fba90051
MD5 2e91725553fdda93c325148982f4f827
BLAKE2b-256 1033c5e02be0f09d4cba7963739db62e7dfa0b61bea8fe1ef7fff0359e5e52c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d0b9f8fcb513dcc400d536f72da750472d388c93843329aa53027a7c03bb82a
MD5 e4c0908311a7a44e4a79861d4621a8b9
BLAKE2b-256 7eb2d062ede0969a8c7172aa0c711e07858336d100f121bbf03e61a32a4f44c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b512032eb232dc0b451203693476ffbd1e22513a9ceeaa904e362e62b07aba2d
MD5 47c915b2c2751eb7d1d25d413295f4a4
BLAKE2b-256 ff26b5524582ef30fbe6cf8e02bf55d65a4909c262a45e3c3b38ef1b60a2e4f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cac7df965186ead68a5553308c89a262155291c34eb9822cce775f2143dc5f62
MD5 e765ed41659937417fa22a9bb40b40f9
BLAKE2b-256 a1847c56a340b8e6edb84b30bf303220919c4cd0490a70ba8dccb045524e3182

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