Example #1
0
def read_from_tractor_cat(fn, same_keys=['ra', 'dec', 'type']):
    '''returns data dict for DECaLS()
	same_keys -- keys that have identical names b/w tractor cat and data dict expected by DeCALS()'''
    from fits import tractor_cat
    a = tractor_cat(fn)
    data = {}
    for k in same_keys:
        data[k] = a[k]
    data['type'] = np.char.strip(data['type'])
    for band, ind in zip(['g', 'r', 'z'], [1, 2, 4]):
        data[band + 'flux'] = a['decam_flux'][:, ind]
        data[band + 'flux_ivar'] = a['decam_flux_ivar'][:, ind]
        data[band + '_ext'] = a['decam_mw_transmission'][:, ind]
        data[band + '_psf_fwhm'] = a['decam_psfsize'][:, ind]
    for band, ind in zip(['w1'], [0]):
        data[band + 'flux'] = a['wise_flux'][:, ind]
        data[band + 'flux_ivar'] = a['wise_flux_ivar'][:, ind]
        data[band + '_ext'] = a['wise_mw_transmission'][:, ind]
    return data
Example #2
0
class Grid(object):
    def __init__(self,ramin,ramax,decmin,decmax,pixscale):
        self.npix_ra= int(deg_to_arcsec(ramax-ramin)/pixscale + 1)
        self.npix_dec= int(deg_to_arcsec(decmax-decmin)/pixscale + 1)
        self.ra_centers= np.linspace(ramin,ramax,num=self.npix_ra)
        self.dec_centers= np.linspace(decmin,decmax,num=self.npix_dec)
    def nearest_cell_index(self,ra,dec):
        '''return x,y index for img of nearest ra,dec pixel center to ra,dec'''
        return np.argsort(np.abs(self.ra_centers-ra))[0], np.argsort(np.abs(self.dec_centers-dec))[0]

parser = ArgumentParser(description="test")
parser.add_argument("-cat",action="store",help='tractor catalogue')
parser.add_argument("-pixscale",type=float,action="store",help='tractor catalogue')
args = parser.parse_args()

cat=tractor_cat(args.cat)
grid= Grid(cat['ra'].min(),cat['ra'].max(),cat['dec'].min(),cat['dec'].max(),args.pixscale)

# size of image
W,H = grid.npix_ra,grid.npix_dec

# PSF size
psfsigma = 1.

# per-pixel noise
noisesigma = 1.e-2

# create tractor.Image object for rendering synthetic galaxy
# images
tim = Image(data=np.zeros((H,W)), invvar=np.ones((H,W)) / (noisesigma**2),
            psf=NCircularGaussianPSF([psfsigma], [1.]))
Example #3
0
    def nearest_cell_index(self, ra, dec):
        '''return x,y index for img of nearest ra,dec pixel center to ra,dec'''
        return np.argsort(np.abs(self.ra_centers - ra))[0], np.argsort(
            np.abs(self.dec_centers - dec))[0]


parser = ArgumentParser(description="test")
parser.add_argument("-cat", action="store", help='tractor catalogue')
parser.add_argument("-pixscale",
                    type=float,
                    action="store",
                    help='tractor catalogue')
args = parser.parse_args()

cat = tractor_cat(args.cat)
grid = Grid(cat['ra'].min(), cat['ra'].max(), cat['dec'].min(),
            cat['dec'].max(), args.pixscale)

# size of image
W, H = grid.npix_ra, grid.npix_dec

# PSF size
psfsigma = 1.

# per-pixel noise
noisesigma = 1.e-2

# create tractor.Image object for rendering synthetic galaxy
# images
tim = Image(data=np.zeros((H, W)),