mirror of
https://github.com/AllenDowney/AstronomicalData.git
synced 2025-12-22 07:10:38 -08:00
Update documentation
This commit is contained in:
101
02_coords.html
101
02_coords.html
@@ -1701,101 +1701,34 @@ For example, we can transform <code class="docutils literal notranslate"><span c
|
||||
<span class="sd">"""</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p><code class="docutils literal notranslate"><span class="pre">corners_icrs</span></code> behaves like a list, so we can use a <code class="docutils literal notranslate"><span class="pre">for</span></code> loop to iterate through the points.</p>
|
||||
<p>The following function does the job:</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="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">corners_icrs</span><span class="p">:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">point</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><SkyCoord (ICRS): (ra, dec) in deg
|
||||
(146.27533314, 19.26190982)>
|
||||
<SkyCoord (ICRS): (ra, dec) in deg
|
||||
(135.42163944, 25.87738723)>
|
||||
<SkyCoord (ICRS): (ra, dec) in deg
|
||||
(141.60264825, 34.3048303)>
|
||||
<SkyCoord (ICRS): (ra, dec) in deg
|
||||
(152.81671045, 27.13611254)>
|
||||
<SkyCoord (ICRS): (ra, dec) in deg
|
||||
(146.27533314, 19.26190982)>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">skycoord_to_string</span><span class="p">(</span><span class="n">skycoord</span><span class="p">):</span>
|
||||
<span class="sd">"""Convert SkyCoord to string."""</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">skycoord</span><span class="o">.</span><span class="n">to_string</span><span class="p">()</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="s1">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' '</span><span class="p">,</span> <span class="s1">', '</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>From that, we can select the coordinates <code class="docutils literal notranslate"><span class="pre">ra</span></code> and <code class="docutils literal notranslate"><span class="pre">dec</span></code>:</p>
|
||||
<p><code class="docutils literal notranslate"><span class="pre">SkyCoord</span></code> provides <code class="docutils literal notranslate"><span class="pre">to_string</span></code>, which returns a list of strings.</p>
|
||||
<p>We use <code class="docutils literal notranslate"><span class="pre">join</span></code> to make a single string with spaces between the coordinates.</p>
|
||||
<p>Then we use <code class="docutils literal notranslate"><span class="pre">replace</span></code> to add commas between the coordinates.</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="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">corners_icrs</span><span class="p">:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">point</span><span class="o">.</span><span class="n">ra</span><span class="p">,</span> <span class="n">point</span><span class="o">.</span><span class="n">dec</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>146d16m31.1993s 19d15m42.8754s
|
||||
135d25m17.902s 25d52m38.594s
|
||||
141d36m09.5337s 34d18m17.3891s
|
||||
152d49m00.1576s 27d08m10.0051s
|
||||
146d16m31.1993s 19d15m42.8754s
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The results are quantities with units, but if we select the <code class="docutils literal notranslate"><span class="pre">value</span></code> part, we get a dimensionless floating-point number.</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="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">corners_icrs</span><span class="p">:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">point</span><span class="o">.</span><span class="n">ra</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">point</span><span class="o">.</span><span class="n">dec</span><span class="o">.</span><span class="n">value</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>146.27533313607782 19.261909820533692
|
||||
135.42163944306296 25.87738722767213
|
||||
141.60264825107333 34.304830296257144
|
||||
152.81671044675923 27.136112541397996
|
||||
146.27533313607782 19.261909820533692
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>We can use string <code class="docutils literal notranslate"><span class="pre">format</span></code> to convert these numbers to strings.</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">point_base</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{point.ra.value}</span><span class="s2">, </span><span class="si">{point.dec.value}</span><span class="s2">"</span>
|
||||
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="p">[</span><span class="n">point_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">point</span><span class="o">=</span><span class="n">point</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">corners_icrs</span><span class="p">]</span>
|
||||
<span class="n">t</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>['146.27533313607782, 19.261909820533692',
|
||||
'135.42163944306296, 25.87738722767213',
|
||||
'141.60264825107333, 34.304830296257144',
|
||||
'152.81671044675923, 27.136112541397996',
|
||||
'146.27533313607782, 19.261909820533692']
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The result is a list of strings, which we can join into a single string using <code class="docutils literal notranslate"><span class="pre">join</span></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="n">point_list</span> <span class="o">=</span> <span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">point_list</span> <span class="o">=</span> <span class="n">skycoord_to_string</span><span class="p">(</span><span class="n">corners_icrs</span><span class="p">)</span>
|
||||
<span class="n">point_list</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>'146.27533313607782, 19.261909820533692, 135.42163944306296, 25.87738722767213, 141.60264825107333, 34.304830296257144, 152.81671044675923, 27.136112541397996, 146.27533313607782, 19.261909820533692'
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>'146.275, 19.2619, 135.422, 25.8774, 141.603, 34.3048, 152.817, 27.1361, 146.275, 19.2619'
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Notice that we invoke <code class="docutils literal notranslate"><span class="pre">join</span></code> on a string and pass the list as an argument.</p>
|
||||
<p>Before we can assemble the query, we need <code class="docutils literal notranslate"><span class="pre">columns</span></code> again (as we saw in the previous notebook).</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -1833,7 +1766,7 @@ FROM gaiadr2.gaia_source
|
||||
WHERE parallax < 1
|
||||
AND bp_rp BETWEEN -0.75 AND 2
|
||||
AND 1 = CONTAINS(POINT(ra, dec),
|
||||
POLYGON(146.27533313607782, 19.261909820533692, 135.42163944306296, 25.87738722767213, 141.60264825107333, 34.304830296257144, 152.81671044675923, 27.136112541397996, 146.27533313607782, 19.261909820533692))
|
||||
POLYGON(146.275, 19.2619, 135.422, 25.8774, 141.603, 34.3048, 152.817, 27.1361, 146.275, 19.2619))
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1849,7 +1782,7 @@ WHERE parallax < 1
|
||||
</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]
|
||||
<Table length=140340>
|
||||
<Table length=140339>
|
||||
name dtype unit description n_bad
|
||||
--------------- ------- -------- ------------------------------------------------------------------ ------
|
||||
source_id int64 Unique source identifier (unique within a particular Data Release) 0
|
||||
@@ -1859,11 +1792,11 @@ WHERE parallax < 1
|
||||
pmdec float64 mas / yr Proper motion in declination direction 0
|
||||
parallax float64 mas Parallax 0
|
||||
parallax_error float64 mas Standard error of parallax 0
|
||||
radial_velocity float64 km / s Radial velocity 139374
|
||||
Jobid: 1609260439320O
|
||||
radial_velocity float64 km / s Radial velocity 139373
|
||||
Jobid: 1609277169233O
|
||||
Phase: COMPLETED
|
||||
Owner: None
|
||||
Output file: async_20201229114719.vot
|
||||
Output file: async_20201229162609.vot
|
||||
Results: None
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -1878,7 +1811,7 @@ Results: None
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>140340
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>140339
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
108
04_select.html
108
04_select.html
@@ -605,62 +605,33 @@ The next step is to use it as part of an ADQL query.</p>
|
||||
<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>
|
||||
<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.
|
||||
Using <code class="docutils literal notranslate"><span class="pre">flatten</span></code> and <code class="docutils literal notranslate"><span class="pre">array2string</span></code>, we can almost get the format we need.</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">t</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">pm_vertices</span><span class="o">.</span><span class="n">flatten</span><span class="p">()]</span>
|
||||
<span class="n">t</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">s</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array2string</span><span class="p">(</span><span class="n">pm_vertices</span><span class="o">.</span><span class="n">flatten</span><span class="p">(),</span>
|
||||
<span class="n">max_line_width</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span>
|
||||
<span class="n">separator</span><span class="o">=</span><span class="s1">','</span><span class="p">)</span>
|
||||
<span class="n">s</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>['-4.050371212154984',
|
||||
'-14.75623260987968',
|
||||
'-3.4198108491382455',
|
||||
'-14.723655456335619',
|
||||
'-3.035219883740934',
|
||||
'-14.443571352854612',
|
||||
'-2.268479190206636',
|
||||
'-13.714023598831554',
|
||||
'-2.611722027231764',
|
||||
'-13.247974712069263',
|
||||
'-2.7347140078529106',
|
||||
'-13.090544709622938',
|
||||
'-3.199231461993783',
|
||||
'-12.594265302440828',
|
||||
'-3.34082545787549',
|
||||
'-12.476119260818695',
|
||||
'-5.674894125178565',
|
||||
'-11.160833381392624',
|
||||
'-5.95159272432137',
|
||||
'-11.105478836426514',
|
||||
'-6.423940229776128',
|
||||
'-11.05981294804957',
|
||||
'-7.096310230579248',
|
||||
'-11.951878058650085',
|
||||
'-7.306415190921692',
|
||||
'-12.245599765990594',
|
||||
'-7.040166963232815',
|
||||
'-12.885807024935527',
|
||||
'-6.0034770546523735',
|
||||
'-13.759120984106968',
|
||||
'-4.42442296194263',
|
||||
'-14.7464117578883']
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>'[ -4.05037121,-14.75623261, -3.41981085,-14.72365546, -3.03521988,-14.44357135, -2.26847919,-13.7140236 , -2.61172203,-13.24797471, -2.73471401,-13.09054471, -3.19923146,-12.5942653 , -3.34082546,-12.47611926, -5.67489413,-11.16083338, -5.95159272,-11.10547884, -6.42394023,-11.05981295, -7.09631023,-11.95187806, -7.30641519,-12.24559977, -7.04016696,-12.88580702, -6.00347705,-13.75912098, -4.42442296,-14.74641176]'
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Now <code class="docutils literal notranslate"><span class="pre">t</span></code> is a list of strings; we can use <code class="docutils literal notranslate"><span class="pre">join</span></code> to make a single string with commas between the elements.</p>
|
||||
<p>We just have to remove the brackets.</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">pm_point_list</span> <span class="o">=</span> <span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">pm_point_list</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">'[]'</span><span class="p">)</span>
|
||||
<span class="n">pm_point_list</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>'-4.050371212154984, -14.75623260987968, -3.4198108491382455, -14.723655456335619, -3.035219883740934, -14.443571352854612, -2.268479190206636, -13.714023598831554, -2.611722027231764, -13.247974712069263, -2.7347140078529106, -13.090544709622938, -3.199231461993783, -12.594265302440828, -3.34082545787549, -12.476119260818695, -5.674894125178565, -11.160833381392624, -5.95159272432137, -11.105478836426514, -6.423940229776128, -11.05981294804957, -7.096310230579248, -11.951878058650085, -7.306415190921692, -12.245599765990594, -7.040166963232815, -12.885807024935527, -6.0034770546523735, -13.759120984106968, -4.42442296194263, -14.7464117578883'
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>' -4.05037121,-14.75623261, -3.41981085,-14.72365546, -3.03521988,-14.44357135, -2.26847919,-13.7140236 , -2.61172203,-13.24797471, -2.73471401,-13.09054471, -3.19923146,-12.5942653 , -3.34082546,-12.47611926, -5.67489413,-11.16083338, -5.95159272,-11.10547884, -6.42394023,-11.05981295, -7.09631023,-11.95187806, -7.30641519,-12.24559977, -7.04016696,-12.88580702, -6.00347705,-13.75912098, -4.42442296,-14.74641176'
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -693,7 +664,10 @@ The next step is to use it as part of an ADQL query.</p>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">gala.coordinates</span> <span class="kn">import</span> <span class="n">GD1Koposov10</span>
|
||||
<span class="kn">from</span> <span class="nn">astropy.coordinates</span> <span class="kn">import</span> <span class="n">SkyCoord</span>
|
||||
|
||||
<span class="n">corners</span> <span class="o">=</span> <span class="n">SkyCoord</span><span class="p">(</span><span class="n">phi1</span><span class="o">=</span><span class="n">phi1_rect</span><span class="p">,</span> <span class="n">phi2</span><span class="o">=</span><span class="n">phi2_rect</span><span class="p">,</span> <span class="n">frame</span><span class="o">=</span><span class="n">GD1Koposov10</span><span class="p">)</span>
|
||||
<span class="n">corners</span> <span class="o">=</span> <span class="n">SkyCoord</span><span class="p">(</span><span class="n">phi1</span><span class="o">=</span><span class="n">phi1_rect</span><span class="p">,</span>
|
||||
<span class="n">phi2</span><span class="o">=</span><span class="n">phi2_rect</span><span class="p">,</span>
|
||||
<span class="n">frame</span><span class="o">=</span><span class="n">GD1Koposov10</span><span class="p">)</span>
|
||||
|
||||
<span class="n">corners_icrs</span> <span class="o">=</span> <span class="n">corners</span><span class="o">.</span><span class="n">transform_to</span><span class="p">(</span><span class="s1">'icrs'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -702,18 +676,24 @@ The next step is to use it as part of an ADQL query.</p>
|
||||
<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">
|
||||
<div class="cell_input docutils container">
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">point_base</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{point.ra.value}</span><span class="s2">, </span><span class="si">{point.dec.value}</span><span class="s2">"</span>
|
||||
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="p">[</span><span class="n">point_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">point</span><span class="o">=</span><span class="n">point</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">point</span> <span class="ow">in</span> <span class="n">corners_icrs</span><span class="p">]</span>
|
||||
|
||||
<span class="n">point_list</span> <span class="o">=</span> <span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">skycoord_to_string</span><span class="p">(</span><span class="n">skycoord</span><span class="p">):</span>
|
||||
<span class="sd">"""Convert SkyCoord to string."""</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">skycoord</span><span class="o">.</span><span class="n">to_string</span><span class="p">()</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="s1">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">' '</span><span class="p">,</span> <span class="s1">', '</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="n">point_list</span> <span class="o">=</span> <span class="n">skycoord_to_string</span><span class="p">(</span><span class="n">corners_icrs</span><span class="p">)</span>
|
||||
<span class="n">point_list</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>'135.30559858565638, 8.398623940157561, 126.50951508623503, 13.44494195652069, 163.0173655836748, 54.24242734020255, 172.9328536286811, 46.47260492416258, 135.30559858565638, 8.398623940157561'
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>'135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862'
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -785,9 +765,9 @@ FROM gaiadr2.gaia_source
|
||||
WHERE parallax < 1
|
||||
AND bp_rp BETWEEN -0.75 AND 2
|
||||
AND 1 = CONTAINS(POINT(ra, dec),
|
||||
POLYGON(135.30559858565638, 8.398623940157561, 126.50951508623503, 13.44494195652069, 163.0173655836748, 54.24242734020255, 172.9328536286811, 46.47260492416258, 135.30559858565638, 8.398623940157561))
|
||||
POLYGON(135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862))
|
||||
AND 1 = CONTAINS(POINT(pmra, pmdec),
|
||||
POLYGON(-4.050371212154984, -14.75623260987968, -3.4198108491382455, -14.723655456335619, -3.035219883740934, -14.443571352854612, -2.268479190206636, -13.714023598831554, -2.611722027231764, -13.247974712069263, -2.7347140078529106, -13.090544709622938, -3.199231461993783, -12.594265302440828, -3.34082545787549, -12.476119260818695, -5.674894125178565, -11.160833381392624, -5.95159272432137, -11.105478836426514, -6.423940229776128, -11.05981294804957, -7.096310230579248, -11.951878058650085, -7.306415190921692, -12.245599765990594, -7.040166963232815, -12.885807024935527, -6.0034770546523735, -13.759120984106968, -4.42442296194263, -14.7464117578883))
|
||||
POLYGON( -4.05037121,-14.75623261, -3.41981085,-14.72365546, -3.03521988,-14.44357135, -2.26847919,-13.7140236 , -2.61172203,-13.24797471, -2.73471401,-13.09054471, -3.19923146,-12.5942653 , -3.34082546,-12.47611926, -5.67489413,-11.16083338, -5.95159272,-11.10547884, -6.42394023,-11.05981295, -7.09631023,-11.95187806, -7.30641519,-12.24559977, -7.04016696,-12.88580702, -6.00347705,-13.75912098, -4.42442296,-14.74641176))
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -803,18 +783,8 @@ WHERE parallax < 1
|
||||
</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
|
||||
INFO: Query finished. [astroquery.utils.tap.core]
|
||||
<Table length=7346>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
|
||||
<Table length=7345>
|
||||
name dtype unit description n_bad
|
||||
--------------- ------- -------- ------------------------------------------------------------------ -----
|
||||
source_id int64 Unique source identifier (unique within a particular Data Release) 0
|
||||
@@ -823,11 +793,11 @@ INFO: Query finished. [astroquery.utils.tap.core]
|
||||
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: 1609260557475O
|
||||
radial_velocity float64 km / s Radial velocity 7294
|
||||
Jobid: 1609278364817O
|
||||
Phase: COMPLETED
|
||||
Owner: None
|
||||
Output file: async_20201229114917.vot
|
||||
Output file: async_20201229164604.vot
|
||||
Results: None
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -842,7 +812,7 @@ Results: None
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>7346
|
||||
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>7345
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -864,7 +834,7 @@ Results: None
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_57_0.png" src="_images/04_select_57_0.png" />
|
||||
<img alt="_images/04_select_58_0.png" src="_images/04_select_58_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>
|
||||
@@ -923,7 +893,7 @@ Results: None
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<img alt="_images/04_select_63_0.png" src="_images/04_select_63_0.png" />
|
||||
<img alt="_images/04_select_64_0.png" src="_images/04_select_64_0.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>We’re starting to see GD-1 more clearly.</p>
|
||||
@@ -954,7 +924,7 @@ Results: None
|
||||
</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 29 11:50 gd1_candidates.hdf5
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 698K Dec 29 16:46 gd1_candidates.hdf5
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -987,7 +957,7 @@ Results: None
|
||||
</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 29 11:50 gd1_candidates.csv
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-rw-rw-r-- 1 downey downey 1.4M Dec 29 16:46 gd1_candidates.csv
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -898,7 +898,7 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>The intention seems to be to define a polygon that gets wider as <code class="docutils literal notranslate"><span class="pre">g</span></code> increases.</p>
|
||||
<p>The intention is to define a polygon that gets wider as <code class="docutils literal notranslate"><span class="pre">g</span></code> increases, to reflect increasing uncertainty.</p>
|
||||
<p>But we can do about as well with a simpler formula:</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
|
||||
BIN
_images/04_select_58_0.png
Normal file
BIN
_images/04_select_58_0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
BIN
_images/04_select_64_0.png
Normal file
BIN
_images/04_select_64_0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -136,7 +136,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install [Astroquery](https://astroquery.readthedocs.io/en/latest/) and [Gala](https://gala-astro.readthedocs.io/en/latest/).\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll need.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
@@ -157,7 +157,7 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery astro-gala"
|
||||
" !pip install astroquery"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install Astroquery and the other libraries we'll use.\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
@@ -114,7 +114,7 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery gala"
|
||||
" !pip install astroquery astro-gala"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1752,154 +1752,51 @@
|
||||
"\"\"\"\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"`corners_icrs` behaves like a list, so we can use a `for` loop to iterate through the points."
|
||||
"The following function does the job:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 58,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<SkyCoord (ICRS): (ra, dec) in deg\n",
|
||||
" (146.27533314, 19.26190982)>\n",
|
||||
"<SkyCoord (ICRS): (ra, dec) in deg\n",
|
||||
" (135.42163944, 25.87738723)>\n",
|
||||
"<SkyCoord (ICRS): (ra, dec) in deg\n",
|
||||
" (141.60264825, 34.3048303)>\n",
|
||||
"<SkyCoord (ICRS): (ra, dec) in deg\n",
|
||||
" (152.81671045, 27.13611254)>\n",
|
||||
"<SkyCoord (ICRS): (ra, dec) in deg\n",
|
||||
" (146.27533314, 19.26190982)>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for point in corners_icrs:\n",
|
||||
" print(point)"
|
||||
"def skycoord_to_string(skycoord):\n",
|
||||
" \"\"\"Convert SkyCoord to string.\"\"\"\n",
|
||||
" t = skycoord.to_string()\n",
|
||||
" s = ' '.join(t)\n",
|
||||
" return s.replace(' ', ', ')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"From that, we can select the coordinates `ra` and `dec`:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"146d16m31.1993s 19d15m42.8754s\n",
|
||||
"135d25m17.902s 25d52m38.594s\n",
|
||||
"141d36m09.5337s 34d18m17.3891s\n",
|
||||
"152d49m00.1576s 27d08m10.0051s\n",
|
||||
"146d16m31.1993s 19d15m42.8754s\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for point in corners_icrs:\n",
|
||||
" print(point.ra, point.dec)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The results are quantities with units, but if we select the `value` part, we get a dimensionless floating-point number."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"146.27533313607782 19.261909820533692\n",
|
||||
"135.42163944306296 25.87738722767213\n",
|
||||
"141.60264825107333 34.304830296257144\n",
|
||||
"152.81671044675923 27.136112541397996\n",
|
||||
"146.27533313607782 19.261909820533692\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for point in corners_icrs:\n",
|
||||
" print(point.ra.value, point.dec.value)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We can use string `format` to convert these numbers to strings."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['146.27533313607782, 19.261909820533692',\n",
|
||||
" '135.42163944306296, 25.87738722767213',\n",
|
||||
" '141.60264825107333, 34.304830296257144',\n",
|
||||
" '152.81671044675923, 27.136112541397996',\n",
|
||||
" '146.27533313607782, 19.261909820533692']"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"point_base = \"{point.ra.value}, {point.dec.value}\"\n",
|
||||
"`SkyCoord` provides `to_string`, which returns a list of strings.\n",
|
||||
"\n",
|
||||
"t = [point_base.format(point=point)\n",
|
||||
" for point in corners_icrs]\n",
|
||||
"t"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The result is a list of strings, which we can join into a single string using `join`."
|
||||
"We use `join` to make a single string with spaces between the coordinates.\n",
|
||||
"\n",
|
||||
"Then we use `replace` to add commas between the coordinates. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 59,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'146.27533313607782, 19.261909820533692, 135.42163944306296, 25.87738722767213, 141.60264825107333, 34.304830296257144, 152.81671044675923, 27.136112541397996, 146.27533313607782, 19.261909820533692'"
|
||||
"'146.275, 19.2619, 135.422, 25.8774, 141.603, 34.3048, 152.817, 27.1361, 146.275, 19.2619'"
|
||||
]
|
||||
},
|
||||
"execution_count": 24,
|
||||
"execution_count": 59,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"point_list = ', '.join(t)\n",
|
||||
"point_list = skycoord_to_string(corners_icrs)\n",
|
||||
"point_list"
|
||||
]
|
||||
},
|
||||
@@ -1907,14 +1804,12 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Notice that we invoke `join` on a string and pass the list as an argument.\n",
|
||||
"\n",
|
||||
"Before we can assemble the query, we need `columns` again (as we saw in the previous notebook)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": 60,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -1930,7 +1825,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"execution_count": 61,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -1952,7 +1847,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 52,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -1964,7 +1859,7 @@
|
||||
"WHERE parallax < 1\n",
|
||||
" AND bp_rp BETWEEN -0.75 AND 2 \n",
|
||||
" AND 1 = CONTAINS(POINT(ra, dec), \n",
|
||||
" POLYGON(146.27533313607782, 19.261909820533692, 135.42163944306296, 25.87738722767213, 141.60264825107333, 34.304830296257144, 152.81671044675923, 27.136112541397996, 146.27533313607782, 19.261909820533692))\n",
|
||||
" POLYGON(146.275, 19.2619, 135.422, 25.8774, 141.603, 34.3048, 152.817, 27.1361, 146.275, 19.2619))\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
@@ -1986,7 +1881,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"execution_count": 53,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
@@ -1996,7 +1891,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO: Query finished. [astroquery.utils.tap.core]\n",
|
||||
"<Table length=140340>\n",
|
||||
"<Table length=140339>\n",
|
||||
" name dtype unit description n_bad \n",
|
||||
"--------------- ------- -------- ------------------------------------------------------------------ ------\n",
|
||||
" source_id int64 Unique source identifier (unique within a particular Data Release) 0\n",
|
||||
@@ -2006,11 +1901,11 @@
|
||||
" pmdec float64 mas / yr Proper motion in declination direction 0\n",
|
||||
" parallax float64 mas Parallax 0\n",
|
||||
" parallax_error float64 mas Standard error of parallax 0\n",
|
||||
"radial_velocity float64 km / s Radial velocity 139374\n",
|
||||
"Jobid: 1609260439320O\n",
|
||||
"radial_velocity float64 km / s Radial velocity 139373\n",
|
||||
"Jobid: 1609277169233O\n",
|
||||
"Phase: COMPLETED\n",
|
||||
"Owner: None\n",
|
||||
"Output file: async_20201229114719.vot\n",
|
||||
"Output file: async_20201229162609.vot\n",
|
||||
"Results: None\n"
|
||||
]
|
||||
}
|
||||
@@ -2029,16 +1924,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"140340"
|
||||
"140339"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install Astroquery and the other libraries we'll use.\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -80,7 +80,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install Astroquery and the other libraries we'll use.\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
@@ -101,7 +101,7 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery astro-gala wget"
|
||||
" !pip install astroquery wget"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install Astroquery and the other libraries we'll use.\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
@@ -107,7 +107,7 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery astro-gala wget"
|
||||
" !pip install wget"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1071,14 +1071,14 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The intention seems to be to define a polygon that gets wider as `g` increases.\n",
|
||||
"The intention is to define a polygon that gets wider as `g` increases, to reflect increasing uncertainty.\n",
|
||||
"\n",
|
||||
"But we can do about as well with a simpler formula:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 54,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
"source": [
|
||||
"## Installing libraries\n",
|
||||
"\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install Astroquery and the other libraries we'll use.\n",
|
||||
"If you are running this notebook on Colab, you can run the following cell to install the libraries we'll use.\n",
|
||||
"\n",
|
||||
"If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface."
|
||||
]
|
||||
@@ -104,7 +104,7 @@
|
||||
"IN_COLAB = 'google.colab' in sys.modules\n",
|
||||
"\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install astroquery astro-gala wget"
|
||||
" !pip install wget"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user