Esempio n. 1
0
# 400 points from start to end
utcs = np.linspace(utc5,utc6,400)
mjds = isun + utcs/24.
mjd6 = isun+utc6/24.

pgsvp(xv1, xv2, yv1+ch/40, yv2-ch/40)
pgswin(utstart,utend,0,1)

# Loop through the stars listed in the ephemeris file, computing their hour
# angles at midnight.  This establishes the plot order.
has = []
midnight = (sunset+sunrise)/2.
for key, star in peinfo.iteritems():
    airmasses, alt, az, ha, pa, delz = \
        sla.amass(midnight,longit,latit,height,star.ra,star.dec)
    has.append((ha, key))

keys = [item[1] for item in sorted(has,key=lambda ha: ha[0], reverse=True)]

# Now compute plot positions
ys = {}
for i,key in enumerate(keys):
    ys[key] = (len(keys)-i)/float(len(keys)+1)

# Plot switches
if args.switch is not None:
    pgsls(1)
    pgscr(5,0.8,0.8,0.8)
    pgslw(10)
    pgsci(5)
        table = hdul[i].data
        ok    = table.field('Sigma_' + str(nap)) > 0.
        mjd   = table.field('MJD')[ok]
        flx   = table.field('Counts_' + str(nap))[ok]

        # Bin up fluxes and times
        nbin     = int(np.ceil((mjd.max() - mjd.min())/(deltat/1440.)))
        bins     = np.linspace(mjd.min(), mjd.max(), nbin)
        nbins, b = np.histogram(mjd, bins)
        bmjd, b  = np.histogram(mjd, bins, weights=mjd)
        bflx, b  = np.histogram(mjd, bins, weights=flx)
        bmjd    /= nbins
        bflx    /= nbins

        # Convert to airmass and magnitudes
        air,alt,az,ha,pa,delz = sla.amass(bmjd, longit, latit, height, ra, dec) 
        mag = 25-2.5*np.log10(bflx)

        if len(airs) < 3:
            airs.append([air[ha < 0], air[ha >= 0]])
            mags.append([mag[ha < 0], mag[ha >= 0]])
        else:
            airs[i-1][0] = np.concatenate((airs[i-1][0],air[ha < 0]))
            airs[i-1][1] = np.concatenate((airs[i-1][1],air[ha >= 0]))
            mags[i-1][0] = np.concatenate((mags[i-1][0],mag[ha < 0]))
            mags[i-1][1] = np.concatenate((mags[i-1][1],mag[ha >= 0]))
 
    hdul.close()
    
# Fit and plot results