|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | | - "id": "f57b0a8f", |
| 5 | + "id": "b4c448b2", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | 8 | "<img align=\"left\" src = https://project.lsst.org/sites/default/files/Rubin-O-Logo_0.png width=250 style=\"padding: 10px\"> \n", |
|
27 | 27 | { |
28 | 28 | "cell_type": "code", |
29 | 29 | "execution_count": null, |
30 | | - "id": "de133e88", |
| 30 | + "id": "186d1af7", |
31 | 31 | "metadata": {}, |
32 | 32 | "outputs": [], |
33 | 33 | "source": [ |
|
38 | 38 | }, |
39 | 39 | { |
40 | 40 | "cell_type": "markdown", |
41 | | - "id": "06717364", |
| 41 | + "id": "5a4bf8bf", |
42 | 42 | "metadata": {}, |
43 | 43 | "source": [ |
44 | 44 | "### 1. Import Common Python Libraries\n", |
|
49 | 49 | { |
50 | 50 | "cell_type": "code", |
51 | 51 | "execution_count": null, |
52 | | - "id": "4249d4a4", |
| 52 | + "id": "0b144186", |
53 | 53 | "metadata": {}, |
54 | 54 | "outputs": [], |
55 | 55 | "source": [ |
|
61 | 61 | }, |
62 | 62 | { |
63 | 63 | "cell_type": "markdown", |
64 | | - "id": "e165773f", |
| 64 | + "id": "c4f7ec82", |
65 | 65 | "metadata": {}, |
66 | 66 | "source": [ |
67 | 67 | "To access tables, we will use the TAP service in a similar manner to what we showed in the [Intro to DP0 notebook](https://github.com/rubin-dp0/tutorial-notebooks/blob/main/01_Intro_to_DP0_Notebooks.ipynb), and explored further in THE TAP TUTORIAL NOTEBOOK. See those notebooks for more details." |
|
70 | 70 | { |
71 | 71 | "cell_type": "code", |
72 | 72 | "execution_count": null, |
73 | | - "id": "06c690d4", |
| 73 | + "id": "19d846b4", |
74 | 74 | "metadata": {}, |
75 | 75 | "outputs": [], |
76 | 76 | "source": [ |
77 | 77 | "# Set up some options, and import a couple more tools we will need:\n", |
78 | | - "pandas.set_option('display.max_rows', 100)\n", |
| 78 | + "pandas.set_option('display.max_rows', 200)\n", |
79 | 79 | "\n", |
80 | 80 | "# from rubin_jupyter_utils.lab.notebook import get_catalog, retrieve_query\n", |
81 | 81 | "from rubin_jupyter_utils.lab.notebook import get_tap_service\n", |
|
87 | 87 | }, |
88 | 88 | { |
89 | 89 | "cell_type": "markdown", |
90 | | - "id": "b37dee2b", |
| 90 | + "id": "4631cbf4", |
91 | 91 | "metadata": {}, |
92 | 92 | "source": [ |
93 | 93 | "### 2. Loading tables with TAP\n", |
|
98 | 98 | { |
99 | 99 | "cell_type": "code", |
100 | 100 | "execution_count": null, |
101 | | - "id": "75f87bac", |
| 101 | + "id": "960aa123", |
102 | 102 | "metadata": {}, |
103 | 103 | "outputs": [], |
104 | 104 | "source": [ |
105 | 105 | "results = service.search(\"SELECT description,\\\n", |
106 | 106 | " table_name FROM TAP_SCHEMA.tables\")\n", |
107 | | - "results.to_table().show_in_notebook()" |
| 107 | + "results_tab = results.to_table()\n", |
| 108 | + "results_tab" |
108 | 109 | ] |
109 | 110 | }, |
110 | 111 | { |
111 | 112 | "cell_type": "markdown", |
112 | | - "id": "e20bb66c", |
| 113 | + "id": "06be5674", |
113 | 114 | "metadata": {}, |
114 | 115 | "source": [ |
115 | 116 | "For our analysis, let's choose the Object table, `dp01_dc2_catalogs.object`, and then we will compare the measurements from this table to the \"truth\" values from `dp01_dc2_catalogs.truth_match`.\n", |
|
120 | 121 | { |
121 | 122 | "cell_type": "code", |
122 | 123 | "execution_count": null, |
123 | | - "id": "4132e8ba", |
| 124 | + "id": "03151319", |
124 | 125 | "metadata": {}, |
125 | 126 | "outputs": [], |
126 | 127 | "source": [ |
|
129 | 130 | "results = service.search(\"SELECT column_name, datatype, description,\\\n", |
130 | 131 | " unit from TAP_SCHEMA.columns\\\n", |
131 | 132 | " WHERE table_name = 'dp01_dc2_catalogs.object'\")\n", |
132 | | - "results.to_table().show_in_notebook()" |
| 133 | + "# Note that we use the .to_pandas() method here so that all rows will display.\n", |
| 134 | + "# Astropy will truncate the table for display, whereas we set the maximum number of \n", |
| 135 | + "# rows for pandas to display to 200 in a cell above.\n", |
| 136 | + "results.to_table().to_pandas()" |
133 | 137 | ] |
134 | 138 | }, |
135 | 139 | { |
136 | 140 | "cell_type": "code", |
137 | 141 | "execution_count": null, |
138 | | - "id": "b1b28378", |
| 142 | + "id": "6154c44d", |
139 | 143 | "metadata": {}, |
140 | 144 | "outputs": [], |
141 | 145 | "source": [ |
|
144 | 148 | "results = service.search(\"SELECT column_name, datatype, description,\\\n", |
145 | 149 | " unit from TAP_SCHEMA.columns\\\n", |
146 | 150 | " WHERE table_name = 'dp01_dc2_catalogs.truth_match'\")\n", |
147 | | - "results.to_table().show_in_notebook()" |
| 151 | + "results_tab = results.to_table()\n", |
| 152 | + "results_tab" |
148 | 153 | ] |
149 | 154 | }, |
150 | 155 | { |
151 | 156 | "cell_type": "markdown", |
152 | | - "id": "cb9b1bc2", |
| 157 | + "id": "31611cc2", |
153 | 158 | "metadata": {}, |
154 | 159 | "source": [ |
155 | 160 | "For this exploration, we will select a small region of sky around a random RA, Dec position. The following two cells read data centered on (RA, Dec) = (62.0, -37.0) degrees, within a radius of 0.1 degrees, for first the Object table, then the Truth-Match table. Note that we are selecting only a subset of the columns seen in the schema above. You can add or remove columns as you wish.\n", |
|
160 | 165 | { |
161 | 166 | "cell_type": "code", |
162 | 167 | "execution_count": null, |
163 | | - "id": "b83f89c3", |
| 168 | + "id": "f52289b2", |
164 | 169 | "metadata": {}, |
165 | 170 | "outputs": [], |
166 | 171 | "source": [ |
|
174 | 179 | " FROM dp01_dc2_catalogs.object\\\n", |
175 | 180 | " WHERE CONTAINS(POINT('ICRS', ra, dec),\\\n", |
176 | 181 | " CIRCLE('ICRS', 62.0, -37.0, 0.1)) = 1 \")\n", |
177 | | - "# results.to_table().show_in_notebook() # To print the table to the screen." |
| 182 | + "# results_tab = results.to_table()\n", |
| 183 | + "# results_tab # To print the table to the screen." |
178 | 184 | ] |
179 | 185 | }, |
180 | 186 | { |
181 | 187 | "cell_type": "code", |
182 | 188 | "execution_count": null, |
183 | | - "id": "c1646302", |
| 189 | + "id": "0c724a81", |
184 | 190 | "metadata": {}, |
185 | 191 | "outputs": [], |
186 | 192 | "source": [ |
|
195 | 201 | " CIRCLE('ICRS', 62.0, -37.0, 0.1)) = 1\\\n", |
196 | 202 | " AND match_objectId >= 0\\\n", |
197 | 203 | " AND is_good_match = 1\")\n", |
198 | | - "# results.to_table().show_in_notebook() # To print the table to the screen." |
| 204 | + "# results_tab = results.to_table() \n", |
| 205 | + "# results_tab # To print the table to the screen." |
199 | 206 | ] |
200 | 207 | }, |
201 | 208 | { |
202 | 209 | "cell_type": "markdown", |
203 | | - "id": "2525473b", |
| 210 | + "id": "8c2e0b33", |
204 | 211 | "metadata": {}, |
205 | 212 | "source": [ |
206 | 213 | "These tables will be much easier to work with as `pandas` \"dataframes\". The query results have convenient methods that we can use to convert them." |
|
209 | 216 | { |
210 | 217 | "cell_type": "code", |
211 | 218 | "execution_count": null, |
212 | | - "id": "11cc80a5", |
| 219 | + "id": "3fe65409", |
213 | 220 | "metadata": {}, |
214 | 221 | "outputs": [], |
215 | 222 | "source": [ |
|
219 | 226 | }, |
220 | 227 | { |
221 | 228 | "cell_type": "markdown", |
222 | | - "id": "0e99f343", |
| 229 | + "id": "fde56720", |
223 | 230 | "metadata": {}, |
224 | 231 | "source": [ |
225 | 232 | "### 3. Merge the two tables and compare measurements to truth values\n", |
|
230 | 237 | { |
231 | 238 | "cell_type": "code", |
232 | 239 | "execution_count": null, |
233 | | - "id": "f4f7429f", |
| 240 | + "id": "7c36b2b5", |
234 | 241 | "metadata": {}, |
235 | 242 | "outputs": [], |
236 | 243 | "source": [ |
|
254 | 261 | { |
255 | 262 | "cell_type": "code", |
256 | 263 | "execution_count": null, |
257 | | - "id": "0c220f27", |
| 264 | + "id": "9ed10152", |
258 | 265 | "metadata": {}, |
259 | 266 | "outputs": [], |
260 | 267 | "source": [ |
|
264 | 271 | { |
265 | 272 | "cell_type": "code", |
266 | 273 | "execution_count": null, |
267 | | - "id": "de91c217", |
| 274 | + "id": "95178746", |
268 | 275 | "metadata": {}, |
269 | 276 | "outputs": [], |
270 | 277 | "source": [ |
|
298 | 305 | }, |
299 | 306 | { |
300 | 307 | "cell_type": "markdown", |
301 | | - "id": "b468299e", |
| 308 | + "id": "39a4506a", |
302 | 309 | "metadata": {}, |
303 | 310 | "source": [ |
304 | 311 | "#### Compare the measurements from the Object table to the \"true\" values for some objects.\n", |
|
311 | 318 | { |
312 | 319 | "cell_type": "code", |
313 | 320 | "execution_count": null, |
314 | | - "id": "f619d477", |
| 321 | + "id": "0dbb8794", |
315 | 322 | "metadata": {}, |
316 | 323 | "outputs": [], |
317 | 324 | "source": [ |
|
321 | 328 | }, |
322 | 329 | { |
323 | 330 | "cell_type": "markdown", |
324 | | - "id": "dc470937", |
| 331 | + "id": "3bb3c8ec", |
325 | 332 | "metadata": {}, |
326 | 333 | "source": [ |
327 | 334 | "Just to confirm that things look like we expect, let's plot a color-magnitude (g vs. g-i) and color-color (r-i vs. g-r) diagram." |
|
330 | 337 | { |
331 | 338 | "cell_type": "code", |
332 | 339 | "execution_count": null, |
333 | | - "id": "a7d08625", |
| 340 | + "id": "c982fc60", |
334 | 341 | "metadata": {}, |
335 | 342 | "outputs": [], |
336 | 343 | "source": [ |
|
370 | 377 | }, |
371 | 378 | { |
372 | 379 | "cell_type": "markdown", |
373 | | - "id": "fe125d6b", |
| 380 | + "id": "dee14f1c", |
374 | 381 | "metadata": {}, |
375 | 382 | "source": [ |
376 | 383 | "Looks pretty normal - the stellar locus in color-color space is right where one expects it to be, and the galaxies dominate at the faint end of the CMD. \n", |
|
381 | 388 | { |
382 | 389 | "cell_type": "code", |
383 | 390 | "execution_count": null, |
384 | | - "id": "caebf863", |
| 391 | + "id": "6ccc02dc", |
385 | 392 | "metadata": {}, |
386 | 393 | "outputs": [], |
387 | 394 | "source": [ |
|
404 | 411 | }, |
405 | 412 | { |
406 | 413 | "cell_type": "markdown", |
407 | | - "id": "ffc9043d", |
| 414 | + "id": "21e17629", |
408 | 415 | "metadata": {}, |
409 | 416 | "source": [ |
410 | 417 | "Well, that looks good -- the ratio of measured to true fluxes is centered on 1.0. It seems like the fluxes are recovered pretty well, on average.\n", |
|
415 | 422 | { |
416 | 423 | "cell_type": "code", |
417 | 424 | "execution_count": null, |
418 | | - "id": "72ec6e46", |
| 425 | + "id": "45b3b378", |
419 | 426 | "metadata": {}, |
420 | 427 | "outputs": [], |
421 | 428 | "source": [] |
|
0 commit comments