Skip to content

How to add a custom indexer. #2986

Closed
Closed
@fbriol

Description

@fbriol

Hello,

I have written a set of indexers for 1D, 2D and 3D geodetic and Cartesian data (up to 5 dimensions for Cartesian data).

I used the Boost/C++ library to write the multidimensional data search algorithm. This tree (R*Tree) is impressive for its performance. It can be built in a few seconds with several million points and made requests for a few seconds with several million points.

import numpy as np
# Install it with conda, if you want, only for python3.7: conda install pyindex -c fbriol
import pyindex.core as core

lon = np.random.uniform(-180.0, 180.0, 2048*4096)
lat = np.random.uniform(-90.0, 90.0, 2048*4096)
# You can not set an altitude if it is not necessary.
alt = np.random.uniform(-10000, 100000, 2048*4096)
# WGS system used
system = core.geodetic.System()
# RTree
tree = core.geodetic.RTree(system)
%timeit tree.packing(np.asarray((lon, lat, alt)).T)
# 3.84 s ± 129 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
coordinates = np.asarray((
    np.random.uniform(-180.0, 180.0, 10000),
    np.random.uniform(-90.0, 90.0, 10000),
    np.random.uniform(-10000, 100000, 10000))).T
%timeit tree.query(coordinates)
# 18 ms ± 377 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

I'm trying to use these indexes with Xarray, but I didn't quite understand how to interface with xarray.

Is there anyone who could explain to me how to write my own indexer to test these indexers with xarray? Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions