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., and Quintino, T., “Polytope: An Algorithm for Efficient Feature Extraction on Hypercubes”, arXiv e-prints, 2023. doi:10.48550/arXiv.2306.11553.

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.2.tar.gz (13.2 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.2-py3-none-any.whl (177.8 kB view details)

Uploaded Python 3

polytope_python-2.1.2-cp312-cp312-manylinux_2_28_x86_64.whl (578.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

polytope_python-2.1.2-cp312-cp312-macosx_11_0_arm64.whl (523.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

polytope_python-2.1.2-cp311-cp311-manylinux_2_28_x86_64.whl (578.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

polytope_python-2.1.2-cp311-cp311-macosx_11_0_arm64.whl (523.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

polytope_python-2.1.2-cp310-cp310-manylinux_2_28_x86_64.whl (578.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

polytope_python-2.1.2-cp310-cp310-macosx_11_0_arm64.whl (523.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

polytope_python-2.1.2-cp39-cp39-manylinux_2_28_x86_64.whl (578.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

polytope_python-2.1.2-cp39-cp39-macosx_11_0_arm64.whl (524.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

polytope_python-2.1.2-cp38-cp38-manylinux_2_28_x86_64.whl (578.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

polytope_python-2.1.2-cp38-cp38-macosx_11_0_arm64.whl (523.6 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for polytope_python-2.1.2.tar.gz
Algorithm Hash digest
SHA256 1a62090e95040e385200600fa7d0993de2dcaf3d401fcfa61cc439239585c9bd
MD5 6aab42a08ac9ba66982aad0bec234560
BLAKE2b-256 28c7f9517a43158f5f800c563a82a7cf8b22e09b8fa77b80148749bf612c9409

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc622a643c35687a622bc5446b499cc171a7664c807559a3efe3d0004688273b
MD5 9ac4a411d4018095a191d4baa28468d2
BLAKE2b-256 90efaa2e1be9a2ca9b130b6002ac05fd1c2b1c9795d455e4a57ac9d3a8330d96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 64a5757f5a7889eb3451d980f4f86055e0d16d5606481e87055ecebaa5ed6064
MD5 3ae55cf5ccded2159d2b00074c09b30b
BLAKE2b-256 6b92c60d6881f4edce9119fd197acf944422057de3e33c501f59104d654905ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e4a45564322d1f79838cc89f72967c01410eb0064be25ae08dac1289ce9c2e99
MD5 84239ae06b284c5e006eacfb928f65a9
BLAKE2b-256 ee9b04d9bceb328261faa49914532396fe5ca94f333a2f1f20db5833b25465ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 16f62a1a98246b245e8e502be22bdad817e49f019ad17e73a92e3e28d26d2ac7
MD5 01410379f45209144ef9639d52858b91
BLAKE2b-256 87b737af6c923af4b952d6e0f5287d1b690a8601ac09156783fda87e9560723e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac6c28c687bad8eb7ba20ec7b273c39ee214926a6d4d7d235de94a7a15deee2e
MD5 e71c19a0db317a358157ec121bf290fd
BLAKE2b-256 af7f77e5d01b2ae237bfd27b0a66292ddd84978743612f5089db1a237c28e9b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a5fa55f102975231fc6a279cddbc272f189177355b952b2d2d2425ae023e506c
MD5 4d490530bd3473d8c4b2ebdafb3c8bcd
BLAKE2b-256 8dc0881330d65ec34c9b6e402cd9b65686d20c640f82c05596e8e2a3f32a089c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ffaf006783d71a866332eccb083134aa8f0c7963cd8907e172dcac2afe2fea32
MD5 78b38c47af8cacb8d255ca1abdabdd63
BLAKE2b-256 24a32af9edcea65b2c1ce6bdb7526d5e0002f124a12797a6432440447e725355

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a072bf7e76acf965d78606b988d504c567353f73f1dfbb365075e9889468d023
MD5 9921f3c0ff60b50396a6d1640ac25494
BLAKE2b-256 054c2a6d49a2706e45c99e1b9eb5baf3d94692bb4efad4f88da5157cc92a44b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7be84e3c6b708de81706a95f67fc6d1afc4b63d887c5ba6755bd1d23bde7325d
MD5 61990b0e3138875e483dea0c35a114c5
BLAKE2b-256 f26b2207a45306ec82b1568d747daebbdeba7d4b53e65a4f74029a986d2c3b6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52d426e307f6ceaf50c03b63b9d29383fe357f98f7c936507ec230ad3963506b
MD5 f175cd3a7e08a627cabb6cd502786f96
BLAKE2b-256 4467c30d8fae474f162143965344f1f1eb6dd6d2094a9d7027f19733dd1116e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polytope_python-2.1.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60b0b4dc408430ac0952b29b5cccb9d52c3b1bcb9b76c73cabde244c1dc9cbc6
MD5 63511267523cec73a8141891567b76b2
BLAKE2b-256 3c74f03a91a07baf35347f828e1aeae986906eae3cbdf479c8b30fbbaed806fa

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