コード例 #1
0
     1] + len(QSO_img) / 2
 fit_result.write("#QSO_img intensity in the band {1}: {0} \n".format(
     round(np.sum(QSO_img), 2), band_seq[k]))
 fit_result.write("#fit result of the QSO by in band {0}: \n".format(
     band_seq[k]))
 objs_img = np.zeros_like(image_host[0])
 if len(source_result) > 1:
     for i in range(1, len(image_host)):
         objs_img += image_host[i]
 data_host = QSO_img - image_ps - objs_img
 data_host_list.append(data_host)
 center = np.asarray(data_host.shape) / 2
 r_flux, r_grids, regions = flux_profile(data_host,
                                         center,
                                         radius=center.min(),
                                         grids=50,
                                         ifplot=False,
                                         fits_plot=fits_plot,
                                         mask_list=None)
 plt.plot(r_grids * pix_scale, r_flux)
 plt.title('Kron curve')
 plt.xlabel('Radius (arcsec)')
 plt.ylabel('Kron flux')
 plt.savefig(folder + '/fit_image_{0}_host_Kron_curve_objID.pdf'.format(
     filename_list[k].split('.fits')[0]))
 if pltshow == 0:
     plt.close()
 else:
     plt.show()
 Kron_radius = 4.
 print("Kron_radius take {0} arcsec".format(Kron_radius))
コード例 #2
0
ファイル: 0_cutout.py プロジェクト: dartoon/my_code
center_match = (np.sum(abs(np.asarray(PSF_gauss_centers)-np.asarray(PSF_bright_centers)<0.7),axis = 1) == 2)
psf_pos_list = [PSF_gauss_centers[i] for i in range(len(PSFs_)) if center_match[i]==True]
PSFs = [PSFs_[i] for i in range(len(PSFs_)) if center_match[i]==True]

save_loc_png(img_sub,center_QSO,psf_pos_list, ID=ID, label='PSF' ,reg_ty = None)

# Compare the Kron slope of the PSFs:
PSF_list = [PSFs[i][0] for i in range(len(PSFs))]
_ = profiles_compare(PSF_list, scal_list=np.ones(len(PSFs)),
                       prf_name_list=['PSF'+str(i) for i in range(len(PSFs))],
                       gridspace = 'log', if_annuli=True)
# =============================================================================
# Test the bkg level for lensed QSO and PSF
# =============================================================================
for i in range(len(PSF_list)):
    _, _, _ = flux_profile(PSF_list[i], [len(PSF_list[i])/2]*2,
                            radius=len(PSF_list[i])/2, grids=50, ifplot=True, fits_plot= True)

#==============================================================================
# Save the lens fitting ingredients including:
#==============================================================================
import copy
file_header = copy.deepcopy(fitsFile[0].header)
file_header['CRPIX1'] = file_header['CRPIX1']-center_QSO[0]+fr
file_header['CRPIX2'] = file_header['CRPIX2']-center_QSO[1]+fr  
pyfits.PrimaryHDU(agn_image, header=file_header).writeto('{0}_cutout.fits'.format(ID),overwrite=True) 
pyfits.PrimaryHDU(agn_rms).writeto('{0}_stdd.fits'.format(ID),overwrite=True) 
#pyfits.PrimaryHDU(agn_exp_map).writeto('{0}_exp_map.fits'.format(ID),overwrite=True) 
for i in range(len(PSFs)):
    pyfits.PrimaryHDU(PSF_list[i]).writeto('PSF{0}.fits'.format(i),overwrite=True)