Beispiel #1
0
def countmap(band,skypos,tranges,skyrange,width=False,height=False,
			 verbose=0,tscale=1000.,memlight=False,hdu=False,retries=20):
	"""Create a count (cnt) map."""
	imsz = gxt.deg2pix(skypos,skyrange)
	count = np.zeros(imsz)
	for trange in tranges:
		# If memlight is requested, break the integration into
		#  smaller chunks.
		step = memlight if memlight else trange[1]-trange[0]
		for i in np.arange(trange[0],trange[1],step):
			t0,t1=i,i+step
			if verbose:
				print_inline('Coadding '+str(t0)+' to '+str(t1))
			events = gQuery.getArray(gQuery.rect(band,skypos[0],skypos[1],t0,t1,
												 skyrange[0],skyrange[1]),
									 verbose=verbose,retries=retries)

			# Check that there is actually data here.
			if not events:
				if verbose>1:
					print "No data in "+str([t0,t1])
				continue

			times = np.array(events,dtype='float64')[:,0 ]/tscale
			coo   =	np.array(events,dtype='float64')[:,1:]

			# If there's no data, return a blank image.
			if len(coo)==0:
				if verbose:
					print 'No data in this frame: '+str([t0,t1])
				continue

			# Define World Coordinate System (WCS)
			wcs = define_wcs(skypos,skyrange,width=False,height=False)

			# Map the sky coordinates onto the focal plane
			foc = wcs.sip_pix2foc(wcs.wcs_world2pix(coo,1),1)

			# Bin the events into actual image pixels
			H,xedges,yedges=np.histogram2d(foc[:,1]-0.5,foc[:,0]-0.5,
								bins=imsz,range=([ [0,imsz[0]],[0,imsz[1]] ]))
			count += H

	return count
Beispiel #2
0
 def test_rect(self):
     self.assertEqual(gq.rect(self.NUV,self.ra0,self.dec0,self.t0,self.t1,self.radius,self.radius),'http://masttest.stsci.edu/portal/Mashup/MashupQuery.asmx/GalexPhotonListQueryTest?query=select time,ra,dec from fGetObjFromRectNUV(176.917525856,176.92152585600002,0.253696872807,0.257696872807,766525332995,866526576995,0)&format=json&timeout={}')