Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit e49a1b2

Browse files
committed
Remove show_in_notebook from NB06.
1 parent 8b415fc commit e49a1b2

1 file changed

Lines changed: 41 additions & 34 deletions

File tree

06_Comparing_Object_and_Truth_Tables.ipynb

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "f57b0a8f",
5+
"id": "b4c448b2",
66
"metadata": {},
77
"source": [
88
"<img align=\"left\" src = https://project.lsst.org/sites/default/files/Rubin-O-Logo_0.png width=250 style=\"padding: 10px\"> \n",
@@ -27,7 +27,7 @@
2727
{
2828
"cell_type": "code",
2929
"execution_count": null,
30-
"id": "de133e88",
30+
"id": "186d1af7",
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
@@ -38,7 +38,7 @@
3838
},
3939
{
4040
"cell_type": "markdown",
41-
"id": "06717364",
41+
"id": "5a4bf8bf",
4242
"metadata": {},
4343
"source": [
4444
"### 1. Import Common Python Libraries\n",
@@ -49,7 +49,7 @@
4949
{
5050
"cell_type": "code",
5151
"execution_count": null,
52-
"id": "4249d4a4",
52+
"id": "0b144186",
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "markdown",
64-
"id": "e165773f",
64+
"id": "c4f7ec82",
6565
"metadata": {},
6666
"source": [
6767
"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,12 +70,12 @@
7070
{
7171
"cell_type": "code",
7272
"execution_count": null,
73-
"id": "06c690d4",
73+
"id": "19d846b4",
7474
"metadata": {},
7575
"outputs": [],
7676
"source": [
7777
"# 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",
7979
"\n",
8080
"# from rubin_jupyter_utils.lab.notebook import get_catalog, retrieve_query\n",
8181
"from rubin_jupyter_utils.lab.notebook import get_tap_service\n",
@@ -87,7 +87,7 @@
8787
},
8888
{
8989
"cell_type": "markdown",
90-
"id": "b37dee2b",
90+
"id": "4631cbf4",
9191
"metadata": {},
9292
"source": [
9393
"### 2. Loading tables with TAP\n",
@@ -98,18 +98,19 @@
9898
{
9999
"cell_type": "code",
100100
"execution_count": null,
101-
"id": "75f87bac",
101+
"id": "960aa123",
102102
"metadata": {},
103103
"outputs": [],
104104
"source": [
105105
"results = service.search(\"SELECT description,\\\n",
106106
" table_name FROM TAP_SCHEMA.tables\")\n",
107-
"results.to_table().show_in_notebook()"
107+
"results_tab = results.to_table()\n",
108+
"results_tab"
108109
]
109110
},
110111
{
111112
"cell_type": "markdown",
112-
"id": "e20bb66c",
113+
"id": "06be5674",
113114
"metadata": {},
114115
"source": [
115116
"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,7 +121,7 @@
120121
{
121122
"cell_type": "code",
122123
"execution_count": null,
123-
"id": "4132e8ba",
124+
"id": "03151319",
124125
"metadata": {},
125126
"outputs": [],
126127
"source": [
@@ -129,13 +130,16 @@
129130
"results = service.search(\"SELECT column_name, datatype, description,\\\n",
130131
" unit from TAP_SCHEMA.columns\\\n",
131132
" 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()"
133137
]
134138
},
135139
{
136140
"cell_type": "code",
137141
"execution_count": null,
138-
"id": "b1b28378",
142+
"id": "6154c44d",
139143
"metadata": {},
140144
"outputs": [],
141145
"source": [
@@ -144,12 +148,13 @@
144148
"results = service.search(\"SELECT column_name, datatype, description,\\\n",
145149
" unit from TAP_SCHEMA.columns\\\n",
146150
" 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"
148153
]
149154
},
150155
{
151156
"cell_type": "markdown",
152-
"id": "cb9b1bc2",
157+
"id": "31611cc2",
153158
"metadata": {},
154159
"source": [
155160
"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,7 +165,7 @@
160165
{
161166
"cell_type": "code",
162167
"execution_count": null,
163-
"id": "b83f89c3",
168+
"id": "f52289b2",
164169
"metadata": {},
165170
"outputs": [],
166171
"source": [
@@ -174,13 +179,14 @@
174179
" FROM dp01_dc2_catalogs.object\\\n",
175180
" WHERE CONTAINS(POINT('ICRS', ra, dec),\\\n",
176181
" 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."
178184
]
179185
},
180186
{
181187
"cell_type": "code",
182188
"execution_count": null,
183-
"id": "c1646302",
189+
"id": "0c724a81",
184190
"metadata": {},
185191
"outputs": [],
186192
"source": [
@@ -195,12 +201,13 @@
195201
" CIRCLE('ICRS', 62.0, -37.0, 0.1)) = 1\\\n",
196202
" AND match_objectId >= 0\\\n",
197203
" 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."
199206
]
200207
},
201208
{
202209
"cell_type": "markdown",
203-
"id": "2525473b",
210+
"id": "8c2e0b33",
204211
"metadata": {},
205212
"source": [
206213
"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,7 +216,7 @@
209216
{
210217
"cell_type": "code",
211218
"execution_count": null,
212-
"id": "11cc80a5",
219+
"id": "3fe65409",
213220
"metadata": {},
214221
"outputs": [],
215222
"source": [
@@ -219,7 +226,7 @@
219226
},
220227
{
221228
"cell_type": "markdown",
222-
"id": "0e99f343",
229+
"id": "fde56720",
223230
"metadata": {},
224231
"source": [
225232
"### 3. Merge the two tables and compare measurements to truth values\n",
@@ -230,7 +237,7 @@
230237
{
231238
"cell_type": "code",
232239
"execution_count": null,
233-
"id": "f4f7429f",
240+
"id": "7c36b2b5",
234241
"metadata": {},
235242
"outputs": [],
236243
"source": [
@@ -254,7 +261,7 @@
254261
{
255262
"cell_type": "code",
256263
"execution_count": null,
257-
"id": "0c220f27",
264+
"id": "9ed10152",
258265
"metadata": {},
259266
"outputs": [],
260267
"source": [
@@ -264,7 +271,7 @@
264271
{
265272
"cell_type": "code",
266273
"execution_count": null,
267-
"id": "de91c217",
274+
"id": "95178746",
268275
"metadata": {},
269276
"outputs": [],
270277
"source": [
@@ -298,7 +305,7 @@
298305
},
299306
{
300307
"cell_type": "markdown",
301-
"id": "b468299e",
308+
"id": "39a4506a",
302309
"metadata": {},
303310
"source": [
304311
"#### Compare the measurements from the Object table to the \"true\" values for some objects.\n",
@@ -311,7 +318,7 @@
311318
{
312319
"cell_type": "code",
313320
"execution_count": null,
314-
"id": "f619d477",
321+
"id": "0dbb8794",
315322
"metadata": {},
316323
"outputs": [],
317324
"source": [
@@ -321,7 +328,7 @@
321328
},
322329
{
323330
"cell_type": "markdown",
324-
"id": "dc470937",
331+
"id": "3bb3c8ec",
325332
"metadata": {},
326333
"source": [
327334
"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,7 +337,7 @@
330337
{
331338
"cell_type": "code",
332339
"execution_count": null,
333-
"id": "a7d08625",
340+
"id": "c982fc60",
334341
"metadata": {},
335342
"outputs": [],
336343
"source": [
@@ -370,7 +377,7 @@
370377
},
371378
{
372379
"cell_type": "markdown",
373-
"id": "fe125d6b",
380+
"id": "dee14f1c",
374381
"metadata": {},
375382
"source": [
376383
"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,7 +388,7 @@
381388
{
382389
"cell_type": "code",
383390
"execution_count": null,
384-
"id": "caebf863",
391+
"id": "6ccc02dc",
385392
"metadata": {},
386393
"outputs": [],
387394
"source": [
@@ -404,7 +411,7 @@
404411
},
405412
{
406413
"cell_type": "markdown",
407-
"id": "ffc9043d",
414+
"id": "21e17629",
408415
"metadata": {},
409416
"source": [
410417
"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,7 +422,7 @@
415422
{
416423
"cell_type": "code",
417424
"execution_count": null,
418-
"id": "72ec6e46",
425+
"id": "45b3b378",
419426
"metadata": {},
420427
"outputs": [],
421428
"source": []

0 commit comments

Comments
 (0)