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

Uploaded Python 3

polytope_python-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl (570.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.3-cp312-cp312-macosx_11_0_arm64.whl (517.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl (571.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.3-cp311-cp311-macosx_11_0_arm64.whl (517.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.3-cp310-cp310-manylinux_2_28_x86_64.whl (571.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.3-cp310-cp310-macosx_11_0_arm64.whl (516.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.3-cp39-cp39-manylinux_2_28_x86_64.whl (571.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.3-cp39-cp39-macosx_11_0_arm64.whl (517.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.3-cp38-cp38-manylinux_2_28_x86_64.whl (571.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.3-cp38-cp38-macosx_11_0_arm64.whl (516.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 fe02c9d03abb57d7eb638c847ed6e694e517230cddd0c5a3f8479bb97d168e20
MD5 17186d83b5a313d3aa7131dc32da2d00
BLAKE2b-256 b3b4712454072ea0d58830eecaf03ce5e03abffb430f09bf37298b13e793e48a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16d979009b15a05e1116f38d5e8ceb0a032bf84b3af6da5119a963b9078b2030
MD5 2e20d3623c6367ce923ea5ff4902545e
BLAKE2b-256 03c1463aefea4e895468388cff3e7463363b7ee0d495523471a481d39ea4c342

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b7a95610ce328f87d16a7b65c88ad01b4a3fb71e768b33bffd5789c65b1668a
MD5 95f0c3c1f4d6fee5b22cee722d482af2
BLAKE2b-256 9512a69907f0e0af4b2c71095af30136d79f64b41a9d0681538c81a6a9aaf8d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b439e3562ddacdde41f73e2178ab0a94c1cd5d0090f3a3e98b3cc5036ea0fd91
MD5 aa45ce4603f3baac31522999be0f41ba
BLAKE2b-256 459fc6f97b7e6b5d0c0acc40561e10db7fac66c0377f46e91a869524c3cd87f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e6d7cdd62d40d2972af541312d2ee1206e3d284fca7cc276f6e422aef37c68f
MD5 831f0f2c1e8b7888908cbbecf35a3576
BLAKE2b-256 a1aa2845026a28a6d6f8b832f3eca50064fe94985b4faaa28de4db310cd1a8a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5ea83994b6fb925ed8e43eed1ed2599a7fc5cfb707729c88d0f60fcb073e985
MD5 7c69a2ffc1a0a6b019695140b4c690fa
BLAKE2b-256 c1ff4d945a435667730965efbae78fc4d74738aa03913b459d825bc8a56f96d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2180d8e2378e291100667f5ec65bf3c9bd715f4febd09298987204eb2a1b9e0b
MD5 7a49e46bd61fe3396a2609bccc985947
BLAKE2b-256 3763d6280720cdf9f664e444ceed6f1e1bfedde075766f7711305ae9699859a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 412c6baa6ce315cebe8eadc0808db32134e3921a645174aae9be5d8393a96adf
MD5 555ce89c43d8fb7559d14d28ccf2cec3
BLAKE2b-256 3be2fef63e1f81b0ed8b0b8483c8a68a4de67680db38d7f0993ffdf0f039d24a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52ca966b68c4cfa4250420aec69738253752bd4809bdd8780d8e2b7567f72dd0
MD5 9b0088a5ad19f1f9d6123d43197b0a60
BLAKE2b-256 7f053330cf91b9b8fd642d97ae2e56e123e8123a1745c337c2caca53abd49174

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66a34af750a981c8dfb5fa44743bbc94095c80ef1c99e16d9f433d6525dbeaac
MD5 72bc619060e8b4828d20f708aa916eea
BLAKE2b-256 e3104538f84e6132c5bb7d6ae3e8d18470d9a2773b5e35e7f48c7212576346d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd1ced50bfceff0e4b76f3dec7f24531ecc0da447d1a26abe8db07408a695109
MD5 9dcd59f2c6bfe4f67380d2be71855b3d
BLAKE2b-256 2e0d8a6ad288deccb2827903a13c2b9a075e469e209f831b395bf7ad7c62f3bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ecc2f11b760aba4ef59e22fee4e513a27277a924d6d464e89f5134404fd54b9f
MD5 7b3d049e21aa3949e94eb9de05d68df3
BLAKE2b-256 4ac8952db90c89fd5421c0f87ad37f24ab5c8e470789e51db902f587b371f3b0

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