Exemplo n.º 1
0
def pullphotons(band, ra0, dec0, tranges, radius, events={}, verbose=0,
                tscale=1000., calpath='../cal/', chunksz=10e6):
    """Retrieve photons within an aperture from the database."""
    events = {'t':[],'ra':[],'dec':[],'xi':[],'eta':[]}
    if verbose:
        print "Retrieving photons at ["+str(ra0)+", "+str(dec0)+"] within a radius of "+str(radius)
    for trange in tranges:
        if verbose:
            mc.print_inline(" and between "+str(trange[0])+" and "+
                            str(trange[1])+".")
        stream = gQuery.getArray(
            gQuery.allphotons(band, ra0, dec0, trange[0], trange[1], radius),
                              verbose=verbose,retries=100)
        if not stream:
            continue
        events['t'] = events['t']+np.array(np.array(stream,
                                        dtype='float64')[:,0]/tscale).tolist()
        # The float64 precision _is_ significant for RA / Dec.
        events['ra'] = events['ra']+np.array(np.array(stream,
                                        dtype='float64')[:,1]).tolist()
        events['dec'] = events['dec']+np.array(np.array(stream,
                                        dtype='float64')[:,2]).tolist()
        events['xi'] = events['xi']+np.array(np.array(stream,
                                        dtype='float32')[:,3]).tolist()
        events['eta'] = events['eta']+np.array(np.array(stream,
                                        dtype='float32')[:,4]).tolist()
    events['t'] = np.array(events['t'],dtype='float64')
    events['ra'] = np.array(events['ra'],dtype='float64')
    events['dec'] = np.array(events['dec'],dtype='float64')
    events['xi'] = np.array(events['xi'],dtype='float32')
    events['eta'] = np.array(events['eta'],dtype='float32')
    events = hashresponse(band, events, calpath=calpath, verbose=verbose)
    return events
Exemplo n.º 2
0
def query_photons(band,ra0,dec0,tranges,radius,verbose=0):
    """Retrieve photons within an aperture from the database."""
    stream = []
    if verbose:
        print "Retrieving photons within {rad} degrees of [{r}, {d}]".format(
                                                        rad=radius,r=ra0,d=dec0)
    for trange in tranges:
        if verbose:
            mc.print_inline(" and between "+str(trange[0])+" and "+
                            str(trange[1])+".")
        thisstream = gQuery.getArray(
            gQuery.allphotons(band, ra0, dec0, trange[0], trange[1], radius),
                              verbose=verbose,retries=100)
        stream.extend(thisstream)
    stream = np.array(stream, 'f8').T
    colnames = ['t', 'ra', 'dec', 'xi', 'eta', 'x', 'y']
    dtypes = ['f8', 'f8', 'f8', 'f4', 'f4', 'f4', 'f4']
    cols = map(np.asarray, stream, dtypes)
    events = dict(zip(colnames, cols))
    events['t']/=tscale # Adjust the timestamp by tscale
    return events
Exemplo n.º 3
0
 def test_allphotons(self):
     self.assertEqual(gq.allphotons(self.NUV,self.ra0,self.dec0,self.t0,self.t1,self.radius),'http://masttest.stsci.edu/portal/Mashup/MashupQuery.asmx/GalexPhotonListQueryTest?query=select time,ra,dec,xi,eta from dbo.fGetNearbyObjEqNUVAllColumns(176.919525856,0.255696872807,0.004,766525332995,866526576995,0)&format=json&timeout={}')