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

Uploaded Python 3

polytope_python-2.1.9-cp312-cp312-manylinux_2_28_x86_64.whl (575.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.9-cp312-cp312-macosx_11_0_arm64.whl (521.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.9-cp311-cp311-manylinux_2_28_x86_64.whl (577.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.9-cp311-cp311-macosx_11_0_arm64.whl (521.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.9-cp310-cp310-manylinux_2_28_x86_64.whl (577.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.9-cp310-cp310-macosx_11_0_arm64.whl (521.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.9-cp39-cp39-manylinux_2_28_x86_64.whl (577.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.9-cp39-cp39-macosx_11_0_arm64.whl (522.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.9-cp38-cp38-manylinux_2_28_x86_64.whl (577.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.9-cp38-cp38-macosx_11_0_arm64.whl (521.6 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.9.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.9.tar.gz
Algorithm Hash digest
SHA256 e3fd7e9cebace6054a683533ba4e4417ebacf54c22f54cd8851df8059cb61337
MD5 11d14a35057013842fea925351a74c1c
BLAKE2b-256 ee03c3416f41fcf820b6d04a35e490b9eaec11b03d16c4e71b8ba1402d5620c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 72856e7aab7d84d607178d09b98c342a16569233a2c305ed0905937842e7a9ce
MD5 7cf4a4d36714ac944e3b42d402e3b7dc
BLAKE2b-256 76dec5ad8436c07e4bcf91efbeeccac7353646605521f9909602dc8d5ac06b65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b80db1d4298098379d9aeb02059c041df4715ad9dabf2618adc2d342aa50d79
MD5 dd8cd975558b70aa457dd109a4db2735
BLAKE2b-256 dcb3f9cd9ecb205aa6c27c38a893eecdbb569d21ef3f7946f94deb01faec969d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d41133c4ff89255f8e261cb3227c0509502b47e2d10138f827c9df3d88e251db
MD5 4634cc2290da8972d49545509cb7c6fa
BLAKE2b-256 dc8917afef218ba99e537e86fa43c281edc4c0e27361ceffb02bc5190fa4adca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c252b94932f5637a0a429bb4fdc809ab09e577f0640d770b38553e41f0534a5d
MD5 020cd0ccbd9f6b227a6b600d569a534e
BLAKE2b-256 3ebb76c72de9553d7734300a82d83b04b92671a3e259bb535580dd3ae6344b9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57cab7004e191be655d26c1d1d5389cfe2370e409147d46f20b0f168dd505c8c
MD5 dbd109274529e3ce4f7d74aee05f674f
BLAKE2b-256 5eb8dfff96e130d29de251caf2ba54378ace446510b22a6d29f310ce99b7c5ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98971ada59974b06fa347056f0f1113afb015d1d515aa0c845642c295c89f807
MD5 b0c70f0db1730bc1b8d25d4761809270
BLAKE2b-256 caef12efb777cbe264fb4f8283e00dfbab7d4f87579d91efdd12a107f6ba6f25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0cc484a061863497ebef828fd7ec5029dea73d5b85bcedce300b649a587baeab
MD5 653a9b022ed313d0ac35ddbe7dbc2262
BLAKE2b-256 3f6ffe906546fcbad841c162b6c474493001d2d3f793029f1eaf66b37cd0ea0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fac36697dd8e3aa95b1bf96d5163ea4cc68cee2d12019a1619fe931803775fe4
MD5 26dfcb8bdf5624715fa73c52bf106d0f
BLAKE2b-256 23247ac5ba87a3effd5aad017b7d32468534062ce715ea43e891bf5b72727f2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ae2580d04fde9cdd39fd4ac222ebe2c355ac9557948a6639ec46fcb7f4ff276
MD5 4a484caaa989accc158f03dc157caefc
BLAKE2b-256 e872be4aa77fd5473e8ac2fabfd4d11609ddfd301dcaddae2f57da306b4c2ebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 951f6e033569d61dc27318c79cccff0276c90e0557ea640ecf3a272a0d180f7e
MD5 60af220cf28d61820e0e32570cfdc2d2
BLAKE2b-256 96342dbd1b3ccaaff688ebfc316361c547a7da7f95e4997058b412454dc8fa59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.9-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0add6d74083fbddf6138be4d265b8be8e91c452073f4b0dc38d827b5c225f77c
MD5 6f0108a16cff02554ca8757fc1a96e3c
BLAKE2b-256 6cd7945e2c06aab91deeb84b15443b126e3dd71493743fb9df83b35b871b63e1

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