mirror of
https://github.com/AllenDowney/AstronomicalData.git
synced 2026-01-07 01:53:27 -08:00
Update documentation
This commit is contained in:
354
04_select.html
354
04_select.html
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user