Beispiel #1
0
    def testBinDeg(self):
        """
        Test that healbin returns correct values and valid healpy maps.
        """

        ra = np.zeros(3)
        dec = np.zeros(3)
        values = ra * 0. + 1.

        nside = 128
        hpid = utils.raDec2Hpid(nside, ra[0], dec[0])

        map1 = utils.healbin(ra, dec, values, nside=nside)
        self.assertEqual(map1[hpid], 1.)
        self.assertEqual(hp.maptype(map1), 0)
        map2 = utils.healbin(ra, dec, values, nside=nside, reduceFunc=np.sum)
        self.assertEqual(map2[hpid], 3.)
        self.assertEqual(hp.maptype(map2), 0)
        map3 = utils.healbin(ra, dec, values, nside=nside, reduceFunc=np.std)
        self.assertEqual(map3[hpid], 0.)
        self.assertEqual(hp.maptype(map3), 0)
import healpy as hp
from lsst.sims.utils import healbin
import matplotlib.pylab as plt

# Just look at the number of stars we're getting on the sky

nside = 8

data = np.load('phot.npz')
phot = data['phot'].copy()
data.close()

umjd = np.unique(phot['mjd'])
phot.sort(order='mjd')
left = np.searchsorted(phot['mjd'], umjd)
right = np.searchsorted(phot['mjd'], umjd, side='right')

nstars = right - left

goodMJD = umjd[np.where(nstars == nstars.max())]
good = np.where(phot['mjd'] == goodMJD)
hmap = healbin(phot['RA'][good],
               phot['dec'][good],
               phot['dec'][good],
               nside=nside,
               reduceFunc=np.size)

fig = plt.figure(1)
hp.mollview(hmap, fig=1, title='%i stars' % np.size(good[0]), unit='N stars')
fig.savefig('stellar_density.png')
Beispiel #3
0
nstars = []

# Crop off junky early things
minMJD = 56900
minID,mjd = sb.allSkyDB(0,'select min(ID) from dates where mjd > %i;' % minMJD, dtypes='int')
maxID,mjd = sb.allSkyDB(0,'select max(ID) from dates where mjd > %i;' % minMJD, dtypes='int')


# Temp pad for testing
# maxID = minID+100

full_range = float(maxID - minID)
for i,dateID in enumerate(np.arange(minID.max(),maxID.max())):
	print i, mjd
	data,mjd = sb.allSkyDB(dateID)#  , sqlQ=sqlQ, dtypes=dtypes)
	starmap = healbin(data['ra'], data['dec'], data['dec'], 
	                  nside=nside, reduceFunc=np.size)
	good = np.where(starmap != hp.UNSEEN)[0]
	mjds.extend([mjd]*good.size)
	hpids.extend(good.tolist())
	nstars.extend(starmap[good].tolist())
	

	
print 'ack'
names = ['mjd', 'hpid', 'nstars']
types = [float, int, int]
result = np.array(zip(mjds, hpids, nstars), dtype=zip(names, types))

np.savez('starDensity_nside%i.npz' % nside, starmap=result, nside=nside)
import numpy as np
import healpy as hp
from lsst.sims.utils import healbin
import matplotlib.pylab as plt

# Just look at the number of stars we're getting on the sky

nside = 8

data = np.load('phot.npz')
phot = data['phot'].copy()
data.close()

umjd = np.unique(phot['mjd'])
phot.sort(order='mjd')
left = np.searchsorted(phot['mjd'], umjd)
right = np.searchsorted(phot['mjd'], umjd, side='right')

nstars = right-left

goodMJD = umjd[np.where(nstars == nstars.max())]
good = np.where(phot['mjd'] == goodMJD)
hmap = healbin(phot['RA'][good], phot['dec'][good], phot['dec'][good], nside=nside, reduceFunc=np.size)

fig = plt.figure(1)
hp.mollview(hmap, fig=1, title='%i stars' % np.size(good[0]), unit='N stars')
fig.savefig('stellar_density.png')
Beispiel #5
0
        darkTimestdResid = data['darkTimestdResid'].copy()
        darkTimesCount = data['darkTimesCount'].copy()
    else:
        darkTimeMaps = []
        for i, indx in enumerate(indices):
            skydata, mjd = sb.allSkyDB(dateData[indx]['dateID'],
                                       filt=filterName)
            if skydata.size > starLimit:
                airmass = 1. / np.cos(np.radians(90. - skydata['alt']))
                skydata = skydata[np.where((airmass < amMax)
                                           & (airmass >= 1.))]
                alt, az, pa = _altAzPaFromRaDec(np.radians(skydata['ra']),
                                                np.radians(skydata['dec']),
                                                telescope.lon, telescope.lat,
                                                mjd)
                skyhp = healbin(az, alt, skydata['sky'], nside=nside)
                skyhp[np.isnan(skyhp)] = hp.UNSEEN

                good = np.where(skyhp != hp.UNSEEN)
                sm.setRaDecMjd(hpra[good],
                               hpdec[good],
                               mjd,
                               degrees=False,
                               azAlt=True)

                # switch moon to ra dec
                moonRA, moonDec = _raDecFromAltAz(sm.moonAlt, sm.moonAz,
                                                  telescope.lon, telescope.lat,
                                                  mjd)
                # compute distances
                moonDistances = haversine(hpra[good], hpdec[good], moonRA,