Skip to content

Investigate HEALPix Support #1028

Closed
2 of 2 issues completed
Closed

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. self-assigned this
    on Oct 22, 2024
  2. moved this from 📚 Backlog to On Pause in UXarray Developmenton Oct 22, 2024
  3. moved this from On Pause to 📝 To-Do in UXarray Developmenton Oct 22, 2024
  4. philipc2 commented on Dec 2, 2024

    @philipc2
    MemberAuthor

    Following a similar track to what I've done with other grid formats, I've initially attempted to represent a HEALPix grid in the UGRID conventions.

    The current expectation from UXarray (and the UGRID conventions) is that at least the following are required to represent a 2D unstructured grid:

    • node_lon: Longitude of the corner nodes that make up each face/cell
    • node_lat: Latitude of the corner nodes that make up each face/cell
    • face_node_connectivity: Indices of the corner nodes that make up each face/cell

    If we posses these three variables, a Grid can be constructed even if we do not support a format directly:

    uxgrid = ux.Grid.from_topology(node_lon, node_lat, face_node_connectivity)

    I used the healpy library to iterate over each pixel to obtain its boundaries using hp.boundaries and used the outputs to generate the face_node_connectivity

    import uxarray as ux
    import healpy as hp
    import numpy as np
    
    n_side = 4
    n_pix = hp.nside2npix(n_side)  
    
    
    unique_lonlat_pairs = dict()
    face_node_connectivity = np.empty((n_pix, 4), dtype=ux.INT_DTYPE)
    
    for pix in range(n_pix):
        vec = hp.boundaries(n_side, pix, step=1, nest=False).T  
    
        # Convert Cartesian coordinates to spherical coordinates
        lon, lat = hp.vec2ang(vec, lonlat=True)
        lon = (lon + 180) % 360 - 180
        
        cur_face_nodes = []
        
        for i in range(4):
            # 4 corner nodes for each pixel
            if lon[i] == -180.0:
                # avoid duplicates
                lon[i] = 180
            
            lonlat = (lon[i], lat[i])
            if lonlat not in unique_lonlat_pairs:
                unique_lonlat_pairs[lonlat] = len(unique_lonlat_pairs)
                
            face_node_connectivity[pix, i] = unique_lonlat_pairs[lonlat]
            
    node_lon = np.empty(len(unique_lonlat_pairs), dtype=np.float32)
    node_lat = np.empty(len(unique_lonlat_pairs), dtype=np.float32)
    
    for i, lonlat in enumerate(unique_lonlat_pairs):
        node_lon[i] = lonlat[0]
        node_lat[i] = lonlat[1]
    
    uxgrid = ux.Grid.from_topology(node_lon, node_lat, face_node_connectivity)

    This was a very initial exploration, but the results appear to be on the right track.

    Image

    Image

    What I'm the most curious about is whether a UGRID to HEALPix conversion is something that is desired by the community, and/or if it is even practical.

  5. linked a pull request that will close this issueDRAFT: HEALPix Support #1096on Dec 5, 2024
  6. self-assigned this
    on Jan 15, 2025
  7. philipc2 commented on Jan 28, 2025

    @philipc2
    MemberAuthor
  8. rajeeja commented on Jan 29, 2025

    @rajeeja
    Contributor

    ntessore/healpix#66

    I was thinking of using healpy:

    Scope: More comprehensive package with a wider range of features, including spherical harmonic transforms, map visualization, and advanced analysis tools.
    Functionality: Offers a broader set of functionalities, including integration with other astronomy libraries.
    Licensing: GNU General Public License (GPL) version 2.
    For use with uxarray, healpix is generally recommended due to its BSD-3-Clause license, which is more permissive than the GPL license of healpy.

  9. rajeeja commented on Jan 29, 2025

    @rajeeja
    Contributor

    ntessore/healpix#66

    Right, we should healpix library you mention:

    Scope: More comprehensive package with a wider range of features, including spherical harmonic transforms, map visualization, and advanced analysis tools. Functionality: Offers a broader set of functionalities, including integration with other astronomy libraries. Licensing: GNU General Public License (GPL) version 2. For use with uxarray, healpix is generally recommended due to its BSD-3-Clause license, which is more permissive than the GPL license of healpy.

  10. linked a pull request that will close this issueAdd HEALPix Support #1147on Feb 12, 2025
  11. moved this from 📝 To-Do to ✅ Done in UXarray Developmenton Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions