def setHdus(self, p): self.hdus = p self.table = fits_table(self.hdus[1].data)[0] T = self.table self.aa = T.aa.astype(float) self.kk = T.kk.astype(float) self.airmass = T.airmass
def getPsfAtPoints(self, bandnum, x, y): ''' Reconstruct the SDSS model PSF from KL basis functions. x,y can be scalars or 1-d numpy arrays. Return value: if x,y are scalars: a PSF image if x,y are arrays: a list of PSF images ''' rtnscalar = np.isscalar(x) and np.isscalar(y) x = np.atleast_1d(x) y = np.atleast_1d(y) psf = fits_table(self.hdus[bandnum + 1].data) psfimgs = None (outh, outw) = (None, None) # From the IDL docs: # http://photo.astro.princeton.edu/photoop_doc.html#SDSS_PSF_RECON # acoeff_k = SUM_i{ SUM_j{ (0.001*ROWC)^i * (0.001*COLC)^j * C_k_ij } } # psfimage = SUM_k{ acoeff_k * RROWS_k } for k in range(len(psf)): nrb = psf.nrow_b[k] ncb = psf.ncol_b[k] c = psf.c[k].reshape(5, 5) c = c[:nrb, :ncb] (gridi, gridj) = np.meshgrid(range(nrb), range(ncb)) if psfimgs is None: psfimgs = [ np.zeros_like(psf.rrows[k]) for xy in np.broadcast(x, y) ] (outh, outw) = (psf.rnrow[k], psf.rncol[k]) else: assert (psf.rnrow[k] == outh) assert (psf.rncol[k] == outw) for i, (xi, yi) in enumerate(np.broadcast(x, y)): #print 'xi,yi', xi,yi acoeff_k = np.sum( ((0.001 * xi)**gridi * (0.001 * yi)**gridj * c)) if False: # DEBUG print 'coeffs:', (0.001 * xi)**gridi * (0.001 * yi)**gridj print 'c:', c for (coi, ci) in zip( ((0.001 * xi)**gridi * (0.001 * yi)**gridj).ravel(), c.ravel()): print 'co %g, c %g' % (coi, ci) print 'acoeff_k', acoeff_k #print 'acoeff_k', acoeff_k.shape, acoeff_k #print 'rrows[k]', psf.rrows[k].shape, psf.rrows[k] psfimgs[i] += acoeff_k * psf.rrows[k] psfimgs = [img.reshape((outh, outw)) for img in psfimgs] if rtnscalar: return psfimgs[0] return psfimgs
def getPsfAtPoints(self, bandnum, x, y): ''' Reconstruct the SDSS model PSF from KL basis functions. x,y can be scalars or 1-d numpy arrays. Return value: if x,y are scalars: a PSF image if x,y are arrays: a list of PSF images ''' rtnscalar = np.isscalar(x) and np.isscalar(y) x = np.atleast_1d(x) y = np.atleast_1d(y) psf = fits_table(self.hdus[bandnum+1].data) psfimgs = None (outh, outw) = (None,None) # From the IDL docs: # http://photo.astro.princeton.edu/photoop_doc.html#SDSS_PSF_RECON # acoeff_k = SUM_i{ SUM_j{ (0.001*ROWC)^i * (0.001*COLC)^j * C_k_ij } } # psfimage = SUM_k{ acoeff_k * RROWS_k } for k in range(len(psf)): nrb = psf.nrow_b[k] ncb = psf.ncol_b[k] c = psf.c[k].reshape(5, 5) c = c[:nrb,:ncb] (gridi,gridj) = np.meshgrid(range(nrb), range(ncb)) if psfimgs is None: psfimgs = [np.zeros_like(psf.rrows[k]) for xy in np.broadcast(x,y)] (outh,outw) = (psf.rnrow[k], psf.rncol[k]) else: assert(psf.rnrow[k] == outh) assert(psf.rncol[k] == outw) for i,(xi,yi) in enumerate(np.broadcast(x,y)): #print 'xi,yi', xi,yi acoeff_k = np.sum(((0.001 * xi)**gridi * (0.001 * yi)**gridj * c)) if False: # DEBUG print 'coeffs:', (0.001 * xi)**gridi * (0.001 * yi)**gridj print 'c:', c for (coi,ci) in zip(((0.001 * xi)**gridi * (0.001 * yi)**gridj).ravel(), c.ravel()): print 'co %g, c %g' % (coi,ci) print 'acoeff_k', acoeff_k #print 'acoeff_k', acoeff_k.shape, acoeff_k #print 'rrows[k]', psf.rrows[k].shape, psf.rrows[k] psfimgs[i] += acoeff_k * psf.rrows[k] psfimgs = [img.reshape((outh,outw)) for img in psfimgs] if rtnscalar: return psfimgs[0] return psfimgs
def getMaskPlane(self, name): # HACK -- this must be described somewhere sensible... # (yeah, fpM extension 11 !) maskmap = { 'INTER': 0, 'SATUR': 1, 'CR' : 8, 'GHOST': 9, } if not name in maskmap: raise RuntimeError('Unknown mask plane \"%s\"' % name) return fits_table(self.hdus[1 + maskmap[name]].data)
def getMaskPlane(self, name): # HACK -- this must be described somewhere sensible... # (yeah, fpM extension 11 !) maskmap = { 'INTER': 0, 'SATUR': 1, 'CR': 8, 'GHOST': 9, } if not name in maskmap: raise RuntimeError('Unknown mask plane \"%s\"' % name) return fits_table(self.hdus[1 + maskmap[name]].data)
def setHdus(self, p): self.hdus = p t = fits_table(p[6].data) # the table has only one row... assert(len(t) == 1) t = t[0] #self.table = t self.gain = t.gain self.dark_variance = t.dark_variance self.sky = t.sky self.skyerr = t.skyerr self.psp_status = t.status # Double-Gaussian PSF params self.dgpsf_s1 = t.psf_sigma1_2g self.dgpsf_s2 = t.psf_sigma2_2g self.dgpsf_b = t.psf_b_2g # summary PSF width (sigmas) self.psf_fwhm = t.psf_width * (2.*np.sqrt(2.*np.log(2.)))
def setHdus(self, p): self.hdus = p t = fits_table(p[6].data) # the table has only one row... assert (len(t) == 1) t = t[0] #self.table = t self.gain = t.gain self.dark_variance = t.dark_variance self.sky = t.sky self.skyerr = t.skyerr self.psp_status = t.status # Double-Gaussian PSF params self.dgpsf_s1 = t.psf_sigma1_2g self.dgpsf_s2 = t.psf_sigma2_2g self.dgpsf_b = t.psf_b_2g # summary PSF width (sigmas) self.psf_fwhm = t.psf_width * (2. * np.sqrt(2. * np.log(2.)))