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

Uploaded Python 3

polytope_python-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl (575.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.8-cp312-cp312-macosx_11_0_arm64.whl (521.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl (576.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.8-cp311-cp311-macosx_11_0_arm64.whl (522.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.8-cp310-cp310-manylinux_2_28_x86_64.whl (576.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.8-cp39-cp39-manylinux_2_28_x86_64.whl (577.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.8-cp39-cp39-macosx_11_0_arm64.whl (522.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.8-cp38-cp38-manylinux_2_28_x86_64.whl (577.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.8-cp38-cp38-macosx_11_0_arm64.whl (521.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: polytope_python-2.1.8.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.8.tar.gz
Algorithm Hash digest
SHA256 28dbdeaae954f72b899a5fec3e15f8ed3a85294bfb600b3075f7341e1bc15da2
MD5 5192c46ac5c0853f86f57fde5dc403a8
BLAKE2b-256 faa4b76e94f51345bd708ea8ed716006e27a4f63c109b0fe4d8ebd5bc6de8609

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 63580146f60b51d078a38eaacf71e21bf7184b9fa07b6f7fc293bdef10be42ea
MD5 afe410dd2c7f7fe8bba983ca3dd28127
BLAKE2b-256 34ed8a0ecfe3abf284b2f1b59b637be4e92a764016ef869f79739e5284f86c54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 acaf94b1ac217a7bc75e3731c583688e491d2e04d170664436fb172f0ce9d30e
MD5 6118ba468a4798104a5fea00bc14ec76
BLAKE2b-256 d21e68510c3710e0aeb3ff6e316b5d62ed647ea7fc1b15e3ef45a5a002fe9947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edf00be5de0b91c61ce2c59d3c0a494c4f3b6fe224fec764463bb38836a8d7e1
MD5 cab131d66de74340cc73110edd53b0f4
BLAKE2b-256 2c0448d54f1ea434a82291d6901668dbbc2f4fb3387dc91a0b0da7e8852244a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 330246c37c30cf05ef2ac8792845f407012e86684b10cab0526124b71263604c
MD5 a07ac03d6e8d5eaf82052f69623fb829
BLAKE2b-256 5182c080437e6c0e4df8115a5a4f0695731d239758543c1039ee8661347ef5d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e465cbd046e7a4ee3ccb994092e8c2848859a65a3fc255bbbca7ac66f9d67ad7
MD5 1dfbea24bc9b392a45fd34bab5d1a05f
BLAKE2b-256 2974640c1fa4db75db8ff738ba2fc961ae5035ce73127911d6af973474cb319a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e56c2e94b29c66f891d80906cbee1f838e1e161b101fa71a58da7c25ca3e0853
MD5 cdbadf9de33bdf011db513145a01f9dc
BLAKE2b-256 580cbbc11eafcf036ebfd1134d1d19e3c5aad746d1db64be5e53626818458156

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30026113e023b377c571cccaf4a9262a6fb50ece3230c789f7b49f2731ef2a28
MD5 7ce1f34d076e8c82db30c44e09602684
BLAKE2b-256 01b7198d342a9df42ce66c23140ce3e588c64e73c5bea3d2f70596ed7f1bfc05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1e6f3bfc355ee801fc57cc3650d7ce3e7e4e84e8e4d636e73efd2a0fced480b
MD5 aed7a2a776d7442d9f5d00481cfc4f8a
BLAKE2b-256 8779768f04410d1b86d09a424539c4baa265ba8e570e35daacd2340e15c85784

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4838a80628ecb6754e5fa1f9d80ff2357ef952666a51f5e23ededbf491c2367c
MD5 3451d2be8c3655bfb84c1d14d9b23b3f
BLAKE2b-256 2b696fb6a5ecb544bfc22d46ac4119f162bbb652a290fbf2047c128e56503b61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04875f53898a0c29c3a581b947719459deb5cc5065b92f6516b5b7a493a28c76
MD5 f861a2d171b169dabdbac1418831b402
BLAKE2b-256 a8188384f8717ca85ca6294ccd714b3831e3e4fc6eb6d40669e28eabd7761be7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.8-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e2e031a8a8a51636bf9b54c93e0c609cf584c269231c40fa5b8cc85afa6042d
MD5 245225e862270f68d67e16b812cd270d
BLAKE2b-256 e5e18b23c6f2995386afadc262946bb654870d78ecf73fa835af5b84d2cb5e5b

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