From 580b0eec0677fc650ceb702bb6c64007da3e849c Mon Sep 17 00:00:00 2001 From: Thomas Sainrat Date: Tue, 30 Mar 2021 12:39:06 +0100 Subject: [PATCH] Added tutorial to documentation --- docs/source/tutorials.rst | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/source/tutorials.rst b/docs/source/tutorials.rst index 75c723275..5724aacd8 100644 --- a/docs/source/tutorials.rst +++ b/docs/source/tutorials.rst @@ -341,3 +341,42 @@ Then we can instantiate the `DrawBlendsGenerator` with the survey of your choice blend_images = batch['blend_images'] blend_list = batch['blend_list'] btk.plot_utils.plot_blends(blend_images, blend_list, limits=(30,90)) + +Using COSMOS galaxies +---------------------- + +We will now focus on generating image using galaxies from the COSMOS catalog. You will find that generating images with COSMOS is very similar to generating images with Catsim. Let's start with the catalog and sampling function. Here we use a small sample of the real COSMOS catalog ; feel free to fill in the correct path if you have the complete catalog on your computer. + +.. jupyter-execute:: + + COSMOS_CATALOG_PATHS = [ + "../data/cosmos/real_galaxy_catalog_23.5_example.fits", + "../data/cosmos/real_galaxy_catalog_23.5_example_fits.fits", + ] + stamp_size = 24.0 + batch_size = 8 + catalog = btk.catalog.CosmosCatalog.from_file(COSMOS_CATALOG_PATHS) + sampling_function = btk.sampling_functions.DefaultSampling(stamp_size=stamp_size) + +We can now create the corresponding instance of DrawBlendsGenerator. There is an important caveat here : as in the other tutorial, we use the Rubin survey. However, the COSMOS catalog only contains images from the f814w band ; when using other bands, the image is only rescaled to get the right flux. Moreover, at the time the flux will not be accurate as we do not have the SED for COSMOS galaxies, meaning that we cannot recover the correct magnitude in other bands than f814w ; the flux is thus computed using the magnitude in that band and the survey parameters provided. We are currently working on getting a more realistic flux. + +.. jupyter-execute:: + + draw_generator = btk.draw_blends.CosmosGenerator( + catalog, + sampling_function, + [btk.survey.Rubin], + batch_size=batch_size, + stamp_size=stamp_size, + cpus=1, + add_noise=True, + verbose=False, + meas_bands=["i"], + ) + +.. jupyter-execute:: + + batch = next(draw_generator) + blend_images = batch['blend_images'] + blend_list = batch['blend_list'] + btk.plot_utils.plot_blends(blend_images, blend_list, limits=(30,90)) \ No newline at end of file