dateIDs = []
hpIDs = []
starMags = []
starMags_err = []
mjds = []
airmasses = []

altLimit = 25.  # Degrees
sunAltLimit = np.radians(-20.)

starBrightLimit = -9.
# Demand this many stars before using the frame in ubercal
nStarLimit = 200

# get the max dateID
maxID, mjd = sb.allSkyDB(0, 'select max(ID) from dates;', dtypes='int')
maxID = np.max(maxID)

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

# See if there are any nights where there were observations, but no
# stars made it into the DB (i.e., it was totally cloudy all night).
allmjds, blah = sb.allSkyDB(0,
                            'select mjd from dates where mjd > %i;' % minMJD,
                            dtypes='float')
db_mjds = np.unique(np.floor(allmjds))
    alt, az = hp.pix2ang(nside,indices)
    alt = np.pi/2.-alt
    airmass = 1./np.cos(np.pi/2.-alt)
    good = np.where((airmass >=1) & (airmass <= airmassLimit) )
    hpIndices.append(indices[good])

# Demand this many stars before using the frame in ubercal
nStarLimit = 200

names = ['ra','dec','starID','starMag', 'starMag_err', 'sky', 'filter']
types = [float,float,float, float,float,float,'|S1']
dtypes = zip(names,types)


# get the max dateID
maxID,mjd = sb.allSkyDB(0,'select max(ID) from dates;', dtypes='int')
maxID = np.max(maxID)

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

altLimit = 10. # Degrees
sunAltLimit = np.radians(-20.)

maxID = 3000
step = 5

for dateID in np.arange(minID.max(),minID.max()+maxID+1, step):
    sqlQ = 'select stars.ra, stars.dec, stars.ID, obs.starMag_inst, obs.starMag_err,obs.sky, obs.filter from obs, stars, dates where obs.starID = stars.ID and obs.dateID = dates.ID and obs.filter = "%s" and obs.dateID = %i and obs.starMag_err != 0 and dates.sunAlt < %f and obs.starMag_inst > %f;' % (filt,dateID,sunAltLimit, starBrightLimit)
# 8191. 8649
#dateIDs = np.arange(8191, 8694, 2)  #np.arange(1665, 2506, 5) #[2133,2134]
dateIDs = np.arange(28793, 29651, 2)
outDir = 'Movie'

cmin = 18.
cmax = 21.5

zp = 12.11

#zps = []
counter = 0
maxI = np.size(dateIDs)
for i,dateID in enumerate(dateIDs):

    skydata, mjd = sb.allSkyDB(dateID , filt=band)#2744
    airmass = 1./np.cos(np.radians(90.-skydata['alt']))
    skydata = skydata[np.where((airmass < 2.1) & (airmass >= 1.))]

    alt,az,pa =  altAzPaFromRaDec(np.radians(skydata['ra']), np.radians(skydata['dec']),
                                  telescope.lon, telescope.lat, mjd)

    skyhp = healplots.healbin(az, alt, skydata['sky'], nside=nside)

    sm.setRaDecMjd(np.radians(skydata['ra']), np.radians(skydata['dec']), mjd, degrees=False)
    if sm.sunAlt < np.radians(-12.):
        sm.computeSpec()
        mags = sm.computeMags(canonDict[band])

        good = np.where(mags > 0)
        if np.size(good[0]) > 10:
Beispiel #4
0
# 8191. 8649
#dateIDs = np.arange(8191, 8694, 2)  #np.arange(1665, 2506, 5) #[2133,2134]
dateIDs = np.arange(28793, 29651, 2)
outDir = 'Movie'

cmin = 18.
cmax = 21.5

zp = 12.11

#zps = []
counter = 0
maxI = np.size(dateIDs)
for i, dateID in enumerate(dateIDs):

    skydata, mjd = sb.allSkyDB(dateID, filt=band)  #2744
    airmass = 1. / np.cos(np.radians(90. - skydata['alt']))
    skydata = skydata[np.where((airmass < 2.1) & (airmass >= 1.))]

    alt, az, pa = altAzPaFromRaDec(np.radians(skydata['ra']),
                                   np.radians(skydata['dec']), telescope.lon,
                                   telescope.lat, mjd)

    skyhp = healplots.healbin(az, alt, skydata['sky'], nside=nside)

    sm.setRaDecMjd(np.radians(skydata['ra']),
                   np.radians(skydata['dec']),
                   mjd,
                   degrees=False)
    if sm.sunAlt < np.radians(-12.):
        sm.computeSpec()
    'B': 'blue_canon.csv'
}

path = os.path.join(os.environ.get('SIMS_SKYBRIGHTNESS_DATA_DIR'), 'Canon')
for key in canonFiles.keys():
    data = np.loadtxt(os.path.join(path, canonFiles[key]),
                      delimiter=',',
                      dtype=zip(['wave', 'throughput'], [float, float]))
    band = Bandpass()
    band.setBandpass(data['wave'], data['throughput'])
    canonDict[key] = band

sqlQ = 'select id,mjd,sunAlt,moonAlt from dates'
dateData, mjd = sb.allSkyDB(2744,
                            sqlQ=sqlQ,
                            filt=None,
                            dtypes=zip(['dateID', 'mjd', 'sunAlt', 'moonAlt'],
                                       [int, float, float, float]))

skipsize = 10
indices = np.arange(0, dateData.size, skipsize)

# Maybe bin things on 15-min timescales to cut down the number of calls I need to make to the model
#binsize = 15./60./24.
#edges = np.arange(skydata['mjd'].min(),skydata['mjd'].max()+binsize*2, binsize)

read = True
filters = ['R', 'G', 'B']
sm = sb.SkyModel(mags=False)
telescope = TelescopeInfo('LSST')
canonDict = {}
canonFiles = {'R':'red_canon.csv','G':'green_canon.csv','B':'blue_canon.csv'}

path = os.path.join(os.environ.get('SIMS_SKYBRIGHTNESS_DATA_DIR'), 'Canon')
for key in canonFiles.keys():
    data = np.loadtxt(os.path.join(path,canonFiles[key]), delimiter=',',
                      dtype=zip(['wave','throughput'],[float,float]))
    band = Bandpass()
    band.setBandpass(data['wave'], data['throughput'])
    canonDict[key]=band




sqlQ = 'select id,mjd,sunAlt,moonAlt from dates'
dateData,mjd = sb.allSkyDB(2744 , sqlQ=sqlQ, filt=None,dtypes=zip(['dateID', 'mjd','sunAlt', 'moonAlt'],
                                                                  [int,float,float,float]))


skipsize = 10
indices = np.arange(0,dateData.size, skipsize)

# Maybe bin things on 15-min timescales to cut down the number of calls I need to make to the model
#binsize = 15./60./24.
#edges = np.arange(skydata['mjd'].min(),skydata['mjd'].max()+binsize*2, binsize)

read = True
filters = ['R','G','B']
sm = sb.SkyModel(mags=False)
telescope = TelescopeInfo('LSST')

nside = 16
Beispiel #7
0
import numpy as np
import lsst.sims.skybrightness as sb
import healpy as hp
from lsst.sims.utils import healbin


nside = 4
filt = 'R'

mjds = []
hpids = []
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())