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

Uploaded Python 3

polytope_python-2.1.12-cp312-cp312-manylinux_2_28_x86_64.whl (571.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.12-cp312-cp312-macosx_11_0_arm64.whl (519.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.12-cp311-cp311-manylinux_2_28_x86_64.whl (572.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.12-cp311-cp311-macosx_11_0_arm64.whl (520.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.12-cp310-cp310-manylinux_2_28_x86_64.whl (572.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.12-cp310-cp310-macosx_11_0_arm64.whl (520.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.12-cp39-cp39-manylinux_2_28_x86_64.whl (573.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.12-cp39-cp39-macosx_11_0_arm64.whl (520.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.12-cp38-cp38-manylinux_2_28_x86_64.whl (572.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.12-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.12.tar.gz.

File metadata

  • Download URL: polytope_python-2.1.12.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.12.tar.gz
Algorithm Hash digest
SHA256 a8f7cda1dda5dd70808b5dd0d032e1b1125e9e327b0a718ff7467ea8440b9581
MD5 5df5fbb6145f11e4b0d04ec6172a5d2e
BLAKE2b-256 54435e3cdb0d627f4afc97450227ae82993f085ccc5c8e6188f2fbbfe1159824

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 58bb88c1a848b36ba49eff5e74f2445deade6bbd5920dd16f86f8aaf95fd67b0
MD5 137c6750c5b9c4babeff9ee7cededb46
BLAKE2b-256 d0cb82d2e04f5ed904812695f94773649f96164a5a4b384386ba0cd298e5eded

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a190f2cf67692368127717bfb1b998d806aad5ededfc292ea6104c635007787
MD5 34990871c67a6877bb9a3d77e897b9d0
BLAKE2b-256 c3390855d7ec31c3394f2d05e1263e0c81bc5fa1f99c67969301d0f059d31951

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4eac32590f04d091595418ff99a8f5ce14fd133a7fc1d961b2f49d33520f91a5
MD5 9635718ad872f61212f7c8e1f146891f
BLAKE2b-256 2afb137576ff0e40eb2e978efe5d31c6ecba82ada3ffe8595f419866f3eb55d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee53d418a42c1f1973325ae0966eeeae43f55edb5fa91c88fab1b86b8ad79847
MD5 8eca4a5dd54f6bcd1043998b0e370601
BLAKE2b-256 301e7cc0206e30b8c3ba88d53883587efc858f690cb4d718b838157284a5e14f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dbc9fee4c2323a3c31939e9e36345ab6a7d146168addffa373170b91a5bff387
MD5 2d8d39c3f6299505ceebbd909f2be648
BLAKE2b-256 b8abec8653036de5a9ce01235694f83143877e9d2d7040df0fb808a50a03a391

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 11ff8d66f64f5d2b9c150491b9f56357b00168602fd81e89086a45a3e9ee04b2
MD5 d2c2bd9663117b13f89e960a3445a928
BLAKE2b-256 f1c1cece4ce6369a9f206b9fd1aa3c709bee81c695a90f4cf65ded3918616cd3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d6dcb0f49a0e53619815215d7506bd54f1409fa5fcf6e4778655c06ac1badbc
MD5 6840e792a54596d5efdf229fb2d2b833
BLAKE2b-256 89a792f4286e6363926806b1dcff1e75350ae0c2b273923d365bb71226f98357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 911e5a598fd4f58be8716e3d9175b48f05620413ca0cbc43d51953efa4a532ae
MD5 19bb3925c935cc802e293baeec55e92d
BLAKE2b-256 7e2c5cd8686a0e5201ec24a09cc2c993331586314f2ed4120d0ce459726df838

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e57f11e602c18dc7d4af1897dad041097d587e6228ef4140596c84cd2da5283
MD5 eba2de07ca15f05d98befaecc451b66e
BLAKE2b-256 83d20db297d3e8bd6ad3589a4f039e7b2ae4c76276a8f101b7b9f610affeb0b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b731685747e929c46a6e0d8269aaf4c27e86f06406e89e2947acd09dad8b4fa7
MD5 1f61199b6ded3f786aa1068c5e381ba3
BLAKE2b-256 07ed80dab91b1f4b6da966f9c8746b47eb1933dc0435d8bc43adc7c9ea06ccdd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.12-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e124b4217778928cca7618e1e71ed8e72f7a9667893c7348a20444cba6c557e
MD5 4725a20e740829436d9fc001246a3c95
BLAKE2b-256 5d1a6dbc7f3ccc17b0e2570eece06e991e9b33da234a6f7327e668565dbcb884

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