Esempio n. 1
0
    import rebin  #From my share_tools
    factor = 4
    pattern_x = [0, 2, 0, 2, 1, 3, 1, 3]
    pattern_y = [0, 0, 2, 2, 3, 3, 1, 1]  #from the info. given by observation
    ################Bin the PSF and save it################
    #exp_psf=rebin.expend_grid(psf_pixel_high_res)
    cut_fd = int(
        (len(psf_data) - ((int(len(psf_data) / 8 * 2) - 1) * 4 + 3)) / 2)
    exp_psf_o = psf_data[1 + cut_fd:-cut_fd, 1 +
                         cut_fd:-cut_fd] + 0  # To change it from 251 to 247.
    exp_psf = rebin.expend_grid(exp_psf_o)
    cut_len = int(round(len(exp_psf_o) / factor) * factor)
    cut_out_psf = np.zeros([len(pattern_x), cut_len, cut_len])
    image_bin_psf = np.zeros(
        [len(pattern_x),
         int(cut_len / factor),
         int(cut_len / factor)])
    for i in range(len(pattern_x)):
        cut_out_psf[i] = exp_psf[pattern_x[i]:cut_len + pattern_x[i],
                                 pattern_y[i]:cut_len +
                                 pattern_y[i]]  #the size before bin
        image_bin_psf[i] = rebin.block(
            cut_out_psf[i], (int(cut_len / factor), int(cut_len / factor)),
            factor=factor)
        image_bin_psf[i] /= np.sum(image_bin_psf[i])  #unify the psf value
        pyfits.PrimaryHDU(image_bin_psf[i]).writeto(
            rebin_folder_name +
            '/non_drizzled_psf_id{0}-{1}.fits'.format(psf_id, i + 1),
            overwrite=False)
#
Esempio n. 2
0
 
 ##==============================================================================
 ## #Bin the image res. from high to low. 
 ##==============================================================================
 sys.path.insert(0, '../share_tools')
 import rebin
 factor=4
 pattern_x=[0,2,0,2,1,3,1,3]
 pattern_y=[0,0,2,2,3,3,1,1]      #from the info. given by observation
 ################Bin the lensed image################
 exp_grid=rebin.expend_grid(image_highres)
 cut_out=np.zeros([len(pattern_x),image_highres.shape[0]-5,image_highres.shape[1]-5])
 image_bin =np.zeros([len(pattern_x),int(image_highres.shape[0]/factor)-1,int(image_highres.shape[1]/factor)-1])
 for i in range(len(pattern_x)):
     cut_out[i]=exp_grid[pattern_x[i]:(numPix-5)+pattern_x[i],pattern_y[i]:(numPix-5)+pattern_y[i]]   #the size before bin
     image_bin[i]=rebin.block(cut_out[i],(int(numPix/factor)-1,int(numPix/factor)-1),factor=factor)
 plt.imshow(image_bin[0], origin='lower',cmap='gist_heat', norm=LogNorm())
 plt.colorbar()
 plt.show()
 ################Bin the PSF and save it################
 #exp_psf=rebin.expend_grid(psf_pixel_high_res)
 cut_fd=int((len(psf_data)-((int(len(psf_data)/8*2)-1)*4+3))/2)
 exp_psf_o=psf_data[1+cut_fd:-cut_fd,1+cut_fd:-cut_fd]+ 0  # To change it from 251 to 247.
 exp_psf=rebin.expend_grid(exp_psf_o)
 cut_len=int(round(len(exp_psf_o)/factor)*factor)
 cut_out_psf=np.zeros([len(pattern_x),cut_len,cut_len])
 image_bin_psf=np.zeros([len(pattern_x),int(cut_len/factor),int(cut_len/factor)])
 for i in range(len(pattern_x)):
     cut_out_psf[i]=exp_psf[pattern_x[i]:cut_len+pattern_x[i],pattern_y[i]:cut_len+pattern_y[i]]   #the size before bin
     image_bin_psf[i]=rebin.block(cut_out_psf[i],(int(cut_len/factor),int(cut_len/factor)),factor=factor)
     image_bin_psf[i] /= np.sum(image_bin_psf[i])  #unify the psf value
Esempio n. 3
0
                len(pattern_x), point_highres.shape[0] - 5,
                point_highres.shape[1] - 5
            ])
            point_image_bin = np.zeros([
                len(pattern_x),
                int(point_highres.shape[0] / factor) - 1,
                int(point_highres.shape[1] / factor) - 1
            ])

            for i in range(len(pattern_x)):
                total_cut_out[i] = total_exp_grid[
                    pattern_x[i]:(numPix - 5) + pattern_x[i],
                    pattern_y[i]:(numPix - 5) +
                    pattern_y[i]]  #the size before bin
                total_image_bin[i] = rebin.block(
                    total_cut_out[i],
                    (int(numPix / factor) - 1, int(numPix / factor) - 1),
                    factor=factor)
                pyfits.PrimaryHDU(total_image_bin[i]).writeto(
                    sim_folder_name +
                    '/non_drizzled-AGNclean-{0}.fits'.format(i + 1),
                    overwrite=False)

                host_cut_out[i] = host_exp_grid[
                    pattern_x[i]:(numPix - 5) + pattern_x[i],
                    pattern_y[i]:(numPix - 5) +
                    pattern_y[i]]  #the size before bin
                host_image_bin[i] = rebin.block(
                    host_cut_out[i],
                    (int(numPix / factor) - 1, int(numPix / factor) - 1),
                    factor=factor)
                pyfits.PrimaryHDU(host_image_bin[i]).writeto(