Пример #1
0
    def test_cache(self):
        """
        Test that EBVbase() only loads each dust map once
        """
        sims_clean_up()
        self.assertEqual(len(EBVbase._ebv_map_cache), 0)

        ebv1 = EBVbase()
        ebv1.load_ebvMapNorth()
        ebv1.load_ebvMapSouth()
        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        ebv2 = EBVbase()
        ebv2.load_ebvMapNorth()
        ebv2.load_ebvMapSouth()
        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        rng = np.random.RandomState(881)
        ra_list = rng.random_sample(10)*2.0*np.pi
        dec_list = rng.random_sample(10)*np.pi - 0.5*np.pi

        ebv1_vals = ebv1.calculateEbv(equatorialCoordinates=np.array([ra_list, dec_list]))
        ebv2_vals = ebv2.calculateEbv(equatorialCoordinates=np.array([ra_list, dec_list]))

        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        np.testing.assert_array_equal(ebv1_vals, ebv2_vals)
Пример #2
0
    def test_cache(self):
        """
        Test that EBVbase() only loads each dust map once
        """
        sims_clean_up()
        self.assertEqual(len(EBVbase._ebv_map_cache), 0)

        ebv1 = EBVbase()
        ebv1.load_ebvMapNorth()
        ebv1.load_ebvMapSouth()
        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        ebv2 = EBVbase()
        ebv2.load_ebvMapNorth()
        ebv2.load_ebvMapSouth()
        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        rng = np.random.RandomState(881)
        ra_list = rng.random_sample(10) * 2.0 * np.pi
        dec_list = rng.random_sample(10) * np.pi - 0.5 * np.pi

        ebv1_vals = ebv1.calculateEbv(
            equatorialCoordinates=np.array([ra_list, dec_list]))
        ebv2_vals = ebv2.calculateEbv(
            equatorialCoordinates=np.array([ra_list, dec_list]))

        self.assertEqual(len(EBVbase._ebv_map_cache), 2)

        np.testing.assert_array_equal(ebv1_vals, ebv2_vals)
Пример #3
0
#!/usr/bin/env python

import numpy as np
import healpy as hp
from lsst.sims.catUtils.dust import EBVbase


if __name__ == '__main__':

    # Read in the Schelgel dust maps and convert them to a healpix map
    dustmap = EBVbase()
    dustmap.load_ebvMapNorth()
    dustmap.load_ebvMapSouth()

    # Set up the Healpixel map
    nsides = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
    for nside in nsides:
        lat, ra = hp.pix2ang(nside, np.arange(hp.nside2npix(nside)))
        # Move dec to +/- 90 degrees
        dec = np.pi/2.0 - lat
        ebvMap = dustmap.calculateEbv(equatorialCoordinates=np.array([ra, dec]), interp=False)
        np.savez('dust_nside_%s.npz'%nside, ebvMap=ebvMap)
Пример #4
0
#!/usr/bin/env python

import numpy as np
import healpy as hp
from lsst.sims.catUtils.dust import EBVbase

if __name__ == '__main__':

    # Read in the Schelgel dust maps and convert them to a healpix map
    dustmap = EBVbase()
    dustmap.load_ebvMapNorth()
    dustmap.load_ebvMapSouth()

    # Set up the Healpixel map
    nsides = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
    for nside in nsides:
        lat, ra = hp.pix2ang(nside, np.arange(hp.nside2npix(nside)))
        # Move dec to +/- 90 degrees
        dec = np.pi / 2.0 - lat
        ebvMap = dustmap.calculateEbv(equatorialCoordinates=np.array([ra,
                                                                      dec]),
                                      interp=False)
        np.savez('dust_nside_%s.npz' % nside, ebvMap=ebvMap)