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

Uploaded Python 3

polytope_python-2.1.13-cp312-cp312-manylinux_2_28_x86_64.whl (572.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.13-cp312-cp312-macosx_11_0_arm64.whl (519.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.13-cp311-cp311-manylinux_2_28_x86_64.whl (572.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.13-cp311-cp311-macosx_11_0_arm64.whl (520.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.13-cp310-cp310-manylinux_2_28_x86_64.whl (572.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.13-cp310-cp310-macosx_11_0_arm64.whl (520.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.13-cp39-cp39-manylinux_2_28_x86_64.whl (572.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.13-cp39-cp39-macosx_11_0_arm64.whl (520.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.13-cp38-cp38-manylinux_2_28_x86_64.whl (572.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.13-cp38-cp38-macosx_11_0_arm64.whl (520.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.13.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.13.tar.gz
Algorithm Hash digest
SHA256 957feae492057dffc70f814ba9ab8c5e637f781edefaeb3518ea081ae778d644
MD5 7277592119a3c3300394a28f0ddd4676
BLAKE2b-256 908256538c7dbf4bf80ca3a3af5c65772826e5c79d9bb56c69f02b4a63e71a9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 a0213383e3c12c4e7bf92a2c313322572c86373204cbed8c47b8380b7eedcabb
MD5 a8cb950ac57d863bf3f925ee13e273f7
BLAKE2b-256 afb8ed102c4ec870bcec1b74c55989bc9971ee5bc5cfe8caeea540e87de14c46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3ca616246a8b606abc054fe71b36b6fb71aa3f40cbe39992a89813d521012f3
MD5 d1761998d951e4711fc35e133cb0d2f0
BLAKE2b-256 7f60dc558b929fcd0c09ea5901dbabf3745865f4bc3c29c71204337348c66e6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99bf984afde6501b9fabca11b1f5e0aefd3f798feb9f2cf97fc02a1e4b36027f
MD5 5f850fe7e3b02a35421161bdcef01d0e
BLAKE2b-256 85aee02f327d40d0a705f4803585ad38afb0a89dcc8e660760168db2a572f9ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76f067bba66bd60de728a72aaaf62e5d697291f2acd5f9d72562be86054d0db1
MD5 23aae331b2142b553e36cec0e168831d
BLAKE2b-256 278c91f46355ef06de5c6dc9f7c11f6895d0cf79a591699df998b497badf20be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88a5da3fa80c661e6cc6be5b16f2655f37510db9e8703cae11c467f1555be8d5
MD5 5c7ffaf7b73eb3c844a6a0c358e1f481
BLAKE2b-256 19e252a1e9518fe3171bba532bf260a26e4a2568381db0a44e897751767af424

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18ffbbec8bac4aef8b783c5f88c62cf62b451dbfbfa38d634a0895fc45660f39
MD5 a0901d8aeec7ac8de369c4c59fae41c1
BLAKE2b-256 3772c52a7198708e06635ccc338c0c09a0bd34ea21f958e7f321681c44ce4270

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80e92b5e5411783ab4365a8c92bdd4d78be9c795aec1c4f6c76d58c2a5a40b8d
MD5 c00127673114fe1da0d61a53efe81f18
BLAKE2b-256 2793bdf677cc6564e734dcaa0744abdf3351f1bae1bb0fe217082538f1fb563b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72dfcd71a48347eb3c120993f9e8e4efdff6b117fefa4449ec72a50f3901a395
MD5 145df963f267a1a628099a3ade2e28ca
BLAKE2b-256 c4d4706da1d94dfa84d51358e32d1673c93e7dde6850f281717aaafdb943c514

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d920e77b8b0c30a5fd52335c364b035ca39220119a256ab988dc005ea1345cca
MD5 fa3c9f2826392068e48b4d1ded252ca5
BLAKE2b-256 ee1e208f48565271797d8b86b10a58f6a5c4061eac732ce7e802ecb75b1cf4fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ba3507f1d25b5db5635e45a3901e845419124554088d3a7f7fb7322814c96c2
MD5 6bc50d0123cfb1658b7d2b2bc9f77217
BLAKE2b-256 8d64ef8acec2a4aff2eb640ae593027a92ba45a2a04f4ff6acf412c1e2daab19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.13-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cffb856265971778034f92cb96d178621e758fa884a1c5431035cb5be4c9e2df
MD5 566d7c2b37d1f864f57168a148fe8141
BLAKE2b-256 9c2d1a61c28a582341134e6b54b4a0698fe26f17508024f0890e0c360bd8016a

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