Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on saving/loading #219

Merged
merged 9 commits into from
Jul 30, 2021
40 changes: 40 additions & 0 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ We can use the ``plot_metrics_summary`` to easily plot the results from the metr

btk.plot_utils.plot_metrics_summary(results,interactive=False)

We can also use the matches from the metrics to plot the isolated galaxy images along with the matching deblended galaxies:

.. jupyter-execute::

btk.plot_utils.plot_with_deblended(
Expand All @@ -430,6 +432,44 @@ We can use the ``plot_metrics_summary`` to easily plot the results from the metr
band_indices=[1, 2, 3]
)

Saving the results
...................

You may wish to save the results of a run of BTK for later use ; or use BTK from the command line (cf documentation) and retrieve the results in a python file later. Here we will show how to save and load the results.

Saving the results can be automatically achieved by providing the save_path argument to the three generators. It can either be a string or use the os.path API. The folder designated by the path must already exist.

.. jupyter-execute::

save_path = "/home/thuiop/Documents/stageAPC/test_output_intro"

draw_generator = btk.draw_blends.CatsimGenerator(
catalog,
sampling_function,
Rubin,
batch_size=100,
stamp_size=stamp_size,
shifts=None,
indexes=None,
cpus=1,
add_noise=True,
save_path=save_path
)
meas_generator = btk.measure.MeasureGenerator(btk.measure.sep_measure,draw_generator,save_path=save_path)
metrics_generator = btk.metrics.MetricsGenerator(meas_generator,
target_meas={"ellipticity":btk.metrics.meas_ksb_ellipticity},
meas_band_num=0,
save_path=save_path)
blend_results,meas_results,results = next(metrics_generator)


To load the results, you can use the `load_all_results` function ; you need to provide it with the name of the surveys and of the measure functions you used when saving the images, as well as the size of the batch.

.. jupyter-execute::

blend_results,meas_results,results = btk.utils.load_all_results(save_path,["Rubin"],["sep_measure"],n_batch=100)



Using COSMOS galaxies
----------------------
Expand Down
Loading