Update documentation

This commit is contained in:
Allen Downey
2020-12-15 11:21:16 -05:00
parent a0916f2887
commit 90189fd014
26 changed files with 1065 additions and 193 deletions
+19 -5
View File
@@ -109,27 +109,27 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="03_motion.html">
Chapter 3
Proper Motion
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="04_select.html">
Chapter 4
Transformation and Selection
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="05_join.html">
Chapter 5
Joining Tables
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="06_photo.html">
Chapter 6
Photometry
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="07_plot.html">
Chapter 7
Visualization
</a>
</li>
</ul>
@@ -899,6 +899,13 @@ Results: None
<div class="section" id="id1">
<h3>Exercise<a class="headerlink" href="#id1" 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_main_tables/ssec_dm_gaia_source.html">the documentation of this table</a> and choose a column that looks interesting to you. Add the column name to the query and run it again. What are the units of the column you selected? What is its data type?</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>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="asynchronous-queries">
@@ -1000,6 +1007,13 @@ Results: None
<li><p>While you are debugging, use <code class="docutils literal notranslate"><span class="pre">TOP</span></code> to limit the number of rows in the result. That will make each test run faster, which reduces your development time.</p></li>
<li><p>Launching test queries synchronously might make them start faster, too.</p></li>
</ul>
<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>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="operators">
+32 -14
View File
@@ -57,7 +57,7 @@
<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" />
<link rel="next" title="Chapter 3" href="03_motion.html" />
<link rel="next" title="Proper Motion" href="03_motion.html" />
<link rel="prev" title="Queries" href="01_query.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -109,27 +109,27 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="03_motion.html">
Chapter 3
Proper Motion
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="04_select.html">
Chapter 4
Transformation and Selection
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="05_join.html">
Chapter 5
Joining Tables
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="06_photo.html">
Chapter 6
Photometry
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="07_plot.html">
Chapter 7
Visualization
</a>
</li>
</ul>
@@ -247,11 +247,13 @@
<a class="reference internal nav-link" href="#selecting-a-region">
Selecting a region
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#exercise">
Exercise
</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="#getting-gd-1-data">
@@ -389,12 +391,28 @@ Created TAP+ (v1.2.1) - Connection:
<tr><td>4057470555320409600</td></tr>
</table></div></div>
</div>
</div>
<div class="section" id="exercise">
<h2>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h2>
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h3>
<p>When you are debugging queries like this, you can use <code class="docutils literal notranslate"><span class="pre">TOP</span></code> to limit the size of the results, but then you still dont know how big the results will be.</p>
<p>An alternative is to use <code class="docutils literal notranslate"><span class="pre">COUNT</span></code>, which asks for the number of rows that would be selected, but it does not return them.</p>
<p>In the previous query, replace <code class="docutils literal notranslate"><span class="pre">TOP</span> <span class="pre">10</span> <span class="pre">source_id</span></code> with <code class="docutils literal notranslate"><span class="pre">COUNT(source_id)</span></code> and run the query again. How many stars has Gaia identified in the cone we searched?</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">query</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">SELECT </span>
<span class="s2">COUNT(source_id)</span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">WHERE 1=CONTAINS(</span>
<span class="s2"> POINT(ra, dec),</span>
<span class="s2"> CIRCLE(266.41683, -29.00781, 0.08333333))</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="getting-gd-1-data">
<h2>Getting GD-1 Data<a class="headerlink" href="#getting-gd-1-data" title="Permalink to this headline"></a></h2>
@@ -1830,7 +1848,7 @@ Results: None
<div class='prev-next-bottom'>
<a class='left-prev' id="prev-link" href="01_query.html" title="previous page">Queries</a>
<a class='right-next' id="next-link" href="03_motion.html" title="next page">Chapter 3</a>
<a class='right-next' id="next-link" href="03_motion.html" title="next page">Proper Motion</a>
</div>
<footer class="footer mt-5 mt-md-0">
+30 -19
View File
@@ -257,11 +257,13 @@
<a class="reference internal nav-link" href="#scatter-plot">
Scatter plot
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#exercise">
Exercise
</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="#transform-back">
@@ -304,11 +306,13 @@
<a class="reference internal nav-link" href="#saving-the-dataframe">
Saving the DataFrame
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#id2">
Exercise
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#id2">
Exercise
</a>
</li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#summary">
@@ -583,13 +587,20 @@ radial_velocity float64 km / s
<p>The functions <code class="docutils literal notranslate"><span class="pre">xlabel</span></code> and <code class="docutils literal notranslate"><span class="pre">ylabel</span></code> put labels on the axes.</p>
<p>This scatter plot has a problem. It is “<a class="reference external" href="https://python-graph-gallery.com/134-how-to-avoid-overplotting-with-python/">overplotted</a>”, which means that there are so many overlapping points, we cant distinguish between high and low density areas.</p>
<p>To fix this, we can provide optional arguments to control the size and transparency of the points.</p>
</div>
<div class="section" id="exercise">
<h2>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h2>
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h3>
<p>In the call to <code class="docutils literal notranslate"><span class="pre">plt.plot</span></code>, add the keyword argument <code class="docutils literal notranslate"><span class="pre">markersize=0.1</span></code> to make the markers smaller.</p>
<p>Then add the argument <code class="docutils literal notranslate"><span class="pre">alpha=0.1</span></code> to make the markers nearly transparent.</p>
<p>Adjust these arguments until you think the figure shows the data most clearly.</p>
<p>Note: Once you have made these changes, you might notice that the figure shows stripes with lower density of stars. These stripes are caused by the way Gaia scans the sky, which <a class="reference external" href="https://www.cosmos.esa.int/web/gaia/scanning-law">you can read about here</a>. The dataset we are using, <a class="reference external" href="https://www.cosmos.esa.int/web/gaia/dr2">Gaia Data Release 2</a>, covers 22 months of observations; during this time, some parts of the sky were scanned more than others.</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>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="transform-back">
<h2>Transform back<a class="headerlink" href="#transform-back" title="Permalink to this headline"></a></h2>
@@ -696,7 +707,7 @@ which is an “interface for celestial coordinate representation, manipulation,
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_46_0.png" src="_images/03_motion_46_0.png" />
<img alt="_images/03_motion_47_0.png" src="_images/03_motion_47_0.png" />
</div>
</div>
<p>Remember that we started with a rectangle in GD-1 coordinates. When transformed to ICRS, its a non-rectangular polygon. Now that we have transformed back to GD-1 coordinates, its a rectangle again.</p>
@@ -1222,7 +1233,7 @@ Name: phi2, dtype: bool
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_84_0.png" src="_images/03_motion_84_0.png" />
<img alt="_images/03_motion_85_0.png" src="_images/03_motion_85_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 +1254,7 @@ Name: phi2, dtype: bool
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_86_0.png" src="_images/03_motion_86_0.png" />
<img alt="_images/03_motion_87_0.png" src="_images/03_motion_87_0.png" />
</div>
</div>
<p>Now we can see the smaller cluster more clearly.</p>
@@ -1291,7 +1302,7 @@ Name: phi2, dtype: bool
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_93_0.png" src="_images/03_motion_93_0.png" />
<img alt="_images/03_motion_94_0.png" src="_images/03_motion_94_0.png" />
</div>
</div>
<p>To select rows that fall within these bounds, well 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 +1372,7 @@ Name: phi2, dtype: bool
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_103_0.png" src="_images/03_motion_103_0.png" />
<img alt="_images/03_motion_104_0.png" src="_images/03_motion_104_0.png" />
</div>
</div>
<p>Now thats starting to look like a tidal stream!</p>
@@ -1402,9 +1413,8 @@ Name: phi2, dtype: bool
</div>
<p>Because an HDF5 file can contain more than one Dataset, we have to provide a name, or “key”, that identifies the Dataset in the file.</p>
<p>We could use any string as the key, but in this example I use the variable name <code class="docutils literal notranslate"><span class="pre">df</span></code>.</p>
</div>
<div class="section" id="id2">
<h2>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h2>
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>Were going to need <code class="docutils literal notranslate"><span class="pre">centerline</span></code> and <code class="docutils literal notranslate"><span class="pre">selected</span></code> later as well. Write a line or two of code to add it as a second Dataset in the HDF5 file.</p>
<div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container">
@@ -1457,6 +1467,7 @@ Name: phi2, dtype: bool
</div>
<p>Pandas can write a variety of other formats, <a class="reference external" href="https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html">which you can read about here</a>.</p>
</div>
</div>
<div class="section" id="summary">
<h2>Summary<a class="headerlink" href="#summary" title="Permalink to this headline"></a></h2>
<p>In this lesson, we re-loaded the Gaia data we saved from a previous query.</p>
+3 -3
View File
@@ -1021,12 +1021,12 @@ dtype: float64
<span class="s2"> ON ps.obj_id = best.original_ext_source_id</span>
<span class="s2">&quot;&quot;&quot;</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="c1"># job3 = Gaia.launch_job_async(query=query3, </span>
<span class="n">upload_resource</span><span class="o">=</span><span class="s1">&#39;candidate_df.xml&#39;</span><span class="p">,</span>
<span class="n">upload_table_name</span><span class="o">=</span><span class="s1">&#39;candidate_df&#39;</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>
<span class="c1"># results3 = job3.get_results()</span>
<span class="c1"># results3</span>
</pre></div>
</div>
</div>
+412 -36
View File
@@ -246,6 +246,13 @@
<a class="reference internal nav-link" href="#making-figures-that-tell-a-story">
Making Figures That Tell a Story
</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="#plotting-gd-1">
@@ -256,11 +263,25 @@
<a class="reference internal nav-link" href="#annotations">
Annotations
</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>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#customization">
Customization
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#id2">
Exercise
</a>
</li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#rcparams">
@@ -296,6 +317,13 @@
<a class="reference internal nav-link" href="#lower-right">
Lower right
</a>
<ul class="nav section-nav flex-column">
<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="#subplots">
@@ -306,6 +334,13 @@
<a class="reference internal nav-link" href="#adjusting-proportions">
Adjusting proportions
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#id4">
Exercise
</a>
</li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#summary">
@@ -360,20 +395,52 @@
<p>Not necessarily in that order.</p>
<p>Lets start by reviewing Figure 1 from the original paper. Weve seen the individual panels, but now lets look at the whole thing, along with the caption:</p>
<a class="reference internal image-reference" href="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-5.png"><img alt="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-5.png" src="https://github.com/datacarpentry/astronomy-python/raw/gh-pages/fig/gd1-5.png" style="width: 500px;" /></a>
<p><strong>Exercise:</strong> Think about the following questions:</p>
<div class="section" id="exercise">
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h3>
<p>Think about the following questions:</p>
<ol class="simple">
<li><p>What is the primary scientific result of this work?</p></li>
<li><p>What story is this figure telling?</p></li>
<li><p>In the design of this figure, can you identify 1-2 choices the authors made that you think are effective? Think about big-picture elements, like the number of panels and how they are arranged, as well as details like the choice of typeface.</p></li>
<li><p>Can you identify 1-2 elements that could be improved, or that you might have done differently?</p></li>
</ol>
<p>Some topics that might come up in this discussion:</p>
<ol class="simple">
<li><p>The primary result is that the multiple stages of selection make it possible to separate likely candidates from the background more effectively than in previous work, which makes it possible to see the structure of GD-1 in “unprecedented detail”.</p></li>
<li><p>The figure documents the selection process as a sequence of steps. Reading right-to-left, top-to-bottom, we see selection based on proper motion, the results of the first selection, selection based on color and magnitude, and the results of the second selection. So this figure documents the methodology and presents the primary result.</p></li>
<li><p>Its mostly black and white, with minimal use of color, so it will work well in print. The annotations in the bottom left panel guide the reader to the most important results. It contains enough technical detail for a professional audience, but most of it is also comprehensible to a more general audience. The two left panels have the same dimensions and their axes are aligned.</p></li>
<li><p>Since the panels represent a sequence, it might be better to arrange them left-to-right. The placement and size of the axis labels could be tweaked. The entire figure could be a little bigger to match the width and proportion of the caption. The top left panel has unnused white space (but that leaves space for the annotations in the bottom left).</p></li>
</ol>
<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="c1"># Some topics that might come up in this discussion:</span>
<span class="c1"># 1. The primary result is that the multiple stages of selection </span>
<span class="c1"># make it possible to separate likely candidates from the </span>
<span class="c1"># background more effectively than in previous work, which makes </span>
<span class="c1"># it possible to see the structure of GD-1 in &quot;unprecedented detail&quot;.</span>
<span class="c1"># 2. The figure documents the selection process as a sequence of </span>
<span class="c1"># steps. Reading right-to-left, top-to-bottom, we see selection </span>
<span class="c1"># based on proper motion, the results of the first selection, </span>
<span class="c1"># selection based on color and magnitude, and the results of the </span>
<span class="c1"># second selection. So this figure documents the methodology and </span>
<span class="c1"># presents the primary result.</span>
<span class="c1"># 3. It&#39;s mostly black and white, with minimal use of color, so </span>
<span class="c1"># it will work well in print. The annotations in the bottom </span>
<span class="c1"># left panel guide the reader to the most important results. </span>
<span class="c1"># It contains enough technical detail for a professional audience, </span>
<span class="c1"># but most of it is also comprehensible to a more general audience. </span>
<span class="c1"># The two left panels have the same dimensions and their axes are </span>
<span class="c1"># aligned.</span>
<span class="c1"># 4. Since the panels represent a sequence, it might be better to </span>
<span class="c1"># arrange them left-to-right. The placement and size of the axis </span>
<span class="c1"># labels could be tweaked. The entire figure could be a little </span>
<span class="c1"># bigger to match the width and proportion of the caption. </span>
<span class="c1"># The top left panel has unnused white space (but that leaves </span>
<span class="c1"># space for the annotations in the bottom left).</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="plotting-gd-1">
<h2>Plotting GD-1<a class="headerlink" href="#plotting-gd-1" title="Permalink to this headline"></a></h2>
@@ -391,6 +458,11 @@
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>gd1_merged.hdf5
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -441,7 +513,9 @@
<li><p>A label that identifies the new region, and</p></li>
<li><p>Several annotations that combine text and arrows to identify features of GD-1.</p></li>
</ul>
<p>As an exercise, choose any or all of these features and add them to the figure:</p>
<div class="section" id="id1">
<h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<p>Choose any or all of these features and add them to the figure:</p>
<ul class="simple">
<li><p>To draw vertical lines, see <a class="reference external" href="https://matplotlib.org/3.3.1/api/_as_gen/matplotlib.pyplot.vlines.html"><code class="docutils literal notranslate"><span class="pre">plt.vlines</span></code></a> and <a class="reference external" href="https://matplotlib.org/3.3.1/api/_as_gen/matplotlib.pyplot.axvline.html#matplotlib.pyplot.axvline"><code class="docutils literal notranslate"><span class="pre">plt.axvline</span></code></a>.</p></li>
<li><p>To add text, see <a class="reference external" href="https://matplotlib.org/3.3.1/api/_as_gen/matplotlib.pyplot.text.html"><code class="docutils literal notranslate"><span class="pre">plt.text</span></code></a>.</p></li>
@@ -472,6 +546,7 @@
</div>
</div>
</div>
</div>
<div class="section" id="customization">
<h2>Customization<a class="headerlink" href="#customization" title="Permalink to this headline"></a></h2>
<p>Matplotlib provides a default style that determines things like the colors of lines, the placement of labels and ticks on the axes, and many other properties.</p>
@@ -487,7 +562,9 @@
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">tick_params</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s1">&#39;in&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Exercise:</strong> Read the documentation of <a class="reference external" href="https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.tick_params.html"><code class="docutils literal notranslate"><span class="pre">tick_params</span></code></a> and use it to put ticks on the top and right sides of the axes.</p>
<div class="section" id="id2">
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>Read the documentation of <a class="reference external" href="https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.tick_params.html"><code class="docutils literal notranslate"><span class="pre">tick_params</span></code></a> and use it to put ticks on the top and right sides of the axes.</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>
@@ -498,6 +575,7 @@
</div>
</div>
</div>
</div>
<div class="section" id="rcparams">
<h2>rcParams<a class="headerlink" href="#rcparams" title="Permalink to this headline"></a></h2>
<p>If you want to make a customization that applies to all figures in a notebook, you can use <code class="docutils literal notranslate"><span class="pre">rcParams</span></code>.</p>
@@ -522,7 +600,7 @@
</div>
</div>
</div>
<p><strong>Exercise:</strong> Plot the previous figure again, and see what font sizes have changed. Look up any other element of <code class="docutils literal notranslate"><span class="pre">rcParams</span></code>, change its value, and check the effect on the figure.</p>
<p>As an exercise, plot the previous figure again, and see what font sizes have changed. Look up any other element of <code class="docutils literal notranslate"><span class="pre">rcParams</span></code>, change its value, and check the effect on the figure.</p>
<p>If you find yourself making the same customizations in several notebooks, you can put changes to <code class="docutils literal notranslate"><span class="pre">rcParams</span></code> in a <code class="docutils literal notranslate"><span class="pre">matplotlibrc</span></code> file, <a class="reference external" href="https://matplotlib.org/3.3.1/tutorials/introductory/customizing.html#customizing-with-matplotlibrc-files">which you can read about here</a>.</p>
</div>
<div class="section" id="style-sheets">
@@ -574,7 +652,7 @@
</pre></div>
</div>
<p>The style sheet you choose will affect the appearance of all figures you plot after calling <code class="docutils literal notranslate"><span class="pre">use</span></code>, unless you override any of the options or call <code class="docutils literal notranslate"><span class="pre">use</span></code> again.</p>
<p><strong>Exercise:</strong> Choose one of the styles on the list and select it by calling <code class="docutils literal notranslate"><span class="pre">use</span></code>. Then go back and plot one of the figures above and see what effect it has.</p>
<p>As an exercise, choose one of the styles on the list and select it by calling <code class="docutils literal notranslate"><span class="pre">use</span></code>. Then go back and plot one of the figures above and see what effect it has.</p>
<p>If you cant find a style sheet thats exactly what you want, you can make your own. This repository includes a style sheet called <code class="docutils literal notranslate"><span class="pre">az-paper-twocol.mplstyle</span></code>, with customizations chosen by Azalee Bostroem for publication in astronomy journals.</p>
<p>The following cell downloads the style sheet.</p>
<div class="cell docutils container">
@@ -657,6 +735,11 @@
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>gd1_dataframe.hdf5
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -737,7 +820,7 @@
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_51_0.png" src="_images/07_plot_51_0.png" />
<img alt="_images/07_plot_54_0.png" src="_images/07_plot_54_0.png" />
</div>
</div>
</div>
@@ -756,6 +839,11 @@
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>gd1_candidates.hdf5
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -794,7 +882,7 @@
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_58_0.png" src="_images/07_plot_58_0.png" />
<img alt="_images/07_plot_61_0.png" src="_images/07_plot_61_0.png" />
</div>
</div>
</div>
@@ -845,11 +933,10 @@
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_64_0.png" src="_images/07_plot_64_0.png" />
<img alt="_images/07_plot_67_0.png" src="_images/07_plot_67_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>
<p>Run these cells to get the polygon coordinates we saved in the previous notebook.</p>
<p>The following cell downloads an HDF file that contains the polygon we used to select starts in the color-magnitude diagram, if it doesnt already exist.</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">os</span>
@@ -862,42 +949,301 @@
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>gd1_polygon.hdf5
</pre></div>
</div>
</div>
</div>
<p>And heres how we read it back.</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">loop</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_hdf</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;loop&#39;</span><span class="p">)</span>
<span class="n">loop</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>gi
0.587571 21.411746
0.567801 21.322466
0.548134 21.233380
0.528693 21.144427
0.509300 21.054549
...
0.773743 21.054549
0.798829 21.144427
0.824000 21.233380
0.849503 21.322466
0.875220 21.411746
Name: g, Length: 234, dtype: float64
</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="n">coords_df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_hdf</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;coords_df&#39;</span><span class="p">)</span>
<span class="n">coords</span> <span class="o">=</span> <span class="n">coords_df</span><span class="o">.</span><span class="n">to_numpy</span><span class="p">()</span>
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">coords</span> <span class="o">=</span> <span class="n">loop</span><span class="o">.</span><span class="n">reset_index</span><span class="p">()</span><span class="o">.</span><span class="n">to_numpy</span><span class="p">()</span>
<span class="n">coords</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>array([[ 0.26433692, 17.84253127],
[ 0.35394265, 18.799117 ],
[ 0.47491039, 19.68211921],
[ 0.63172043, 20.45474614],
[ 0.76612903, 20.78587196],
[ 0.80645161, 21.41133186],
[ 0.58691756, 21.30095659],
[ 0.39426523, 20.56512141],
[ 0.22401434, 19.2406181 ],
[ 0.19713262, 18.02649007]])
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>array([[ 0.58757135, 21.41174601],
[ 0.56780097, 21.32246601],
[ 0.54813409, 21.23338001],
[ 0.5286928 , 21.14442701],
[ 0.50929987, 21.05454901],
[ 0.48991266, 20.96383501],
[ 0.47084777, 20.87386601],
[ 0.45222635, 20.78511001],
[ 0.43438902, 20.69865301],
[ 0.42745198, 20.66469601],
[ 0.42067029, 20.63135301],
[ 0.41402867, 20.59850601],
[ 0.40738016, 20.56529901],
[ 0.40088387, 20.53264001],
[ 0.39449608, 20.50023501],
[ 0.38843797, 20.46871801],
[ 0.38251577, 20.43765101],
[ 0.3766547 , 20.40653701],
[ 0.37088531, 20.37564701],
[ 0.36522325, 20.34505401],
[ 0.35962415, 20.31443001],
[ 0.35413292, 20.28413501],
[ 0.34871894, 20.25390101],
[ 0.34339273, 20.22385701],
[ 0.33815825, 20.19395801],
[ 0.33305724, 20.16427301],
[ 0.32820637, 20.13508501],
[ 0.32348139, 20.10604901],
[ 0.31883343, 20.07716101],
[ 0.31425423, 20.04833101],
[ 0.30974976, 20.01961701],
[ 0.30531997, 19.99097001],
[ 0.30097354, 19.96246401],
[ 0.29669999, 19.93401801],
[ 0.29250157, 19.90573101],
[ 0.28837983, 19.87746501],
[ 0.28441584, 19.84955001],
[ 0.28065057, 19.82188301],
[ 0.27700644, 19.79450101],
[ 0.27342328, 19.76713801],
[ 0.26989305, 19.73985301],
[ 0.26641258, 19.71265801],
[ 0.26298257, 19.68540001],
[ 0.25960216, 19.65824401],
[ 0.2562733 , 19.63113701],
[ 0.25299978, 19.60409301],
[ 0.24977307, 19.57714401],
[ 0.24660506, 19.55024001],
[ 0.24348829, 19.52341001],
[ 0.24042159, 19.49666601],
[ 0.23741737, 19.46998501],
[ 0.23447423, 19.44339301],
[ 0.23158726, 19.41688701],
[ 0.22876474, 19.39045101],
[ 0.22600432, 19.36410901],
[ 0.22330395, 19.33786601],
[ 0.220663 , 19.31170101],
[ 0.21808571, 19.28560101],
[ 0.21557456, 19.25960101],
[ 0.21312279, 19.23368701],
[ 0.21073349, 19.20785601],
[ 0.20840975, 19.18210401],
[ 0.20614799, 19.15640601],
[ 0.20395119, 19.13076401],
[ 0.20182156, 19.10523201],
[ 0.19975572, 19.07977101],
[ 0.19775195, 19.05436401],
[ 0.19581903, 19.02902801],
[ 0.19395701, 19.00376101],
[ 0.19216276, 18.97857301],
[ 0.19044513, 18.95347601],
[ 0.1888007 , 18.92850001],
[ 0.18723796, 18.90368201],
[ 0.18576648, 18.87905401],
[ 0.18438763, 18.85466301],
[ 0.18310871, 18.83056001],
[ 0.18193706, 18.80672701],
[ 0.18087817, 18.78327401],
[ 0.17993184, 18.76015001],
[ 0.17910244, 18.73740501],
[ 0.17838817, 18.71496101],
[ 0.17779005, 18.69282101],
[ 0.177312 , 18.67099501],
[ 0.17694971, 18.64944001],
[ 0.1767112 , 18.62815801],
[ 0.17659065, 18.60714001],
[ 0.17658939, 18.58636601],
[ 0.17671618, 18.56585701],
[ 0.17696696, 18.54562201],
[ 0.17733781, 18.52565801],
[ 0.1778346 , 18.50597901],
[ 0.17846661, 18.48656801],
[ 0.17922891, 18.46742401],
[ 0.18012796, 18.44859001],
[ 0.18116197, 18.43005501],
[ 0.18233604, 18.41181501],
[ 0.18363223, 18.39379401],
[ 0.18506009, 18.37602901],
[ 0.18660932, 18.35862101],
[ 0.18829849, 18.34153201],
[ 0.19012805, 18.32480701],
[ 0.19210919, 18.30851301],
[ 0.19422686, 18.29250401],
[ 0.1964951 , 18.27685701],
[ 0.19890209, 18.26156301],
[ 0.20145338, 18.24666001],
[ 0.20417715, 18.23260501],
[ 0.20705285, 18.21898101],
[ 0.21005661, 18.20562501],
[ 0.21319339, 18.19254201],
[ 0.22126873, 18.16185301],
[ 0.2300065 , 18.13259301],
[ 0.23950909, 18.10508001],
[ 0.24974677, 18.07932501],
[ 0.26066153, 18.05527801],
[ 0.27224553, 18.03295501],
[ 0.28447607, 18.01227601],
[ 0.40566013, 18.01227601],
[ 0.39412682, 18.03295501],
[ 0.38329907, 18.05527801],
[ 0.37320316, 18.07932501],
[ 0.36384734, 18.10508001],
[ 0.35529237, 18.13259301],
[ 0.34756872, 18.16185301],
[ 0.34056407, 18.19254201],
[ 0.33788593, 18.20562501],
[ 0.33535176, 18.21898101],
[ 0.33295648, 18.23260501],
[ 0.33072983, 18.24666001],
[ 0.32870734, 18.26156301],
[ 0.32684482, 18.27685701],
[ 0.3251355 , 18.29250401],
[ 0.32359167, 18.30851301],
[ 0.32219665, 18.32480701],
[ 0.32097089, 18.34153201],
[ 0.31990093, 18.35862101],
[ 0.31898485, 18.37602901],
[ 0.3182056 , 18.39379401],
[ 0.31756993, 18.41181501],
[ 0.31706705, 18.43005501],
[ 0.31671781, 18.44859001],
[ 0.3165174 , 18.46742401],
[ 0.31646817, 18.48656801],
[ 0.3165622 , 18.50597901],
[ 0.31680458, 18.52565801],
[ 0.31718682, 18.54562201],
[ 0.31770268, 18.56585701],
[ 0.31835632, 18.58636601],
[ 0.31915162, 18.60714001],
[ 0.32007915, 18.62815801],
[ 0.3211385 , 18.64944001],
[ 0.32233599, 18.67099501],
[ 0.32366367, 18.69282101],
[ 0.32512771, 18.71496101],
[ 0.32672398, 18.73740501],
[ 0.32845154, 18.76015001],
[ 0.33031546, 18.78327401],
[ 0.33230964, 18.80672701],
[ 0.33443651, 18.83056001],
[ 0.3366864 , 18.85466301],
[ 0.3390529 , 18.87905401],
[ 0.34152681, 18.90368201],
[ 0.34410502, 18.92850001],
[ 0.34677677, 18.95347601],
[ 0.34953217, 18.97857301],
[ 0.35237348, 19.00376101],
[ 0.35529144, 19.02902801],
[ 0.35828883, 19.05436401],
[ 0.36136575, 19.07977101],
[ 0.36451277, 19.10523201],
[ 0.36773241, 19.13076401],
[ 0.37102978, 19.15640601],
[ 0.37440044, 19.18210401],
[ 0.37784139, 19.20785601],
[ 0.38135736, 19.23368701],
[ 0.38494552, 19.25960101],
[ 0.388603 , 19.28560101],
[ 0.39233725, 19.31170101],
[ 0.39614435, 19.33786601],
[ 0.40002069, 19.36410901],
[ 0.40396796, 19.39045101],
[ 0.40798805, 19.41688701],
[ 0.41208235, 19.44339301],
[ 0.41624335, 19.46998501],
[ 0.42047622, 19.49666601],
[ 0.42478124, 19.52341001],
[ 0.42914714, 19.55024001],
[ 0.43357463, 19.57714401],
[ 0.43806989, 19.60409301],
[ 0.44262347, 19.63113701],
[ 0.44724247, 19.65824401],
[ 0.4519225 , 19.68540001],
[ 0.45666424, 19.71265801],
[ 0.46146067, 19.73985301],
[ 0.46631851, 19.76713801],
[ 0.47124047, 19.79450101],
[ 0.47623175, 19.82188301],
[ 0.48136578, 19.84955001],
[ 0.48671855, 19.87746501],
[ 0.49225451, 19.90573101],
[ 0.49787627, 19.93401801],
[ 0.50358931, 19.96246401],
[ 0.50938655, 19.99097001],
[ 0.51528266, 20.01961701],
[ 0.52126534, 20.04833101],
[ 0.52733726, 20.07716101],
[ 0.53348957, 20.10604901],
[ 0.53973535, 20.13508501],
[ 0.54612384, 20.16427301],
[ 0.55279781, 20.19395801],
[ 0.55962597, 20.22385701],
[ 0.56656311, 20.25390101],
[ 0.57360789, 20.28413501],
[ 0.58074299, 20.31443001],
[ 0.5880138 , 20.34505401],
[ 0.59535596, 20.37564701],
[ 0.60283203, 20.40653701],
[ 0.61042265, 20.43765101],
[ 0.61808231, 20.46871801],
[ 0.62591386, 20.50023501],
[ 0.63413647, 20.53264001],
[ 0.64249372, 20.56529901],
[ 0.65104657, 20.59850601],
[ 0.659584 , 20.63135301],
[ 0.66830253, 20.66469601],
[ 0.67722496, 20.69865301],
[ 0.70017638, 20.78511001],
[ 0.72413715, 20.87386601],
[ 0.74870785, 20.96383501],
[ 0.77374297, 21.05454901],
[ 0.7988286 , 21.14442701],
[ 0.8240001 , 21.23338001],
[ 0.84950281, 21.32246601],
[ 0.8752204 , 21.41174601]])
</pre></div>
</div>
</div>
</div>
<div class="section" id="id3">
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3>
<p>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>
<p>Hint: pass <code class="docutils literal notranslate"><span class="pre">coords</span></code> as an argument to <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> and plot it using <code class="docutils literal notranslate"><span class="pre">add_patch</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>
<span class="c1">#poly = Polygon(coords, closed=True, </span>
<span class="c1"># facecolor=&#39;C1&#39;, alpha=0.4)</span>
<span class="c1">#plt.gca().add_patch(poly)</span>
<span class="c1"># poly = Polygon(coords, closed=True, </span>
<span class="c1"># facecolor=&#39;C1&#39;, alpha=0.4)</span>
<span class="c1"># plt.gca().add_patch(poly)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="subplots">
<h2>Subplots<a class="headerlink" href="#subplots" title="Permalink to this headline"></a></h2>
<p>Now were ready to put it all together. To make a figure with four subplots, well use <code class="docutils literal notranslate"><span class="pre">subplot2grid</span></code>, <a class="reference external" href="https://matplotlib.org/3.3.1/api/_as_gen/matplotlib.pyplot.subplot2grid.html">which requires two arguments</a>:</p>
@@ -931,11 +1277,11 @@
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_70_0.png" src="_images/07_plot_70_0.png" />
<img alt="_images/07_plot_76_0.png" src="_images/07_plot_76_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 dont overlap.</p>
<p><strong>Exercise:</strong> See what happens if you leave out <code class="docutils literal notranslate"><span class="pre">tight_layout</span></code>.</p>
<p>As an exercise, see what happens if you leave out <code class="docutils literal notranslate"><span class="pre">tight_layout</span></code>.</p>
</div>
<div class="section" id="adjusting-proportions">
<h2>Adjusting proportions<a class="headerlink" href="#adjusting-proportions" title="Permalink to this headline"></a></h2>
@@ -969,11 +1315,41 @@
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_73_0.png" src="_images/07_plot_73_0.png" />
<img alt="_images/07_plot_79_0.png" src="_images/07_plot_79_0.png" />
</div>
</div>
<p>This is looking more and more like the figure in the paper.</p>
<p><strong>Exercise:</strong> In this example, the ratio of the widths of the panels is 3:1. How would you adjust it if you wanted the ratio to be 3:2?</p>
<div class="section" id="id4">
<h3>Exercise<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h3>
<p>In this example, the ratio of the widths of the panels is 3:1. How would you adjust it if you wanted the ratio to be 3:2?</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="c1"># plt.figure(figsize=(9, 4.5))</span>
<span class="c1"># shape = (2, 5) # CHANGED</span>
<span class="c1"># plt.subplot2grid(shape, (0, 0), colspan=3)</span>
<span class="c1"># plot_first_selection(candidate_df)</span>
<span class="c1"># plt.subplot2grid(shape, (0, 3), colspan=2) # CHANGED</span>
<span class="c1"># plot_proper_motion(centerline)</span>
<span class="c1"># plt.subplot2grid(shape, (1, 0), colspan=3)</span>
<span class="c1"># plot_second_selection(selected)</span>
<span class="c1"># plt.subplot2grid(shape, (1, 3), colspan=2) # CHANGED</span>
<span class="c1"># plot_cmd(merged)</span>
<span class="c1"># poly = Polygon(coords, closed=True, </span>
<span class="c1"># facecolor=&#39;C1&#39;, alpha=0.4)</span>
<span class="c1"># plt.gca().add_patch(poly)</span>
<span class="c1"># plt.tight_layout()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="summary">
<h2>Summary<a class="headerlink" href="#summary" title="Permalink to this headline"></a></h2>
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

