From 168a1bf5ec936b6ca8195f8606c077ad0a9f38cb Mon Sep 17 00:00:00 2001 From: Allen Downey Date: Fri, 26 Mar 2021 11:15:42 -0400 Subject: [PATCH] Updating notebooks --- 03_motion.ipynb | 110 +++++++++++++++---------------- 04_select.ipynb | 83 ++++++++++++----------- 05_join.ipynb | 92 +++++++++++++------------- 06_photo.ipynb | 172 +++++++++++++++++++----------------------------- 07_plot.ipynb | 123 ++++++++++++++-------------------- 5 files changed, 263 insertions(+), 317 deletions(-) diff --git a/03_motion.ipynb b/03_motion.ipynb index 5880d85..95cfee7 100644 --- a/03_motion.ipynb +++ b/03_motion.ipynb @@ -57,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 55, "metadata": { "tags": [] }, @@ -69,7 +69,7 @@ "IN_COLAB = 'google.colab' in sys.modules\n", "\n", "if IN_COLAB:\n", - " !pip install astroquery astro-gala wget" + " !pip install astroquery astro-gala" ] }, { @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -113,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 58, "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 59, "metadata": {}, "outputs": [], "source": [ @@ -170,7 +170,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -202,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -218,7 +218,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -237,7 +237,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -281,7 +281,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -321,7 +321,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 68, "metadata": { "tags": [] }, @@ -393,7 +393,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ @@ -415,7 +415,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -445,7 +445,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -490,7 +490,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -514,7 +514,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 73, "metadata": { "scrolled": true }, @@ -546,7 +546,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 74, "metadata": {}, "outputs": [], "source": [ @@ -562,7 +562,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 75, "metadata": {}, "outputs": [], "source": [ @@ -588,7 +588,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ @@ -606,7 +606,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 77, "metadata": {}, "outputs": [], "source": [ @@ -622,7 +622,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 78, "metadata": {}, "outputs": [], "source": [ @@ -645,7 +645,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ @@ -663,7 +663,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 80, "metadata": {}, "outputs": [], "source": [ @@ -693,7 +693,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 81, "metadata": {}, "outputs": [], "source": [ @@ -715,7 +715,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 82, "metadata": { "tags": [] }, @@ -753,7 +753,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 83, "metadata": {}, "outputs": [], "source": [ @@ -775,7 +775,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 84, "metadata": {}, "outputs": [], "source": [ @@ -817,7 +817,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 85, "metadata": {}, "outputs": [], "source": [ @@ -836,7 +836,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 86, "metadata": {}, "outputs": [], "source": [ @@ -856,7 +856,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 87, "metadata": {}, "outputs": [], "source": [ @@ -873,7 +873,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 88, "metadata": {}, "outputs": [], "source": [ @@ -898,7 +898,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 89, "metadata": {}, "outputs": [], "source": [ @@ -914,7 +914,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 90, "metadata": {}, "outputs": [], "source": [ @@ -934,7 +934,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 91, "metadata": {}, "outputs": [], "source": [ @@ -950,7 +950,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 92, "metadata": {}, "outputs": [], "source": [ @@ -975,7 +975,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 93, "metadata": {}, "outputs": [], "source": [ @@ -1004,7 +1004,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 94, "metadata": {}, "outputs": [], "source": [ @@ -1041,7 +1041,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 95, "metadata": {}, "outputs": [], "source": [ @@ -1060,7 +1060,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 96, "metadata": {}, "outputs": [], "source": [ @@ -1073,7 +1073,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 97, "metadata": {}, "outputs": [], "source": [ @@ -1090,7 +1090,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 98, "metadata": {}, "outputs": [], "source": [ @@ -1109,7 +1109,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 99, "metadata": {}, "outputs": [], "source": [ @@ -1127,7 +1127,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 100, "metadata": {}, "outputs": [], "source": [ @@ -1147,7 +1147,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 101, "metadata": {}, "outputs": [], "source": [ @@ -1163,7 +1163,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 102, "metadata": {}, "outputs": [], "source": [ @@ -1180,7 +1180,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 103, "metadata": {}, "outputs": [], "source": [ @@ -1212,7 +1212,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 104, "metadata": {}, "outputs": [], "source": [ @@ -1253,7 +1253,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 105, "metadata": {}, "outputs": [], "source": [ @@ -1286,7 +1286,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 106, "metadata": { "tags": [] }, @@ -1304,7 +1304,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 107, "metadata": {}, "outputs": [], "source": [ @@ -1323,7 +1323,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 108, "metadata": {}, "outputs": [], "source": [ diff --git a/04_select.ipynb b/04_select.ipynb index 7c77afb..b24f809 100644 --- a/04_select.ipynb +++ b/04_select.ipynb @@ -52,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 37, "metadata": { "tags": [] }, @@ -64,7 +64,7 @@ "IN_COLAB = 'google.colab' in sys.modules\n", "\n", "if IN_COLAB:\n", - " !pip install astroquery astro-gala wget" + " !pip install astroquery astro-gala" ] }, { @@ -73,12 +73,12 @@ "source": [ "## Reload the data\n", "\n", - "The following cells download the data from the previous lesson, if necessary, and load it into a Pandas `DataFrame`." + "You can [download the data from the previous lesson](https://github.com/AllenDowney/AstronomicalData/raw/main/data/gd1_data.hdf) or run the following cell, which downloads it if necessary." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -95,9 +95,16 @@ " 'data/gd1_data.hdf')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can reload `centerline_df` and `selected_df`." + ] + }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -135,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -147,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ @@ -160,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 42, "metadata": {}, "outputs": [], "source": [ @@ -177,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 43, "metadata": {}, "outputs": [], "source": [ @@ -214,7 +221,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -236,7 +243,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -277,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -303,7 +310,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -322,7 +329,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -338,7 +345,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -355,7 +362,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -373,7 +380,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -413,7 +420,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -442,7 +449,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -463,7 +470,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -480,7 +487,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 55, "metadata": {}, "outputs": [], "source": [ @@ -505,7 +512,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -518,7 +525,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ @@ -535,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 58, "metadata": {}, "outputs": [], "source": [ @@ -551,7 +558,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 59, "metadata": {}, "outputs": [], "source": [ @@ -583,7 +590,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -602,7 +609,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 61, "metadata": { "scrolled": true }, @@ -623,7 +630,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 62, "metadata": { "tags": [] }, @@ -643,7 +650,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 63, "metadata": { "tags": [] }, @@ -661,7 +668,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 64, "metadata": { "scrolled": true }, @@ -682,7 +689,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -706,7 +713,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -723,7 +730,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ @@ -740,7 +747,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ @@ -759,7 +766,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ @@ -783,7 +790,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -825,7 +832,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -841,7 +848,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ diff --git a/05_join.ipynb b/05_join.ipynb index de1aff5..4df59d9 100644 --- a/05_join.ipynb +++ b/05_join.ipynb @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 28, "metadata": { "tags": [] }, @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -158,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -202,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 33, "metadata": {}, "outputs": [], "source": [ @@ -211,7 +211,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 34, "metadata": { "scrolled": true }, @@ -232,7 +232,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -257,7 +257,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -284,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -297,7 +297,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -306,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 40, "metadata": { "scrolled": true }, @@ -350,7 +350,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ @@ -373,7 +373,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 42, "metadata": {}, "outputs": [], "source": [ @@ -384,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 43, "metadata": { "scrolled": true }, @@ -404,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -426,7 +426,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -445,7 +445,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -454,7 +454,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 47, "metadata": { "scrolled": true }, @@ -484,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -516,7 +516,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -536,7 +536,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -545,7 +545,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 51, "metadata": { "scrolled": true }, @@ -583,7 +583,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -603,7 +603,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -628,7 +628,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -648,7 +648,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 55, "metadata": {}, "outputs": [], "source": [ @@ -670,7 +670,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -679,7 +679,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 57, "metadata": { "scrolled": true }, @@ -705,7 +705,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 58, "metadata": {}, "outputs": [], "source": [ @@ -723,7 +723,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 59, "metadata": {}, "outputs": [], "source": [ @@ -741,7 +741,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -762,7 +762,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -790,7 +790,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -835,7 +835,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -851,7 +851,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ @@ -884,7 +884,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -902,7 +902,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -945,7 +945,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ @@ -961,7 +961,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ @@ -977,7 +977,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ @@ -990,7 +990,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -1008,7 +1008,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -1024,7 +1024,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -1033,7 +1033,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 73, "metadata": {}, "outputs": [], "source": [ diff --git a/06_photo.ipynb b/06_photo.ipynb index 9d68930..3200197 100644 --- a/06_photo.ipynb +++ b/06_photo.ipynb @@ -43,67 +43,48 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ - "## Installing libraries\n", + "## Reload the data\n", "\n", - "If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n", - "\n", - "If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface." + "You can [download the data from the previous lesson](https://github.com/AllenDowney/AstronomicalData/raw/main/data/gd1_data.hdf) or run the following cell, which downloads it if necessary." ] }, { "cell_type": "code", - "execution_count": 1, - "metadata": { - "tags": [] - }, + "execution_count": 47, + "metadata": {}, "outputs": [], "source": [ - "# If we're running on Colab, install libraries\n", + "from os.path import basename, exists\n", "\n", - "import sys\n", - "IN_COLAB = 'google.colab' in sys.modules\n", + "def download(url):\n", + " filename = basename(url)\n", + " if not exists(filename):\n", + " from urllib.request import urlretrieve\n", + " local, _ = urlretrieve(url, filename)\n", + " print('Downloaded ' + local)\n", "\n", - "if IN_COLAB:\n", - " !pip install wget" + "download('https://github.com/AllenDowney/AstronomicalData/raw/main/' +\n", + " 'data/gd1_data.hdf')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Reload the data\n", - "\n", - "The following cell downloads the photometry data we created in the previous notebook." + "Now we can reload `candidate_df`." ] }, { "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "from wget import download\n", - "\n", - "filename = 'gd1_data.hdf'\n", - "filepath = 'https://github.com/AllenDowney/AstronomicalData/raw/main/data/'\n", - "\n", - "if not os.path.exists(filename):\n", - " print(download(filepath+filename))" - ] - }, - { - "cell_type": "code", - "execution_count": 3, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", + "filename = 'gd1_data.hdf'\n", "candidate_df = pd.read_hdf(filename, 'candidate_df')" ] }, @@ -139,7 +120,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -195,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -238,18 +219,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ - "import os\n", - "from wget import download\n", - "\n", - "filename = 'MIST_iso_5fd2532653c27.iso.cmd'\n", - "filepath = 'https://github.com/AllenDowney/AstronomicalData/raw/main/data/'\n", - "\n", - "if not os.path.exists(filename):\n", - " print(download(filepath+filename))" + "download('https://github.com/AllenDowney/AstronomicalData/raw/main/' +\n", + " 'data/MIST_iso_5fd2532653c27.iso.cmd')" ] }, { @@ -261,18 +236,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ - "import os\n", - "from wget import download\n", - "\n", - "filename = 'read_mist_models.py'\n", - "filepath = 'https://github.com/jieunchoi/MIST_codes/raw/master/scripts/'\n", - "\n", - "if not os.path.exists(filename):\n", - " print(download(filepath+filename))" + "download('https://github.com/jieunchoi/MIST_codes/raw/master/scripts/' +\n", + " 'read_mist_models.py')" ] }, { @@ -284,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -303,7 +272,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -319,7 +288,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 55, "metadata": {}, "outputs": [], "source": [ @@ -335,7 +304,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -351,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ @@ -367,7 +336,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 58, "metadata": {}, "outputs": [], "source": [ @@ -383,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 59, "metadata": {}, "outputs": [], "source": [ @@ -399,7 +368,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -415,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -425,7 +394,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -446,7 +415,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -467,7 +436,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ @@ -484,7 +453,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -505,7 +474,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -527,7 +496,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ @@ -546,18 +515,12 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ - "import os\n", - "from wget import download\n", - "\n", - "filename = 'gd1_isochrone.hdf5'\n", - "filepath = 'https://github.com/AllenDowney/AstronomicalData/raw/main/data/'\n", - "\n", - "if not os.path.exists(filename):\n", - " print(download(filepath+filename))" + "download('https://github.com/AllenDowney/AstronomicalData/raw/main/data/' +\n", + " 'gd1_isochrone.hdf5')" ] }, { @@ -569,10 +532,11 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ + "filename = 'gd1_isochrone.hdf5'\n", "iso_df = pd.read_hdf(filename, 'iso_df')\n", "iso_df.head()" ] @@ -586,7 +550,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -609,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -628,7 +592,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -647,7 +611,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 73, "metadata": {}, "outputs": [], "source": [ @@ -667,7 +631,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 74, "metadata": {}, "outputs": [], "source": [ @@ -685,7 +649,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 75, "metadata": {}, "outputs": [], "source": [ @@ -712,7 +676,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ @@ -746,7 +710,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 77, "metadata": {}, "outputs": [], "source": [ @@ -763,7 +727,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 78, "metadata": {}, "outputs": [], "source": [ @@ -780,7 +744,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ @@ -797,7 +761,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 80, "metadata": {}, "outputs": [], "source": [ @@ -816,7 +780,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 81, "metadata": {}, "outputs": [], "source": [ @@ -837,7 +801,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 82, "metadata": {}, "outputs": [], "source": [ @@ -854,7 +818,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 83, "metadata": {}, "outputs": [], "source": [ @@ -889,7 +853,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 84, "metadata": {}, "outputs": [], "source": [ @@ -909,7 +873,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 85, "metadata": {}, "outputs": [], "source": [ @@ -930,7 +894,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 86, "metadata": {}, "outputs": [], "source": [ @@ -947,7 +911,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 87, "metadata": {}, "outputs": [], "source": [ @@ -963,7 +927,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 88, "metadata": {}, "outputs": [], "source": [ @@ -979,7 +943,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 89, "metadata": {}, "outputs": [], "source": [ @@ -1003,7 +967,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 90, "metadata": {}, "outputs": [], "source": [ @@ -1043,7 +1007,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 91, "metadata": {}, "outputs": [], "source": [ @@ -1053,7 +1017,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 92, "metadata": {}, "outputs": [], "source": [ diff --git a/07_plot.ipynb b/07_plot.ipynb index 3dac4f8..f983379 100644 --- a/07_plot.ipynb +++ b/07_plot.ipynb @@ -38,36 +38,6 @@ "* Generate a figure with multiple subplots." ] }, - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "## Installing libraries\n", - "\n", - "If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n", - "\n", - "If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# If we're running on Colab, install libraries\n", - "\n", - "import sys\n", - "IN_COLAB = 'google.colab' in sys.modules\n", - "\n", - "if IN_COLAB:\n", - " !pip install wget" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -113,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -126,39 +96,50 @@ "source": [ "## Plotting GD-1\n", "\n", - "Let's start with the panel in the lower left. The following cell reloads the data." + "Let's start with the panel in the lower left. You can [download the data from the previous lesson](https://github.com/AllenDowney/AstronomicalData/raw/main/data/gd1_data.hdf) or run the following cell, which downloads it if necessary." ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ - "import os\n", - "from wget import download\n", + "from os.path import basename, exists\n", "\n", - "filename = 'gd1_data.hdf'\n", - "path = 'https://github.com/AllenDowney/AstronomicalData/raw/main/data/'\n", + "def download(url):\n", + " filename = basename(url)\n", + " if not exists(filename):\n", + " from urllib.request import urlretrieve\n", + " local, _ = urlretrieve(url, filename)\n", + " print('Downloaded ' + local)\n", "\n", - "if not os.path.exists(filename):\n", - " print(download(path+filename))" + "download('https://github.com/AllenDowney/AstronomicalData/raw/main/' +\n", + " 'data/gd1_data.hdf')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can reload `winner_df`" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", + "filename = 'gd1_data.hdf'\n", "winner_df = pd.read_hdf(filename, 'winner_df')" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 33, "metadata": {}, "outputs": [], "source": [ @@ -186,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ @@ -228,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 35, "metadata": { "tags": [] }, @@ -280,7 +261,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 36, "metadata": { "tags": [] }, @@ -302,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -318,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -356,7 +337,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -403,23 +384,17 @@ "source": [ "If you can't find a style sheet that's exactly what you want, you can make your own. This repository includes a style sheet called `az-paper-twocol.mplstyle`, with customizations chosen by Azalee Bostroem for publication in astronomy journals.\n", "\n", - "The following cell downloads the style sheet." + "You can [download the style sheet](https://github.com/AllenDowney/AstronomicalData/raw/main/az-paper-twocol.mplstyle) or run the following cell, which downloads it if necessary." ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ - "import os\n", - "from wget import download\n", - "\n", - "filename = 'az-paper-twocol.mplstyle'\n", - "path = 'https://github.com/AllenDowney/AstronomicalData/raw/main/'\n", - "\n", - "if not os.path.exists(filename):\n", - " print(download(path+filename))" + "download('https://github.com/AllenDowney/AstronomicalData/raw/main/' +\n", + " 'az-paper-twocol.mplstyle')" ] }, { @@ -487,7 +462,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ @@ -515,7 +490,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 42, "metadata": {}, "outputs": [], "source": [ @@ -555,7 +530,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 43, "metadata": {}, "outputs": [], "source": [ @@ -572,7 +547,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -596,7 +571,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -615,7 +590,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -649,7 +624,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -667,7 +642,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -684,7 +659,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -710,7 +685,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 50, "metadata": { "scrolled": true }, @@ -730,7 +705,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -763,7 +738,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -779,7 +754,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -801,7 +776,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 54, "metadata": { "tags": [] }, @@ -831,7 +806,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 55, "metadata": {}, "outputs": [], "source": [ @@ -882,7 +857,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -925,7 +900,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [