Skip to content

Commit da4cc9d

Browse files
committed
updated nb
1 parent cfe99ad commit da4cc9d

1 file changed

Lines changed: 47 additions & 5 deletions

File tree

DP1/100_How_to_Use_RSP_Tools/103_Image_access_and_display/103_8_Image_display_with_matplotlib.ipynb

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@
804804
"id": "232f4189-d6f3-49f2-b5ce-4c65a0360de4",
805805
"metadata": {},
806806
"source": [
807-
"Retrieve the `patch` and the objects' x and y coordinates."
807+
"Retrieve the `patch`, the objects' x and y coordinates, and the r-band Point Spread Function (PSF) flux (with uncertainty)."
808808
]
809809
},
810810
{
@@ -815,7 +815,8 @@
815815
"outputs": [],
816816
"source": [
817817
"use_columns = ['objectId', 'patch',\n",
818-
" 'r_centroid_x', 'r_centroid_y']\n",
818+
" 'r_centroid_x', 'r_centroid_y',\n",
819+
" 'r_psfFlux', 'r_psfFluxErr']\n",
819820
"objects = butler.get('object', tract=dataId.get('tract'),\n",
820821
" parameters={'columns': use_columns})"
821822
]
@@ -839,6 +840,27 @@
839840
"print(\"Number of objects: \", len(tx))"
840841
]
841842
},
843+
{
844+
"cell_type": "markdown",
845+
"id": "ac155358-63e0-424a-aa3e-e2bb674356b7",
846+
"metadata": {},
847+
"source": [
848+
"Since there are many objects, filter objects by their Signal-to-Noise ratio (S/N) to make the following scatter plot more clear. "
849+
]
850+
},
851+
{
852+
"cell_type": "code",
853+
"execution_count": null,
854+
"id": "ca27a145-8b32-4647-bd94-3f13a4766fc3",
855+
"metadata": {},
856+
"outputs": [],
857+
"source": [
858+
"sel = objects['r_psfFlux'] / objects['r_psfFluxErr'] > 300\n",
859+
"objects = objects[sel]\n",
860+
"tx = np.where(objects['patch'] == dataId.get('patch'))[0]\n",
861+
"print(\"Number of objects: \", len(tx))"
862+
]
863+
},
842864
{
843865
"cell_type": "markdown",
844866
"id": "8cd049b7-b478-4cea-943b-a7e9dc75dc90",
@@ -863,7 +885,7 @@
863885
" for i in tx:\n",
864886
" afw_display.dot('o', objects[i]['r_centroid_x'],\n",
865887
" objects[i]['r_centroid_y'],\n",
866-
" size=20, ctype='orange')\n",
888+
" size=30, ctype='orange')\n",
867889
"plt.show()\n",
868890
"remove_figure(fig)"
869891
]
@@ -904,14 +926,34 @@
904926
"dataId = visit_image_refs[0].dataId\n",
905927
"\n",
906928
"use_columns = ['sourceId', 'visit',\n",
907-
" 'x', 'y']\n",
929+
" 'x', 'y',\n",
930+
" 'psfFlux', 'psfFluxErr']\n",
908931
"\n",
909932
"sources = butler.get('source', dataId=dataId,\n",
910933
" parameters={'columns': use_columns})\n",
911934
"\n",
912935
"print(\"Number of sources: \", len(sources))"
913936
]
914937
},
938+
{
939+
"cell_type": "markdown",
940+
"id": "0f14f134-308c-4ead-b759-70d610d03718",
941+
"metadata": {},
942+
"source": [
943+
"Filter the sources by S/N."
944+
]
945+
},
946+
{
947+
"cell_type": "code",
948+
"execution_count": null,
949+
"id": "c34db8eb-09fd-487f-b6f7-a7320851e2df",
950+
"metadata": {},
951+
"outputs": [],
952+
"source": [
953+
"sel = sources['psfFlux'] / sources['psfFluxErr'] > 300\n",
954+
"sources = sources[sel]"
955+
]
956+
},
915957
{
916958
"cell_type": "markdown",
917959
"id": "a94cacd5-1b60-4943-9c88-381c87f14490",
@@ -936,7 +978,7 @@
936978
" for i in sources:\n",
937979
" afw_display.dot('o', i['x'],\n",
938980
" i['y'],\n",
939-
" size=3, ctype='orange')\n",
981+
" size=30, ctype='orange')\n",
940982
"plt.show()\n",
941983
"remove_figure(fig)"
942984
]

0 commit comments

Comments
 (0)