Esempio n. 1
0
def makemap(band,skypos,trange,skyrange,response=False,verbose=0,detsize=1.1):
	imsz = gxt.deg2pix(skypos,skyrange)
	photons = np.array(gQuery.getArray(gQuery.skyrect(band,
		skypos[0],skypos[1],trange[0],trange[1],skyrange[0],skyrange[1]),
		verbose=verbose),dtype='float64')
	try:
		events = {'t':photons[:,0 ]/tscale,'ra':photons[:,1],'dec':photons[:,2],
			'xi':photons[:,3],'eta':photons[:,4],
			'x':photons[:,5], 'y':photons[:,6]}
	except IndexError:
		if verbose>2:
			print 'No events found at {s} +/- {r} in {t}.'.format(
				s=skypos,r=skyrange,t=trange)
		return np.zeros(imsz)
	# Trim the data on detsize
	col, row = ct.xieta2colrow(events['xi'],events['eta'],band)
	ix = np.where((1.25/800.)*mc.distance(col,row,400,400)<=detsize)
	n = len(ix[0])
	m = len(col)
	#print 'With detsize {d} using {n} of {m} data.'.format(d=detsize,n=n,m=m)
	if n == 0:
		return np.zeros(imsz)
	for k in events.keys():
		events[k] = events[k][ix]
	events = ct.hashresponse(band,events)
	wcs = define_wcs(skypos,skyrange,width=False,height=False)
	coo = zip(events['ra'],events['dec'])
	foc = wcs.sip_pix2foc(wcs.wcs_world2pix(coo,1),1)
	weights = 1./events['response'] if response else None
	H,xedges,yedges=np.histogram2d(foc[:,1]-0.5,foc[:,0]-0.5,bins=imsz,
		range=([ [0,imsz[0]],[0,imsz[1]] ]),weights=weights)
	return H
Esempio n. 2
0
def makemap(band,skypos,trange,skyrange,response=False,verbose=0):
    imsz = gxt.deg2pix(skypos,skyrange)
    photons = np.array(gQuery.getArray(gQuery.skyrect(band,
		skypos[0],skypos[1],trange[0],trange[1],skyrange[0],skyrange[1]),
		verbose=verbose),dtype='float64')
    events = {'t':photons[:,0 ]/tscale, 'ra':photons[:,1], 'dec':photons[:,2],
              'xi':photons[:,3],'eta':photons[:,4],
			  'x':photons[:,5], 'y':photons[:,6]}
    if len(events['t'])==0:
        return np.zeros(imsz)
    events = ct.hashresponse(band,events)
    wcs = define_wcs(skypos,skyrange,width=False,height=False)
    coo = zip(events['ra'],events['dec'])
    foc = wcs.sip_pix2foc(wcs.wcs_world2pix(coo,1),1)
    weights = 1./events['response'] if response else None
    H,xedges,yedges=np.histogram2d(foc[:,1]-0.5,foc[:,0]-0.5,bins=imsz,
		range=([ [0,imsz[0]],[0,imsz[1]] ]),weights=weights)
    return H