Exemplo n.º 1
0
                                 pos_type='wcs',
                                 header=header,
                                 rm_bkglight=True,
                                 if_plot=False,
                                 zp=zp)

    data_process_0.noise_map = err_data

    data_process_0.generate_target_materials(radius=None,
                                             detect_tool='sep',
                                             create_mask=False,
                                             nsigma=2.8,
                                             exp_sz=1.2,
                                             npixels=15,
                                             if_plot=True)
    data_process_0.PSF_list = [PSF]
    data_process_0.checkout()  #Check if all the materials is known.

    fit_sepc_0 = FittingSpecify(data_process_0)
    fit_sepc_0.prepare_fitting_seq(
        point_source_num=1)  #, fix_n_list= [[0,4]], fix_center_list = [[0,0]])
    fit_sepc_0.plot_fitting_sets()
    fit_sepc_0.build_fitting_seq()
    # Setting the fitting method and run.
    fit_run_0 = FittingProcess(fit_sepc_0,
                               savename=save_name + ID + '_single_Sersic')
    fit_run_0.run(algorithm_list=['PSO', 'PSO'],
                  setting_list=[{
                      'sigma_scale': 1.,
                      'n_particles': 50,
                      'n_iterations': 50
Exemplo n.º 2
0
            #Load the fov image data:
            fov_image = fitsFile[1].data # check the back grounp
            #Derive the header informaion, might be used to obtain the pixel scale and the exposure time.
            header = fitsFile[1].header # if target position is add in WCS, the header should have the wcs information, i.e. header['EXPTIME']
            #Derive the fov noise level map:
            err_data= fitsFile[3].data ** 0.5
            #Load the PSF data:
            PSF_files = glob.glob('psf*{0}*.fits'.format(HSCband))
            PSF = pyfits.getdata(PSF_files[0])
            
            data_process = DataProcess(fov_image = fov_image, fov_noise_map = err_data, target_pos = [QSO_RA, QSO_DEC],
                                        pos_type = 'wcs', header = header,
                                      rm_bkglight = True, if_plot=False, zp = zp)
            
            #Generate the fitting materials
            data_process.generate_target_materials(radius=120, create_mask = False, nsigma=2.8,
                                                  exp_sz= 1.5, npixels = 40, if_plot=False)
            
            # data_process.apertures = [] #Assuming there is no host (i.e., as constant.) #!!!
    
            #Manually input the PSF:
            data_process.PSF_list = [PSF]
            print('{0}-band{1}'.format(folder,band))
            
            file_header = copy.deepcopy(fitsFile[1].header)
            file_header['CRPIX1'] = file_header['CRPIX1']-data_process.target_pos[0]+len(data_process.target_stamp)/2
            file_header['CRPIX2'] = file_header['CRPIX2']-data_process.target_pos[1]+len(data_process.target_stamp)/2
            
            pyfits.PrimaryHDU(data_process.target_stamp,header=file_header).writeto('{0}-band{1}.fits'.format(folder,band) ,overwrite=True)
            pyfits.PrimaryHDU(data_process.noise_map,header=file_header).writeto('{0}-band{1}_noise.fits'.format(folder,band) ,overwrite=True)
Exemplo n.º 3
0
plt.imshow(image_noisy, origin='lower')
plt.show()

#%%
from galight.data_process import DataProcess
from galight.fitting_specify import FittingSpecify
from galight.fitting_process import FittingProcess
data_process = DataProcess(fov_image=image_noisy,
                           target_pos=[25, 25],
                           pos_type='pixel',
                           exptime=100,
                           rm_bkglight=False,
                           if_plot=False,
                           zp=25)

data_process.PSF_list = [psf_class.kernel_pixel]

data_process.generate_target_materials(radius=25,
                                       create_mask=False,
                                       nsigma=2.8,
                                       exp_sz=1,
                                       npixels=10,
                                       if_plot=True,
                                       bkg_std=background_rms)
data_process.deltaPix = 1
data_process.checkout()  #Check if all the materials is known.
fit_sepc = FittingSpecify(data_process)
fit_sepc.prepare_fitting_seq(
    point_source_num=0, sersic_major_axis=False
)  #, fix_n_list= [[0,4]], fix_center_list = [[0,0]])
fit_sepc.plot_fitting_sets()
Exemplo n.º 4
0
                           pos_type='pixel',
                           header=header,
                           rm_bkglight=True,
                           exptime=np.ones_like(data_sb) * exptime,
                           if_plot=False,
                           zp=zp)  #Gain value assuming as 1
data_process.generate_target_materials(radius=65,
                                       create_mask=False,
                                       nsigma=2.8,
                                       if_select_obj=False,
                                       exp_sz=1.2,
                                       npixels=15,
                                       if_plot=True)
# data_process.find_PSF(radius = 50, user_option = True, psf_edge=10)
data_process.plot_overview(label='Example', target_label=None)
data_process.PSF_list = [psf_list[0]]

#Start to produce the class and params for lens fitting.
from galight.fitting_specify import FittingSpecify

# data_process.apertures = []
fit_sepc = FittingSpecify(data_process)
fit_sepc.prepare_fitting_seq(point_source_num=1)  #, fix_n_list= [[0,4],[1,1]])
fit_sepc.build_fitting_seq()

#Plot the initial settings for fittings.
fit_sepc.plot_fitting_sets()

#Setting the fitting method and run.
from galight.fitting_process import FittingProcess
fit_run = FittingProcess(fit_sepc, savename='savename', fitting_level='norm')
Exemplo n.º 5
0
                                        if_select_obj=False,
                                        exp_sz=1.2,
                                        npixels=15,
                                        if_plot=False)
 data_process.plot_overview(label=filt + '_' + str(fov_cut_idx) + '_FOV',
                            target_label=name[:7],
                            ifsave=True,
                            filename=filename + '_FOV',
                            if_plot=if_plot)
 # data_process.find_PSF(radius = 50, user_option = True, psf_edge=10)
 data_process.apertures = [data_process.apertures[0]]
 info = {}
 for psf, name in [[psf_true, 'same_psf'], [psf_model, 'diff_psf']]:
     # for psf, name in [[psf_model,'diff_psf']]:
     plot_fit_name = filename + name + '_fit'
     data_process.PSF_list = [psf]
     #Start to produce the class and params for lens fitting.
     fit_sepc = FittingSpecify(data_process)
     fit_sepc.prepare_fitting_seq(
         point_source_num=1)  #, fix_n_list= [[0,4],[1,1]])
     fit_sepc.build_fitting_seq()
     #Plot the initial settings for fittings.
     # fit_sepc.plot_fitting_sets()
     #
     fit_run = FittingProcess(fit_sepc,
                              savename=plot_fit_name,
                              fitting_level='norm')
     fit_run.run(algorithm_list=['PSO', 'PSO'])
     if fit_run.reduced_Chisq > 1.3:
         fit_run = FittingProcess(fit_sepc,
                                  savename=plot_fit_name,
Exemplo n.º 6
0
        target_pos=[len(sim_image_noise) / 2,
                    len(sim_image_noise) / 2],
        pos_type='pixel',
        header=None,
        rm_bkglight=False,
        if_plot=False,
        zp=zp)
    data_process_0.deltaPix = deltaPix
    data_process_0.generate_target_materials(radius=None,
                                             create_mask=False,
                                             nsigma=2.8,
                                             exp_sz=1.2,
                                             npixels=15,
                                             if_plot=False)

    data_process_0.PSF_list = [psf_data]
    data_process_0.checkout()  #Check if all the materials is known.
    #%%Start to produce the class and params for lens fitting.
    # #Manually input another component:
    # apertures_0 = copy.deepcopy(data_process_0.apertures)
    # add_aperture1 = copy.deepcopy(apertures_0[0])
    # add_pos = [60, 60]   #The position of the component.
    # if isinstance(add_aperture1.positions[0],float):
    #     add_aperture1.positions = np.array(add_pos)
    # elif isinstance(add_aperture1.positions[0],np.ndarray):
    #     add_aperture1.positions = np.array([add_pos])
    # add_aperture1.a, add_aperture1.b = 2, 2  #define the a, b value of this component, i.e., Reff = sqrt(a^2 +b^2)
    # apertures_0 = apertures_0 + [add_aperture1]  #attach the added aperture into the group.
    # data_process_0.apertures = apertures_0 #Pass apertures to the data
    fit_sepc_0 = FittingSpecify(data_process_0)
    fit_sepc_0.prepare_fitting_seq(
Exemplo n.º 7
0
data_process = DataProcess(fov_image=fov_image_rebin,
                           target_pos=[318.0, 239.6],
                           pos_type='pixel',
                           rm_bkglight=True,
                           exptime=exp_map,
                           if_plot=False,
                           zp=27.0)
data_process.generate_target_materials(radius=len(fov_image_rebin) / 2,
                                       create_mask=False,
                                       nsigma=2.8,
                                       if_select_obj=False,
                                       exp_sz=1.2,
                                       npixels=300,
                                       if_plot=False,
                                       bkg_std=bkg_std)
data_process.PSF_list = [PSF_rebin]
data_process.deltaPix = 1
data_process.noise_map[np.isnan(data_process.noise_map)] = bkg_std
from galight.tools.measure_tools import mask_obj
import copy

apertures = copy.deepcopy(data_process.apertures)
apertures[0].a, apertures[0].b = apertures[0].a * expzs, apertures[0].b * expzs
apertures[1].a, apertures[1].b = apertures[1].a * expzs, apertures[1].b * expzs
masks = mask_obj(data_process.target_stamp, apertures, sum_mask=True)
masks = 1 - masks
data_process.target_mask = masks
# plt.imshow(masks, origin='lower')
# plt.show()

#%%