+19 -1
View File
@@ -14,6 +14,7 @@
"exercises: 0\n",
"questions:\n",
"- \"How can we select and download the data we want from the Gaia server?\"\n",
"\n",
"objectives:\n",
"- \"Compose a basic query in ADQL/SQL.\"\n",
"- \"Use queries to explore a database and its tables.\"\n",
@@ -38,7 +39,6 @@
"lines, but you should.\"\n",
"\n",
"---\n",
"FIXME\n",
"\n",
"{% include links.md %}\n"
]
@@ -887,6 +887,15 @@
"Read [the documentation of this table](https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_main_tables/ssec_dm_gaia_source.html) and choose a column that looks interesting to you. Add the column name to the query and run it again. What are the units of the column you selected? What is its data type?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -1071,6 +1080,15 @@
"* Launching test queries synchronously might make them start faster, too."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
+19 -2
View File
@@ -35,7 +35,6 @@
"- \"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"
]
@@ -243,7 +242,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"### Exercise\n",
"\n",
"When you are debugging queries like this, you can use `TOP` to limit the size of the results, but then you still don't know how big the results will be.\n",
"\n",
@@ -252,6 +251,24 @@
"In the previous query, replace `TOP 10 source_id` with `COUNT(source_id)` and run the query again. How many stars has Gaia identified in the cone we searched?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Solution\n",
"\n",
"query = \"\"\"\n",
"SELECT \n",
"COUNT(source_id)\n",
"FROM gaiadr2.gaia_source\n",
"WHERE 1=CONTAINS(\n",
" POINT(ra, dec),\n",
" CIRCLE(266.41683, -29.00781, 0.08333333))\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
+16 -9
View File
@@ -12,11 +12,10 @@
"title: \"Plotting and Pandas\"\n",
"teaching: 3000\n",
"exercises: 0\n",
"\n",
"questions:\n",
"\n",
"- \"How do we make scatter plots in Matplotlib?\"\n",
"\n",
"- \"How do we store data in a Pandas `DataFrame`?\"\n",
"- \"How do we make scatter plots in Matplotlib? How do we store data in a Pandas `DataFrame`?\"\n",
"\n",
"objectives:\n",
"\n",
@@ -32,14 +31,13 @@
"\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",
"- \"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",
"- \"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"
]
@@ -123,7 +121,7 @@
"IN_COLAB = 'google.colab' in sys.modules\n",
"\n",
"if IN_COLAB:\n",
" !pip install astroquery astro-gala python-wget"
" !pip install astroquery astro-gala wget"
]
},
{
@@ -577,7 +575,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"### Exercise\n",
"\n",
"In the call to `plt.plot`, add the keyword argument `markersize=0.1` to make the markers smaller.\n",
"\n",
@@ -588,6 +586,15 @@
"Note: Once you have made these changes, you might notice that the figure shows stripes with lower density of stars. These stripes are caused by the way Gaia scans the sky, which [you can read about here](https://www.cosmos.esa.int/web/gaia/scanning-law). The dataset we are using, [Gaia Data Release 2](https://www.cosmos.esa.int/web/gaia/dr2), covers 22 months of observations; during this time, some parts of the sky were scanned more than others."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -1996,7 +2003,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise \n",
"### Exercise \n",
"\n",
"We're going to need `centerline` and `selected` later as well. Write a line or two of code to add it as a second Dataset in the HDF5 file."
]
+2 -3
View File
@@ -14,7 +14,7 @@
"exercises: 0\n",
"questions:\n",
"\n",
"- \"Question?\"\n",
"- \"How do we transform proper motion from one frame to another?\"\n",
"\n",
"objectives:\n",
"\n",
@@ -35,7 +35,6 @@
"- \"On the other hand, CSV is a 'least common denominator' format; that is, it can be read by practically any application that works with data.\"\n",
"\n",
"---\n",
"FIXME\n",
"\n",
"{% include links.md %}\n"
]
@@ -115,7 +114,7 @@
"IN_COLAB = 'google.colab' in sys.modules\n",
"\n",
"if IN_COLAB:\n",
" !pip install astroquery astro-gala python-wget"
" !pip install astroquery astro-gala wget"
]
},
{
+5 -6
View File
@@ -22,10 +22,9 @@
"\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",
"- \"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"
]
@@ -101,7 +100,7 @@
"IN_COLAB = 'google.colab' in sys.modules\n",
"\n",
"if IN_COLAB:\n",
" !pip install astroquery astro-gala python-wget"
" !pip install astroquery astro-gala wget"
]
},
{
@@ -1393,12 +1392,12 @@
" ON ps.obj_id = best.original_ext_source_id\n",
"\"\"\"\n",
"\n",
"job3 = Gaia.launch_job_async(query=query3, \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"
"# results3 = job3.get_results()\n",
"# results3"
]
},
{
+3 -4
View File
@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"---\n",
"title: \"Title\"\n",
"title: \"Photometry\"\n",
"teaching: 3000\n",
"exercises: 0\n",
"questions:\n",
@@ -14,7 +14,7 @@
"\n",
"objectives:\n",
"\n",
"- \"Use Matplotlib to specify a `Polygon` and determine which points fall inside it.\"\n",
"- \"Use Matplotlib to specify a polygon and determine which points fall inside it.\"\n",
"\n",
"- \"Use Pandas to merge data from multiple `DataFrames`, much like a database `JOIN` operation.\"\n",
"\n",
@@ -29,7 +29,6 @@
"- \"Be sure to record every element of the data analysis pipeline that would be needed to replicate the results.\"\n",
"\n",
"---\n",
"FIXME\n",
"\n",
"{% include links.md %}\n"
]
@@ -108,7 +107,7 @@
"IN_COLAB = 'google.colab' in sys.modules\n",
"\n",
"if IN_COLAB:\n",
" !pip install astroquery astro-gala python-wget"
" !pip install astroquery astro-gala wget"
]
},
{
+477 -84
View File
File diff suppressed because one or more lines are too long
+12 -1
View File
@@ -12,7 +12,9 @@
"\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."
"3. A cell where you will paste a line of code you copy from Slack, to check for a potential problem with \"smart\" quotes.\n",
"\n",
"At the end there's a link to a survey where you can let us know you're done, or if you have any problems."
]
},
{
@@ -227,6 +229,15 @@
"If you have trouble with this, let us know and we will provide more details."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Survey\n",
"\n",
"Please fill out [this survey](https://forms.gle/aWikZ88xA1Rcvsvx8) to let us know when you are done."
]
},
{
"cell_type": "code",
"execution_count": null,
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -5
View File
@@ -107,27 +107,27 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="03_motion.html">
Chapter 3
Proper Motion
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="04_select.html">
Chapter 4
Transformation and Selection
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="05_join.html">
Chapter 5
Joining Tables
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="06_photo.html">
Chapter 6
Photometry
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="07_plot.html">
Chapter 7
Visualization
</a>
</li>
</ul>
@@ -263,6 +263,11 @@
Check for code-pasting problems
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#survey">
Survey
</a>
</li>
</ul>
</nav>
@@ -282,6 +287,7 @@
<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>
<p>At the end theres a link to a survey where you can let us know youre done, or if you have any problems.</p>
<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>
@@ -412,6 +418,10 @@ 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 class="section" id="survey">
<h2>Survey<a class="headerlink" href="#survey" title="Permalink to this headline"></a></h2>
<p>Please fill out <a class="reference external" href="https://forms.gle/aWikZ88xA1Rcvsvx8">this survey</a> to let us know when you are done.</p>
</div>
</div>
<script type="text/x-thebe-config">