This notebook shows how to use the functionality in the HealpixTree
class. This is a useful function to find groups of Healpixels at high resolution which are connected and nearby. In particular this notebook illustrates two useful methods:
pixelsAtNextLevel
pixelsAtResolutionLevel
In [1]:
from mpl_toolkits.basemap import Basemap
In [2]:
import opsimsummary as oss
In [3]:
oss.__VERSION__
Out[3]:
In [4]:
from opsimsummary import HealpixTree, pixelsForAng, HealpixTiles
In [5]:
import numpy as np
In [6]:
%matplotlib inline
import matplotlib.pyplot as plt
In [7]:
import healpy as hp
In [8]:
htree = HealpixTree(nside=1, nest=True)
In [9]:
# By default the nside argument to this function is the nside at which htree was instantiated
print(htree.nside)
ipix = np.array([0, 1])
htree.pixelsAtNextLevel(ipix)
Out[9]:
In [10]:
# We can also be specific, and do this for a particular NSIDE
htree.pixelsAtNextLevel(ipix, nside=128)
Out[10]:
In [11]:
# How many subdivisions required to go to NSIDE =256 ?
desideredNSIDE = 256
res = int(np.log2(desideredNSIDE))
In [12]:
# nsidenew should be the NSIDE at the resolution we want
nsidenew, pixels = htree.pixelsAtResolutionLevel(1, res, 1)
In [13]:
assert nsidenew == desideredNSIDE
In [14]:
n256 = hp.nside2npix(256)
n1 = hp.nside2npix(1)
arr1 = np.ones(n1) * hp.UNSEEN
arr1[1] = 1
arr256 = np.ones(n256) * hp.UNSEEN
arr256[pixels] = -2
hp.mollview(arr1, nest=True)
hp.mollview(arr256, nest=True)
In [ ]: