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

Uploaded Python 3

polytope_python-2.1.6-cp312-cp312-manylinux_2_28_x86_64.whl (574.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.6-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.6-cp311-cp311-macosx_11_0_arm64.whl (520.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.6-cp38-cp38-manylinux_2_28_x86_64.whl (574.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.6-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.6.tar.gz.

File metadata

  • Download URL: polytope_python-2.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5e38f65e8442cbf3f3f6c81c92a15390c195d161f94f49dcec57dc1e69950e0b
MD5 458095b296321b92a21ab39026aebc2c
BLAKE2b-256 53fa5445ea9faae334b3dc33b39ceff3c14333d8f92138a95adeb2c02584bf13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4b70e1b956d13a2ca8a8c5a40830d19e56c7e7de57d7adf1886f93100f009749
MD5 524682a391081e03b60a859c26eaaf27
BLAKE2b-256 4ab5c8ba5d0ccc91d8e35afd69194b7106ba3a8c64649de718c3a12e2af3be23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 981126ca2a2674bea96054532ab956eceb0273076f7dd896f070529435449865
MD5 a0299723cfe005549dd5fa04af9da3ed
BLAKE2b-256 b40748a362d03d5258f3b2c9b182635b78ea8d4f166c56183f8678d907f650f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 581b06037e5e5984c4e0830481ad306e410d6ed40faa48f89db48421330f63dc
MD5 dd33088f9ad671142de62753cfebdc08
BLAKE2b-256 834291b14ea6087d8dbdced2ab75bcd58376bb8dd38434969a7611190ae37879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ae80c623c559e30e031eaae8f16b13ac94f026fc95c7e5f56b286ef83829da9
MD5 9f94098f3e64c747ae2aa8a0eb7da5ea
BLAKE2b-256 0d0e0378dc77f6b92908ca18df559dcf7f1e6dc8f46fa9bc3dece8e851d888d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0c231c7704210a2657ec6ad09b1992fce52c796d28013c3e15a97b578a31f8e
MD5 c2b0e6cfe85e546c4702b2205ba41138
BLAKE2b-256 fddc9a704128de40be3855e9c0e0ba73e127779250175a24a2f5c9ba92610e61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38fd8e75daf3083d78cf738a4493130a7964a8a4cd610ddf1a2001f24d52241d
MD5 a03a0a3ea794f6aae4ca382080992514
BLAKE2b-256 cc967ae8153919191fb510d7c3b3cc96808a86df916babae4b8acc8b60d26c3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0214638e5e3f4b32460ca0c26144109a28947fb99e994a0bd46e5e4704d0313c
MD5 b7652edbd57987e880f8f0e1f4efa1f7
BLAKE2b-256 7976cf06e0a6720b8a7abb65c8b8b0afeb0e4d40acf796f1b5375844bb7a443c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f80d5b36b30728264a0b090df88686064ec85cf6fb4ecfd45862504005431e06
MD5 35471eb3c6d8d4623e5a88dbda823689
BLAKE2b-256 f3295a39e2d88a0bd51d3e0108a8b829fa252c746ed4ffcc21f9e9b1262f7b71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1d56d6d5add665181f7d17933444af4f574100604a3210077ad2128a05c714c
MD5 c7707b7f4b5bcf7df90a96e22f179fac
BLAKE2b-256 3646400bc51b865bb9eb1351fcbd38e2fb2244f3f7e11cc77f03c28009a2eb22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 92b36b601d1c6e239a569527a24fbfc846b0e163439a3c027f81244cf406cfe7
MD5 d3a89f34aeb578c85d7c031a962ab8c7
BLAKE2b-256 5e30e2f0fd5c2513f9a4c1bda8b4be1436b11bcf86e4915fa3804f8ac2df1cc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.6-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc011dceb42f3f393eb82d3e7833aa5d4534b0af368e14734beca8c124c33654
MD5 361d69aace5e3c84dae3a7e770f53475
BLAKE2b-256 0f1180ac2c51afaac0650644ff1ca01c3907321970b6f6fd9265c1714d301a3e

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