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

Uploaded Python 3

polytope_python-2.1.15-cp312-cp312-manylinux_2_28_x86_64.whl (569.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.15-cp312-cp312-macosx_11_0_arm64.whl (517.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.15-cp311-cp311-manylinux_2_28_x86_64.whl (569.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.15-cp311-cp311-macosx_11_0_arm64.whl (517.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.15-cp310-cp310-manylinux_2_28_x86_64.whl (569.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.15-cp310-cp310-macosx_11_0_arm64.whl (517.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.15-cp39-cp39-manylinux_2_28_x86_64.whl (569.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.15-cp39-cp39-macosx_11_0_arm64.whl (518.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.15-cp38-cp38-manylinux_2_28_x86_64.whl (569.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.15-cp38-cp38-macosx_11_0_arm64.whl (517.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for polytope_python-2.1.15.tar.gz
Algorithm Hash digest
SHA256 567da9c7a269763a1714f845ecad3dddbc764248779fdb945db0c05f86aa5c94
MD5 445b6263c233311c5360d8b517e36c05
BLAKE2b-256 21814fb9f9a06920f7fe3d09f5748b4679cf5861f35906a5e212eaec77588491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 e3db9e8373ac4fbab3dd0594134143ee40625c5ef7a1e2a598e73df299b94306
MD5 4e7881ea2c37d326f9f8b881fd014666
BLAKE2b-256 377710090cbee795a948b0ccc2fecf00972e802160c426f3725eeb86643b820f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 187bb1d1ea60e3cfab40f25fe197c6d0c1352637a64187650ced644e839fd07a
MD5 7fce4b8b294df82a043471418394a74b
BLAKE2b-256 095d12683a633d274308ed0f7223a0659f456d4a733ea1c8eab4d0f5e43efcc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab888a35e0d620a8949bef36d0486b4dc0e85e38a3b14cde2de69a71c8e90bb4
MD5 79efa006eb1db2c87aea45f15c6378a2
BLAKE2b-256 28d29d54fb6ec6d310d336e6306a87b30e08fa74ec848b8b40131e4b2aff5514

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0157cbc2bedb4fb390f34e3c9bc51d8ab7950d43a8776f8781c88822d727cf77
MD5 62b29ada4b673a7ecb7ccf5db3b20ae0
BLAKE2b-256 4cb7e877470321d51fbbe50be288db41ec97a107d9146673e6479b1fa6911202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36fa2a9fe29c90af6d4de0958a70a49c088a23711edbc01584fe42cf4f6fade0
MD5 aadee5f7a871f55e70df886c59c58930
BLAKE2b-256 d12beb0b540c59985e188b5af9d14b28adc9564a561c92d554684b09d78e0c07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc1c50d0aeef621824d376a3629b1beeaaa1f0dddaf2418629710d4b4947ae77
MD5 5e1cc0221fd983c9c92389f06e774cd0
BLAKE2b-256 c6ee7abb996f0081f61f18a4a7e4a92bd7068cddabdd5343507ce1ff0c5d22f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fdd13e9cbb9eae22f6070346b719d3b2f3571f1587b620206b677ca6eab89349
MD5 55511f0a255037a09f6d75c30080b814
BLAKE2b-256 0c72790a4763531b764b5e07e5fcb1527b568582e2baa0d41042765654ccb4f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 690da9b2c85d4701c1f73cbf7cf6e8c1416de3093311931f8a8a07a67db4c183
MD5 8640390fd5dd52bd1930a86c212a34a2
BLAKE2b-256 0c8af30e58414c24ed277434d6643bcb4fdad4ce84b7badc6b37151ebc8b2585

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90eabb64056de2fcb2bf146fb93b96d7e11ff0f855a7e1b0507673f908c40cc6
MD5 c842ba13ae343ce94c9aa52e79aa21f3
BLAKE2b-256 0a2b29f64c405972a7e8cee8f7f2d229e41c6a3c8aef41f66f297b6a597159e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7e4ba9d894b9f4d58aaa53524acb854ec354573ff8da4321869dfd5b33e41c2
MD5 7e51e958b5bd7cf6f5a4bf1038e57ab7
BLAKE2b-256 0b5dc1adfd96433e18f2186fe517a0885bc24228094b4d60d3973c4c542638de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.15-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9aaa0810137164fa7db21ba99a3b75d8bbba73ff7c955bcdc1b47b1af61d99e7
MD5 c428a76b63ca53f55a15d9c1df5b2bad
BLAKE2b-256 2171345a8a45e227f1fdafe62f169fabb3f1f4a4db0c4eb7a7c9c1655ab765c1

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