cdshealpix-rust

CDS implementation of the HEALPix tesselation in Rust and modules to generate libraries in WebAssemnly, Python, ...

About

For informations on HEALPix in general, see: * The official web site * The Wikipedia page * The two main related papers: Gorsky (2005) and Calabretta (2007)

See also the official page containing GPL v2 codes in Fortran, C++, Java, IDL, Python, ...

(Help me to add links to other HEALPix resources and codes).

This library is mainly a port of a part of the CDS Java library available here.

Features

Missing Features

Examples

Compute the cell number of a given position on the unit-sphere at a given HEALPix depth.

```rust use cdshealpix::{nside}; use cdshealpix::nested::{getorcreate, Layer};

let depth = 12u8; let lon = 12.5f64.toradians(); let lat = 89.99999f64.to_radians();

let nestedd12 = getorcreate(depth); let nside = nside(depth) as u64; let expectedcellnumber = nside * nside - 1

asserteq!(expectedcellnumber, nestedd12.hash(lon, lat)); ```

Get the spherical coorinates of the 4 vertices of a given cell at a given depth:

```rust use cdshealpix::nested::{getorcreate, Layer};

let depth = 12u8; let celllnumber= 10_u64;

let nestedd12 = getor_create(depth);

let [ (lonsouth, latsouth), (loneast, lateast), (lonnorth, latnorth), (lonwest, latwest) ] = nestedd12.vertices(cellnumber);

```

Get a hierarchical view (a MOC) on the cells overlapped by a given cone:

```rust use cdshealpix::nested::{getorcreate, Layer};

let depth = 6u8; let nestedd6 = getorcreate(depth);

let lon = 13.158329f64.toradians(); let lat = -72.80028f64.toradians(); let radius = 5.64323f64.toradians();

let moc = nested3.coneoverlapapprox(lon, lat, radius); ```

Standalone

The code source of the very beginning of a standalone exec can be found in src/bin.rs.

WebAssembly

To build and use the WebAssembly (and Javascript) files, the libwasmbingen directory. We rely on wasm-bingen.

Python

See the libpython directory containing so far a very basic python script showing how to use the library from python. We are currently working on making a clean Python wrapper and generating Python Wheels for a simple install through pip.

License

Like most projects in Rust, this project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Disclaimer

This is my very first project in Rust so please be indulgent and find better examples if you want to learn Rust.