コード例 #1
0
plt.imshow(QSO_img, origin='low', norm=LogNorm())
for i in range(len(obj)):
    obj_x, obj_y = len(QSO_img) / 2 + obj[i][0][0], len(
        QSO_img) / 2 + obj[i][0][1]
    plt.text(obj_x, obj_y, "obj{0}".format(i), fontsize=15, color='k')
plt.show()

#%%

for k in run_list:  #len(band_seq)):
    print("Fiting the: " + filename_list[k])
    psf, QSO_img, QSO_std = psf_l[k], QSO_img_l[k], QSO_std_l[k]
    #==============================================================================
    #Compare the PSF and QSO profiles
    #==============================================================================
    profiles_compare([psf, QSO_img], [1, 1], ['PSF', 'QSO'], if_annuli=True)
    if pltshow == 0:
        plt.close()
    else:
        plt.show()
    #==============================================================================
    # input the objects components and parameteres
    #==============================================================================
    fixed_source = []
    kwargs_source_init = []
    kwargs_source_sigma = []
    kwargs_lower_source = []
    kwargs_upper_source = []

    ps_x = ((arr_x - fit_frame_size / 2) * pix_scale) * -1
    ps_y = (arr_y - fit_frame_size / 2) * pix_scale
コード例 #2
0
ファイル: 0_cutout.py プロジェクト: dartoon/my_code
        PSF_mask = np.sum(np.asarray(PSF_mask),axis=0)
    elif len(PSF_mask) == 1:
        PSF_mask = PSF_mask[0]
    PSF_mask = (1 - (PSF_mask != 0)*1.)
    PSFs_.append([PSF,PSF_center,PSF_mask])
    count += 1
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