예제 #1
0
def rrhr(band,skypos,tranges,skyrange,width=False,height=False,stepsz=1.,
		 verbose=0,calpath='../cal/',tscale=1000.,response=True,hdu=False,
		 retries=20):
	"""Generate a high resolution relative response (rrhr) map."""
	imsz = gxt.deg2pix(skypos,skyrange)
	# TODO the if width / height

	flat = get_fits_data(flat_filename(band,calpath),verbose=verbose)
	flatinfo = get_fits_header(flat_filename(band,calpath))
	npixx,npixy 	= flat.shape
	fltsz 		= flat.shape
	pixsz = flatinfo['CDELT2']
	detsize = 1.25

	# Rotate the flat into the correct orientation to start.
	flat   = np.flipud(np.rot90(flat))

	# NOTE: This upsample interpolation is done _last_ in the canonical
	#	pipeline as part of the poissonbg.c routine.
	# 	The interpolation function is "congrid" in the same file.
	# TODO: Should this be first order interpolation? (i.e. bilinear)
	hrflat = scipy.ndimage.interpolation.zoom(flat,4.,order=0,prefilter=False)
	img = np.zeros(hrflat.shape)[
				hrflat.shape[0]/2.-imsz[0]/2.:hrflat.shape[0]/2.+imsz[0]/2.,
				hrflat.shape[1]/2.-imsz[1]/2.:hrflat.shape[1]/2+imsz[1]/2.]

	for trange in tranges:
		t0,t1=trange
		entries = gQuery.getArray(gQuery.aspect(t0,t1),retries=retries)
		n = len(entries)

		asptime = np.float64(np.array(entries)[:,2])/tscale
		aspra   = np.float32(np.array(entries)[:,3])
		aspdec  = np.float32(np.array(entries)[:,4])
		asptwist= np.float32(np.array(entries)[:,5])
		aspflags= np.float32(np.array(entries)[:,6])
		asptwist= np.float32(np.array(entries)[:,9])
		aspra0  = np.zeros(n)+skypos[0]
		aspdec0 = np.zeros(n)+skypos[1]

		xi_vec, eta_vec = gnomonic.gnomfwd_simple(
							aspra,aspdec,aspra0,aspdec0,-asptwist,1.0/36000.,0.)

		col = 4.*( ((( xi_vec/36000.)/(detsize/2.)*(detsize/(fltsz[0]*pixsz)) + 1.)/2. * fltsz[0]) - (fltsz[0]/2.) )
		row = 4.*( (((eta_vec/36000.)/(detsize/2.)*(detsize/(fltsz[1]*pixsz)) + 1.)/2. * fltsz[1]) - (fltsz[1]/2.) )

		vectors = rotvec(np.array([col,row]),-asptwist)

		for i in range(n):
			if verbose>1:
				print_inline('Stamping '+str(asptime[i]))
				# FIXME: Clean this mess up a little just for clarity.
	        	img += scipy.ndimage.interpolation.shift(scipy.ndimage.interpolation.rotate(hrflat,-asptwist[i],reshape=False,order=0,prefilter=False),[vectors[1,i],vectors[0,i]],order=0,prefilter=False)[hrflat.shape[0]/2.-imsz[0]/2.:hrflat.shape[0]/2.+imsz[0]/2.,hrflat.shape[1]/2.-imsz[1]/2.:hrflat.shape[1]/2+imsz[1]/2.]*dbt.compute_exptime(band,[asptime[i],asptime[i]+1],verbose=verbose,retries=retries)*gxt.compute_flat_scale(asptime[i]+0.5,band,verbose=0)

	return img
예제 #2
0
def get_aspect(band,skypos,trange=[6e8,11e8],tscale=1000.,verbose=0):
    """Get aspect solution in a dict() for given time range."""
    asp = np.array(gQuery.getArray(gQuery.aspect(trange[0],trange[1]),
                   verbose=verbose))
    return {'eclipse':np.array(asp[:,0],dtype='int16'),'filename':asp[:,1],
            't':np.array(asp[:,2],dtype='float64')/tscale,
            'ra':np.array(asp[:,3],dtype='float64'),
            'dec':np.array(asp[:,4],dtype='float64'),
            'twist':np.array(asp[:,5],dtype='float64'),
            'flag':np.array(asp[:,6],dtype='int8'),
            'ra0':np.array(asp[:,7],dtype='float64'),
            'dec0':np.array(asp[:,8],dtype='float64'),
            'twist0':np.array(asp[:,9],dtype='float64')}
예제 #3
0
 def test_aspect(self):
     self.assertEqual(gq.aspect(self.t0,self.t1),'http://masttest.stsci.edu/portal/Mashup/MashupQuery.asmx/GalexPhotonListQueryTest?query=select eclipse, filename, time, ra, dec, twist, flag, ra0, dec0, twist0 from aspect where time between 766525332995 and 866526576995 order by time&format=json&timeout={}')