Skip to content

Commit

Permalink
REF delete trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ismael-mendoza committed Apr 30, 2024
1 parent 0656dcf commit 516eb9e
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions notebooks/00-quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"seed = 0 # random seed for reproducibility purposes # seed = 8\n",
"sampling_function = btk.sampling_functions.DefaultSampling(\n",
" max_number=max_number, min_number=max_number, # always get `max_number` galaxies\n",
" stamp_size=stamp_size, max_shift=max_shift, \n",
" stamp_size=stamp_size, max_shift=max_shift,\n",
" min_mag = 24, max_mag = 25,\n",
" seed = seed)"
]
Expand Down Expand Up @@ -314,7 +314,7 @@
}
],
"source": [
"blend_batch.blend_images.shape \n",
"blend_batch.blend_images.shape\n",
"# shape = (batch_size, n_bands, stamp_size, stamp_size)"
]
},
Expand Down Expand Up @@ -359,7 +359,7 @@
}
],
"source": [
"blend_batch.catalog_list[0] \n",
"blend_batch.catalog_list[0]\n",
"# blend_list is a list of astropy tables, one for each blend in the batch."
]
},
Expand Down Expand Up @@ -750,11 +750,10 @@
"plt.imshow(blend_batch.blend_images[0, 2, :, :], cmap=\"gray\")\n",
"\n",
"# plot centers of truth\n",
"plt.scatter(blend_batch.catalog_list[0][\"x_peak\"], blend_batch.catalog_list[0][\"y_peak\"], c=\"r\", marker=\"x\")\n",
"plt.scatter(blend_batch.catalog_list[0][\"x_peak\"],\n",
" blend_batch.catalog_list[0][\"y_peak\"], c=\"r\", marker=\"x\")\n",
"\n",
"# plot centers of prediction\n",
"\n",
"# need to use wcs to convert ra and dec to x and y\n",
"x, y = deblend_batch.catalog_list[0]['x_peak'], deblend_batch.catalog_list[0]['y_peak']\n",
"plt.scatter(x, y, c=\"b\", marker=\"+\", s=50)"
]
Expand All @@ -765,7 +764,7 @@
"source": [
"We can also inspect the deblended images and compare with the isolated ones. \n",
"\n",
"**Note:** Images do not necessarily line up in general as below, need to match (see next section)"
"**Note:** Images do not necessarily line up in general, need to match (see next section)"
]
},
{
Expand Down Expand Up @@ -795,7 +794,7 @@
}
],
"source": [
"# plot isolated images from truth \n",
"# plot isolated images from truth\n",
"fig, axes = plt.subplots(2, 3, figsize=(12, 8))\n",
"\n",
"clip = 40 # zoom into images\n",
Expand All @@ -809,19 +808,21 @@
"\n",
"for ii in range(3):\n",
" ax = axes.flatten()[ii]\n",
" ax.imshow(blend_batch.isolated_images[0, ii, 2, clip:-clip, clip:-clip], cmap=\"gray\", \n",
" ax.imshow(blend_batch.isolated_images[0, ii, 2, clip:-clip, clip:-clip], cmap=\"gray\",\n",
" vmin=vmin, vmax=vmax)\n",
"\n",
"# plot isolated images from prediction\n",
"for ii in range(3, 6):\n",
" ax = axes.flatten()[ii]\n",
" ax.imshow(deblend_batch.deblended_images[0, ii-3, 0, clip:-clip, clip:-clip], cmap=\"gray\", \n",
" ax.imshow(deblend_batch.deblended_images[0, ii-3, 0, clip:-clip, clip:-clip], cmap=\"gray\",\n",
" vmin=vmin, vmax=vmax)\n",
"\n",
"# add colorbar\n",
"fig.subplots_adjust(right=0.8)\n",
"cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])\n",
"fig.colorbar(axes[0, 0].imshow(blend_batch.isolated_images[0, 0, 2, clip:-clip, clip:-clip], cmap=\"gray\", vmin=vmin, vmax=vmax), cax=cbar_ax)"
"fig.colorbar(axes[0, 0].imshow(blend_batch.isolated_images[0, 0, 2, clip:-clip, clip:-clip],\n",
" cmap=\"gray\", vmin=vmin, vmax=vmax),\n",
" cax=cbar_ax)"
]
},
{
Expand Down Expand Up @@ -863,7 +864,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Before matching, we need to add pixel centroids to the catalogs of `deblend_batch`. As it currently only contains `ra` and `dec`. We can do it easily with the utility function `btk.utils.add_pixel_columns`:"
"Note that for the `SepSingleBand` deblender, the catalogs already contain an `x_peak` and `y_peak` columns. The `PixelHungarianMatcher` requires these columns, otherwise they would need to be added separately."
]
},
{
Expand Down Expand Up @@ -892,7 +893,7 @@
"metadata": {},
"outputs": [],
"source": [
"# matchers operate on `catalog_lists`, so we need to extract them from our batch classes. \n",
"# matchers operate on `catalog_lists`, so we need to extract them from our batch classes.\n",
"true_catalog_list = blend_batch.catalog_list\n",
"pred_catalog_list = deblend_batch.catalog_list\n",
"matching = matcher(true_catalog_list, pred_catalog_list) # matching object"
Expand Down Expand Up @@ -922,10 +923,10 @@
}
],
"source": [
"(matching.true_matches[0], # index of each true source that is matched with predicted \n",
"(matching.true_matches[0], # index of each true source that is matched with predicted\n",
" matching.pred_matches[0], #index of each pred source that is matched with truth\n",
" matching.n_true[0], # number of truth total\n",
" matching.n_pred[0], # number of predicted total \n",
" matching.n_pred[0], # number of predicted total\n",
")"
]
},
Expand Down Expand Up @@ -1175,7 +1176,7 @@
"source": [
"# for reconstruction and segmentation, need to match first and then apply metric\n",
"iso_images1 = blend_batch.isolated_images[:, :, 2] # only r-band\n",
"iso_images2 = deblend_batch.deblended_images[:, :, 0] \n",
"iso_images2 = deblend_batch.deblended_images[:, :, 0]\n",
"iso_images_matched1 = matching.match_true_arrays(iso_images1)\n",
"iso_images_matched2 = matching.match_pred_arrays(iso_images2)"
]
Expand Down Expand Up @@ -1312,7 +1313,7 @@
"ellips1 = get_ksb_ellipticity(iso_images_matched1, psf_r, pixel_scale=0.2)\n",
"\n",
"# NOTE: assumed deblended images are psf convolved with same psf\n",
"ellips2 = get_ksb_ellipticity(iso_images_matched2, psf_r, pixel_scale=0.2) \n",
"ellips2 = get_ksb_ellipticity(iso_images_matched2, psf_r, pixel_scale=0.2)\n",
"\n",
"\n",
"# mask nan's (non-matches), look at first component only\n",
Expand Down Expand Up @@ -1351,7 +1352,7 @@
}
],
"source": [
"# look at first component \n",
"# look at first component\n",
"plt.scatter(e11, e12)\n",
"plt.plot([-1, 1], [-1, 1])"
]
Expand Down

0 comments on commit 516eb9e

Please sign in to comment.