From f34ecfe509ca891a07984e1f50de71d0ef8c7413 Mon Sep 17 00:00:00 2001 From: thuiop Date: Tue, 27 Jul 2021 14:39:38 +0200 Subject: [PATCH] Fix scarlet measure function failing sometimes (#210) --- notebooks/scarlet-measure.ipynb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/notebooks/scarlet-measure.ipynb b/notebooks/scarlet-measure.ipynb index 8902d5276..5a80405ff 100644 --- a/notebooks/scarlet-measure.ipynb +++ b/notebooks/scarlet-measure.ipynb @@ -123,8 +123,13 @@ " if len(catalog) == 0:\n", " t = astropy.table.Table()\n", " t[\"ra\"], t[\"dec\"] = wcs_ref.pixel_to_world_values(catalog[\"x\"], catalog[\"y\"])\n", - " return {\"catalog\":t,\"segmentation\":None,\"deblended_images\":{s.name: [np.zeros((len(s.filters),batch[\"blend_images\"][s.name][idx].shape[1],\n", - " batch[\"blend_images\"][s.name][idx].shape[1]))] for s in surveys}}\n", + " if multiresolution:\n", + " return {\"catalog\":t,\"segmentation\":None,\"deblended_images\":{s.name: np.array([np.zeros((len(s.filters),batch[\"blend_images\"][s.name][idx].shape[1],\n", + " batch[\"blend_images\"][s.name][idx].shape[1]))]) for s in surveys}}\n", + " else:\n", + " s = surveys[0]\n", + " return {\"catalog\":t,\"segmentation\":None,\"deblended_images\":np.array([np.zeros((len(s.filters),batch[\"blend_images\"][idx].shape[1],\n", + " batch[\"blend_images\"][idx].shape[1]))])}\n", " \n", "\n", " \n", @@ -195,13 +200,16 @@ " except AssertionError: #If the fitting fails\n", " t = astropy.table.Table()\n", " t[\"ra\"], t[\"dec\"] = wcs_ref.pixel_to_world_values(catalog[\"x\"], catalog[\"y\"])\n", - " deblended_images={s.name: np.array([np.zeros((len(s.filters),batch[\"blend_images\"][s.name][idx].shape[1],\n", - " batch[\"blend_images\"][s.name][idx].shape[1])) for c in catalog]) for s in surveys}\n", + " if multiresolution:\n", + " deblended_images={s.name: np.array([np.zeros((len(s.filters),batch[\"blend_images\"][s.name][idx].shape[1],\n", + " batch[\"blend_images\"][s.name][idx].shape[1])) for c in catalog]) for s in surveys}\n", + " else:\n", + " deblended_images={s.name: np.array([np.zeros((len(s.filters),batch[\"blend_images\"][idx].shape[1],\n", + " batch[\"blend_images\"][idx].shape[1])) for c in catalog]) for s in surveys}\n", " print(\"failed\")\n", " \n", " if len(surveys) == 1:\n", " deblended_images = deblended_images[surveys[0].name]\n", - " \n", " return {\"catalog\":t,\"segmentation\":None,\"deblended_images\":deblended_images}" ] },