In [1]:
# Make sure you have healpy installed by running either command
#!conda install -c conda-forge healpy
#!pip install healpy
In [2]:
import vaex as vx
import healpy as hp
%matplotlib inline
In [3]:
tgas = vx.datasets.tgas.fetch()
Using healpix is made available using the healpy package. Vaex does not need special support for healpix, only for plotting, but some helper functions are introduced to make working with healpix easier.
To understand this better, we will start from the beginning. If we want to make a density sky plot, we would like to pass healpy a 1d numpy array where each value represents the density at a location of the sphere, where the location is determined by the array size (the healpix level) and the offset (the location). Since the Gaia data includes the healpix index encoded in the source_id. By diving the source_id by 34359738368 you get a healpix index level 12, and diving it further will take you to lower levels.
In [4]:
level = 2
factor = 34359738368 * (4**(12-level))
nmax = hp.nside2npix(2**level)
counts = tgas.count(binby="source_id/" + str(factor), limits=[0, nmax], shape=nmax)
counts
Out[4]:
Using the healpy package, we can plot this in a molleweide projection
In [5]:
hp.mollview(counts, nest=True)
To avoid typing this over and over again, instead, we can use Dataset.healpix_count.
In [6]:
counts = tgas.healpix_count(healpix_level=6)
hp.mollview(counts, nest=True)
Instead of using healpy, we can use vaex' Dataset.healpix_plot method.
In [7]:
tgas.healpix_plot(f="log1p", healpix_level=6, figsize=(10,8), healpix_output="ecliptic")
In [ ]: