<jupyter_start><jupyter_text>Note For this to work, you will need the `lsst.sims` stack to be installed.  - opsimsummary uses `healpy` which is installed with the sims stack, but also available from pip/conda - snsims uses the `lsst.sims` stack.<jupyter_code>import opsimsummary as oss
from opsimsummary import Tiling, HealpixTiles
# import snsims
import healpy as hp
%matplotlib inline
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>This section pertains to how to write a new Tiling class ```noTile = snsims.Tiling()---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last) in ()----> 1 noTile = snsims.Tiling()TypeError: Can't instantiate abstract class Tiling with abstract methods __init__, area, pointingSequenceForTile, tileIDSequence, tileIDsForSN``` The class `snsims.Tiling` is an abstract Base class. Therefore, this cannot be instantiated. It must be subclassed, and the set of methods outlined have to be implemented for this to work.<jupyter_code>class NoTile(Tiling):
    pass
noTile = NoTile()<jupyter_output><empty_output><jupyter_text>```"""noTile = NoTile()---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last) in ()----> 1 noTile = NoTile()TypeError: Can't instantiate abstract class NoTile with abstract methods __init__, area, pointingSequenceForTile, positions, tileIDSequence, tileIDsForSN"""``` The above fails because the methods are not implemented. Below is a stupid (ie. not useful) but minimalist class that would work:<jupyter_code>class MyTile(Tiling):
    def __init__(self):
        pass
    @property
    def tileIDSequence(self):
        return np.arange(100)
    
    def tileIDsForSN(self, ra, dec):
        x = ra + dec
        y = np.remainder(x, 100.)
        return np.floor(y)
    def area(self, tileID):
        return 1.
    def pointingSequenceForTile(self, tileID, pointings):
        return None
    def positions(self):
        pass
    
myTile = MyTile()<jupyter_output><empty_output><jupyter_text>Using the class HealpixTiles Currently there is only concrete tiling class that has been implemented. This is the `snsims.HealpixTiles` class.This shows how to use the HealpixTiles Class<jupyter_code>issubclass(HealpixTiles, Tiling)
help(HealpixTiles)
datadir = os.path.join(oss.__path__[0], 'example_data')
opsimdb = os.path.join(datadir, 'enigma_1189_micro.db')
NSIDE = 4
hpOpSim = oss.HealPixelizedOpSim.fromOpSimDB(opsimdb, NSIDE=NSIDE)
NSIDE
hpTileshpOpSim = HealpixTiles(healpixelizedOpSim=hpOpSim, nside=NSIDE)
hpTileshpOpSim.pointingSequenceForTile(1, allPointings=None)
phi, theta = hpTileshpOpSim.positions(1, 10000)
mapvals = np.ones(hp.nside2npix(NSIDE)) * hp.UNSEEN
mapvals[1] = 100
hp.ang2pix(NSIDE, np.radians(theta), np.radians(phi), nest=True)
theta_c, phi_c = hp.pix2ang(4, 1, nest=True)
hp.mollview(mapvals, nest=True)
hp.projscatter(np.radians(theta), np.radians(phi), **dict(s=0.0002))
hp.projscatter(theta_c, phi_c, **dict(s=8., c='r'))
%timeit hpTileshpOpSim.pointingSequenceForTile(33, allPointings=None)
preCompMap = os.path.join(oss.__path__[0], 'example_data', 'healpixels_micro.db')
hpTilesMap = HealpixTiles(nside=1, preComputedMap=preCompMap)
hpTilesMap.pointingSequenceForTile(10, allPointings=None)
%timeit hpOpSim.obsHistIdsForTile(34)
hpTiles = HealpixTiles(healpixelizedOpSim=hpOpSim)
hpTiles.pointingSequenceForTile(34, allPointings=None)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1400560224089636, 'fraction_numerical': 0.013165266106442577, 'mean_word_length': 4.043785310734464, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '528155', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1165, 'n_words': 297, 'path': 'example/UsingTheTilingClass.ipynb', 'repo_name': 'Catarina-Alves/OpSimSummary', 'size': '3570'}