### Setup WASM Build Environment Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/README.md Installs the wasm32-unknown-unknown target and the wasm-bindgen CLI for building Rust WASM projects. ```bash rustup target add wasm32-unknown-unknown --toolchain nightly wasm-bindgen --version ``` -------------------------------- ### Install Rust Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/README.md Installs Rust using the official installation script. Ensure you have a stable internet connection. ```bash curl https://sh.rustup.rs -sSf | sh ``` -------------------------------- ### Install hpx-cli using pip Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Install the hpx-cli tool and its executable for Python users via pip. This is a quick way to get started if you are working within a Python environment. ```bash pip install -U hpx-cli hpx --help ``` -------------------------------- ### Start Local HTTP Server (Python 3) Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/README.md Starts a simple HTTP server using Python 3 for serving local files. Useful for testing web assets. ```bash python -m http.server ``` -------------------------------- ### Start Local HTTP Server (Python 2) Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/README.md Starts a simple HTTP server using Python 2 for serving local files. Useful for testing web assets. ```bash python -m SimpleHTTPServer ``` -------------------------------- ### Build and Install HEALPix PSQL Extension Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Builds the release version of the HEALPix extension using native CPU features and installs it. This is a prerequisite before creating the extension in the database. ```bash RUSTFLAGS='-C target-cpu=native' cargo build --release make make install ``` -------------------------------- ### Install hpx-cli from Source using Cargo Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Build and install the hpx-cli tool from the cloned source code using Cargo, Rust's package manager. Note that compilation may take a significant amount of time due to heavy monomorphization. ```bash cargo install --path crates/cli ``` -------------------------------- ### Find PostgreSQL Library Directory Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Utility command to locate the directory where PostgreSQL extensions are installed. Useful for troubleshooting installation issues. ```bash pg_config --pkglibdir ``` -------------------------------- ### Compile for 32-bit Target on 64-bit Linux Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md To target 32-bit on a 64-bit Linux system, first install the target using rustup, then install the necessary multilib support for GCC, and finally build with the specified target and RUSTFLAGS. ```bash rustup target install i686-unknown-linux-gnu sudo apt-get install gcc-multilib RUSTFLAGS=' - C target-cpu=native' cargo build - - target=i686-unknown-linux-gnu - - release ``` -------------------------------- ### Install cdshealpix Python Package Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md Installs the cdshealpix Python package using pip. This command is used to set up the Python interface for cdshealpix. ```bash pip install -U cdshealpix ``` -------------------------------- ### Update Rust Compiler Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Ensure you have the latest Rust compiler installed, which may be necessary for building the hpx-cli from source. This command updates your existing Rust toolchain. ```bash rustup update ``` -------------------------------- ### Run HEALPix PSQL Extension Regression Tests Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Executes the regression tests for the HEALPix PostgreSQL extension to verify its installation and functionality. May require specifying a PostgreSQL user with creation permissions. ```bash make installcheck ``` ```bash PGUSER=postgres make installcheck ``` -------------------------------- ### Approximate Cone Overlap MOC Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md Generates a HEALPix MOC representing the cells overlapped by a given cone, using an approximate method. Requires importing `get` and `Layer` from `cdshealpix::nested`. ```rust use cdshealpix::nested::{get, Layer}; let depth = 6_u8; let nested_d6 = get(depth); let lon = 13.158329_f64.to_radians(); let lat = - 72.80028_f64.to_radians(); let radius = 5.64323_f64.to_radians(); let moc = nested_d6.cone_overlap_approx(lon, lat, radius); for cell in moc.into_iter() { println ! ("cell: {:?}", cell); } ``` -------------------------------- ### Get HEALPix Cell Vertices Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md Retrieves the spherical coordinates of the four vertices for a given HEALPix cell at a specified depth. Requires importing `get_or_create` and `Layer` from `cdshealpix::nested`. ```rust use cdshealpix::nested::{get_or_create, Layer}; let depth = 12_u8; let cell_number= 10_u64; let nested_d12 = get_or_create(depth); let [ (lon_south, lat_south), (lon_east, lat_east), (lon_north, lat_north), (lon_west, lat_west) ] = nested_d12.vertices(cell_number); ``` -------------------------------- ### Compute HEALPix Cell Number Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md Calculates the HEALPix cell number for a given spherical position at a specific depth. Requires importing `nside`, `get`, and `Layer` from `cdshealpix`. ```rust use cdshealpix::nside; use cdshealpix::nested::{get, Layer}; let depth = 12_u8; let lon = 12.5_f64.to_radians(); let lat = 89.99999_f64.to_radians(); let nested_d12 = get(depth); let nside = nside(depth) as u64; let expected_cell_number = nside * nside - 1; assert_eq!(expected_cell_number, nested_d12.hash(lon, lat)); ``` -------------------------------- ### Initialize HEALPix WebAssembly Module Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/demo.html Initializes the WebAssembly module and sets up an event listener for the compute button. This code should be run when the page loads. ```javascript delete WebAssembly.instantiateStreaming; function init() { hpx = wasm_bindgen; $('#compute').click(function() { $('#hpxhash').val(hpx.lonlatToNested($('#depth').val(), $('#lon').val(), $('#lat').val())); }); } wasm_bindgen('./cdshealpix_bg.wasm') .then(init) .catch(console.error); ``` -------------------------------- ### HEALPix CLI Main Help Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Displays the main help message for the HEALPix CLI tool, listing available commands and global options. ```bash > hpx --help Command-line tool to play with HEALPix Usage: hpx Commands: proj Computes the projected coordinates (x, y) ∊ ([0..8[, [-2..2]) of input equatorial coordinates unproj Computes the equatorial coordinates of Healpix projected coordinates (x, y) ∊ ([0..8[, [-2..2]) nested Operations in the HEALPix NESTED scheme sort Sorts a CSV file by order 29 HEALPix NESTED indices, uses external sort to support huge files hcidx Create an index on an HEALPix NESTED sorted CSV file to then quickly retrieve rows in a given HEALPix cell qhcidx Query an HEALPix sorted and indexed CSV file (see the 'hcidx' command) map Create and manipulate HEALPix count and density maps mom Create and manipulate HEALPix count and density maps cov Compute the list of NESTED Healpix cells in a given sky region (see also moc-cli) help Print this message or the help of the given subcommand(s) Options: -h, --help Print help -V, --version Print version ``` -------------------------------- ### HEALPix WebAssembly Initialization and Usage Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/wasm/test.html Initializes the HEALPix WebAssembly module and demonstrates calling various HEALPix functions from JavaScript. This snippet shows how to use the 'hpx' alias for wasm_bindgen and logs the output of different HEALPix operations to the browser console. ```javascript delete WebAssembly.instantiateStreaming; function run() { // use 'hpx', an alias nicer than 'wasm_bindgen' hpx = wasm_bindgen; console.log("You can call methods (coordinate are given and returned in degrees):") console.log(" hpx.getOrderMax()") console.log(" hpx.lonlatToNested(order, ra, dec)") console.log(" hpx.multiLonlatToNested(order, [ra1, dec1, ra2, dec2, ..., raN, decN])") console.log(" hpx.nestedCenter(order, cellNumber)") console.log(" hpx.vertices(order, cellNumber)") console.log(" hpx.nestedNeighbours(order, cellNumber)") console.log(" hpx.nestedQueryCone(order, cone_ra, cone_dec, cone_radius)") console.log(" hpx.nestedQueryConeBMOC(order, cone_ra, cone_dec, cone_radius)") console.log(" hpx.nestedQueryPolygon(order, [ra1, dec1, ra2, dec2, ..., raN, decN])") console.log(" hpx.nestedQueryPolygonBMOC(order, [ra1, dec1, ra2, dec2, ..., raN, decN])") console.log("From a BMOC, you can get its number of cells `bmoc.getSize()` and access each cell `bmoc.getCell(i)`") console.log("From a Cell, you can access directly its `order`, `icell` and `idfull` attributes") console.log("") console.log("Unrelated to HELPix: multi-polygone query") console.log(" map = hpx.PolygonMap.new()") console.log(" map.addPolygon(int_ID, [ra1, dec1, ra2, dec2, ..., raN, decN]);") console.log(" map.addPolygon(int_ID, [ra1, dec1, ra2, dec2, ..., raN, decN]);") console.log(" map.polygonContaining(ra, dec);") console.log(" map.rmPolygon(int_ID);") } wasm_bindgen('./cdshealpix_bg.wasm') .then(run) .catch(console.error); Look at your web browser console! ``` -------------------------------- ### Compile with Native CPU Optimizations Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md To achieve best performance on your hardware, compile using RUSTFLAGS='-C target-cpu=native'. This enables BMI2 instructions PDEP and PEXT for bit interleaving if supported by your processor. ```bash RUSTFLAGS='-C target-cpu=native' cargo build --release ``` -------------------------------- ### Visualize Density MOM Map as PNG Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Converts a HEALPix density MOM FITS file into a PNG image for visualization. This process is faster than visualizing the raw density map. ```bash time hpx mom view --silent gaia_edr3_dist.dens.mom.fits gaia_edr3_dist.dens.mom.png allsky 400 real 0m0,494s user 0m0,478s sys 0m0,013s ``` -------------------------------- ### Initialize KaTeX Rendering for Math Expressions Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/katex.html This script renders KaTeX math expressions found in elements with the class 'language-math' in display mode. It also processes inline math expressions marked with '$'. ```javascript use strict"; document.addEventListener("DOMContentLoaded", function () { var maths = document.getElementsByClassName("language-math"); for (var i=0; i hpx nested --help Operations in the HEALPix NESTED scheme Usage: hpx nested Commands: table Prints the table of Healpix layers properties (depth, nside, ncells, ...) bestdepth For a cone of given radius, returns the largest depth at which the cone covers max 9 cells hash Get the Healpix hash value (aka ipix or cell number) of given equatorial position(s) bilinear Get the bilinear interpolation parameters, 4x(hash, weight), of given equatorial position(s) center Get the longitude and latitude (in degrees) of the center of the cell of given hash value vertices Get the longitude and latitude (in degrees) of the 4 vertices (S, W, N, E) of the cell of given hash value neighbours Get the hash value (aka ipix or cell number) of the neighbours of the cell of given hash value (S, SE, E, SW, NE, W, NW, N) touniq Transform regular hash values (aka ipix or cell numbers) into the UNIQ representation toring Transform regular hash values (aka ipix or cell numbers) from the NESTED to the RING scheme help Print this message or the help of the given subcommand(s) Options: -h, --help Print help ``` -------------------------------- ### HEALPix Coverage Command Help Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Displays help for the 'cov' command, used to compute HEALPix cell coverage for various sky regions. ```bash > hpx cov --help Compute the list of NESTED Healpix cells in a given sky region (see also moc-cli) Usage: hpx cov [OPTIONS] Commands: cone Cone coverage ellipse Elliptical cone coverage ring Ring coverage zone Zone coverage box Box coverage polygon Polygon coverage stcs STC-S region coverage stcsfile STC-S region provided in a file coverage convert From reading a regular FITS encoded BMOC help Print this message or the help of the given subcommand(s) Arguments: Maximum depth (aka order) of the Healpix cells in the coverage Options: -t, --out-type Output type [default: csv] Possible values: - csv: CSV serialization - fits: FITS serialization - bintable: FITS BINTABLE serialization -o, --output-file Write in the given output file instead of stdout (mandatory for FITS) -h, --help Print help (see a summary with '-h') ``` -------------------------------- ### Visualize Density MOM Map Zoomed Region Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Generates a PNG visualization of a specific region of a density MOM map. Provides a compressed and noise-reduced view of localized data. ```bash > time hpx mom view --silent gaia_edr3_dist.dens.mom.fits gaia_edr3_dist.dens.mom.lmc.png custom -l 280.4652 -b -32.8884 sin 400 400 --x-bounds [-0.15..0.15] --y-bounds [-0.15..0.15] real 0m0,237s user 0m0,227s sys 0m0,010s ``` -------------------------------- ### Visualize Density Map as PNG Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Converts a HEALPix density map FITS file into a PNG image for visualization. Supports custom projections and dimensions. ```bash > time hpx map view --silent gaia_edr3_dist.dens.fits gaia_edr3_dist.dens.png allsky 400 real 0m20,361s user 0m19,246s sys 0m0,492s ``` -------------------------------- ### Benchmark Native CPU Optimizations Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/README.md You can test the performance impact of native CPU optimizations by running benchmarks. If the result of 'ZOrderCurve/BMI' is slower than 'ZOrderCurve/LUPT', it is recommended to compile without 'native' support. ```bash RUSTFLAGS='-C target-cpu=native' cargo bench ``` -------------------------------- ### Create HEALPix Extension in PostgreSQL Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md This SQL command registers the HEALPix extension within your PostgreSQL database, making its functions available for use. It only needs to be run once. ```sql CREATE EXTENSION pg_cds_healpix; ``` -------------------------------- ### Compute Density Map from CSV Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Builds a HEALPix density map from a large CSV file. Use this for initial density estimation. Supports parallel processing and chunking for large files. ```bash > time hpx map dens 11 gaia_edr3_dist.dens.fits csv -d , -l 2 -b 3 --header --chunk-size 100000000 --parallel 32 gaia_edr3_dist.csv real 15m27,858s user 27m20,545s sys 34m42,810s ``` -------------------------------- ### Clone CDS HEALPix Rust Project Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Obtain the source code for the CDS HEALPix Rust library, which is required if you plan to build the hpx-cli from source. This command clones the official repository. ```bash git clone https://github.com/cds-astro/cds-healpix-rust ``` -------------------------------- ### Compute Density Map (Optimized) Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md An optimized method for computing density maps by piping pre-processed CSV data. This approach is faster for single-threaded operations. ```bash > time cut -d , -f 2,3 gaia_edr3_dist.csv | tail -n +2 \ | hpx map dens 11 gaia_edr3_dist.dens.fits list -d , real 8m25,812s user 11m7,242s sys 3m40,669s ``` -------------------------------- ### Compute BMOC for a Sky Cone Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Computes a Binary Occupancy Cube (BMOC) for a specified cone on the sky. This is used to represent regions of interest efficiently. ```bash time hpx cov 9 --out-type fits --output-file cone.bmoc.fits cone 080.8942 -69.7561 0.2 real 0m0,006s user 0m0,001s sys 0m0,005s ``` -------------------------------- ### Visualize Density Map Zoomed Region Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Generates a PNG visualization of a specific region of a density map. Useful for detailed inspection of smaller areas. ```bash > time hpx map view --silent gaia_edr3_dist.dens.fits gaia_edr3_dist.dens.lmc.png custom -l 280.4652 -b -32.8884 sin 400 400 --x-bounds [-0.15..0.15] --y-bounds [-0.15..0.15] real 0m7,507s user 0m7,277s sys 0m0,229s ``` -------------------------------- ### Index Sorted CSV File to HEALPix FITS Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Indexes a pre-sorted CSV file into a HEALPix FITS format. This is useful for creating compact and queryable HEALPix indices. ```bash time hpx hcidx --header -d , --depth 9 -o gaia_edr3_dist.sorted.hci.fits -l 2 -b 3 gaia_edr3_dist.sorted.csv real 6m39,257s user 4m51,979s sys 1m30,032s ``` -------------------------------- ### Visualize and Center HEALPix Cells from BMOC Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Converts a BMOC to a list of HEALPix cells and computes their centers. This helps in visualizing the coverage of the BMOC. ```bash time hpx cov 9 convert cone.bmoc.fits | tail -n +2 | hpx nested center 9 csv -d , -f 2 --header --paste --paste-header "center_lon,center_lat" order,ipix,is_fully_covered_flag,center_lon,center_lat 9,2118189,0,080.7110091743119,-69.9794867201383 9,2118191,0,080.3424657534247,-69.8866968891410 9,2118194,0,081.1238532110092,-69.9794867201383 9,2118195,0,081.1643835616438,-69.8866968891410 9,2118196,0,081.5753424657534,-69.7938937311056 9,2118197,0,081.6136363636364,-69.7938937311056 9,2118198,0,081.2045454545455,-69.7938937311056 9,2118199,0,081.2443438914027,-69.7010771793946 9,2118200,0,080.7534246575343,-69.8866968891410 9,2118201,1,080.7954545454545,-69.7938937311056 9,2118202,0,080.3863636363636,-69.7938937311056 9,2118203,0,080.4298642533936,-69.7010771793946 9,2118204,1,080.8371040723982,-69.7010771793946 9,2118205,0,080.8783783783784,-69.6082471672874 9,2118206,0,080.4729729729730,-69.6082471672874 9,2118207,0,080.5156950672646,-69.5154036279795 9,2118240,0,081.6515837104072,-69.7010771793946 9,2118242,0,081.2837837837838,-69.6082471672874 9,2118248,0,080.9192825112108,-69.5154036279795 real 0m0,008s user 0m0,005s sys 0m0,013s ``` -------------------------------- ### Convert Density Map to Density MOM Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Converts a density map into a density MOM (multi-resolution map) using a chi-square criterion. This significantly compresses the data and removes noise. ```bash > time hpx map convert gaia_edr3_dist.dens.fits gaia_edr3_dist.dens.mom.fits dens2chi2mom real 0m0,978s user 0m0,661s sys 0m0,317s ``` -------------------------------- ### Query HEALPix Index with BMOC Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Queries a HEALPix index file using a BMOC to retrieve and count sources within the specified regions. This is a fast operation for large datasets. ```bash time hpx qhcidx gaia_edr3_dist.sorted.hci.fits bmoc cone.bmoc.fits | wc -l 240021 real 0m0,207s (0m0.034s with a hot cache) user 0m0,000s sys 0m0,076s ``` -------------------------------- ### hpx_nside Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Computes the Nside for a given HEALPix depth. The depth must be between 0 and 29. ```APIDOC ## hpx_nside(INTEGER)->INTEGER ### Description Computes the Nside for a given HEALPix depth. The depth must be an integer within the range [0, 29]. ### Parameters #### Path Parameters - **depth** (INTEGER) - Required - The HEALPix depth. ### Response #### Success Response (200) - **nside** (INTEGER) - The computed Nside value. ### Response Example ```json { "nside": 16 } ``` ``` -------------------------------- ### Sort Large CSV File by HEALPix Order Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/cli/README.md Sorts a large CSV file based on HEALPix indices. Use this to prepare data for efficient HEALPix indexing. ```bash time hpx sort --header -d , -o gaia_edr3_dist.sorted.csv -l 2 -b 3 gaia_edr3_dist.csv real 89m5,997s user 184m9.269s sys 23m21,342s ``` -------------------------------- ### hpx_hash Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Computes the hash/index of a HEALPix cell for a given position and depth. Depth must be [0,29] and latitude [-90,90]. ```APIDOC ## hpx_hash(INTEGER, DOUBLE PRECISION, DOUBLE PRECISION)->BIGINT ### Description Computes the hash/index of the HEALPix cell including the given position at the given depth. The depth must be within [0,29] and the latitude within [-90,90]. ### Parameters #### Path Parameters - **depth** (INTEGER) - Required - The HEALPix depth. - **latitude** (DOUBLE PRECISION) - Required - The latitude of the position. - **longitude** (DOUBLE PRECISION) - Required - The longitude of the position. ### Response #### Success Response (200) - **hash** (BIGINT) - The computed HEALPix cell hash/index. ### Response Example ```json { "hash": 19456 } ``` ``` -------------------------------- ### hpx_center Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Computes the center coordinates (longitude, latitude) of a specified HEALPix cell. Depth must be [0,29] and hash within [0, 12*Nside^2[. ```APIDOC ## hpx_center(INTEGER, BIGINT)->DOUBLE PRECISION[] ### Description Computes the center of the specified HEALPix cell. The depth must be within [0,29] and the hash within [0, 12*Nside^2[. ### Parameters #### Path Parameters - **depth** (INTEGER) - Required - The HEALPix depth. - **hash** (BIGINT) - Required - The hash/index of the HEALPix cell. ### Response #### Success Response (200) - **center** (DOUBLE PRECISION[]) - An array containing the longitude and latitude of the cell's center. ### Response Example ```json { "center": [69.609375, 34.2288663278126] } ``` ``` -------------------------------- ### Compute HEALPix Hash Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Computes the HEALPix cell hash (index) for a given depth and spherical coordinates (longitude, latitude). Valid depths are [0, 29] and latitudes are [-90, 90]. ```sql psql=# SELECT hpx_hash(6, 0.0, 0.0); hpx_hash ---------- 19456 (1 row) ``` -------------------------------- ### Compute HEALPix Nside Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Calculates the Nside value for a given HEALPix depth. Ensure the depth is within the valid range [0, 29]. ```sql psql=# SELECT hpx_nside(4); hpx_nside ----------- 16 (1 row) ``` -------------------------------- ### Compute HEALPix Cell Center Source: https://github.com/cds-astro/cds-healpix-rust/blob/master/crates/libpsql/README.md Calculates the center coordinates (longitude, latitude) of a specified HEALPix cell identified by its depth and hash. Ensure depth is within [0, 29] and hash is within [0, 12*Nside^2[. ```sql psql=# SELECT hpx_center(6, 1234); hpx_center ------------------------------ {69.609375,34.2288663278126} (1 row) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.