HealSparse has a basic geometry library that allows you to generate maps from circles and convex polygons, as supported by
healpy. Each geometric object is associated with a single value. On construction, geometry objects only contain information about the shape, and they are only rendered onto a HEALPix grid when requested.
There are two methods to realize geometry objects. The first is that each object can be used to generate a
HealSparseMap map, and the second, for integer-valued objects is the
realize_geom() method which can be used to combine multiple objects by
or-ing the integer values together.
HealSparse Geometry Shapes¶
The two shapes supported are
Polygon. They share a base class, and while the instantiation is different, the operations are the same.
import healsparse # All units are decimal degrees circ = healsparse.Circle(ra=200.0, dec=0.0, radius=1.0, value=1)
# All units are decimal degrees poly = healsparse.Polygon(ra=[200.0, 200.2, 200.3, 200.2, 200.1], dec=[0.0, 0.1, 0.2, 0.25, 0.13], value=8)
Making a Map¶
To make a map from a geometry object, use the
get_map() method as such. The higher resolution you choose, the better the aliasing at the edges (given that these are pixelized approximations of the true shapes). You can also combine two maps using the general operations. Note that if the polygon is an integer value, the default sentinel when using
smap_poly = poly.get_map(nside_coverage=32, nside_sparse=32768, dtype=np.int16) smap_circ = circ.get_map(nside_coverage=32, nside_sparse=32768, dtype=np.int16) combo = healsparse.or_union([smap_poly, smap_circ])
You can only use
realize_geom() to create maps from combinations of polygons if you are using integer maps, and want to
or them together. This method is more memory efficient than generating each individual individual map and combining them, as above.
realized_combo = healsparse.HealSparseMap.make_empty(32, 32768, np.int16, sentinel=0) healsparse.realize_geom([poly, circ], realized_combo)