Example #1
0
                           exptime=np.ones_like(data) * 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=30, user_option=True)
data_process.plot_overview(label='Example', target_label=None)

#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')
fit_run.run(algorithm_list=['PSO', 'PSO'])
fit_run.plot_final_galaxy_fit()
print(fit_run.final_result_galaxy[0])
print(fit_run.final_result_ps[0])
    fit_sepc_1.build_fitting_seq()
    # fit_sepc_1.kwargs_params['lens_light_model'][0][0] = fit_run_0.final_result_galaxy[0] #Input to bulge

    fit_run_1 = FittingProcess(fit_sepc_1, savename=save_name + 'bulge+disk')

    fit_run_1.run(algorithm_list=['PSO', 'PSO'],
                  setting_list=[{
                      'sigma_scale': 1.,
                      'n_particles': 150,
                      'n_iterations': 150
                  }] * 2)
    bic_1 = fit_run_1.fitting_seq.bic
    fit_run_1.dump_result()
    print(fit_run_1.final_result_galaxy[0]['q'],
          fit_run_1.final_result_galaxy[1]['q'])
    fit_run_1.plot_final_galaxy_fit(target_ID=ID)
    bulge1 = fit_run_1.image_host_list[1]
    disk1 = fit_run_1.image_host_list[0]
    B2T = np.sum(bulge1) / np.sum(bulge1 + disk1)
    AGN1 = fit_run_0.image_ps_list[0]
    disk_Re1 = fit_run_1.final_result_galaxy[0]['R_sersic']
    bulge_Re1 = fit_run_1.final_result_galaxy[1]['R_sersic']
    flux_list_2d = [bulge1, disk1, AGN1]
    label_list_2d = ['Bulge', 'Disk', 'nuclei']
    flux_list_1d = [bulge1, disk1, AGN1]
    label_list_1d = ['Bulge', 'Disk', 'nuclei']
    profile_plots(flux_list_2d,
                  label_list_2d,
                  flux_list_1d,
                  label_list_1d,
                  deltaPix=fit_run_1.fitting_specify_class.deltaPix,