Update documentation
@@ -576,7 +576,7 @@ radial_velocity float64 km / s
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_28_0.png" src="_images/03_motion_28_0.png" />
|
||||
<img alt="_images/03_motion_29_0.png" src="_images/03_motion_29_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>The arguments to <code class="docutils literal notranslate"><span class="pre">plt.plot</span></code> are <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>, and a string that specifies the style. In this case, the letters <code class="docutils literal notranslate"><span class="pre">ko</span></code> indicate that we want a black, round marker (<code class="docutils literal notranslate"><span class="pre">k</span></code> is for black because <code class="docutils literal notranslate"><span class="pre">b</span></code> is for blue).</p>
|
||||
@@ -696,7 +696,7 @@ which is an “interface for celestial coordinate representation, manipulation,
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_45_0.png" src="_images/03_motion_45_0.png" />
|
||||
<img alt="_images/03_motion_46_0.png" src="_images/03_motion_46_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Remember that we started with a rectangle in GD-1 coordinates. When transformed to ICRS, it’s a non-rectangular polygon. Now that we have transformed back to GD-1 coordinates, it’s a rectangle again.</p>
|
||||
@@ -885,7 +885,7 @@ which is an “interface for celestial coordinate representation, manipulation,
|
||||
</div>
|
||||
<div class="section" id="exploring-data">
|
||||
<h2>Exploring data<a class="headerlink" href="#exploring-data" title="Permalink to this headline">¶</a></h2>
|
||||
<p>One benefit of using Pandas is that it provides function for exploring the data and checking for problems.</p>
|
||||
<p>One benefit of using Pandas is that it provides functions for exploring the data and checking for problems.</p>
|
||||
<p>One of the most useful of these functions is <code class="docutils literal notranslate"><span class="pre">describe</span></code>, which computes summary statistics for each column.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -1222,7 +1222,7 @@ Name: phi2, dtype: bool
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_83_0.png" src="_images/03_motion_83_0.png" />
|
||||
<img alt="_images/03_motion_84_0.png" src="_images/03_motion_84_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Looking at these results, we see a large cluster around (0, 0), and a smaller cluster near (0, -10).</p>
|
||||
@@ -1243,7 +1243,7 @@ Name: phi2, dtype: bool
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_85_0.png" src="_images/03_motion_85_0.png" />
|
||||
<img alt="_images/03_motion_86_0.png" src="_images/03_motion_86_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Now we can see the smaller cluster more clearly.</p>
|
||||
@@ -1291,7 +1291,7 @@ Name: phi2, dtype: bool
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_92_0.png" src="_images/03_motion_92_0.png" />
|
||||
<img alt="_images/03_motion_93_0.png" src="_images/03_motion_93_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>To select rows that fall within these bounds, we’ll use the following function, which uses Pandas operators to make a mask that selects rows where <code class="docutils literal notranslate"><span class="pre">series</span></code> falls between <code class="docutils literal notranslate"><span class="pre">low</span></code> and <code class="docutils literal notranslate"><span class="pre">high</span></code>.</p>
|
||||
@@ -1361,7 +1361,7 @@ Name: phi2, dtype: bool
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/03_motion_102_0.png" src="_images/03_motion_102_0.png" />
|
||||
<img alt="_images/03_motion_103_0.png" src="_images/03_motion_103_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Now that’s starting to look like a tidal stream!</p>
|
||||
|
||||
@@ -254,14 +254,26 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#selecting-the-region">
|
||||
Selecting the region
|
||||
<a class="reference internal nav-link" href="#convex-hull">
|
||||
Convex Hull
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#assemble-the-query">
|
||||
Assemble the query
|
||||
<a class="reference internal nav-link" href="#assembling-the-query">
|
||||
Assembling the query
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#exercise">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#id1">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#plotting-one-more-time">
|
||||
@@ -317,8 +329,10 @@
|
||||
<p>That will make it possible to search a bigger region of the sky in a single query.</p>
|
||||
<p>After completing this lesson, you should be able to</p>
|
||||
<ul class="simple">
|
||||
<li><p>Convert proper motion between frames.</p></li>
|
||||
<li><p>Transform proper motions from one frame to another.</p></li>
|
||||
<li><p>Compute the convex hull of a set of points.</p></li>
|
||||
<li><p>Write an ADQL query that selects based on proper motion.</p></li>
|
||||
<li><p>Save data in CSV format.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="reload-the-data">
|
||||
@@ -352,6 +366,13 @@
|
||||
</div>
|
||||
<div class="section" id="selection-by-proper-motion">
|
||||
<h2>Selection by proper motion<a class="headerlink" href="#selection-by-proper-motion" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Let’s review how we got to this point.</p>
|
||||
<ol class="simple">
|
||||
<li><p>We made an ADQL query to the Gaia server to get data for stars in the vicinity of GD-1.</p></li>
|
||||
<li><p>We transformed the coordinates to the <code class="docutils literal notranslate"><span class="pre">GD1Koposov10</span></code> frame so we could select stars along the centerline of GD-1.</p></li>
|
||||
<li><p>We plotted the proper motion of the centerline stars to identify the bounds of the overdense region.</p></li>
|
||||
<li><p>We made a mask that selects stars whose proper motion is in the overdense region.</p></li>
|
||||
</ol>
|
||||
<p>At this point we have downloaded data for a relatively large number of stars (more than 100,000) and selected a relatively small number (around 1000).</p>
|
||||
<p>It would be more efficient to use ADQL to select only the stars we need. That would also make it possible to download data covering a larger region of the sky.</p>
|
||||
<p>However, the selection we did was based on proper motion in the <code class="docutils literal notranslate"><span class="pre">GD1Koposov10</span></code> frame. In order to do the same selection in ADQL, we have to work with proper motions in ICRS.</p>
|
||||
@@ -405,7 +426,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_11_0.png" src="_images/04_select_11_0.png" />
|
||||
<img alt="_images/04_select_12_0.png" src="_images/04_select_12_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Now we’ll make the same plot using proper motions in the ICRS frame, which are stored in columns <code class="docutils literal notranslate"><span class="pre">pmra</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec</span></code>.</p>
|
||||
@@ -428,14 +449,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_13_0.png" src="_images/04_select_13_0.png" />
|
||||
<img alt="_images/04_select_14_0.png" src="_images/04_select_14_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>The proper motions of the selected stars are more spread out in this frame, which is why it was preferable to do the selection in the GD-1 frame.</p>
|
||||
<p>But now we can define a polygon that encloses the proper motions of these stars in ICRS,
|
||||
and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
<p>But now we can define a polygon that encloses the proper motions of these stars in ICRS, and use that polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
<div class="section" id="convex-hull">
|
||||
<h2>Convex Hull<a class="headerlink" href="#convex-hull" title="Permalink to this headline">¶</a></h2>
|
||||
<p>SciPy provides a function that computes the <a class="reference external" href="https://en.wikipedia.org/wiki/Convex_hull">convex hull</a> of a set of points, which is the smallest convex polygon that contains all of the points.</p>
|
||||
<p>To use it, I’ll select columns <code class="docutils literal notranslate"><span class="pre">pmra</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec</span></code> and convert them to a NumPy array.</p>
|
||||
<p>To use it, we’ll select columns <code class="docutils literal notranslate"><span class="pre">pmra</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec</span></code> and convert them to a NumPy array.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
@@ -467,7 +490,7 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span><scipy.spatial.qhull.ConvexHull at 0x7f8dec2b8c10>
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span><scipy.spatial.qhull.ConvexHull at 0x7f0d570cd700>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -523,6 +546,7 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>This use of <code class="docutils literal notranslate"><span class="pre">transpose</span></code> is a bit of a NumPy trick. Because <code class="docutils literal notranslate"><span class="pre">pm_vertices</span></code> has two columns, its transpose has two rows, which are assigned to the two variables <code class="docutils literal notranslate"><span class="pre">pmra_poly</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec_poly</span></code>.</p>
|
||||
<p>The following figure shows proper motion in ICRS again, along with the convex hull we just computed.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -545,9 +569,34 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_25_0.png" src="_images/04_select_25_0.png" />
|
||||
<img alt="_images/04_select_28_0.png" src="_images/04_select_28_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>So <code class="docutils literal notranslate"><span class="pre">pm_vertices</span></code> represents the polygon we want to select.
|
||||
The next step is to use it as part of an ADQL query.</p>
|
||||
</div>
|
||||
<div class="section" id="assembling-the-query">
|
||||
<h2>Assembling the query<a class="headerlink" href="#assembling-the-query" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Here’s the base string we used for the query in the previous lesson.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">query_base</span> <span class="o">=</span> <span class="s2">"""SELECT </span>
|
||||
<span class="si">{columns}</span><span class="s2"></span>
|
||||
<span class="s2">FROM gaiadr2.gaia_source</span>
|
||||
<span class="s2">WHERE parallax < 1</span>
|
||||
<span class="s2"> AND bp_rp BETWEEN -0.75 AND 2 </span>
|
||||
<span class="s2"> AND 1 = CONTAINS(POINT(ra, dec), </span>
|
||||
<span class="s2"> POLYGON(</span><span class="si">{point_list}</span><span class="s2">))</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>And here are the changes we’ll make in this lesson:</p>
|
||||
<ol class="simple">
|
||||
<li><p>We will add another clause to select stars whose proper motion is in the polygon we just computed, <code class="docutils literal notranslate"><span class="pre">pm_vertices</span></code>.</p></li>
|
||||
<li><p>We will select stars with coordinates in a larger region.</p></li>
|
||||
</ol>
|
||||
<p>To use <code class="docutils literal notranslate"><span class="pre">pm_vertices</span></code> as part of an ADQL query, we have to convert it to a string.</p>
|
||||
<p>We’ll use <code class="docutils literal notranslate"><span class="pre">flatten</span></code> to convert from a 2-D array to a 1-D array, and <code class="docutils literal notranslate"><span class="pre">str</span></code> to convert each element to a string.</p>
|
||||
<div class="cell docutils container">
|
||||
@@ -608,27 +657,8 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="selecting-the-region">
|
||||
<h2>Selecting the region<a class="headerlink" href="#selecting-the-region" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Let’s review how we got to this point.</p>
|
||||
<ol class="simple">
|
||||
<li><p>We made an ADQL query to the Gaia server to get data for stars in the vicinity of GD-1.</p></li>
|
||||
<li><p>We transformed to <code class="docutils literal notranslate"><span class="pre">GD1</span></code> coordinates so we could select stars along the centerline of GD-1.</p></li>
|
||||
<li><p>We plotted the proper motion of the centerline stars to identify the bounds of the overdense region.</p></li>
|
||||
<li><p>We made a mask that selects stars whose proper motion is in the overdense region.</p></li>
|
||||
</ol>
|
||||
<p>The problem is that we downloaded data for more than 100,000 stars and selected only about 1000 of them.</p>
|
||||
<p>It will be more efficient if we select on proper motion as part of the query. That will allow us to work with a larger region of the sky in a single query, and download less unneeded data.</p>
|
||||
<p>This query will select on the following conditions:</p>
|
||||
<ul class="simple">
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">parallax</span> <span class="pre"><</span> <span class="pre">1</span></code></p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">bp_rp</span> <span class="pre">BETWEEN</span> <span class="pre">-0.75</span> <span class="pre">AND</span> <span class="pre">2</span></code></p></li>
|
||||
<li><p>Coordinates within a rectangle in the GD-1 frame, transformed to ICRS.</p></li>
|
||||
<li><p>Proper motion with the polygon we just computed.</p></li>
|
||||
</ul>
|
||||
<p>The first three conditions are the same as in the previous query. Only the last one is new.</p>
|
||||
<p>Here’s the rectangle in the GD-1 frame we’ll select.</p>
|
||||
<p>We’ll add this string to the query soon, but first let’s compute the other polygon, the one that specifies the region of the sky we want.</p>
|
||||
<p>Here are the coordinates of the rectangle we’ll select, in the GD-1 frame.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">phi1_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">70</span>
|
||||
@@ -658,6 +688,11 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>WARNING: AstropyDeprecationWarning: Transforming a frame instance to a frame class (as opposed to another frame instance) will not be supported in the future. Either explicitly instantiate the target frame, or first convert the source frame instance to a `astropy.coordinates.SkyCoord` and use its `transform_to()` method. [astropy.coordinates.baseframe]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>To use <code class="docutils literal notranslate"><span class="pre">corners_icrs</span></code> as part of an ADQL query, we have to convert it to a string. Here’s how we do that, as we saw in the previous lesson.</p>
|
||||
<div class="cell docutils container">
|
||||
@@ -678,11 +713,8 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Now we have everything we need to assemble the query.</p>
|
||||
</div>
|
||||
<div class="section" id="assemble-the-query">
|
||||
<h2>Assemble the query<a class="headerlink" href="#assemble-the-query" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Here’s the base string we used for the query in the previous lesson.</p>
|
||||
<p>Now we have everything we need to assemble the query.
|
||||
Here’s the base query from the previous lesson again:</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">query_base</span> <span class="o">=</span> <span class="s2">"""SELECT </span>
|
||||
@@ -697,7 +729,9 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><strong>Exercise:</strong> Modify <code class="docutils literal notranslate"><span class="pre">query_base</span></code> by adding a new clause to select stars whose coordinates of proper motion, <code class="docutils literal notranslate"><span class="pre">pmra</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec</span></code>, fall within the polygon defined by <code class="docutils literal notranslate"><span class="pre">pm_point_list</span></code>.</p>
|
||||
<div class="section" id="exercise">
|
||||
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Modify <code class="docutils literal notranslate"><span class="pre">query_base</span></code> by adding a new clause to select stars whose coordinates of proper motion, <code class="docutils literal notranslate"><span class="pre">pmra</span></code> and <code class="docutils literal notranslate"><span class="pre">pmdec</span></code>, fall within the polygon defined by <code class="docutils literal notranslate"><span class="pre">pm_point_list</span></code>.</p>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
@@ -719,12 +753,15 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
<p>Here again are the columns we want to select.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">columns</span> <span class="o">=</span> <span class="s1">'source_id, ra, dec, pmra, pmdec, parallax, parallax_error, radial_velocity'</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">columns</span> <span class="o">=</span> <span class="s1">'source_id, ra, dec, pmra, pmdec, parallax, radial_velocity'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><strong>Exercise:</strong> Use <code class="docutils literal notranslate"><span class="pre">format</span></code> to format <code class="docutils literal notranslate"><span class="pre">query_base</span></code> and define <code class="docutils literal notranslate"><span class="pre">query</span></code>, filling in the values of <code class="docutils literal notranslate"><span class="pre">columns</span></code>, <code class="docutils literal notranslate"><span class="pre">point_list</span></code>, and <code class="docutils literal notranslate"><span class="pre">pm_point_list</span></code>.</p>
|
||||
</div>
|
||||
<div class="section" id="id1">
|
||||
<h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Use <code class="docutils literal notranslate"><span class="pre">format</span></code> to format <code class="docutils literal notranslate"><span class="pre">query_base</span></code> and define <code class="docutils literal notranslate"><span class="pre">query</span></code>, filling in the values of <code class="docutils literal notranslate"><span class="pre">columns</span></code>, <code class="docutils literal notranslate"><span class="pre">point_list</span></code>, and <code class="docutils literal notranslate"><span class="pre">pm_point_list</span></code>.</p>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
@@ -738,7 +775,7 @@ and use the polygon as a selection criterion in an ADQL query.</p>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
|
||||
source_id, ra, dec, pmra, pmdec, parallax, parallax_error, radial_velocity
|
||||
source_id, ra, dec, pmra, pmdec, parallax, radial_velocity
|
||||
FROM gaiadr2.gaia_source
|
||||
WHERE parallax < 1
|
||||
AND bp_rp BETWEEN -0.75 AND 2
|
||||
@@ -750,7 +787,7 @@ WHERE parallax < 1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Here’s how we run it.</p>
|
||||
<p>Now we can run the query like this:</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">astroquery.gaia</span> <span class="kn">import</span> <span class="n">Gaia</span>
|
||||
@@ -771,24 +808,22 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
Use HTTPS: True
|
||||
Port: 443
|
||||
SSL Port: 443
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
|
||||
<span class="ne">HTTPError</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
|
||||
<span class="o"><</span><span class="n">ipython</span><span class="o">-</span><span class="nb">input</span><span class="o">-</span><span class="mi">24</span><span class="o">-</span><span class="mi">05</span><span class="n">c718e32682</span><span class="o">></span> <span class="ow">in</span> <span class="o"><</span><span class="n">module</span><span class="o">></span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">1</span> <span class="kn">from</span> <span class="nn">astroquery.gaia</span> <span class="kn">import</span> <span class="n">Gaia</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">2</span>
|
||||
<span class="ne">----> </span><span class="mi">3</span> <span class="n">job</span> <span class="o">=</span> <span class="n">Gaia</span><span class="o">.</span><span class="n">launch_job_async</span><span class="p">(</span><span class="n">query</span><span class="p">)</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">4</span> <span class="nb">print</span><span class="p">(</span><span class="n">job</span><span class="p">)</span>
|
||||
|
||||
<span class="nn">~/anaconda3/envs/AstronomicalData/lib/python3.8/site-packages/astroquery/utils/tap/core.py</span> in <span class="ni">launch_job_async</span><span class="nt">(self, query, name, output_file, output_format, verbose, dump_to_file, background, upload_resource, upload_table_name, autorun)</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">422</span> <span class="bp">self</span><span class="o">.</span><span class="n">__connHandler</span><span class="o">.</span><span class="n">dump_to_file</span><span class="p">(</span><span class="n">suitableOutputFile</span><span class="p">,</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">423</span> <span class="n">response</span><span class="p">)</span>
|
||||
<span class="ne">--> </span><span class="mi">424</span> <span class="k">raise</span> <span class="n">requests</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">HTTPError</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">reason</span><span class="p">)</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">425</span> <span class="k">else</span><span class="p">:</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">426</span> <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__connHandler</span><span class="o">.</span><span class="n">find_header</span><span class="p">(</span>
|
||||
|
||||
<span class="ne">HTTPError</span>: OK
|
||||
INFO: Query finished. [astroquery.utils.tap.core]
|
||||
<Table length=7346>
|
||||
name dtype unit description n_bad
|
||||
--------------- ------- -------- ------------------------------------------------------------------ -----
|
||||
source_id int64 Unique source identifier (unique within a particular Data Release) 0
|
||||
ra float64 deg Right ascension 0
|
||||
dec float64 deg Declination 0
|
||||
pmra float64 mas / yr Proper motion in right ascension direction 0
|
||||
pmdec float64 mas / yr Proper motion in declination direction 0
|
||||
parallax float64 mas Parallax 0
|
||||
radial_velocity float64 km / s Radial velocity 7295
|
||||
Jobid: 1607614394159O
|
||||
Phase: COMPLETED
|
||||
Owner: None
|
||||
Output file: async_20201210103314.vot
|
||||
Results: None
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -801,6 +836,12 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>7346
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="plotting-one-more-time">
|
||||
@@ -817,6 +858,9 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_56_0.png" src="_images/04_select_56_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Here we can see why it was useful to transform these coordinates. In ICRS, it is more difficult to identity the stars near the centerline of GD-1.</p>
|
||||
<p>So, before we move on to the next step, let’s collect the code we used to transform the coordinates and make a Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>:</p>
|
||||
@@ -830,10 +874,10 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
<span class="sd"> returns: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">skycoord</span> <span class="o">=</span> <span class="n">coord</span><span class="o">.</span><span class="n">SkyCoord</span><span class="p">(</span>
|
||||
<span class="n">ra</span><span class="o">=</span><span class="n">results</span><span class="p">[</span><span class="s1">'ra'</span><span class="p">],</span>
|
||||
<span class="n">dec</span><span class="o">=</span><span class="n">results</span><span class="p">[</span><span class="s1">'dec'</span><span class="p">],</span>
|
||||
<span class="n">pm_ra_cosdec</span><span class="o">=</span><span class="n">results</span><span class="p">[</span><span class="s1">'pmra'</span><span class="p">],</span>
|
||||
<span class="n">pm_dec</span><span class="o">=</span><span class="n">results</span><span class="p">[</span><span class="s1">'pmdec'</span><span class="p">],</span>
|
||||
<span class="n">ra</span><span class="o">=</span><span class="n">table</span><span class="p">[</span><span class="s1">'ra'</span><span class="p">],</span>
|
||||
<span class="n">dec</span><span class="o">=</span><span class="n">table</span><span class="p">[</span><span class="s1">'dec'</span><span class="p">],</span>
|
||||
<span class="n">pm_ra_cosdec</span><span class="o">=</span><span class="n">table</span><span class="p">[</span><span class="s1">'pmra'</span><span class="p">],</span>
|
||||
<span class="n">pm_dec</span><span class="o">=</span><span class="n">table</span><span class="p">[</span><span class="s1">'pmdec'</span><span class="p">],</span>
|
||||
<span class="n">distance</span><span class="o">=</span><span class="mi">8</span><span class="o">*</span><span class="n">u</span><span class="o">.</span><span class="n">kpc</span><span class="p">,</span>
|
||||
<span class="n">radial_velocity</span><span class="o">=</span><span class="mi">0</span><span class="o">*</span><span class="n">u</span><span class="o">.</span><span class="n">km</span><span class="o">/</span><span class="n">u</span><span class="o">.</span><span class="n">s</span><span class="p">)</span>
|
||||
|
||||
@@ -871,6 +915,9 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_62_0.png" src="_images/04_select_62_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>We’re starting to see GD-1 more clearly.</p>
|
||||
<p>We can compare this figure with one of these panels in Figure 1 from the original paper:</p>
|
||||
@@ -899,6 +946,11 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 698K Dec 10 19:18 gd1_candidates.hdf5
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>If you are using Windows, <code class="docutils literal notranslate"><span class="pre">ls</span></code> might not work; in that case, try:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>!dir gd1_candidates.hdf5
|
||||
@@ -927,6 +979,11 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 1.4M Dec 10 19:19 gd1_candidates.csv
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The CSV file about 2 times bigger than the HDF5 file (so that’s not that bad, really).</p>
|
||||
<p>We can see the first few lines like this:</p>
|
||||
@@ -936,6 +993,13 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>,source_id,ra,dec,pmra,pmdec,parallax,radial_velocity,phi1,phi2,pm_phi1,pm_phi2
|
||||
0,635559124339440000,137.58671691646745,19.1965441084838,-3.770521900009566,-12.490481778113859,0.7913934419894347,,-59.63048941944402,-1.2164852515042963,-7.361362712597496,-0.592632882064492
|
||||
1,635860218726658176,138.5187065217173,19.09233926905897,-5.941679495793577,-11.346409129876392,0.30745551377348623,,-59.247329893833296,-2.016078400820631,-7.527126084640531,1.7487794924176672
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The CSV file contains the names of the columns, but not the data types.</p>
|
||||
<p>We can read the CSV file back like this:</p>
|
||||
@@ -953,6 +1017,84 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>source_id</th>
|
||||
<th>ra</th>
|
||||
<th>dec</th>
|
||||
<th>pmra</th>
|
||||
<th>pmdec</th>
|
||||
<th>parallax</th>
|
||||
<th>radial_velocity</th>
|
||||
<th>phi1</th>
|
||||
<th>phi2</th>
|
||||
<th>pm_phi1</th>
|
||||
<th>pm_phi2</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>635559124339440000</td>
|
||||
<td>137.586717</td>
|
||||
<td>19.196544</td>
|
||||
<td>-3.770522</td>
|
||||
<td>-12.490482</td>
|
||||
<td>0.791393</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.630489</td>
|
||||
<td>-1.216485</td>
|
||||
<td>-7.361363</td>
|
||||
<td>-0.592633</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>635860218726658176</td>
|
||||
<td>138.518707</td>
|
||||
<td>19.092339</td>
|
||||
<td>-5.941679</td>
|
||||
<td>-11.346409</td>
|
||||
<td>0.307456</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.247330</td>
|
||||
<td>-2.016078</td>
|
||||
<td>-7.527126</td>
|
||||
<td>1.748779</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>635674126383965568</td>
|
||||
<td>138.842874</td>
|
||||
<td>19.031798</td>
|
||||
<td>-3.897001</td>
|
||||
<td>-12.702780</td>
|
||||
<td>0.779463</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.133391</td>
|
||||
<td>-2.306901</td>
|
||||
<td>-7.560608</td>
|
||||
<td>-0.741800</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div></div>
|
||||
</div>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -960,6 +1102,88 @@ Created TAP+ (v1.2.1) - Connection:
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>Unnamed: 0</th>
|
||||
<th>source_id</th>
|
||||
<th>ra</th>
|
||||
<th>dec</th>
|
||||
<th>pmra</th>
|
||||
<th>pmdec</th>
|
||||
<th>parallax</th>
|
||||
<th>radial_velocity</th>
|
||||
<th>phi1</th>
|
||||
<th>phi2</th>
|
||||
<th>pm_phi1</th>
|
||||
<th>pm_phi2</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>0</td>
|
||||
<td>635559124339440000</td>
|
||||
<td>137.586717</td>
|
||||
<td>19.196544</td>
|
||||
<td>-3.770522</td>
|
||||
<td>-12.490482</td>
|
||||
<td>0.791393</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.630489</td>
|
||||
<td>-1.216485</td>
|
||||
<td>-7.361363</td>
|
||||
<td>-0.592633</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>1</td>
|
||||
<td>635860218726658176</td>
|
||||
<td>138.518707</td>
|
||||
<td>19.092339</td>
|
||||
<td>-5.941679</td>
|
||||
<td>-11.346409</td>
|
||||
<td>0.307456</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.247330</td>
|
||||
<td>-2.016078</td>
|
||||
<td>-7.527126</td>
|
||||
<td>1.748779</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>2</td>
|
||||
<td>635674126383965568</td>
|
||||
<td>138.842874</td>
|
||||
<td>19.031798</td>
|
||||
<td>-3.897001</td>
|
||||
<td>-12.702780</td>
|
||||
<td>0.779463</td>
|
||||
<td>NaN</td>
|
||||
<td>-59.133391</td>
|
||||
<td>-2.306901</td>
|
||||
<td>-7.560608</td>
|
||||
<td>-0.741800</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div></div>
|
||||
</div>
|
||||
<p>Notice that the index in <code class="docutils literal notranslate"><span class="pre">candidate_df</span></code> has become an unnamed column in <code class="docutils literal notranslate"><span class="pre">read_back_csv</span></code>. The Pandas functions for writing and reading CSV files provide options to avoid that problem, but this is an example of the kind of thing that can go wrong with CSV files.</p>
|
||||
</div>
|
||||
|
||||
@@ -262,6 +262,13 @@
|
||||
<a class="reference internal nav-link" href="#preparing-a-table-for-uploading">
|
||||
Preparing a table for uploading
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#exercise">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#uploading-a-table">
|
||||
@@ -277,6 +284,23 @@
|
||||
<a class="reference internal nav-link" href="#getting-the-photometry-data">
|
||||
Getting the photometry data
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#id1">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#id2">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#id3">
|
||||
Exercise
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#write-the-data">
|
||||
@@ -308,9 +332,9 @@
|
||||
<h1>Chapter 5<a class="headerlink" href="#chapter-5" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This is the fifth in a series of notebooks related to astronomy data.</p>
|
||||
<p>As a continuing example, we will replicate part of the analysis in a recent paper, “<a class="reference external" href="https://arxiv.org/abs/1805.00425">Off the beaten path: Gaia reveals GD-1 stars outside of the main stream</a>” by Adrian M. Price-Whelan and Ana Bonaca.</p>
|
||||
<p>Picking up where we left off, the next step in the analysis is to select candidate stars based on photometry. The following figure from the paper is a color-magnitude diagram for the stars selected based on proper motion:</p>
|
||||
<p>Picking up where we left off, the next step in the analysis is to select candidate stars based on photometry data. The following figure from the paper is a color-magnitude diagram for the stars selected based on proper motion:</p>
|
||||
<a class="reference internal image-reference" href="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-3.png"><img alt="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-3.png" src="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-3.png" style="width: 300px;" /></a>
|
||||
<p>In red is a theoretical isochrone, showing where we expect the stars in GD-1 to fall based on the metallicity and age of their original globular cluster.</p>
|
||||
<p>In red is a <a class="reference external" href="https://en.wikipedia.org/wiki/Stellar_isochrone">stellar isochrone</a>, showing where we expect the stars in GD-1 to fall based on the metallicity and age of their original globular cluster.</p>
|
||||
<p>By selecting stars in the shaded area, we can further distinguish the main sequence of GD-1 from younger background stars.</p>
|
||||
<div class="section" id="outline">
|
||||
<h2>Outline<a class="headerlink" href="#outline" title="Permalink to this headline">¶</a></h2>
|
||||
@@ -369,7 +393,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/05_join_9_0.png" src="_images/05_join_9_0.png" />
|
||||
<img alt="_images/05_join_10_0.png" src="_images/05_join_10_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>This is the same figure we saw at the end of the previous notebook. GD-1 is visible against the background stars, but we will be able to see it more clearly after selecting based on photometry data.</p>
|
||||
@@ -450,7 +474,7 @@ We could write the entire table to a file, but that would take longer to transmi
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span><?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Produced with astropy.io.votable version 4.0.2
|
||||
<!-- Produced with astropy.io.votable version 4.2
|
||||
http://www.astropy.org/ -->
|
||||
<VOTABLE version="1.4" xmlns="http://www.ivoa.net/xml/VOTable/v1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/v1.4">
|
||||
<RESOURCE type="results">
|
||||
@@ -475,7 +499,7 @@ The size of the file is about 750 KB, so that’s not too bad.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 396K Nov 18 19:21 candidate_df.xml
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 396K Dec 10 11:33 candidate_df.xml
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -484,7 +508,9 @@ The size of the file is about 750 KB, so that’s not too bad.</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>!dir candidate_df.xml
|
||||
</pre></div>
|
||||
</div>
|
||||
<p><strong>Exercise:</strong> There’s a gotcha here we want to warn you about. Why do you think we used double brackets to specify the column we wanted? What happens if you use single brackets?</p>
|
||||
<div class="section" id="exercise">
|
||||
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline">¶</a></h3>
|
||||
<p>There’s a gotcha here we want to warn you about. Why do you think we used double brackets to specify the column we wanted? What happens if you use single brackets?</p>
|
||||
<p>Run these cells to find out.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -514,12 +540,15 @@ The size of the file is about 750 KB, so that’s not too bad.</p>
|
||||
</div>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># writeto(column, 'candidate_df.xml')</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># This line is commented out because it would cause an error</span>
|
||||
|
||||
<span class="c1"># writeto(column, 'candidate_df.xml')</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="uploading-a-table">
|
||||
<h2>Uploading a table<a class="headerlink" href="#uploading-a-table" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The next step is to upload this table to the Gaia server and use it as part of a query.</p>
|
||||
@@ -575,7 +604,7 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><i>Table length=7346</i>
|
||||
<table id="table140178070186304" class="table-striped table-bordered table-condensed">
|
||||
<table id="table140668290919488" class="table-striped table-bordered table-condensed">
|
||||
<thead><tr><th>source_id</th></tr></thead>
|
||||
<thead><tr><th>int64</th></tr></thead>
|
||||
<tr><td>635559124339440000</td></tr>
|
||||
@@ -637,7 +666,7 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">query1</span> <span class="o">=</span> <span class="s2">"""SELECT *</span>
|
||||
<span class="s2">FROM gaiadr2.panstarrs1_best_neighbour as best</span>
|
||||
<span class="s2">JOIN tap_upload.candidate_df as candidate_df</span>
|
||||
<span class="s2">ON best.source_id = candidate_df.source_id</span>
|
||||
<span class="s2"> ON best.source_id = candidate_df.source_id</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -676,7 +705,7 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><i>Table length=3724</i>
|
||||
<table id="table140178046436112" class="table-striped table-bordered table-condensed">
|
||||
<table id="table140668268803072" class="table-striped table-bordered table-condensed">
|
||||
<thead><tr><th>source_id</th><th>original_ext_source_id</th><th>angular_distance</th><th>number_of_neighbours</th><th>number_of_mates</th><th>best_neighbour_multiplicity</th><th>gaia_astrometric_params</th><th>source_id_2</th></tr></thead>
|
||||
<thead><tr><th></th><th></th><th>arcsec</th><th></th><th></th><th></th><th></th><th></th></tr></thead>
|
||||
<thead><tr><th>int64</th><th>int64</th><th>float64</th><th>int32</th><th>int16</th><th>int16</th><th>int16</th><th>int64</th></tr></thead>
|
||||
@@ -723,7 +752,7 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
</div>
|
||||
</div>
|
||||
<p>Because one of the column names appears in both tables, the second instance of <code class="docutils literal notranslate"><span class="pre">source_id</span></code> has been appended with the suffix <code class="docutils literal notranslate"><span class="pre">_2</span></code>.</p>
|
||||
<p>The length of the results table is about 2000, which means we were not able to find matches for all stars in the list of candidate_df.</p>
|
||||
<p>The length of <code class="docutils literal notranslate"><span class="pre">results1</span></code> is about 3000, which means we were not able to find matches for all stars in the list of candidates.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">len</span><span class="p">(</span><span class="n">results1</span><span class="p">)</span>
|
||||
@@ -737,42 +766,92 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
</div>
|
||||
</div>
|
||||
<p>To get more information about the matching process, we can inspect <code class="docutils literal notranslate"><span class="pre">best_neighbour_multiplicity</span></code>, which indicates for each star in Gaia how many stars in Pan-STARRS are equally likely matches.</p>
|
||||
<p>For this kind of data exploration, we’ll convert a column from the table to a Pandas <code class="docutils literal notranslate"><span class="pre">Series</span></code> so we can use <code class="docutils literal notranslate"><span class="pre">value_counts</span></code>, which counts the number of times each value appears in a <code class="docutils literal notranslate"><span class="pre">Series</span></code>, like a histogram.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">results1</span><span class="p">[</span><span class="s1">'best_neighbour_multiplicity'</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><MaskedColumn name='best_neighbour_multiplicity' dtype='int16' description='Number of neighbours with same probability as best neighbour' length=3724>
|
||||
<table>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>...</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
<tr><td>1</td></tr>
|
||||
</table></div></div>
|
||||
</div>
|
||||
<p>It looks like most of the values are <code class="docutils literal notranslate"><span class="pre">1</span></code>, which is good; that means that for each candidate star we have identified exactly one source in Pan-STARRS that is likely to be the same star.</p>
|
||||
<p>To check whether there are any values other than <code class="docutils literal notranslate"><span class="pre">1</span></code>, we can convert this column to a Pandas <code class="docutils literal notranslate"><span class="pre">Series</span></code> and use <code class="docutils literal notranslate"><span class="pre">describe</span></code>, which we saw in in Lesson 3.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
<span class="n">nn</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">results1</span><span class="p">[</span><span class="s1">'best_neighbour_multiplicity'</span><span class="p">])</span>
|
||||
<span class="n">nn</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()</span>
|
||||
<span class="n">multiplicity</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">results1</span><span class="p">[</span><span class="s1">'best_neighbour_multiplicity'</span><span class="p">])</span>
|
||||
<span class="n">multiplicity</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>1 3724
|
||||
dtype: int64
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>count 3724.0
|
||||
mean 1.0
|
||||
std 0.0
|
||||
min 1.0
|
||||
25% 1.0
|
||||
50% 1.0
|
||||
75% 1.0
|
||||
max 1.0
|
||||
dtype: float64
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The result shows that <code class="docutils literal notranslate"><span class="pre">1</span></code> is the only value in the <code class="docutils literal notranslate"><span class="pre">Series</span></code>, appearing xxx times.</p>
|
||||
<p>That means that in every case where a match was found, the matching algorithm identified a single neighbor as the most likely match.</p>
|
||||
<p>Similarly, <code class="docutils literal notranslate"><span class="pre">number_of_mates</span></code> indicates the number of other stars in Gaia that match with the same star in Pan-STARRS.</p>
|
||||
<p>In fact, <code class="docutils literal notranslate"><span class="pre">1</span></code> is the only value in the <code class="docutils literal notranslate"><span class="pre">Series</span></code>, so every candidate star has a single best match.</p>
|
||||
<p>Similarly, <code class="docutils literal notranslate"><span class="pre">number_of_mates</span></code> indicates the number of <em>other</em> stars in Gaia that match with the same star in Pan-STARRS.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">nm</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">results1</span><span class="p">[</span><span class="s1">'number_of_mates'</span><span class="p">])</span>
|
||||
<span class="n">nm</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">mates</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">(</span><span class="n">results1</span><span class="p">[</span><span class="s1">'number_of_mates'</span><span class="p">])</span>
|
||||
<span class="n">mates</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0 3724
|
||||
dtype: int64
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>count 3724.0
|
||||
mean 0.0
|
||||
std 0.0
|
||||
min 0.0
|
||||
25% 0.0
|
||||
50% 0.0
|
||||
75% 0.0
|
||||
max 0.0
|
||||
dtype: float64
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>For this set of candidate_df, almost all of the stars we’ve selected from Pan-STARRS are only matched with a single star in the Gaia catalog.</p>
|
||||
<p><strong>Detail</strong> The table also contains <code class="docutils literal notranslate"><span class="pre">number_of_neighbors</span></code> which is the number of stars in Pan-STARRS that match in terms of position, before using other critieria to choose the most likely match.</p>
|
||||
<p>All values in this column are <code class="docutils literal notranslate"><span class="pre">0</span></code>, which means that for each match we found in Pan-STARRS, there are no other stars in Gaia that also match.</p>
|
||||
<p><strong>Detail:</strong> The table also contains <code class="docutils literal notranslate"><span class="pre">number_of_neighbors</span></code> which is the number of stars in Pan-STARRS that match in terms of position, before using other criteria to choose the most likely match.</p>
|
||||
</div>
|
||||
<div class="section" id="getting-the-photometry-data">
|
||||
<h2>Getting the photometry data<a class="headerlink" href="#getting-the-photometry-data" title="Permalink to this headline">¶</a></h2>
|
||||
@@ -785,7 +864,9 @@ dtype: int64
|
||||
<li><p>Run the query using the uploaded table.</p></li>
|
||||
</ol>
|
||||
<p>Since we’ve done everything here before, we’ll do these steps as an exercise.</p>
|
||||
<p><strong>Exercise:</strong> Select <code class="docutils literal notranslate"><span class="pre">source_id</span></code> and <code class="docutils literal notranslate"><span class="pre">original_ext_source_id</span></code> from <code class="docutils literal notranslate"><span class="pre">results1</span></code> and write the resulting table as a file named <code class="docutils literal notranslate"><span class="pre">external.xml</span></code>.</p>
|
||||
<div class="section" id="id1">
|
||||
<h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Select <code class="docutils literal notranslate"><span class="pre">source_id</span></code> and <code class="docutils literal notranslate"><span class="pre">original_ext_source_id</span></code> from <code class="docutils literal notranslate"><span class="pre">results1</span></code> and write the resulting table as a file named <code class="docutils literal notranslate"><span class="pre">external.xml</span></code>.</p>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
@@ -805,7 +886,7 @@ dtype: int64
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span><?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Produced with astropy.io.votable version 4.0.2
|
||||
<!-- Produced with astropy.io.votable version 4.2
|
||||
http://www.astropy.org/ -->
|
||||
<VOTABLE version="1.4" xmlns="http://www.ivoa.net/xml/VOTable/v1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/v1.4">
|
||||
<RESOURCE type="results">
|
||||
@@ -818,7 +899,10 @@ dtype: int64
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><strong>Exercise:</strong> Read <a class="reference external" href="https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_external_catalogues/ssec_dm_panstarrs1_original_valid.html">the documentation of the Pan-STARRS table</a> and make note of <code class="docutils literal notranslate"><span class="pre">obj_id</span></code>, which contains the object IDs we’ll use to find the rows we want.</p>
|
||||
</div>
|
||||
<div class="section" id="id2">
|
||||
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Read <a class="reference external" href="https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_external_catalogues/ssec_dm_panstarrs1_original_valid.html">the documentation of the Pan-STARRS table</a> and make note of <code class="docutils literal notranslate"><span class="pre">obj_id</span></code>, which contains the object IDs we’ll use to find the rows we want.</p>
|
||||
<p>Write a query that uses each value of <code class="docutils literal notranslate"><span class="pre">original_ext_source_id</span></code> from the uploaded table to find a row in <code class="docutils literal notranslate"><span class="pre">gaiadr2.panstarrs1_original_valid</span></code> with the same value in <code class="docutils literal notranslate"><span class="pre">obj_id</span></code>, and select all columns from both tables.</p>
|
||||
<p>Suggestion: Develop and test your query incrementally. For example:</p>
|
||||
<ol class="simple">
|
||||
@@ -837,67 +921,39 @@ dtype: int64
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
|
||||
<span class="c1"># First test</span>
|
||||
|
||||
<span class="n">query2</span> <span class="o">=</span> <span class="s2">"""SELECT *</span>
|
||||
<span class="s2">FROM tap_upload.external as external</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
|
||||
<span class="c1"># Second test</span>
|
||||
|
||||
<span class="n">query2</span> <span class="o">=</span> <span class="s2">"""SELECT TOP 10 *</span>
|
||||
<span class="s2">FROM gaiadr2.panstarrs1_original_valid</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
|
||||
<span class="c1"># Third test</span>
|
||||
|
||||
<span class="n">query2</span> <span class="o">=</span> <span class="s2">"""SELECT *</span>
|
||||
<span class="s2">FROM gaiadr2.panstarrs1_original_valid as ps</span>
|
||||
<span class="s2">JOIN tap_upload.external as external</span>
|
||||
<span class="s2">ON ps.obj_id = external.original_ext_source_id</span>
|
||||
<span class="s2"> ON ps.obj_id = external.original_ext_source_id</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
|
||||
<span class="c1"># Complete query</span>
|
||||
|
||||
<span class="n">query2</span> <span class="o">=</span> <span class="s2">"""SELECT</span>
|
||||
<span class="s2">external.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag</span>
|
||||
<span class="s2">FROM gaiadr2.panstarrs1_original_valid as ps</span>
|
||||
<span class="s2">JOIN tap_upload.external as external</span>
|
||||
<span class="s2">ON ps.obj_id = external.original_ext_source_id</span>
|
||||
<span class="s2"> ON ps.obj_id = external.original_ext_source_id</span>
|
||||
<span class="s2">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="n">query2</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
|
||||
external.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag
|
||||
FROM gaiadr2.panstarrs1_original_valid as ps
|
||||
JOIN tap_upload.external as external
|
||||
ON ps.obj_id = external.original_ext_source_id
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Here’s how we launch the job and get the results.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">job2</span> <span class="o">=</span> <span class="n">Gaia</span><span class="o">.</span><span class="n">launch_job_async</span><span class="p">(</span><span class="n">query</span><span class="o">=</span><span class="n">query2</span><span class="p">,</span>
|
||||
@@ -921,7 +977,7 @@ ON ps.obj_id = external.original_ext_source_id
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_html"><i>Table length=3724</i>
|
||||
<table id="table140178044101488" class="table-striped table-bordered table-condensed">
|
||||
<table id="table140668299958448" class="table-striped table-bordered table-condensed">
|
||||
<thead><tr><th>source_id</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>
|
||||
<thead><tr><th></th><th></th><th>mag</th></tr></thead>
|
||||
<thead><tr><th>int64</th><th>float64</th><th>float64</th></tr></thead>
|
||||
@@ -947,9 +1003,65 @@ ON ps.obj_id = external.original_ext_source_id
|
||||
<tr><td>612256418500423168</td><td>20.8715991973877</td><td>19.9612007141113</td></tr>
|
||||
</table></div></div>
|
||||
</div>
|
||||
<p><strong>Challenge exercise</strong></p>
|
||||
<p>Do both joins in one query.</p>
|
||||
</div>
|
||||
<div class="section" id="id3">
|
||||
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Optional Challenge: Do both joins in one query.</p>
|
||||
<p>There’s an <a class="reference external" href="https://github.com/smoh/Getting-started-with-Gaia/blob/master/gaia-adql-snippets.md">example here</a> you could start with.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
|
||||
|
||||
<span class="n">query3</span> <span class="o">=</span> <span class="s2">"""SELECT</span>
|
||||
<span class="s2">candidate_df.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag</span>
|
||||
<span class="s2">FROM tap_upload.candidate_df as candidate_df</span>
|
||||
<span class="s2">JOIN gaiadr2.panstarrs1_best_neighbour as best</span>
|
||||
<span class="s2"> ON best.source_id = candidate_df.source_id</span>
|
||||
<span class="s2">JOIN gaiadr2.panstarrs1_original_valid as ps</span>
|
||||
<span class="s2"> ON ps.obj_id = best.original_ext_source_id</span>
|
||||
<span class="s2">"""</span>
|
||||
|
||||
<span class="n">job3</span> <span class="o">=</span> <span class="n">Gaia</span><span class="o">.</span><span class="n">launch_job_async</span><span class="p">(</span><span class="n">query</span><span class="o">=</span><span class="n">query3</span><span class="p">,</span>
|
||||
<span class="n">upload_resource</span><span class="o">=</span><span class="s1">'candidate_df.xml'</span><span class="p">,</span>
|
||||
<span class="n">upload_table_name</span><span class="o">=</span><span class="s1">'candidate_df'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">results3</span> <span class="o">=</span> <span class="n">job3</span><span class="o">.</span><span class="n">get_results</span><span class="p">()</span>
|
||||
<span class="n">results3</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output text_html"><i>Table length=3724</i>
|
||||
<table id="table140668275467456" class="table-striped table-bordered table-condensed">
|
||||
<thead><tr><th>source_id</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>
|
||||
<thead><tr><th></th><th></th><th>mag</th></tr></thead>
|
||||
<thead><tr><th>int64</th><th>float64</th><th>float64</th></tr></thead>
|
||||
<tr><td>635860218726658176</td><td>17.8978004455566</td><td>17.5174007415771</td></tr>
|
||||
<tr><td>635674126383965568</td><td>19.2873001098633</td><td>17.6781005859375</td></tr>
|
||||
<tr><td>635535454774983040</td><td>16.9237995147705</td><td>16.478099822998</td></tr>
|
||||
<tr><td>635497276810313600</td><td>19.9242000579834</td><td>18.3339996337891</td></tr>
|
||||
<tr><td>635614168640132864</td><td>16.1515998840332</td><td>14.6662998199463</td></tr>
|
||||
<tr><td>635598607974369792</td><td>16.5223999023438</td><td>16.1375007629395</td></tr>
|
||||
<tr><td>635737661835496576</td><td>14.5032997131348</td><td>13.9849004745483</td></tr>
|
||||
<tr><td>635850945892748672</td><td>16.5174999237061</td><td>16.0450000762939</td></tr>
|
||||
<tr><td>635600532119713664</td><td>20.4505996704102</td><td>19.5177001953125</td></tr>
|
||||
<tr><td>...</td><td>...</td><td>...</td></tr>
|
||||
<tr><td>612241781249124608</td><td>20.2343997955322</td><td>18.6518001556396</td></tr>
|
||||
<tr><td>612332147361443072</td><td>21.3848991394043</td><td>20.3076000213623</td></tr>
|
||||
<tr><td>612426744016802432</td><td>17.8281002044678</td><td>17.4281005859375</td></tr>
|
||||
<tr><td>612331739340341760</td><td>21.8656997680664</td><td>19.5223007202148</td></tr>
|
||||
<tr><td>612282738058264960</td><td>22.5151996612549</td><td>19.9743995666504</td></tr>
|
||||
<tr><td>612386332668697600</td><td>19.3792991638184</td><td>17.9923000335693</td></tr>
|
||||
<tr><td>612296172717818624</td><td>17.4944000244141</td><td>16.926700592041</td></tr>
|
||||
<tr><td>612250375480101760</td><td>15.3330001831055</td><td>14.6280002593994</td></tr>
|
||||
<tr><td>612394926899159168</td><td>16.4414005279541</td><td>15.8212003707886</td></tr>
|
||||
<tr><td>612256418500423168</td><td>20.8715991973877</td><td>19.9612007141113</td></tr>
|
||||
</table></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="write-the-data">
|
||||
<h2>Write the data<a class="headerlink" href="#write-the-data" title="Permalink to this headline">¶</a></h2>
|
||||
@@ -970,7 +1082,7 @@ ON ps.obj_id = external.original_ext_source_id
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 96K Nov 18 19:22 gd1_photo.fits
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 96K Dec 10 11:34 gd1_photo.fits
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -429,7 +429,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_13_0.png" src="_images/07_plot_13_0.png" />
|
||||
<img alt="_images/07_plot_14_0.png" src="_images/07_plot_14_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -737,7 +737,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_50_0.png" src="_images/07_plot_50_0.png" />
|
||||
<img alt="_images/07_plot_51_0.png" src="_images/07_plot_51_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -794,7 +794,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_57_0.png" src="_images/07_plot_57_0.png" />
|
||||
<img alt="_images/07_plot_58_0.png" src="_images/07_plot_58_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -845,7 +845,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_63_0.png" src="_images/07_plot_63_0.png" />
|
||||
<img alt="_images/07_plot_64_0.png" src="_images/07_plot_64_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p><strong>Exercise:</strong> Add a few lines to <code class="docutils literal notranslate"><span class="pre">plot_cmd</span></code> to show the Polygon we selected as a shaded area.</p>
|
||||
@@ -931,7 +931,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_69_0.png" src="_images/07_plot_69_0.png" />
|
||||
<img alt="_images/07_plot_70_0.png" src="_images/07_plot_70_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>We use <a class="reference external" href="https://matplotlib.org/3.3.1/tutorials/intermediate/tight_layout_guide.html"><code class="docutils literal notranslate"><span class="pre">plt.tight_layout</span></code></a> at the end, which adjusts the sizes of the panels to make sure the titles and axis labels don’t overlap.</p>
|
||||
@@ -969,7 +969,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/07_plot_72_0.png" src="_images/07_plot_72_0.png" />
|
||||
<img alt="_images/07_plot_73_0.png" src="_images/07_plot_73_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>This is looking more and more like the figure in the paper.</p>
|
||||
|
||||
@@ -1,337 +0,0 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Astronomical Data in Python — Astronomical Data in Python</title>
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/index.d431a4ee1c1efae0e38bdfebc22debff.css">
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../_static/vendor/open-sans_all/1.44.1/index.css">
|
||||
<link rel="stylesheet"
|
||||
href="../_static/vendor/lato_latin-ext/1.44.1/index.css">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/sphinx-book-theme.bfb7730f9caf2ec0b46a44615585038c.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/togglebutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/mystnb.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/sphinx-thebe.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
|
||||
|
||||
<link rel="preload" as="script" href="../_static/js/index.30270b6e4c972e43c488.js">
|
||||
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<script src="../_static/togglebutton.js"></script>
|
||||
<script src="../_static/clipboard.min.js"></script>
|
||||
<script src="../_static/copybutton.js"></script>
|
||||
<script >var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
|
||||
<script src="../_static/sphinx-book-theme.be0a4a0c39cd630af62a2fcf693f3f06.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]], "processRefs": false, "processEnvironments": false}})</script>
|
||||
<script async="async" src="https://unpkg.com/thebelab@latest/lib/index.js"></script>
|
||||
<script >
|
||||
const thebe_selector = ".thebe"
|
||||
const thebe_selector_input = "pre"
|
||||
const thebe_selector_output = ".output"
|
||||
</script>
|
||||
<script async="async" src="../_static/sphinx-thebe.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="docsearch:language" content="en" />
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
|
||||
|
||||
|
||||
<div class="container-xl">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
|
||||
|
||||
<div class="navbar-brand-box">
|
||||
<a class="navbar-brand text-wrap" href="../index.html">
|
||||
|
||||
|
||||
<h1 class="site-logo" id="site-title">Astronomical Data in Python</h1>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form class="bd-search d-flex align-items-center" action="../search.html" method="get">
|
||||
<i class="icon fas fa-search"></i>
|
||||
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
|
||||
</form>
|
||||
|
||||
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../README.html">
|
||||
Astronomical Data in Python
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../01_query.html">
|
||||
Lesson 1
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../02_coords.html">
|
||||
Lesson 2
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<!-- To handle the deprecated key -->
|
||||
|
||||
<div class="navbar_extra_footer">
|
||||
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
|
||||
|
||||
<div class="row topbar fixed-top container-xl">
|
||||
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show">
|
||||
</div>
|
||||
<div class="col pl-2 topbar-main">
|
||||
|
||||
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
|
||||
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
|
||||
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
|
||||
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
|
||||
<i class="fas fa-bars"></i>
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-buttons-trigger">
|
||||
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
|
||||
class="fas fa-download"></i></button>
|
||||
|
||||
|
||||
<div class="dropdown-buttons">
|
||||
<!-- ipynb file if we had a myst markdown file -->
|
||||
|
||||
<!-- Download raw file -->
|
||||
<a class="dropdown-buttons" href="../_sources/AstronomicalData/README.md"><button type="button"
|
||||
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
|
||||
data-placement="left">.md</button></a>
|
||||
<!-- Download PDF via print -->
|
||||
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
|
||||
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Source interaction buttons -->
|
||||
|
||||
|
||||
<!-- Full screen (wrap in <a> to have style consistency -->
|
||||
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
|
||||
data-placement="bottom" onclick="toggleFullScreen()" title="Fullscreen mode"><i
|
||||
class="fas fa-expand"></i></button></a>
|
||||
|
||||
<!-- Launch buttons -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Table of contents -->
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-content" class="row">
|
||||
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
|
||||
|
||||
<div>
|
||||
|
||||
<div class="section" id="astronomical-data-in-python">
|
||||
<h1>Astronomical Data in Python<a class="headerlink" href="#astronomical-data-in-python" title="Permalink to this headline">¶</a></h1>
|
||||
<p><em>Astronomical Data in Python</em> is an introduction to tools and practices for working with astronomical data. Topics covered include:</p>
|
||||
<ul class="simple">
|
||||
<li><p>Writing queries that select and download data from a database.</p></li>
|
||||
<li><p>Using data stored in an Astropy <code class="docutils literal notranslate"><span class="pre">Table</span></code> or Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>.</p></li>
|
||||
<li><p>Working with coordinates and other quantities with units.</p></li>
|
||||
<li><p>Storing data in various formats.</p></li>
|
||||
<li><p>Performing database join operations that combine data from multiple tables.</p></li>
|
||||
<li><p>Visualizing data and preparing publication-quality figures.</p></li>
|
||||
</ul>
|
||||
<p>As a running example, we will replicate part of the analysis in a recent paper, “<a class="reference external" href="https://arxiv.org/abs/1805.00425">Off the beaten path: Gaia reveals GD-1 stars outside of the main stream</a>” by Adrian M. Price-Whelan and Ana Bonaca.</p>
|
||||
<p>This material was developed in collaboration with <a class="reference external" href="https://carpentries.org/">The Carpentries</a> and the Astronomy Curriculum Development Committee, and supported by funding from the American Institute of Physics through the American Astronomical Society.</p>
|
||||
<p>I am grateful for contributions from the members of the committee – Azalee Bostroem, Rodolfo Montez, and Phil Rosenfield – and from Erin Becker, Brett Morris and Adrian Price-Whelan.</p>
|
||||
<p>The original format of this material is a series of Jupyter notebooks. Using the
|
||||
links below, you can read the notebooks on NBViewer or run them on Colab. If you
|
||||
want to run the notebooks in your own environment, you can download them from
|
||||
this repository and follow the instructions below to set up your environment.</p>
|
||||
<p>This material is also available in the form of <a class="reference external" href="https://datacarpentry.github.io/astronomy-python">Carpentries lessons</a>, but you should be
|
||||
aware that these versions might diverge in the future.</p>
|
||||
<p><strong>Prerequisites</strong></p>
|
||||
<p>This material should be accessible to people familiar with basic Python, but not necessarily the libraries we will use, like Astropy or Pandas. If you are familiar with Python lists and dictionaries, and you know how to write a function that takes parameters and returns a value, that should be enough.</p>
|
||||
<p>We assume that you are familiar with astronomy at the undergraduate level, but we will not assume specialized knowledge of the datasets or analysis methods we’ll use.</p>
|
||||
<p><strong>Notebook 1</strong></p>
|
||||
<p>This notebook demonstrates the following steps:</p>
|
||||
<ol class="simple">
|
||||
<li><p>Making a connection to the Gaia server,</p></li>
|
||||
<li><p>Exploring information about the database and the tables it contains,</p></li>
|
||||
<li><p>Writing a query and sending it to the server, and finally</p></li>
|
||||
<li><p>Downloading the response from the server as an Astropy <code class="docutils literal notranslate"><span class="pre">Table</span></code>.</p></li>
|
||||
</ol>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/01_query.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/01_query.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 2</strong></p>
|
||||
<p>This notebook starts with an example that does a “cone search”; that is, it selects stars that appear in a circular region of the sky.</p>
|
||||
<p>Then, to select stars in the vicinity of GD-1, we:</p>
|
||||
<ul class="simple">
|
||||
<li><p>Use <code class="docutils literal notranslate"><span class="pre">Quantity</span></code> objects to represent measurements with units.</p></li>
|
||||
<li><p>Use the <code class="docutils literal notranslate"><span class="pre">Gala</span></code> library to convert coordinates from one frame to another.</p></li>
|
||||
<li><p>Use the ADQL keywords <code class="docutils literal notranslate"><span class="pre">POLYGON</span></code>, <code class="docutils literal notranslate"><span class="pre">CONTAINS</span></code>, and <code class="docutils literal notranslate"><span class="pre">POINT</span></code> to select stars that fall within a polygonal region.</p></li>
|
||||
<li><p>Submit a query and download the results.</p></li>
|
||||
<li><p>Store the results in a FITS file.</p></li>
|
||||
</ul>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/02_coords.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/02_coords.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 3</strong></p>
|
||||
<p>Here are the steps in this notebook:</p>
|
||||
<ol class="simple">
|
||||
<li><p>We’ll read back the results from the previous notebook, which we saved in a FITS file.</p></li>
|
||||
<li><p>Then we’ll transform the coordinates and proper motion data from ICRS back to the coordinate frame of GD-1.</p></li>
|
||||
<li><p>We’ll put those results into a Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>, which we’ll use to select stars near the centerline of GD-1.</p></li>
|
||||
<li><p>Plotting the proper motion of those stars, we’ll identify a region of proper motion for stars that are likely to be in GD-1.</p></li>
|
||||
<li><p>Finally, we’ll select and plot the stars whose proper motion is in that region.</p></li>
|
||||
</ol>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/03_motion.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/03_motion.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 4</strong></p>
|
||||
<p>Here are the steps in this notebook:</p>
|
||||
<ol class="simple">
|
||||
<li><p>Using data from the previous notebook, we’ll identify the values of proper motion for stars likely to be in GD-1.</p></li>
|
||||
<li><p>Then we’ll compose an ADQL query that selects stars based on proper motion, so we can download only the data we need.</p></li>
|
||||
<li><p>We’ll also see how to write the results to a CSV file.</p></li>
|
||||
</ol>
|
||||
<p>That will make it possible to search a bigger region of the sky in a single query.</p>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/04_select.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/04_select.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 5</strong></p>
|
||||
<p>Here are the steps in this notebook:</p>
|
||||
<ol class="simple">
|
||||
<li><p>We’ll reload the candidate stars we identified in the previous notebook.</p></li>
|
||||
<li><p>Then we’ll run a query on the Gaia server that uploads the table of candidates and uses a <code class="docutils literal notranslate"><span class="pre">JOIN</span></code> operation to select photometry data for the candidate stars.</p></li>
|
||||
<li><p>We’ll write the results to a file for use in the next notebook.</p></li>
|
||||
</ol>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/05_join.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/05_join.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 6</strong></p>
|
||||
<p>Here are the steps in this notebook:</p>
|
||||
<ol class="simple">
|
||||
<li><p>We’ll reload the data from the previous notebook and make a color-magnitude diagram.</p></li>
|
||||
<li><p>Then we’ll specify a polygon in the diagram that contains stars with the photometry we expect.</p></li>
|
||||
<li><p>Then we’ll merge the photometry data with the list of candidate stars, storing the result in a Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>.</p></li>
|
||||
</ol>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/06_photo.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/06_photo.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Notebook 7</strong></p>
|
||||
<p>Here are the steps in this notebook:</p>
|
||||
<ol class="simple">
|
||||
<li><p>Starting with the figure from the previous notebook, we’ll add annotations to present the results more clearly.</p></li>
|
||||
<li><p>The we’ll see several ways to customize figures to make them more appealing and effective.</p></li>
|
||||
<li><p>Finally, we’ll see how to make a figure with multiple panels or subplots.</p></li>
|
||||
</ol>
|
||||
<p>Press this button to run this notebook on Colab:</p>
|
||||
<p><a class="reference external" href="https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/07_plot.ipynb"><img src="run_on_colab_small.png"></a></p>
|
||||
<p><a class="reference external" href="https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/07_plot.ipynb">or click here to read it on NBViewer</a></p>
|
||||
<p><strong>Installation instructions</strong></p>
|
||||
<p>Coming soon.</p>
|
||||
</div>
|
||||
|
||||
<script type="text/x-thebe-config">
|
||||
{
|
||||
requestKernel: true,
|
||||
binderOptions: {
|
||||
repo: "binder-examples/jupyter-stacks-datascience",
|
||||
ref: "master",
|
||||
},
|
||||
codeMirrorConfig: {
|
||||
theme: "abcdef",
|
||||
mode: "python"
|
||||
},
|
||||
kernelOptions: {
|
||||
kernelName: "python3",
|
||||
path: "./AstronomicalData"
|
||||
},
|
||||
predefinedOutput: true
|
||||
}
|
||||
</script>
|
||||
<script>kernelName = 'python3'</script>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='prev-next-bottom'>
|
||||
|
||||
|
||||
</div>
|
||||
<footer class="footer mt-5 mt-md-0">
|
||||
<div class="container">
|
||||
<p>
|
||||
|
||||
By Allen B. Downey<br/>
|
||||
|
||||
© Copyright 2020.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="../_static/js/index.30270b6e4c972e43c488.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,260 +0,0 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><no title> — Astronomical Data in Python</title>
|
||||
|
||||
<link rel="stylesheet" href="../../../../../../../_static/css/index.d431a4ee1c1efae0e38bdfebc22debff.css">
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/css/all.min.css">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/open-sans_all/1.44.1/index.css">
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/lato_latin-ext/1.44.1/index.css">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../../../../../../../_static/sphinx-book-theme.bfb7730f9caf2ec0b46a44615585038c.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../../../../../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/togglebutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/copybutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/mystnb.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/sphinx-thebe.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
|
||||
|
||||
<link rel="preload" as="script" href="../../../../../../../_static/js/index.30270b6e4c972e43c488.js">
|
||||
|
||||
<script id="documentation_options" data-url_root="../../../../../../../" src="../../../../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../../../../_static/language_data.js"></script>
|
||||
<script src="../../../../../../../_static/togglebutton.js"></script>
|
||||
<script src="../../../../../../../_static/clipboard.min.js"></script>
|
||||
<script src="../../../../../../../_static/copybutton.js"></script>
|
||||
<script >var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
|
||||
<script src="../../../../../../../_static/sphinx-book-theme.be0a4a0c39cd630af62a2fcf693f3f06.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]], "processRefs": false, "processEnvironments": false}})</script>
|
||||
<script async="async" src="https://unpkg.com/thebelab@latest/lib/index.js"></script>
|
||||
<script >
|
||||
const thebe_selector = ".thebe"
|
||||
const thebe_selector_input = "pre"
|
||||
const thebe_selector_output = ".output"
|
||||
</script>
|
||||
<script async="async" src="../../../../../../../_static/sphinx-thebe.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../../../../search.html" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="docsearch:language" content="en" />
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
|
||||
|
||||
|
||||
<div class="container-xl">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
|
||||
|
||||
<div class="navbar-brand-box">
|
||||
<a class="navbar-brand text-wrap" href="../../../../../../../index.html">
|
||||
|
||||
|
||||
<h1 class="site-logo" id="site-title">Astronomical Data in Python</h1>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form class="bd-search d-flex align-items-center" action="../../../../../../../search.html" method="get">
|
||||
<i class="icon fas fa-search"></i>
|
||||
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
|
||||
</form>
|
||||
|
||||
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../README.html">
|
||||
Astronomical Data in Python
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../01_query.html">
|
||||
Lesson 1
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../02_coords.html">
|
||||
Lesson 2
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<!-- To handle the deprecated key -->
|
||||
|
||||
<div class="navbar_extra_footer">
|
||||
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
|
||||
|
||||
<div class="row topbar fixed-top container-xl">
|
||||
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show">
|
||||
</div>
|
||||
<div class="col pl-2 topbar-main">
|
||||
|
||||
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
|
||||
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
|
||||
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
|
||||
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
|
||||
<i class="fas fa-bars"></i>
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-buttons-trigger">
|
||||
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
|
||||
class="fas fa-download"></i></button>
|
||||
|
||||
|
||||
<div class="dropdown-buttons">
|
||||
<!-- ipynb file if we had a myst markdown file -->
|
||||
|
||||
<!-- Download raw file -->
|
||||
<a class="dropdown-buttons" href="../../../../../../../_sources/AstronomicalData/_build/html/_static/vendor/lato_latin-ext/1.44.1/LICENSE.md"><button type="button"
|
||||
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
|
||||
data-placement="left">.md</button></a>
|
||||
<!-- Download PDF via print -->
|
||||
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
|
||||
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Source interaction buttons -->
|
||||
|
||||
|
||||
<!-- Full screen (wrap in <a> to have style consistency -->
|
||||
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
|
||||
data-placement="bottom" onclick="toggleFullScreen()" title="Fullscreen mode"><i
|
||||
class="fas fa-expand"></i></button></a>
|
||||
|
||||
<!-- Launch buttons -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Table of contents -->
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show">
|
||||
|
||||
<div class="tocsection onthispage pt-5 pb-3">
|
||||
<i class="fas fa-list"></i> Contents
|
||||
</div>
|
||||
<nav id="bd-toc-nav">
|
||||
<ul class="simple nav section-nav flex-column">
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-content" class="row">
|
||||
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
|
||||
|
||||
<div>
|
||||
|
||||
<p>Copyright (c) 2019 Jan Bednar</p>
|
||||
<p>Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
“Software”), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:</p>
|
||||
<p>The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.</p>
|
||||
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
|
||||
<script type="text/x-thebe-config">
|
||||
{
|
||||
requestKernel: true,
|
||||
binderOptions: {
|
||||
repo: "binder-examples/jupyter-stacks-datascience",
|
||||
ref: "master",
|
||||
},
|
||||
codeMirrorConfig: {
|
||||
theme: "abcdef",
|
||||
mode: "python"
|
||||
},
|
||||
kernelOptions: {
|
||||
kernelName: "python3",
|
||||
path: "./AstronomicalData/_build/html/_static/vendor/lato_latin-ext/1.44.1"
|
||||
},
|
||||
predefinedOutput: true
|
||||
}
|
||||
</script>
|
||||
<script>kernelName = 'python3'</script>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='prev-next-bottom'>
|
||||
|
||||
|
||||
</div>
|
||||
<footer class="footer mt-5 mt-md-0">
|
||||
<div class="container">
|
||||
<p>
|
||||
|
||||
By Allen B. Downey<br/>
|
||||
|
||||
© Copyright 2020.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="../../../../../../../_static/js/index.30270b6e4c972e43c488.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,260 +0,0 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><no title> — Astronomical Data in Python</title>
|
||||
|
||||
<link rel="stylesheet" href="../../../../../../../_static/css/index.d431a4ee1c1efae0e38bdfebc22debff.css">
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/css/all.min.css">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin
|
||||
href="../../../../../../../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/open-sans_all/1.44.1/index.css">
|
||||
<link rel="stylesheet"
|
||||
href="../../../../../../../_static/vendor/lato_latin-ext/1.44.1/index.css">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../../../../../../../_static/sphinx-book-theme.bfb7730f9caf2ec0b46a44615585038c.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../../../../../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/togglebutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/copybutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/mystnb.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/sphinx-thebe.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
|
||||
|
||||
<link rel="preload" as="script" href="../../../../../../../_static/js/index.30270b6e4c972e43c488.js">
|
||||
|
||||
<script id="documentation_options" data-url_root="../../../../../../../" src="../../../../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../../../../_static/language_data.js"></script>
|
||||
<script src="../../../../../../../_static/togglebutton.js"></script>
|
||||
<script src="../../../../../../../_static/clipboard.min.js"></script>
|
||||
<script src="../../../../../../../_static/copybutton.js"></script>
|
||||
<script >var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
|
||||
<script src="../../../../../../../_static/sphinx-book-theme.be0a4a0c39cd630af62a2fcf693f3f06.js"></script>
|
||||
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]], "processRefs": false, "processEnvironments": false}})</script>
|
||||
<script async="async" src="https://unpkg.com/thebelab@latest/lib/index.js"></script>
|
||||
<script >
|
||||
const thebe_selector = ".thebe"
|
||||
const thebe_selector_input = "pre"
|
||||
const thebe_selector_output = ".output"
|
||||
</script>
|
||||
<script async="async" src="../../../../../../../_static/sphinx-thebe.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../../../../search.html" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="docsearch:language" content="en" />
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
|
||||
|
||||
|
||||
<div class="container-xl">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
|
||||
|
||||
<div class="navbar-brand-box">
|
||||
<a class="navbar-brand text-wrap" href="../../../../../../../index.html">
|
||||
|
||||
|
||||
<h1 class="site-logo" id="site-title">Astronomical Data in Python</h1>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form class="bd-search d-flex align-items-center" action="../../../../../../../search.html" method="get">
|
||||
<i class="icon fas fa-search"></i>
|
||||
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
|
||||
</form>
|
||||
|
||||
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../README.html">
|
||||
Astronomical Data in Python
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../01_query.html">
|
||||
Lesson 1
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="../../../../../../../02_coords.html">
|
||||
Lesson 2
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<!-- To handle the deprecated key -->
|
||||
|
||||
<div class="navbar_extra_footer">
|
||||
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
|
||||
|
||||
<div class="row topbar fixed-top container-xl">
|
||||
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show">
|
||||
</div>
|
||||
<div class="col pl-2 topbar-main">
|
||||
|
||||
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
|
||||
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
|
||||
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
|
||||
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
|
||||
<i class="fas fa-bars"></i>
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-buttons-trigger">
|
||||
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
|
||||
class="fas fa-download"></i></button>
|
||||
|
||||
|
||||
<div class="dropdown-buttons">
|
||||
<!-- ipynb file if we had a myst markdown file -->
|
||||
|
||||
<!-- Download raw file -->
|
||||
<a class="dropdown-buttons" href="../../../../../../../_sources/AstronomicalData/_build/html/_static/vendor/open-sans_all/1.44.1/LICENSE.md"><button type="button"
|
||||
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
|
||||
data-placement="left">.md</button></a>
|
||||
<!-- Download PDF via print -->
|
||||
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
|
||||
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Source interaction buttons -->
|
||||
|
||||
|
||||
<!-- Full screen (wrap in <a> to have style consistency -->
|
||||
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
|
||||
data-placement="bottom" onclick="toggleFullScreen()" title="Fullscreen mode"><i
|
||||
class="fas fa-expand"></i></button></a>
|
||||
|
||||
<!-- Launch buttons -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Table of contents -->
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show">
|
||||
|
||||
<div class="tocsection onthispage pt-5 pb-3">
|
||||
<i class="fas fa-list"></i> Contents
|
||||
</div>
|
||||
<nav id="bd-toc-nav">
|
||||
<ul class="simple nav section-nav flex-column">
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-content" class="row">
|
||||
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
|
||||
|
||||
<div>
|
||||
|
||||
<p>Copyright (c) 2019 Jan Bednar</p>
|
||||
<p>Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
“Software”), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:</p>
|
||||
<p>The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.</p>
|
||||
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
|
||||
<script type="text/x-thebe-config">
|
||||
{
|
||||
requestKernel: true,
|
||||
binderOptions: {
|
||||
repo: "binder-examples/jupyter-stacks-datascience",
|
||||
ref: "master",
|
||||
},
|
||||
codeMirrorConfig: {
|
||||
theme: "abcdef",
|
||||
mode: "python"
|
||||
},
|
||||
kernelOptions: {
|
||||
kernelName: "python3",
|
||||
path: "./AstronomicalData/_build/html/_static/vendor/open-sans_all/1.44.1"
|
||||
},
|
||||
predefinedOutput: true
|
||||
}
|
||||
</script>
|
||||
<script>kernelName = 'python3'</script>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='prev-next-bottom'>
|
||||
|
||||
|
||||
</div>
|
||||
<footer class="footer mt-5 mt-md-0">
|
||||
<div class="container">
|
||||
<p>
|
||||
|
||||
By Allen B. Downey<br/>
|
||||
|
||||
© Copyright 2020.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="../../../../../../../_static/js/index.30270b6e4c972e43c488.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
@@ -1,5 +1,45 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"remove-cell"
|
||||
]
|
||||
},
|
||||
"source": [
|
||||
"---\n",
|
||||
"title: \"Coordinate Transformations\"\n",
|
||||
"teaching: 3000\n",
|
||||
"exercises: 0\n",
|
||||
"questions:\n",
|
||||
"\n",
|
||||
"- \"How do we transform celestial coordinates from one frame to another and save results in files?\"\n",
|
||||
"\n",
|
||||
"objectives:\n",
|
||||
"\n",
|
||||
"- \"Use Python string formatting to compose more complex ADQL queries.\"\n",
|
||||
"\n",
|
||||
"- \"Work with coordinates and other quantities that have units.\"\n",
|
||||
"\n",
|
||||
"- \"Download the results of a query and store them in a file.\"\n",
|
||||
"\n",
|
||||
"keypoints:\n",
|
||||
"\n",
|
||||
"- \"For measurements with units, use `Quantity` objects that represent units explicitly and check for errors.\"\n",
|
||||
"\n",
|
||||
"- \"Use the `format` function to compose queries; it is often faster and less error-prone.\"\n",
|
||||
"\n",
|
||||
"- \"Develop queries incrementally: start with something simple, test it, and add a little bit at a time.\"\n",
|
||||
"\n",
|
||||
"- \"Once you have a query working, save the data in a local file. If you shut down the notebook and come back to it later, you can reload the file; you don't have to run the query again.\"\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
"FIXME\n",
|
||||
"\n",
|
||||
"{% include links.md %}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -1955,6 +1995,7 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"celltoolbar": "Tags",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
|
||||
@@ -1,5 +1,49 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"remove-cell"
|
||||
]
|
||||
},
|
||||
"source": [
|
||||
"---\n",
|
||||
"title: \"Plotting and Pandas\"\n",
|
||||
"teaching: 3000\n",
|
||||
"exercises: 0\n",
|
||||
"questions:\n",
|
||||
"\n",
|
||||
"- \"How do we make scatter plots in Matplotlib?\"\n",
|
||||
"\n",
|
||||
"- \"How do we store data in a Pandas `DataFrame`?\"\n",
|
||||
"\n",
|
||||
"objectives:\n",
|
||||
"\n",
|
||||
"- \"Select rows and columns from an Astropy `Table`.\"\n",
|
||||
"\n",
|
||||
"- \"Use Matplotlib to make a scatter plot.\"\n",
|
||||
"\n",
|
||||
"- \"Use Gala to transform coordinates.\"\n",
|
||||
"\n",
|
||||
"- \"Make a Pandas `DataFrame` and use a Boolean `Series` to select rows.\"\n",
|
||||
"\n",
|
||||
"- \"Save a `DataFrame` in an HDF5 file.\"\n",
|
||||
"\n",
|
||||
"keypoints:\n",
|
||||
"\n",
|
||||
"- \"When you make a scatter plot, adjust the size of the markers and their transparency so the figure is not overplotted; otherwise it can misrepresent the data badly.\n",
|
||||
"\n",
|
||||
"- \"For simple scatter plots in Matplotlib, `plot` is faster than `scatter`.\n",
|
||||
"\n",
|
||||
"- \"An Astropy `Table` and a Pandas `DataFrame` are similar in many ways and they provide many of the same functions. They have pros and cons, but for many projects, either one would be a reasonable choice.\"\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
"FIXME\n",
|
||||
"\n",
|
||||
"{% include links.md %}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -1075,7 +1119,7 @@
|
||||
"source": [
|
||||
"## Exploring data\n",
|
||||
"\n",
|
||||
"One benefit of using Pandas is that it provides function for exploring the data and checking for problems.\n",
|
||||
"One benefit of using Pandas is that it provides functions for exploring the data and checking for problems.\n",
|
||||
"\n",
|
||||
"One of the most useful of these functions is `describe`, which computes summary statistics for each column."
|
||||
]
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"---\n",
|
||||
"title: \"Join\"\n",
|
||||
"teaching: 3000\n",
|
||||
"exercises: 0\n",
|
||||
"questions:\n",
|
||||
"\n",
|
||||
"- \"How do we use `JOIN` to combine information from multiple tables?\"\n",
|
||||
"\n",
|
||||
"objectives:\n",
|
||||
"\n",
|
||||
"- \"Upload a table to the Gaia server.\"\n",
|
||||
"\n",
|
||||
"- \"Write ADQL queries involving `JOIN` operations.\"\n",
|
||||
"\n",
|
||||
"keypoints:\n",
|
||||
"\n",
|
||||
"- \"Use `JOIN` operations to combine data from multiple tables in a databased, using some kind of identifier to match up records from one table with records from another.\"\n",
|
||||
"\n",
|
||||
"* \"This is another example of a practice we saw in the previous notebook, moving the computation to the data.\"\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
"FIXME\n",
|
||||
"\n",
|
||||
"{% include links.md %}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -10,11 +40,11 @@
|
||||
"\n",
|
||||
"As a continuing example, we will replicate part of the analysis in a recent paper, \"[Off the beaten path: Gaia reveals GD-1 stars outside of the main stream](https://arxiv.org/abs/1805.00425)\" by Adrian M. Price-Whelan and Ana Bonaca.\n",
|
||||
"\n",
|
||||
"Picking up where we left off, the next step in the analysis is to select candidate stars based on photometry. The following figure from the paper is a color-magnitude diagram for the stars selected based on proper motion:\n",
|
||||
"Picking up where we left off, the next step in the analysis is to select candidate stars based on photometry data. The following figure from the paper is a color-magnitude diagram for the stars selected based on proper motion:\n",
|
||||
"\n",
|
||||
"<img width=\"300\" src=\"https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-3.png\">\n",
|
||||
"\n",
|
||||
"In red is a theoretical isochrone, showing where we expect the stars in GD-1 to fall based on the metallicity and age of their original globular cluster. \n",
|
||||
"In red is a [stellar isochrone](https://en.wikipedia.org/wiki/Stellar_isochrone), showing where we expect the stars in GD-1 to fall based on the metallicity and age of their original globular cluster. \n",
|
||||
"\n",
|
||||
"By selecting stars in the shaded area, we can further distinguish the main sequence of GD-1 from younger background stars."
|
||||
]
|
||||
@@ -311,7 +341,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n",
|
||||
"<!-- Produced with astropy.io.votable version 4.0.2\r\n",
|
||||
"<!-- Produced with astropy.io.votable version 4.2\r\n",
|
||||
" http://www.astropy.org/ -->\r\n",
|
||||
"<VOTABLE version=\"1.4\" xmlns=\"http://www.ivoa.net/xml/VOTable/v1.4\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.ivoa.net/xml/VOTable/v1.4\">\r\n",
|
||||
" <RESOURCE type=\"results\">\r\n",
|
||||
@@ -350,7 +380,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"-rw-rw-r-- 1 downey downey 396K Nov 18 19:21 candidate_df.xml\r\n"
|
||||
"-rw-rw-r-- 1 downey downey 396K Dec 10 11:33 candidate_df.xml\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -373,7 +403,9 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Exercise:** There's a gotcha here we want to warn you about. Why do you think we used double brackets to specify the column we wanted? What happens if you use single brackets?\n",
|
||||
"### Exercise\n",
|
||||
"\n",
|
||||
"There's a gotcha here we want to warn you about. Why do you think we used double brackets to specify the column we wanted? What happens if you use single brackets?\n",
|
||||
"\n",
|
||||
"Run these cells to find out."
|
||||
]
|
||||
@@ -426,6 +458,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# This line is commented out because it would cause an error\n",
|
||||
"\n",
|
||||
"# writeto(column, 'candidate_df.xml')"
|
||||
]
|
||||
},
|
||||
@@ -517,7 +551,7 @@
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<i>Table length=7346</i>\n",
|
||||
"<table id=\"table140178070186304\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<table id=\"table140668290919488\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<thead><tr><th>source_id</th></tr></thead>\n",
|
||||
"<thead><tr><th>int64</th></tr></thead>\n",
|
||||
"<tr><td>635559124339440000</td></tr>\n",
|
||||
@@ -655,7 +689,7 @@
|
||||
"query1 = \"\"\"SELECT *\n",
|
||||
"FROM gaiadr2.panstarrs1_best_neighbour as best\n",
|
||||
"JOIN tap_upload.candidate_df as candidate_df\n",
|
||||
"ON best.source_id = candidate_df.source_id\n",
|
||||
" ON best.source_id = candidate_df.source_id\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
@@ -713,7 +747,7 @@
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<i>Table length=3724</i>\n",
|
||||
"<table id=\"table140178046436112\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<table id=\"table140668268803072\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<thead><tr><th>source_id</th><th>original_ext_source_id</th><th>angular_distance</th><th>number_of_neighbours</th><th>number_of_mates</th><th>best_neighbour_multiplicity</th><th>gaia_astrometric_params</th><th>source_id_2</th></tr></thead>\n",
|
||||
"<thead><tr><th></th><th></th><th>arcsec</th><th></th><th></th><th></th><th></th><th></th></tr></thead>\n",
|
||||
"<thead><tr><th>int64</th><th>int64</th><th>float64</th><th>int32</th><th>int16</th><th>int16</th><th>int16</th><th>int64</th></tr></thead>\n",
|
||||
@@ -819,7 +853,7 @@
|
||||
"source": [
|
||||
"Because one of the column names appears in both tables, the second instance of `source_id` has been appended with the suffix `_2`.\n",
|
||||
"\n",
|
||||
"The length of the results table is about 2000, which means we were not able to find matches for all stars in the list of candidate_df."
|
||||
"The length of `results1` is about 3000, which means we were not able to find matches for all stars in the list of candidates."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -846,9 +880,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"To get more information about the matching process, we can inspect `best_neighbour_multiplicity`, which indicates for each star in Gaia how many stars in Pan-STARRS are equally likely matches.\n",
|
||||
"\n",
|
||||
"For this kind of data exploration, we'll convert a column from the table to a Pandas `Series` so we can use `value_counts`, which counts the number of times each value appears in a `Series`, like a histogram."
|
||||
"To get more information about the matching process, we can inspect `best_neighbour_multiplicity`, which indicates for each star in Gaia how many stars in Pan-STARRS are equally likely matches."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -858,9 +890,63 @@
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<MaskedColumn name='best_neighbour_multiplicity' dtype='int16' description='Number of neighbours with same probability as best neighbour' length=3724>\n",
|
||||
"<table>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>...</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"<tr><td>1</td></tr>\n",
|
||||
"</table>"
|
||||
],
|
||||
"text/plain": [
|
||||
"1 3724\n",
|
||||
"dtype: int64"
|
||||
"<MaskedColumn name='best_neighbour_multiplicity' dtype='int16' description='Number of neighbours with same probability as best neighbour' length=3724>\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
"...\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1\n",
|
||||
" 1"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
@@ -869,21 +955,16 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"nn = pd.Series(results1['best_neighbour_multiplicity'])\n",
|
||||
"nn.value_counts()"
|
||||
"results1['best_neighbour_multiplicity']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The result shows that `1` is the only value in the `Series`, appearing xxx times.\n",
|
||||
"It looks like most of the values are `1`, which is good; that means that for each candidate star we have identified exactly one source in Pan-STARRS that is likely to be the same star.\n",
|
||||
"\n",
|
||||
"That means that in every case where a match was found, the matching algorithm identified a single neighbor as the most likely match.\n",
|
||||
"\n",
|
||||
"Similarly, `number_of_mates` indicates the number of other stars in Gaia that match with the same star in Pan-STARRS."
|
||||
"To check whether there are any values other than `1`, we can convert this column to a Pandas `Series` and use `describe`, which we saw in in Lesson 3."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -894,8 +975,15 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"0 3724\n",
|
||||
"dtype: int64"
|
||||
"count 3724.0\n",
|
||||
"mean 1.0\n",
|
||||
"std 0.0\n",
|
||||
"min 1.0\n",
|
||||
"25% 1.0\n",
|
||||
"50% 1.0\n",
|
||||
"75% 1.0\n",
|
||||
"max 1.0\n",
|
||||
"dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
@@ -904,17 +992,57 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"nm = pd.Series(results1['number_of_mates'])\n",
|
||||
"nm.value_counts()"
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"multiplicity = pd.Series(results1['best_neighbour_multiplicity'])\n",
|
||||
"multiplicity.describe()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"For this set of candidate_df, almost all of the stars we've selected from Pan-STARRS are only matched with a single star in the Gaia catalog.\n",
|
||||
"In fact, `1` is the only value in the `Series`, so every candidate star has a single best match.\n",
|
||||
"\n",
|
||||
"**Detail** The table also contains `number_of_neighbors` which is the number of stars in Pan-STARRS that match in terms of position, before using other critieria to choose the most likely match."
|
||||
"Similarly, `number_of_mates` indicates the number of *other* stars in Gaia that match with the same star in Pan-STARRS."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"count 3724.0\n",
|
||||
"mean 0.0\n",
|
||||
"std 0.0\n",
|
||||
"min 0.0\n",
|
||||
"25% 0.0\n",
|
||||
"50% 0.0\n",
|
||||
"75% 0.0\n",
|
||||
"max 0.0\n",
|
||||
"dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mates = pd.Series(results1['number_of_mates'])\n",
|
||||
"mates.describe()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"All values in this column are `0`, which means that for each match we found in Pan-STARRS, there are no other stars in Gaia that also match. \n",
|
||||
"\n",
|
||||
"**Detail:** The table also contains `number_of_neighbors` which is the number of stars in Pan-STARRS that match in terms of position, before using other criteria to choose the most likely match."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -935,14 +1063,21 @@
|
||||
"\n",
|
||||
"4. Run the query using the uploaded table.\n",
|
||||
"\n",
|
||||
"Since we've done everything here before, we'll do these steps as an exercise.\n",
|
||||
"Since we've done everything here before, we'll do these steps as an exercise."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Exercise\n",
|
||||
"\n",
|
||||
"**Exercise:** Select `source_id` and `original_ext_source_id` from `results1` and write the resulting table as a file named `external.xml`."
|
||||
"Select `source_id` and `original_ext_source_id` from `results1` and write the resulting table as a file named `external.xml`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"hide-cell"
|
||||
@@ -965,7 +1100,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -973,7 +1108,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n",
|
||||
"<!-- Produced with astropy.io.votable version 4.0.2\r\n",
|
||||
"<!-- Produced with astropy.io.votable version 4.2\r\n",
|
||||
" http://www.astropy.org/ -->\r\n",
|
||||
"<VOTABLE version=\"1.4\" xmlns=\"http://www.ivoa.net/xml/VOTable/v1.4\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.ivoa.net/xml/VOTable/v1.4\">\r\n",
|
||||
" <RESOURCE type=\"results\">\r\n",
|
||||
@@ -993,7 +1128,9 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Exercise:** Read [the documentation of the Pan-STARRS table](https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_external_catalogues/ssec_dm_panstarrs1_original_valid.html) and make note of `obj_id`, which contains the object IDs we'll use to find the rows we want.\n",
|
||||
"### Exercise\n",
|
||||
"\n",
|
||||
"Read [the documentation of the Pan-STARRS table](https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_external_catalogues/ssec_dm_panstarrs1_original_valid.html) and make note of `obj_id`, which contains the object IDs we'll use to find the rows we want.\n",
|
||||
"\n",
|
||||
"Write a query that uses each value of `original_ext_source_id` from the uploaded table to find a row in `gaiadr2.panstarrs1_original_valid` with the same value in `obj_id`, and select all columns from both tables.\n",
|
||||
"\n",
|
||||
@@ -1017,23 +1154,6 @@
|
||||
"Hint: When you select a column from a join, you have to specify which table the column is in."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"hide-cell"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Solution\n",
|
||||
"\n",
|
||||
"query2 = \"\"\"SELECT *\n",
|
||||
"FROM tap_upload.external as external\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
@@ -1046,75 +1166,46 @@
|
||||
"source": [
|
||||
"# Solution\n",
|
||||
"\n",
|
||||
"# First test\n",
|
||||
"\n",
|
||||
"query2 = \"\"\"SELECT *\n",
|
||||
"FROM tap_upload.external as external\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Second test\n",
|
||||
"\n",
|
||||
"query2 = \"\"\"SELECT TOP 10 *\n",
|
||||
"FROM gaiadr2.panstarrs1_original_valid\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"hide-cell"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Solution\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Third test\n",
|
||||
"\n",
|
||||
"query2 = \"\"\"SELECT *\n",
|
||||
"FROM gaiadr2.panstarrs1_original_valid as ps\n",
|
||||
"JOIN tap_upload.external as external\n",
|
||||
"ON ps.obj_id = external.original_ext_source_id\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"hide-cell"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Solution\n",
|
||||
" ON ps.obj_id = external.original_ext_source_id\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"# Complete query\n",
|
||||
"\n",
|
||||
"query2 = \"\"\"SELECT\n",
|
||||
"external.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag\n",
|
||||
"FROM gaiadr2.panstarrs1_original_valid as ps\n",
|
||||
"JOIN tap_upload.external as external\n",
|
||||
"ON ps.obj_id = external.original_ext_source_id\n",
|
||||
" ON ps.obj_id = external.original_ext_source_id\n",
|
||||
"\"\"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SELECT\n",
|
||||
"external.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag\n",
|
||||
"FROM gaiadr2.panstarrs1_original_valid as ps\n",
|
||||
"JOIN tap_upload.external as external\n",
|
||||
"ON ps.obj_id = external.original_ext_source_id\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(query2)"
|
||||
"Here's how we launch the job and get the results."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -1133,14 +1224,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<i>Table length=3724</i>\n",
|
||||
"<table id=\"table140178044101488\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<table id=\"table140668299958448\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<thead><tr><th>source_id</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>\n",
|
||||
"<thead><tr><th></th><th></th><th>mag</th></tr></thead>\n",
|
||||
"<thead><tr><th>int64</th><th>float64</th><th>float64</th></tr></thead>\n",
|
||||
@@ -1194,7 +1285,7 @@
|
||||
"612256418500423168 20.8715991973877 19.9612007141113"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -1208,13 +1299,108 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Challenge exercise**\n",
|
||||
"### Exercise\n",
|
||||
"\n",
|
||||
"Do both joins in one query.\n",
|
||||
"Optional Challenge: Do both joins in one query.\n",
|
||||
"\n",
|
||||
"There's an [example here](https://github.com/smoh/Getting-started-with-Gaia/blob/master/gaia-adql-snippets.md) you could start with."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO: Query finished. [astroquery.utils.tap.core]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<i>Table length=3724</i>\n",
|
||||
"<table id=\"table140668275467456\" class=\"table-striped table-bordered table-condensed\">\n",
|
||||
"<thead><tr><th>source_id</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>\n",
|
||||
"<thead><tr><th></th><th></th><th>mag</th></tr></thead>\n",
|
||||
"<thead><tr><th>int64</th><th>float64</th><th>float64</th></tr></thead>\n",
|
||||
"<tr><td>635860218726658176</td><td>17.8978004455566</td><td>17.5174007415771</td></tr>\n",
|
||||
"<tr><td>635674126383965568</td><td>19.2873001098633</td><td>17.6781005859375</td></tr>\n",
|
||||
"<tr><td>635535454774983040</td><td>16.9237995147705</td><td>16.478099822998</td></tr>\n",
|
||||
"<tr><td>635497276810313600</td><td>19.9242000579834</td><td>18.3339996337891</td></tr>\n",
|
||||
"<tr><td>635614168640132864</td><td>16.1515998840332</td><td>14.6662998199463</td></tr>\n",
|
||||
"<tr><td>635598607974369792</td><td>16.5223999023438</td><td>16.1375007629395</td></tr>\n",
|
||||
"<tr><td>635737661835496576</td><td>14.5032997131348</td><td>13.9849004745483</td></tr>\n",
|
||||
"<tr><td>635850945892748672</td><td>16.5174999237061</td><td>16.0450000762939</td></tr>\n",
|
||||
"<tr><td>635600532119713664</td><td>20.4505996704102</td><td>19.5177001953125</td></tr>\n",
|
||||
"<tr><td>...</td><td>...</td><td>...</td></tr>\n",
|
||||
"<tr><td>612241781249124608</td><td>20.2343997955322</td><td>18.6518001556396</td></tr>\n",
|
||||
"<tr><td>612332147361443072</td><td>21.3848991394043</td><td>20.3076000213623</td></tr>\n",
|
||||
"<tr><td>612426744016802432</td><td>17.8281002044678</td><td>17.4281005859375</td></tr>\n",
|
||||
"<tr><td>612331739340341760</td><td>21.8656997680664</td><td>19.5223007202148</td></tr>\n",
|
||||
"<tr><td>612282738058264960</td><td>22.5151996612549</td><td>19.9743995666504</td></tr>\n",
|
||||
"<tr><td>612386332668697600</td><td>19.3792991638184</td><td>17.9923000335693</td></tr>\n",
|
||||
"<tr><td>612296172717818624</td><td>17.4944000244141</td><td>16.926700592041</td></tr>\n",
|
||||
"<tr><td>612250375480101760</td><td>15.3330001831055</td><td>14.6280002593994</td></tr>\n",
|
||||
"<tr><td>612394926899159168</td><td>16.4414005279541</td><td>15.8212003707886</td></tr>\n",
|
||||
"<tr><td>612256418500423168</td><td>20.8715991973877</td><td>19.9612007141113</td></tr>\n",
|
||||
"</table>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<Table length=3724>\n",
|
||||
" source_id g_mean_psf_mag i_mean_psf_mag \n",
|
||||
" mag \n",
|
||||
" int64 float64 float64 \n",
|
||||
"------------------ ---------------- ----------------\n",
|
||||
"635860218726658176 17.8978004455566 17.5174007415771\n",
|
||||
"635674126383965568 19.2873001098633 17.6781005859375\n",
|
||||
"635535454774983040 16.9237995147705 16.478099822998\n",
|
||||
"635497276810313600 19.9242000579834 18.3339996337891\n",
|
||||
"635614168640132864 16.1515998840332 14.6662998199463\n",
|
||||
"635598607974369792 16.5223999023438 16.1375007629395\n",
|
||||
"635737661835496576 14.5032997131348 13.9849004745483\n",
|
||||
"635850945892748672 16.5174999237061 16.0450000762939\n",
|
||||
"635600532119713664 20.4505996704102 19.5177001953125\n",
|
||||
" ... ... ...\n",
|
||||
"612241781249124608 20.2343997955322 18.6518001556396\n",
|
||||
"612332147361443072 21.3848991394043 20.3076000213623\n",
|
||||
"612426744016802432 17.8281002044678 17.4281005859375\n",
|
||||
"612331739340341760 21.8656997680664 19.5223007202148\n",
|
||||
"612282738058264960 22.5151996612549 19.9743995666504\n",
|
||||
"612386332668697600 19.3792991638184 17.9923000335693\n",
|
||||
"612296172717818624 17.4944000244141 16.926700592041\n",
|
||||
"612250375480101760 15.3330001831055 14.6280002593994\n",
|
||||
"612394926899159168 16.4414005279541 15.8212003707886\n",
|
||||
"612256418500423168 20.8715991973877 19.9612007141113"
|
||||
]
|
||||
},
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Solution\n",
|
||||
"\n",
|
||||
"query3 = \"\"\"SELECT\n",
|
||||
"candidate_df.source_id, ps.g_mean_psf_mag, ps.i_mean_psf_mag\n",
|
||||
"FROM tap_upload.candidate_df as candidate_df\n",
|
||||
"JOIN gaiadr2.panstarrs1_best_neighbour as best\n",
|
||||
" ON best.source_id = candidate_df.source_id\n",
|
||||
"JOIN gaiadr2.panstarrs1_original_valid as ps\n",
|
||||
" ON ps.obj_id = best.original_ext_source_id\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"job3 = Gaia.launch_job_async(query=query3, \n",
|
||||
" upload_resource='candidate_df.xml', \n",
|
||||
" upload_table_name='candidate_df')\n",
|
||||
"\n",
|
||||
"results3 = job3.get_results()\n",
|
||||
"results3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -1226,7 +1412,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -1243,14 +1429,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"-rw-rw-r-- 1 downey downey 96K Nov 18 19:22 gd1_photo.fits\r\n"
|
||||
"-rw-rw-r-- 1 downey downey 96K Dec 10 11:34 gd1_photo.fits\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "raw",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"---\n",
|
||||
"title: \"Title\"\n",
|
||||
"teaching: 3000\n",
|
||||
"exercises: 0\n",
|
||||
"questions:\n",
|
||||
"\n",
|
||||
"- \"Question?\"\n",
|
||||
"\n",
|
||||
"objectives:\n",
|
||||
"\n",
|
||||
"- \"Objective.\"\n",
|
||||
"\n",
|
||||
"keypoints:\n",
|
||||
"\n",
|
||||
"- \"Keypoint.\"\n",
|
||||
"\n",
|
||||
"---\n",
|
||||
"FIXME\n",
|
||||
"\n",
|
||||
"{% include links.md %}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
# Astronomical Data in Python
|
||||
|
||||
*Astronomical Data in Python* is an introduction to tools and practices for working with astronomical data. Topics covered include:
|
||||
|
||||
* Writing queries that select and download data from a database.
|
||||
|
||||
* Using data stored in an Astropy `Table` or Pandas `DataFrame`.
|
||||
|
||||
* Working with coordinates and other quantities with units.
|
||||
|
||||
* Storing data in various formats.
|
||||
|
||||
* Performing database join operations that combine data from multiple tables.
|
||||
|
||||
* Visualizing data and preparing publication-quality figures.
|
||||
|
||||
As a running example, we will replicate part of the analysis in a recent paper, "[Off the beaten path: Gaia reveals GD-1 stars outside of the main stream](https://arxiv.org/abs/1805.00425)" by Adrian M. Price-Whelan and Ana Bonaca.
|
||||
|
||||
This material was developed in collaboration with [The Carpentries](https://carpentries.org/) and the Astronomy Curriculum Development Committee, and supported by funding from the American Institute of Physics through the American Astronomical Society.
|
||||
|
||||
I am grateful for contributions from the members of the committee -- Azalee Bostroem, Rodolfo Montez, and Phil Rosenfield -- and from Erin Becker, Brett Morris and Adrian Price-Whelan.
|
||||
|
||||
The original format of this material is a series of Jupyter notebooks. Using the
|
||||
links below, you can read the notebooks on NBViewer or run them on Colab. If you
|
||||
want to run the notebooks in your own environment, you can download them from
|
||||
this repository and follow the instructions below to set up your environment.
|
||||
|
||||
This material is also available in the form of [Carpentries lessons](https://datacarpentry.github.io/astronomy-python), but you should be
|
||||
aware that these versions might diverge in the future.
|
||||
|
||||
**Prerequisites**
|
||||
|
||||
This material should be accessible to people familiar with basic Python, but not necessarily the libraries we will use, like Astropy or Pandas. If you are familiar with Python lists and dictionaries, and you know how to write a function that takes parameters and returns a value, that should be enough.
|
||||
|
||||
We assume that you are familiar with astronomy at the undergraduate level, but we will not assume specialized knowledge of the datasets or analysis methods we'll use.
|
||||
|
||||
**Notebook 1**
|
||||
|
||||
This notebook demonstrates the following steps:
|
||||
|
||||
1. Making a connection to the Gaia server,
|
||||
|
||||
2. Exploring information about the database and the tables it contains,
|
||||
|
||||
3. Writing a query and sending it to the server, and finally
|
||||
|
||||
4. Downloading the response from the server as an Astropy `Table`.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/01_query.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/01_query.ipynb)
|
||||
|
||||
|
||||
**Notebook 2**
|
||||
|
||||
This notebook starts with an example that does a "cone search"; that is, it selects stars that appear in a circular region of the sky.
|
||||
|
||||
Then, to select stars in the vicinity of GD-1, we:
|
||||
|
||||
* Use `Quantity` objects to represent measurements with units.
|
||||
|
||||
* Use the `Gala` library to convert coordinates from one frame to another.
|
||||
|
||||
* Use the ADQL keywords `POLYGON`, `CONTAINS`, and `POINT` to select stars that fall within a polygonal region.
|
||||
|
||||
* Submit a query and download the results.
|
||||
|
||||
* Store the results in a FITS file.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/02_coords.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/02_coords.ipynb)
|
||||
|
||||
|
||||
**Notebook 3**
|
||||
|
||||
Here are the steps in this notebook:
|
||||
|
||||
1. We'll read back the results from the previous notebook, which we saved in a FITS file.
|
||||
|
||||
2. Then we'll transform the coordinates and proper motion data from ICRS back to the coordinate frame of GD-1.
|
||||
|
||||
3. We'll put those results into a Pandas `DataFrame`, which we'll use to select stars near the centerline of GD-1.
|
||||
|
||||
4. Plotting the proper motion of those stars, we'll identify a region of proper motion for stars that are likely to be in GD-1.
|
||||
|
||||
5. Finally, we'll select and plot the stars whose proper motion is in that region.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/03_motion.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/03_motion.ipynb)
|
||||
|
||||
|
||||
**Notebook 4**
|
||||
|
||||
Here are the steps in this notebook:
|
||||
|
||||
1. Using data from the previous notebook, we'll identify the values of proper motion for stars likely to be in GD-1.
|
||||
|
||||
2. Then we'll compose an ADQL query that selects stars based on proper motion, so we can download only the data we need.
|
||||
|
||||
3. We'll also see how to write the results to a CSV file.
|
||||
|
||||
That will make it possible to search a bigger region of the sky in a single query.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/04_select.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/04_select.ipynb)
|
||||
|
||||
|
||||
**Notebook 5**
|
||||
|
||||
Here are the steps in this notebook:
|
||||
|
||||
1. We'll reload the candidate stars we identified in the previous notebook.
|
||||
|
||||
2. Then we'll run a query on the Gaia server that uploads the table of candidates and uses a `JOIN` operation to select photometry data for the candidate stars.
|
||||
|
||||
3. We'll write the results to a file for use in the next notebook.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/05_join.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/05_join.ipynb)
|
||||
|
||||
|
||||
**Notebook 6**
|
||||
|
||||
Here are the steps in this notebook:
|
||||
|
||||
1. We'll reload the data from the previous notebook and make a color-magnitude diagram.
|
||||
|
||||
2. Then we'll specify a polygon in the diagram that contains stars with the photometry we expect.
|
||||
|
||||
3. Then we'll merge the photometry data with the list of candidate stars, storing the result in a Pandas `DataFrame`.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/06_photo.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/06_photo.ipynb)
|
||||
|
||||
|
||||
**Notebook 7**
|
||||
|
||||
Here are the steps in this notebook:
|
||||
|
||||
1. Starting with the figure from the previous notebook, we'll add annotations to present the results more clearly.
|
||||
|
||||
2. The we'll see several ways to customize figures to make them more appealing and effective.
|
||||
|
||||
3. Finally, we'll see how to make a figure with multiple panels or subplots.
|
||||
|
||||
Press this button to run this notebook on Colab:
|
||||
|
||||
[<img src="run_on_colab_small.png">](https://colab.research.google.com/github/AllenDowney/AstronomicalData/blob/main/07_plot.ipynb)
|
||||
|
||||
[or click here to read it on NBViewer](https://nbviewer.jupyter.org/github/AllenDowney/AstronomicalData/blob/main/07_plot.ipynb)
|
||||
|
||||
|
||||
**Installation instructions**
|
||||
|
||||
Coming soon.
|
||||
@@ -1,20 +0,0 @@
|
||||
Copyright (c) 2019 Jan Bednar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,20 +0,0 @@
|
||||
Copyright (c) 2019 Jan Bednar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -13,7 +13,7 @@
|
||||
"source": [
|
||||
"If you are not able to get everything installed that we need for the workshop, you have the option of running this notebook on Colab.\n",
|
||||
"\n",
|
||||
"Before you get started, you probably want to press the Save button!"
|
||||
"The following cell installs the libraries we need that are not already in the Colab runtime environment."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -32,14 +32,21 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery astro-gala pyia"
|
||||
" !pip install astroquery astro-gala"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"That should be everything you need. Now you can type code and run it in the following cells."
|
||||
"That should be everything you need. \n",
|
||||
"\n",
|
||||
"Before you get started, you probably want to press the Save button!\n",
|
||||
"That will allow you to save your copy of this notebook in your Google Drive.\n",
|
||||
"\n",
|
||||
"If you don't save this notebook, any changes you make will be lost if you close the browser window or leave it idle too long.\n",
|
||||
"\n",
|
||||
"Now you can type code and run it in the following cells."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,16 +6,128 @@
|
||||
"source": [
|
||||
"# Data Carpentry Astronomy Workshop\n",
|
||||
"\n",
|
||||
"This notebook imports the libraries we need for the workshop.\n",
|
||||
"Please run this notebook before the workshop. There are three sections:\n",
|
||||
"\n",
|
||||
"If any of them are missing, you'll get an error message.\n",
|
||||
"1. A short introduction to Jupyter, with pointers to more resources.\n",
|
||||
"\n",
|
||||
"2. `import` statements to check whether you have everything installed that we need.\n",
|
||||
"\n",
|
||||
"3. A cell where you will paste a line of code you copy from Slack, to check for a potential problem with \"smart\" quotes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Introduction to Jupyter\n",
|
||||
"\n",
|
||||
"This is a Jupyter notebook, which is a computational document that contains text, code, and results.\n",
|
||||
"\n",
|
||||
"There are several development environments you can use to work with notebooks. Currently the two most common are:\n",
|
||||
"\n",
|
||||
"* Jupyter Classic Notebook, and\n",
|
||||
"\n",
|
||||
"* JupyterLab, which is a newer environment with some improved features, but also some limitations. \n",
|
||||
"\n",
|
||||
"During the workshop, we will use the Classic Notebook environment. If you are new to Jupyter, we suggest you should, too.\n",
|
||||
"\n",
|
||||
"If you are familiar with JupyterLab and you would rather use it for the workshop, that's fine. Just be aware that there will be differences between your environment and ours.\n",
|
||||
"\n",
|
||||
"If you are new to Jupyter, you can [read about it here](https://jupyter.org/try) and follow the tutorial called \"Try Classic Notebook\".\n",
|
||||
"\n",
|
||||
"You also might like [this tutorial from DataQuest](https://www.dataquest.io/blog/jupyter-notebook-tutorial/).\n",
|
||||
"\n",
|
||||
"The following sections introduce the features you will need for the workshop."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Selecting and running cells\n",
|
||||
"\n",
|
||||
"Notebooks are divided into cells that contain either text or code.\n",
|
||||
"\n",
|
||||
"This cell is text; the following cell is code:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('Hello')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"To select a cell, click in the left margin next to the cell. You should see a blue frame surrounding the selected cell.\n",
|
||||
"\n",
|
||||
"To edit a code cell, click inside the cell. You should see a green frame around the selected cell, and you should see a cursor inside the cell.\n",
|
||||
"\n",
|
||||
"To edit a text cell, double-click inside the cell. Again, you should see a green frame around the selected cell, and you should see a cursor inside the cell.\n",
|
||||
"\n",
|
||||
"Text cells use the Markdown typesetting language, which [you can read about here](https://www.markdownguide.org/).\n",
|
||||
"\n",
|
||||
"To run a cell, hold down Shift and press Enter.\n",
|
||||
"\n",
|
||||
"* If you run a text cell, Jupyter formats the text and displays the result.\n",
|
||||
"\n",
|
||||
"* If you run a code cell, Jupyter runs the code in the cell and displays the result, if any.\n",
|
||||
"\n",
|
||||
"To try it out, select the previous code cell and press Shift-Enter. It should run the code and print `Hello`.\n",
|
||||
"\n",
|
||||
"Then edit this cell, change some of the text, and press Shift-Enter to format it."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Adding and removing cells\n",
|
||||
"\n",
|
||||
"You can add and remove cells from a notebook using the menu at the top of the page and the tool bar below the menu.\n",
|
||||
"\n",
|
||||
"Try the following exercises:\n",
|
||||
"\n",
|
||||
"1. From the Insert menu select \"Insert cell below\" to add a cell below this one. By default, you get a code cell, as you can see in the pull-down menu that says \"Code\".\n",
|
||||
"\n",
|
||||
"2. In the new cell, add a line of Python code and run it.\n",
|
||||
"\n",
|
||||
"3. Add another cell, select the new cell, and then click on the pull-down menu that says \"Code\". Select \"Markdown\". This makes the new cell a text cell.\n",
|
||||
"\n",
|
||||
"4. In the new cell, type some text and format it.\n",
|
||||
"\n",
|
||||
"5. Use the arrow buttons in the tool bar to move cells up and down.\n",
|
||||
"\n",
|
||||
"6. Use the cut, copy, and paste buttons to delete, add, and move cells.\n",
|
||||
"\n",
|
||||
"As you make changes, Jupyter saves your notebook automatically, but if you want to make sure, you can press the save button, which looks like a floppy disk from the 1990s.\n",
|
||||
"\n",
|
||||
"Finally, when you are done with a notebook, select \"Close and Halt\" from the File menu."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check your installation\n",
|
||||
"\n",
|
||||
"Run the following cells to import the libraries we need for the workshop.\n",
|
||||
"\n",
|
||||
"If any of the libraries are missing, you'll get an error message.\n",
|
||||
"\n",
|
||||
"If you don't get any error messages, you are all set."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -24,7 +136,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -32,9 +144,27 @@
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's make sure you have a recent version of Pandas.\n",
|
||||
"\n",
|
||||
"If the following cell causes an error, you probably have an old version of Pandas. Please update it before the workshop."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pd.Series([0]).to_numpy()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -46,7 +176,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -57,7 +187,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -66,26 +196,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Created TAP+ (v1.2.1) - Connection:\n",
|
||||
"\tHost: gea.esac.esa.int\n",
|
||||
"\tUse HTTPS: True\n",
|
||||
"\tPort: 443\n",
|
||||
"\tSSL Port: 443\n",
|
||||
"Created TAP+ (v1.2.1) - Connection:\n",
|
||||
"\tHost: geadata.esac.esa.int\n",
|
||||
"\tUse HTTPS: True\n",
|
||||
"\tPort: 443\n",
|
||||
"\tSSL Port: 443\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Note: running this import statement opens a connection\n",
|
||||
"# to a Gaia server, so it will fail if you are not connected\n",
|
||||
@@ -98,11 +211,13 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check for code-pasting problems\n",
|
||||
"\n",
|
||||
"During the workshop, we might put code on Slack and ask you to cut and paste it into the notebook.\n",
|
||||
"\n",
|
||||
"If you are on a Mac, you might encounter a problem with smart quotes.\n",
|
||||
"\n",
|
||||
"To check, following this link to [our Slack workspace](https://app.slack.com/client/T01DJHEP8Q1/C01D2TZA8SH/details/pins) and find the pinned message with the setup instructions.\n",
|
||||
"To check, following this link to [our Slack workspace](https://app.slack.com/client/T01GF8N96TD/C01G8AS0QBG/details/pins) and find the pinned message with the setup instructions.\n",
|
||||
"It contains a line of Python code.\n",
|
||||
"\n",
|
||||
"Copy the code from Slack and paste it in the cell below.\n",
|
||||
|
||||
@@ -97,12 +97,12 @@
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="01_query.html">
|
||||
Chapter 1
|
||||
Queries
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="02_coords.html">
|
||||
Chapter 2
|
||||
Coordinates and units
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
|
||||
@@ -97,12 +97,12 @@
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="01_query.html">
|
||||
Chapter 1
|
||||
Queries
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="02_coords.html">
|
||||
Chapter 2
|
||||
Coordinates and units
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
@@ -241,7 +241,7 @@
|
||||
<div class="section" id="the-notebook-of-last-resort">
|
||||
<h1>The Notebook of Last Resort<a class="headerlink" href="#the-notebook-of-last-resort" title="Permalink to this headline">¶</a></h1>
|
||||
<p>If you are not able to get everything installed that we need for the workshop, you have the option of running this notebook on Colab.</p>
|
||||
<p>Before you get started, you probably want to press the Save button!</p>
|
||||
<p>The following cell installs the libraries we need that are not already in the Colab runtime environment.</p>
|
||||
<div class="cell tag_hide-cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># If we're running on Colab, install libraries</span>
|
||||
@@ -250,12 +250,16 @@
|
||||
<span class="n">IN_COLAB</span> <span class="o">=</span> <span class="s1">'google.colab'</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">IN_COLAB</span><span class="p">:</span>
|
||||
<span class="o">!</span>pip install astroquery astro-gala pyia
|
||||
<span class="o">!</span>pip install astroquery astro-gala
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>That should be everything you need. Now you can type code and run it in the following cells.</p>
|
||||
<p>That should be everything you need.</p>
|
||||
<p>Before you get started, you probably want to press the Save button!
|
||||
That will allow you to save your copy of this notebook in your Google Drive.</p>
|
||||
<p>If you don’t save this notebook, any changes you make will be lost if you close the browser window or leave it idle too long.</p>
|
||||
<p>Now you can type code and run it in the following cells.</p>
|
||||
</div>
|
||||
|
||||
<script type="text/x-thebe-config">
|
||||
|
||||
@@ -97,12 +97,12 @@
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="01_query.html">
|
||||
Chapter 1
|
||||
Queries
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="02_coords.html">
|
||||
Chapter 2
|
||||
Coordinates and units
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
|
||||
@@ -97,12 +97,12 @@
|
||||
<ul class="nav sidenav_l1">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="01_query.html">
|
||||
Chapter 1
|
||||
Queries
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="02_coords.html">
|
||||
Chapter 2
|
||||
Coordinates and units
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB |
@@ -231,6 +231,42 @@
|
||||
<!-- Table of contents -->
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show">
|
||||
|
||||
<div class="tocsection onthispage pt-5 pb-3">
|
||||
<i class="fas fa-list"></i> Contents
|
||||
</div>
|
||||
<nav id="bd-toc-nav">
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#introduction-to-jupyter">
|
||||
Introduction to Jupyter
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#selecting-and-running-cells">
|
||||
Selecting and running cells
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#adding-and-removing-cells">
|
||||
Adding and removing cells
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#check-your-installation">
|
||||
Check your installation
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#check-for-code-pasting-problems">
|
||||
Check for code-pasting problems
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-content" class="row">
|
||||
@@ -240,8 +276,68 @@
|
||||
|
||||
<div class="section" id="data-carpentry-astronomy-workshop">
|
||||
<h1>Data Carpentry Astronomy Workshop<a class="headerlink" href="#data-carpentry-astronomy-workshop" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This notebook imports the libraries we need for the workshop.</p>
|
||||
<p>If any of them are missing, you’ll get an error message.</p>
|
||||
<p>Please run this notebook before the workshop. There are three sections:</p>
|
||||
<ol class="simple">
|
||||
<li><p>A short introduction to Jupyter, with pointers to more resources.</p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">import</span></code> statements to check whether you have everything installed that we need.</p></li>
|
||||
<li><p>A cell where you will paste a line of code you copy from Slack, to check for a potential problem with “smart” quotes.</p></li>
|
||||
</ol>
|
||||
<div class="section" id="introduction-to-jupyter">
|
||||
<h2>Introduction to Jupyter<a class="headerlink" href="#introduction-to-jupyter" title="Permalink to this headline">¶</a></h2>
|
||||
<p>This is a Jupyter notebook, which is a computational document that contains text, code, and results.</p>
|
||||
<p>There are several development environments you can use to work with notebooks. Currently the two most common are:</p>
|
||||
<ul class="simple">
|
||||
<li><p>Jupyter Classic Notebook, and</p></li>
|
||||
<li><p>JupyterLab, which is a newer environment with some improved features, but also some limitations.</p></li>
|
||||
</ul>
|
||||
<p>During the workshop, we will use the Classic Notebook environment. If you are new to Jupyter, we suggest you should, too.</p>
|
||||
<p>If you are familiar with JupyterLab and you would rather use it for the workshop, that’s fine. Just be aware that there will be differences between your environment and ours.</p>
|
||||
<p>If you are new to Jupyter, you can <a class="reference external" href="https://jupyter.org/try">read about it here</a> and follow the tutorial called “Try Classic Notebook”.</p>
|
||||
<p>You also might like <a class="reference external" href="https://www.dataquest.io/blog/jupyter-notebook-tutorial/">this tutorial from DataQuest</a>.</p>
|
||||
<p>The following sections introduce the features you will need for the workshop.</p>
|
||||
<div class="section" id="selecting-and-running-cells">
|
||||
<h3>Selecting and running cells<a class="headerlink" href="#selecting-and-running-cells" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Notebooks are divided into cells that contain either text or code.</p>
|
||||
<p>This cell is text; the following cell is code:</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">'Hello'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>To select a cell, click in the left margin next to the cell. You should see a blue frame surrounding the selected cell.</p>
|
||||
<p>To edit a code cell, click inside the cell. You should see a green frame around the selected cell, and you should see a cursor inside the cell.</p>
|
||||
<p>To edit a text cell, double-click inside the cell. Again, you should see a green frame around the selected cell, and you should see a cursor inside the cell.</p>
|
||||
<p>Text cells use the Markdown typesetting language, which <a class="reference external" href="https://www.markdownguide.org/">you can read about here</a>.</p>
|
||||
<p>To run a cell, hold down Shift and press Enter.</p>
|
||||
<ul class="simple">
|
||||
<li><p>If you run a text cell, Jupyter formats the text and displays the result.</p></li>
|
||||
<li><p>If you run a code cell, Jupyter runs the code in the cell and displays the result, if any.</p></li>
|
||||
</ul>
|
||||
<p>To try it out, select the previous code cell and press Shift-Enter. It should run the code and print <code class="docutils literal notranslate"><span class="pre">Hello</span></code>.</p>
|
||||
<p>Then edit this cell, change some of the text, and press Shift-Enter to format it.</p>
|
||||
</div>
|
||||
<div class="section" id="adding-and-removing-cells">
|
||||
<h3>Adding and removing cells<a class="headerlink" href="#adding-and-removing-cells" title="Permalink to this headline">¶</a></h3>
|
||||
<p>You can add and remove cells from a notebook using the menu at the top of the page and the tool bar below the menu.</p>
|
||||
<p>Try the following exercises:</p>
|
||||
<ol class="simple">
|
||||
<li><p>From the Insert menu select “Insert cell below” to add a cell below this one. By default, you get a code cell, as you can see in the pull-down menu that says “Code”.</p></li>
|
||||
<li><p>In the new cell, add a line of Python code and run it.</p></li>
|
||||
<li><p>Add another cell, select the new cell, and then click on the pull-down menu that says “Code”. Select “Markdown”. This makes the new cell a text cell.</p></li>
|
||||
<li><p>In the new cell, type some text and format it.</p></li>
|
||||
<li><p>Use the arrow buttons in the tool bar to move cells up and down.</p></li>
|
||||
<li><p>Use the cut, copy, and paste buttons to delete, add, and move cells.</p></li>
|
||||
</ol>
|
||||
<p>As you make changes, Jupyter saves your notebook automatically, but if you want to make sure, you can press the save button, which looks like a floppy disk from the 1990s.</p>
|
||||
<p>Finally, when you are done with a notebook, select “Close and Halt” from the File menu.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="check-your-installation">
|
||||
<h2>Check your installation<a class="headerlink" href="#check-your-installation" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Run the following cells to import the libraries we need for the workshop.</p>
|
||||
<p>If any of the libraries are missing, you’ll get an error message.</p>
|
||||
<p>If you don’t get any error messages, you are all set.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -258,6 +354,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Let’s make sure you have a recent version of Pandas.</p>
|
||||
<p>If the following cell causes an error, you probably have an old version of Pandas. Please update it before the workshop.</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">([</span><span class="mi">0</span><span class="p">])</span><span class="o">.</span><span class="n">to_numpy</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
|
||||
@@ -294,29 +399,19 @@
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Created TAP+ (v1.2.1) - Connection:
|
||||
Host: gea.esac.esa.int
|
||||
Use HTTPS: True
|
||||
Port: 443
|
||||
SSL Port: 443
|
||||
Created TAP+ (v1.2.1) - Connection:
|
||||
Host: geadata.esac.esa.int
|
||||
Use HTTPS: True
|
||||
Port: 443
|
||||
SSL Port: 443
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="check-for-code-pasting-problems">
|
||||
<h2>Check for code-pasting problems<a class="headerlink" href="#check-for-code-pasting-problems" title="Permalink to this headline">¶</a></h2>
|
||||
<p>During the workshop, we might put code on Slack and ask you to cut and paste it into the notebook.</p>
|
||||
<p>If you are on a Mac, you might encounter a problem with smart quotes.</p>
|
||||
<p>To check, following this link to <a class="reference external" href="https://app.slack.com/client/T01DJHEP8Q1/C01D2TZA8SH/details/pins">our Slack workspace</a> and find the pinned message with the setup instructions.
|
||||
<p>To check, following this link to <a class="reference external" href="https://app.slack.com/client/T01GF8N96TD/C01G8AS0QBG/details/pins">our Slack workspace</a> and find the pinned message with the setup instructions.
|
||||
It contains a line of Python code.</p>
|
||||
<p>Copy the code from Slack and paste it in the cell below.
|
||||
If it runs without producing an error, you are all set.</p>
|
||||
<p>Otherwise, you might have to change your system settings so it does not convert straight quotes to smart quotes.
|
||||
If you have trouble with this, let us know and we will provide more details.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/x-thebe-config">
|
||||
|
||||