Exemple #1
0
def benchmark_parameter_constraints(posbound, fluxbound, groupsize, seed=0):
    def recipe():
        return scopesim_groups(N1d=1,
                               border=300,
                               group_size=groupsize,
                               group_radius=12,
                               jitter=13,
                               magnitude=lambda N: np.random.normal(21, 2, N),
                               custom_subpixel_psf=epsf,
                               seed=seed)

    cfg.bounds = {
        'x_0': (posbound, posbound),
        'y_0': (posbound, posbound),
        'flux_0': (fluxbound, fluxbound)
    }

    img, tab = read_or_generate_image(f'1x{groupsize}_groups_seed{seed}', cfg,
                                      recipe)
    session = Session(cfg, image=img, input_table=tab)
    session.fitter = TRFLSQFitter()
    session.epsf = epsf
    session.determine_psf_parameters()
    n_calls, time = timeit.Timer(lambda: session.do_astrometry()).autorange()
    return {'runtime': time / n_calls}
Exemple #2
0
    return scopesim_groups(N1d=13,
                           border=70,
                           group_size=1,
                           group_radius=1,
                           jitter=15,
                           magnitude=lambda N: [20.5] * N,
                           custom_subpixel_psf=epsf,
                           seed=10)


cfg.fithshape = 199
cfg.bounds = {'x_0': (0.3, 0.3), 'y_0': (0.3, 0.3), 'flux_0': (10000, 10000)}
cfg.niters = 1

img, tab = read_or_generate_image(f'169x1_group', cfg, recipe)
trialsession = Session(cfg, image=img, input_table=tab)
trialsession.fitter = TRFLSQFitter()
trialsession.epsf = epsf
trialsession.determine_psf_parameters()
trialsession.do_astrometry()

# %%
plot_image_with_source_and_measured(img, tab, trialsession.tables.result_table)
pass

# %%
plot_xy_deviation(trialsession.tables.result_table)
pass

# %% [markdown]
# # visualizing the grouper
import matplotlib.pyplot as plt
#download()

epsf = make_anisocado_model()

cfg = config.Config()
cfg.use_catalogue_positions = True
cfg.separation_factor = 20
cfg.photometry_iterations = 1
cfg.perturb_catalogue_guess = 0.01


def recipe():
    return scopesim_groups(N1d=1, border=500, group_size=10, group_radius=10, jitter=12,
                           magnitude=lambda N: [20.5]*N,
                           custom_subpixel_psf=epsf, seed=10)

cfg.fithshape=91
cfg.bounds = {'x_0': (0.2, 0.2), 'y_0': (0.2, 0.2), 'flux_0': (10000, 10000)}

img, tab = read_or_generate_image(f'1x10_group', cfg, recipe)
trialsession = Session(cfg, image=img, input_table=tab)
trialsession.fitter = TRFLSQFitter()
trialsession.epsf = epsf
trialsession.determine_psf_parameters()
trialsession.do_astrometry_mine()

plot_image_with_source_and_measured(img, tab, trialsession.tables.result_table)
plot_xy_deviation(trialsession.tables.result_table)
plt.show()
def do_it():
    session_lpc = Session(lowpass_config, image_name_lpc)
    session_lpc.correct_scopesim_flux_hack()
    #session_lpc.find_stars().select_epsfstars_auto().make_epsf()
    session_lpc.do_it_all()
    return session_lpc
def do_it():
    scc_session = Session(default_config, 'scopesim_cluster')
    scc_session.do_it_all()
    return scc_session
fig = plots.plot_image_with_source_and_measured(
    scc_session.image, filtered_input_table, scc_session.tables.result_table)
plt.xlim(0, 1024)
plt.ylim(0, 1024)
cb = plt.colorbar(shrink=0.7)
cb.set_label('pixel count')
fig.set_size_inches(7, 7)
plt.tight_layout()

save_plot(outdir, 'standard_photutils')

# %% [markdown]
# # Benchmark Images

# %%
sg_session = Session(default_config, 'scopesim_grid_16_perturb2_mag18_24')
gc_session = Session(default_config, 'gausscluster_N2000_mag22')

# %%
#fig = plots_and_sanitycheck.plot_image_with_source_and_measured(
#    photometry_result_sg.image, photometry_result_sg.input_table, photometry_result_sg.result_table)


def show_image(img):
    fig = plt.figure()
    plt.imshow(img[8:-8, 8:-8], norm=LogNorm())
    plt.title('')
    cb = plt.colorbar(shrink=0.8)
    cb.set_label('pixel count')
    fig.set_size_inches(7, 7)
    #plt.plot(sg_session.tables.input_table['x'], sg_session.tables.input_table['y'], '.')
Exemple #7
0
print(result_table_multi_conv['x_offset'].mean(),
      result_table_multi_conv['y_offset'].mean())
print(result_table_multi_subpixel['x_offset'].mean(),
      result_table_multi_subpixel['y_offset'].mean())
figa = plots.plot_xy_deviation(result_table_multi_conv)
figb = plots.plot_xy_deviation(result_table_multi_subpixel)

# %%
lowpass_config.oversampling = 2
lowpass_config.cutout_size = 40
lowpass_config.fitshape = 25

#session_std = Session(lowpass_config, 'scopesim_grid_16_perturb2_mag18_24')
#session_known_psf = Session(lowpass_config, 'scopesim_grid_16_perturb2_mag18_24')

session_std = Session(lowpass_config, 'gausscluster_N2000_mag22_subpixel')
session_known_psf = Session(lowpass_config,
                            'gausscluster_N2000_mag22_subpixel')

session_std.do_it_all()

session_known_psf.epsf = make_anisocado_model()
session_known_psf.do_astrometry()

# %%
figa = plots.plot_xy_deviation(session_std.tables.valid_result_table)
figb = plots.plot_xy_deviation(session_known_psf.tables.valid_result_table)

# %%
fig, axs = plt.subplots(1, 2)
axs[0].imshow(session_known_psf.epsf.data, norm=LogNorm())