Update documentation

This commit is contained in:
Allen Downey
2021-08-30 14:35:02 -04:00
parent 127cd39331
commit 896aa6bd35
34 changed files with 9432 additions and 342 deletions

View File

@@ -253,11 +253,6 @@
Using Jupyter Using Jupyter
</a> </a>
</li> </li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#installing-libraries">
Installing libraries
</a>
</li>
<li class="toc-h2 nav-item toc-entry"> <li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#connecting-to-gaia"> <a class="reference internal nav-link" href="#connecting-to-gaia">
Connecting to Gaia Connecting to Gaia
@@ -396,24 +391,6 @@ But you might find it easier to learn from <a class="reference external" href="h
</ul> </ul>
<p>Before you go on, you might want to explore the other menus and the toolbar to see what else you can do.</p> <p>Before you go on, you might want to explore the other menus and the toolbar to see what else you can do.</p>
</div> </div>
<div class="section" id="installing-libraries">
<h2>Installing libraries<a class="headerlink" href="#installing-libraries" title="Permalink to this headline"></a></h2>
<p>If you are running this notebook on Colab, you should run the following cell to install the libraries well need.</p>
<p>If you are running this notebook on your own computer, you might have to install these libraries yourself.</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"># If we&#39;re running on Colab, install libraries</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">IN_COLAB</span> <span class="o">=</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span>
<span class="k">if</span> <span class="n">IN_COLAB</span><span class="p">:</span>
<span class="o">!</span>pip install astroquery
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="connecting-to-gaia"> <div class="section" id="connecting-to-gaia">
<h2>Connecting to Gaia<a class="headerlink" href="#connecting-to-gaia" title="Permalink to this headline"></a></h2> <h2>Connecting to Gaia<a class="headerlink" href="#connecting-to-gaia" title="Permalink to this headline"></a></h2>
<p>The library well use to get Gaia data is <a class="reference external" href="https://astroquery.readthedocs.io/en/latest/">Astroquery</a>. <p>The library well use to get Gaia data is <a class="reference external" href="https://astroquery.readthedocs.io/en/latest/">Astroquery</a>.
@@ -425,6 +402,20 @@ Astroquery provides <code class="docutils literal notranslate"><span class="pre"
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Created TAP+ (v1.2.1) - Connection:
Host: gea.esac.esa.int
Use HTTPS: True
Port: 443
SSL Port: 443
Created TAP+ (v1.2.1) - Connection:
Host: geadata.esac.esa.int
Use HTTPS: True
Port: 443
SSL Port: 443
</pre></div>
</div>
</div>
</div> </div>
<p>This import statement creates a <a class="reference external" href="http://www.ivoa.net/documents/TAP/">TAP+</a> connection; TAP stands for “Table Access Protocol”, which is a network protocol for sending queries to the database and getting back the results.</p> <p>This import statement creates a <a class="reference external" href="http://www.ivoa.net/documents/TAP/">TAP+</a> connection; TAP stands for “Table Access Protocol”, which is a network protocol for sending queries to the database and getting back the results.</p>
</div> </div>
@@ -442,15 +433,160 @@ Astroquery provides <code class="docutils literal notranslate"><span class="pre"
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Retrieving tables... [astroquery.utils.tap.core]
INFO: Parsing tables... [astroquery.utils.tap.core]
INFO: Done. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<p>The following <code class="docutils literal notranslate"><span class="pre">for</span></code> loop prints the names of the tables.</p> <p>The following <code class="docutils literal notranslate"><span class="pre">for</span></code> loop prints the names of the tables.</p>
<div class="cell docutils container"> <div class="cell tag_hide-output tag_truncate-output docutils container">
<div class="cell_input 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">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>external.apassdr9
external.gaiadr2_geometric_distance
external.gaiaedr3_distance
external.galex_ais
external.ravedr5_com
external.ravedr5_dr5
external.ravedr5_gra
external.ravedr5_on
external.sdssdr13_photoprimary
external.skymapperdr1_master
external.skymapperdr2_master
external.tmass_xsc
public.hipparcos
public.hipparcos_newreduction
public.hubble_sc
public.igsl_source
public.igsl_source_catalog_ids
public.tycho2
public.dual
tap_config.coord_sys
tap_config.properties
tap_schema.columns
tap_schema.key_columns
tap_schema.keys
tap_schema.schemas
tap_schema.tables
gaiaedr3.gaia_source
gaiaedr3.agn_cross_id
gaiaedr3.commanded_scan_law
gaiaedr3.dr2_neighbourhood
gaiaedr3.frame_rotator_source
gaiaedr3.allwise_best_neighbour
gaiaedr3.allwise_neighbourhood
gaiaedr3.apassdr9_best_neighbour
gaiaedr3.apassdr9_join
gaiaedr3.apassdr9_neighbourhood
gaiaedr3.gsc23_best_neighbour
gaiaedr3.gsc23_join
gaiaedr3.gsc23_neighbourhood
gaiaedr3.hipparcos2_best_neighbour
gaiaedr3.hipparcos2_neighbourhood
gaiaedr3.panstarrs1_best_neighbour
gaiaedr3.panstarrs1_join
gaiaedr3.panstarrs1_neighbourhood
gaiaedr3.ravedr5_best_neighbour
gaiaedr3.ravedr5_join
gaiaedr3.ravedr5_neighbourhood
gaiaedr3.sdssdr13_best_neighbour
gaiaedr3.sdssdr13_join
gaiaedr3.sdssdr13_neighbourhood
gaiaedr3.skymapperdr2_best_neighbour
gaiaedr3.skymapperdr2_join
gaiaedr3.skymapperdr2_neighbourhood
gaiaedr3.tmass_psc_xsc_best_neighbour
gaiaedr3.tmass_psc_xsc_join
gaiaedr3.tmass_psc_xsc_neighbourhood
gaiaedr3.tycho2tdsc_merge_best_neighbour
gaiaedr3.tycho2tdsc_merge_neighbourhood
gaiaedr3.urat1_best_neighbour
gaiaedr3.urat1_neighbourhood
gaiaedr3.gaia_source_simulation
gaiaedr3.gaia_universe_model
gaiaedr3.tycho2tdsc_merge
gaiadr1.aux_qso_icrf2_match
gaiadr1.ext_phot_zero_point
gaiadr1.allwise_best_neighbour
gaiadr1.allwise_neighbourhood
gaiadr1.gsc23_best_neighbour
gaiadr1.gsc23_neighbourhood
gaiadr1.ppmxl_best_neighbour
gaiadr1.ppmxl_neighbourhood
gaiadr1.sdss_dr9_best_neighbour
gaiadr1.sdss_dr9_neighbourhood
gaiadr1.tmass_best_neighbour
gaiadr1.tmass_neighbourhood
gaiadr1.ucac4_best_neighbour
gaiadr1.ucac4_neighbourhood
gaiadr1.urat1_best_neighbour
gaiadr1.urat1_neighbourhood
gaiadr1.cepheid
gaiadr1.phot_variable_time_series_gfov
gaiadr1.phot_variable_time_series_gfov_statistical_parameters
gaiadr1.rrlyrae
gaiadr1.variable_summary
gaiadr1.allwise_original_valid
gaiadr1.gsc23_original_valid
gaiadr1.ppmxl_original_valid
gaiadr1.sdssdr9_original_valid
gaiadr1.tmass_original_valid
gaiadr1.ucac4_original_valid
gaiadr1.urat1_original_valid
gaiadr1.gaia_source
gaiadr1.tgas_source
gaiadr2.aux_allwise_agn_gdr2_cross_id
gaiadr2.aux_iers_gdr2_cross_id
gaiadr2.aux_sso_orbit_residuals
gaiadr2.aux_sso_orbits
gaiadr2.dr1_neighbourhood
gaiadr2.allwise_best_neighbour
gaiadr2.allwise_neighbourhood
gaiadr2.apassdr9_best_neighbour
gaiadr2.apassdr9_neighbourhood
gaiadr2.gsc23_best_neighbour
gaiadr2.gsc23_neighbourhood
gaiadr2.hipparcos2_best_neighbour
gaiadr2.hipparcos2_neighbourhood
gaiadr2.panstarrs1_best_neighbour
gaiadr2.panstarrs1_neighbourhood
gaiadr2.ppmxl_best_neighbour
gaiadr2.ppmxl_neighbourhood
gaiadr2.ravedr5_best_neighbour
gaiadr2.ravedr5_neighbourhood
gaiadr2.sdssdr9_best_neighbour
gaiadr2.sdssdr9_neighbourhood
gaiadr2.tmass_best_neighbour
gaiadr2.tmass_neighbourhood
gaiadr2.tycho2_best_neighbour
gaiadr2.tycho2_neighbourhood
gaiadr2.urat1_best_neighbour
gaiadr2.urat1_neighbourhood
gaiadr2.sso_observation
gaiadr2.sso_source
gaiadr2.vari_cepheid
gaiadr2.vari_classifier_class_definition
gaiadr2.vari_classifier_definition
gaiadr2.vari_classifier_result
gaiadr2.vari_long_period_variable
gaiadr2.vari_rotation_modulation
gaiadr2.vari_rrlyrae
gaiadr2.vari_short_timescale
gaiadr2.vari_time_series_statistics
gaiadr2.panstarrs1_original_valid
gaiadr2.gaia_source
gaiadr2.ruwe
</pre></div>
</div>
</div>
</div> </div>
<p>So thats a lot of tables. The ones well use are:</p> <p>So thats a lot of tables. The ones well use are:</p>
<ul class="simple"> <ul class="simple">
@@ -466,6 +602,16 @@ Astroquery provides <code class="docutils literal notranslate"><span class="pre"
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Retrieving table &#39;gaiadr2.gaia_source&#39;
Parsing table &#39;gaiadr2.gaia_source&#39;...
Done.
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;astroquery.utils.tap.model.taptable.TapTableMeta at 0x7f50edd2aeb0&gt;
</pre></div>
</div>
</div>
</div> </div>
<p>Jupyter shows that the result is an object of type <code class="docutils literal notranslate"><span class="pre">TapTableMeta</span></code>, but it does not display the contents.</p> <p>Jupyter shows that the result is an object of type <code class="docutils literal notranslate"><span class="pre">TapTableMeta</span></code>, but it does not display the contents.</p>
<p>To see the metadata, we have to print the object.</p> <p>To see the metadata, we have to print the object.</p>
@@ -475,18 +621,129 @@ Astroquery provides <code class="docutils literal notranslate"><span class="pre"
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>TAP Table name: gaiadr2.gaiadr2.gaia_source
Description: This table has an entry for every Gaia observed source as listed in the
Main Database accumulating catalogue version from which the catalogue
release has been generated. It contains the basic source parameters,
that is only final data (no epoch data) and no spectra (neither final
nor epoch).
Num. columns: 96
</pre></div>
</div>
</div>
</div> </div>
</div> </div>
<div class="section" id="columns"> <div class="section" id="columns">
<h2>Columns<a class="headerlink" href="#columns" title="Permalink to this headline"></a></h2> <h2>Columns<a class="headerlink" href="#columns" title="Permalink to this headline"></a></h2>
<p>The following loop prints the names of the columns in the table.</p> <p>The following loop prints the names of the columns in the table.</p>
<div class="cell docutils container"> <div class="cell tag_hide-output tag_truncate-output docutils container">
<div class="cell_input 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">column</span> <span class="ow">in</span> <span class="n">meta</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">meta</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>solution_id
designation
source_id
random_index
ref_epoch
ra
ra_error
dec
dec_error
parallax
parallax_error
parallax_over_error
pmra
pmra_error
pmdec
pmdec_error
ra_dec_corr
ra_parallax_corr
ra_pmra_corr
ra_pmdec_corr
dec_parallax_corr
dec_pmra_corr
dec_pmdec_corr
parallax_pmra_corr
parallax_pmdec_corr
pmra_pmdec_corr
astrometric_n_obs_al
astrometric_n_obs_ac
astrometric_n_good_obs_al
astrometric_n_bad_obs_al
astrometric_gof_al
astrometric_chi2_al
astrometric_excess_noise
astrometric_excess_noise_sig
astrometric_params_solved
astrometric_primary_flag
astrometric_weight_al
astrometric_pseudo_colour
astrometric_pseudo_colour_error
mean_varpi_factor_al
astrometric_matched_observations
visibility_periods_used
astrometric_sigma5d_max
frame_rotator_object_type
matched_observations
duplicated_source
phot_g_n_obs
phot_g_mean_flux
phot_g_mean_flux_error
phot_g_mean_flux_over_error
phot_g_mean_mag
phot_bp_n_obs
phot_bp_mean_flux
phot_bp_mean_flux_error
phot_bp_mean_flux_over_error
phot_bp_mean_mag
phot_rp_n_obs
phot_rp_mean_flux
phot_rp_mean_flux_error
phot_rp_mean_flux_over_error
phot_rp_mean_mag
phot_bp_rp_excess_factor
phot_proc_mode
bp_rp
bp_g
g_rp
radial_velocity
radial_velocity_error
rv_nb_transits
rv_template_teff
rv_template_logg
rv_template_fe_h
phot_variable_flag
l
b
ecl_lon
ecl_lat
priam_flags
teff_val
teff_percentile_lower
teff_percentile_upper
a_g_val
a_g_percentile_lower
a_g_percentile_upper
e_bp_min_rp_val
e_bp_min_rp_percentile_lower
e_bp_min_rp_percentile_upper
flame_flags
radius_val
radius_percentile_lower
radius_percentile_upper
lum_val
lum_percentile_lower
lum_percentile_upper
datalink_url
epoch_photometry_url
</pre></div>
</div>
</div>
</div> </div>
<p>You can probably infer what many of these columns are by looking at the names, but you should resist the temptation to guess. <p>You can probably infer what many of these columns are by looking at the names, but you should resist the temptation to guess.
To find out what the columns mean, <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">read the documentation</a>.</p> To find out what the columns mean, <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">read the documentation</a>.</p>
@@ -496,7 +753,113 @@ To find out what the columns mean, <a class="reference external" href="https://g
<p>One of the other tables well use is <code class="docutils literal notranslate"><span class="pre">gaiadr2.panstarrs1_original_valid</span></code>. Use <code class="docutils literal notranslate"><span class="pre">load_table</span></code> to get the metadata for this table. How many columns are there and what are their names?</p> <p>One of the other tables well use is <code class="docutils literal notranslate"><span class="pre">gaiadr2.panstarrs1_original_valid</span></code>. Use <code class="docutils literal notranslate"><span class="pre">load_table</span></code> to get the metadata for this table. How many columns are there and what are their names?</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">meta2</span> <span class="o">=</span> <span class="n">Gaia</span><span class="o">.</span><span class="n">load_table</span><span class="p">(</span><span class="s1">&#39;gaiadr2.panstarrs1_original_valid&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">meta2</span><span class="p">)</span>
<span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">meta2</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">name</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>Retrieving table &#39;gaiadr2.panstarrs1_original_valid&#39;
Parsing table &#39;gaiadr2.panstarrs1_original_valid&#39;...
Done.
TAP Table name: gaiadr2.gaiadr2.panstarrs1_original_valid
Description: The Panoramic Survey Telescope and Rapid Response System (Pan-STARRS) is
a system for wide-field astronomical imaging developed and operated by
the Institute for Astronomy at the University of Hawaii. Pan-STARRS1
(PS1) is the first part of Pan-STARRS to be completed and is the basis
for Data Release 1 (DR1). The PS1 survey used a 1.8 meter telescope and
its 1.4 Gigapixel camera to image the sky in five broadband filters (g,
r, i, z, y).
The current table contains a filtered subsample of the 10723304629
entries listed in the original ObjectThin table.
We used only ObjectThin and MeanObject tables to extract
panstarrs1OriginalValid table, this means that objects detected only in
stack images are not included here. The main reason for us to avoid the
use of objects detected in stack images is that their astrometry is not
as good as the mean objects astrometry: “The stack positions (raStack,
decStack) have considerably larger systematic astrometric errors than
the mean epoch positions (raMean, decMean).” The astrometry for the
MeanObject positions uses Gaia DR1 as a reference catalog, while the
stack positions use 2MASS as a reference catalog.
In details, we filtered out all objects where:
- nDetections = 1
- no good quality data in Pan-STARRS, objInfoFlag 33554432 not set
- mean astrometry could not be measured, objInfoFlag 524288 set
- stack position used for mean astrometry, objInfoFlag 1048576 set
- error on all magnitudes equal to 0 or to -999;
- all magnitudes set to -999;
- error on RA or DEC greater than 1 arcsec.
The number of objects in panstarrs1OriginalValid is 2264263282.
The panstarrs1OriginalValid table contains only a subset of the columns
available in the combined ObjectThin and MeanObject tables. A
description of the original ObjectThin and MeanObjects tables can be
found at:
https://outerspace.stsci.edu/display/PANSTARRS/PS1+Database+object+and+detection+tables
Download:
http://mastweb.stsci.edu/ps1casjobs/home.aspx
Documentation:
https://outerspace.stsci.edu/display/PANSTARRS
http://pswww.ifa.hawaii.edu/pswww/
References:
The Pan-STARRS1 Surveys, Chambers, K.C., et al. 2016, arXiv:1612.05560
Pan-STARRS Data Processing System, Magnier, E. A., et al. 2016,
arXiv:1612.05240
Pan-STARRS Pixel Processing: Detrending, Warping, Stacking, Waters, C.
Z., et al. 2016, arXiv:1612.05245
Pan-STARRS Pixel Analysis: Source Detection and Characterization,
Magnier, E. A., et al. 2016, arXiv:1612.05244
Pan-STARRS Photometric and Astrometric Calibration, Magnier, E. A., et
al. 2016, arXiv:1612.05242
The Pan-STARRS1 Database and Data Products, Flewelling, H. A., et al.
2016, arXiv:1612.05243
Catalogue curator:
SSDC - ASI Space Science Data Center
https://www.ssdc.asi.it/
Num. columns: 26
obj_name
obj_id
ra
dec
ra_error
dec_error
epoch_mean
g_mean_psf_mag
g_mean_psf_mag_error
g_flags
r_mean_psf_mag
r_mean_psf_mag_error
r_flags
i_mean_psf_mag
i_mean_psf_mag_error
i_flags
z_mean_psf_mag
z_mean_psf_mag_error
z_flags
y_mean_psf_mag
y_mean_psf_mag_error
y_flags
n_detections
zone_id
obj_info_flag
quality_flag
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -537,6 +900,11 @@ To find out what the columns mean, <a class="reference external" href="https://g
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;astroquery.utils.tap.model.job.Job at 0x7f50edd2adc0&gt;
</pre></div>
</div>
</div>
</div> </div>
<p>The result is an object that represents the job running on a Gaia server.</p> <p>The result is an object that represents the job running on a Gaia server.</p>
<p>If you print it, it displays metadata for the forthcoming results.</p> <p>If you print it, it displays metadata for the forthcoming results.</p>
@@ -546,6 +914,22 @@ To find out what the columns mean, <a class="reference external" href="https://g
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;Table length=10&gt;
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
parallax float64 mas Parallax 2
Jobid: None
Phase: COMPLETED
Owner: None
Output file: sync_20210315090602.xml.gz
Results: None
</pre></div>
</div>
</div>
</div> </div>
<p>Dont worry about <code class="docutils literal notranslate"><span class="pre">Results:</span> <span class="pre">None</span></code>. That does not actually mean there are no results.</p> <p>Dont worry about <code class="docutils literal notranslate"><span class="pre">Results:</span> <span class="pre">None</span></code>. That does not actually mean there are no results.</p>
<p>However, <code class="docutils literal notranslate"><span class="pre">Phase:</span> <span class="pre">COMPLETED</span></code> indicates that the job is complete, so we can get the results like this:</p> <p>However, <code class="docutils literal notranslate"><span class="pre">Phase:</span> <span class="pre">COMPLETED</span></code> indicates that the job is complete, so we can get the results like this:</p>
@@ -556,6 +940,11 @@ To find out what the columns mean, <a class="reference external" href="https://g
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.table.table.Table
</pre></div>
</div>
</div>
</div> </div>
<p>The <code class="docutils literal notranslate"><span class="pre">type</span></code> function indicates that the result is an <a class="reference external" href="https://docs.astropy.org/en/stable/table/">Astropy Table</a>.</p> <p>The <code class="docutils literal notranslate"><span class="pre">type</span></code> function indicates that the result is an <a class="reference external" href="https://docs.astropy.org/en/stable/table/">Astropy Table</a>.</p>
<p><strong>Optional detail:</strong> Why is <code class="docutils literal notranslate"><span class="pre">table</span></code> repeated three times? The first is the name of the module, the second is the name of the submodule, and the third is the name of the class. Most of the time we only care about the last one. Its like the Linnean name for gorilla, which is <em>Gorilla gorilla gorilla</em>.</p> <p><strong>Optional detail:</strong> Why is <code class="docutils literal notranslate"><span class="pre">table</span></code> repeated three times? The first is the name of the module, the second is the name of the submodule, and the third is the name of the class. Most of the time we only care about the last one. Its like the Linnean name for gorilla, which is <em>Gorilla gorilla gorilla</em>.</p>
@@ -571,6 +960,23 @@ To find out what the columns mean, <a class="reference external" href="https://g
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=10</i>
<table id="table139985564118224" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>parallax</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>5887983246081387776</td><td>227.978818386372</td><td>-53.64996962450103</td><td>1.0493172163332998</td></tr>
<tr><td>5887971250213117952</td><td>228.32280834041364</td><td>-53.66270726203726</td><td>0.29455652682279093</td></tr>
<tr><td>5887991866047288704</td><td>228.1582047014091</td><td>-53.454724911639794</td><td>-0.5789179941669236</td></tr>
<tr><td>5887968673232040832</td><td>228.07420888099884</td><td>-53.8064612895961</td><td>0.41030970779603076</td></tr>
<tr><td>5887979844465854720</td><td>228.42547805195946</td><td>-53.48882284470035</td><td>-0.23379683441525864</td></tr>
<tr><td>5887978607515442688</td><td>228.23831627636855</td><td>-53.56328249482688</td><td>-0.9252161956789068</td></tr>
<tr><td>5887978298278520704</td><td>228.26015640396173</td><td>-53.607284412896476</td><td>--</td></tr>
<tr><td>5887995581231772928</td><td>228.12871598211902</td><td>-53.373625663608316</td><td>-0.3325818206439385</td></tr>
<tr><td>5887982043490374016</td><td>227.985260087594</td><td>-53.683444499055575</td><td>0.02878111976456593</td></tr>
<tr><td>5887982971205433856</td><td>227.89884570686218</td><td>-53.67430215342567</td><td>--</td></tr>
</table></div></div>
</div> </div>
<p>Each column has a name, units, and a data type.</p> <p>Each column has a name, units, and a data type.</p>
<p>For example, the units of <code class="docutils literal notranslate"><span class="pre">ra</span></code> and <code class="docutils literal notranslate"><span class="pre">dec</span></code> are degrees, and their data type is <code class="docutils literal notranslate"><span class="pre">float64</span></code>, which is a 64-bit <a class="reference external" href="https://en.wikipedia.org/wiki/Floating-point_arithmetic">floating-point number</a>, used to store measurements with a fraction part.</p> <p>For example, the units of <code class="docutils literal notranslate"><span class="pre">ra</span></code> and <code class="docutils literal notranslate"><span class="pre">dec</span></code> are degrees, and their data type is <code class="docutils literal notranslate"><span class="pre">float64</span></code>, which is a 64-bit <a class="reference external" href="https://en.wikipedia.org/wiki/Floating-point_arithmetic">floating-point number</a>, used to store measurements with a fraction part.</p>
@@ -580,7 +986,23 @@ To find out what the columns mean, <a class="reference external" href="https://g
<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</a> of this table 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> <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</a> of this table 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 tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># Let&#39;s add</span>
<span class="c1">#</span>
<span class="c1"># radial_velocity : Radial velocity (double, Velocity[km/s] )</span>
<span class="c1">#</span>
<span class="c1"># Spectroscopic radial velocity in the solar barycentric </span>
<span class="c1"># reference frame.</span>
<span class="c1">#</span>
<span class="c1"># The radial velocity provided is the median value of the </span>
<span class="c1"># radial velocity measurements at all epochs.</span>
<span class="n">query</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="s2">TOP 10</span>
<span class="s2">source_id, ra, dec, parallax, radial_velocity</span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -622,6 +1044,14 @@ Well use this clause to exclude nearby stars that are unlikely to be part of
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;astroquery.utils.tap.model.job.Job at 0x7f50edd40f40&gt;
</pre></div>
</div>
</div>
</div> </div>
<p>And here are the results.</p> <p>And here are the results.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -631,6 +1061,23 @@ Well use this clause to exclude nearby stars that are unlikely to be part of
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=10</i>
<table id="table139986226873968" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>parallax</th><th>radial_velocity</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas</th><th>km / s</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>5895270396817359872</td><td>213.08433715252883</td><td>-56.64104701005694</td><td>2.041947005434917</td><td>--</td></tr>
<tr><td>5895272561481374080</td><td>213.2606587905109</td><td>-56.55044401535715</td><td>0.15693467895110133</td><td>--</td></tr>
<tr><td>5895247410183786368</td><td>213.38479712976664</td><td>-56.97008551185148</td><td>-0.19017525742552605</td><td>--</td></tr>
<tr><td>5895249226912448000</td><td>213.41587389088238</td><td>-56.849596577635786</td><td>--</td><td>--</td></tr>
<tr><td>5895261875598904576</td><td>213.5508930114549</td><td>-56.61037780154348</td><td>-0.29471722363529257</td><td>--</td></tr>
<tr><td>5895258302187834624</td><td>213.87631129557286</td><td>-56.678537259039906</td><td>0.6468437015289753</td><td>--</td></tr>
<tr><td>5895247444506644992</td><td>213.33215109206796</td><td>-56.975347759380995</td><td>0.390215490234287</td><td>--</td></tr>
<tr><td>5895259470417635968</td><td>213.78815034206346</td><td>-56.64585047451594</td><td>0.953377710788918</td><td>--</td></tr>
<tr><td>5895264899260932352</td><td>213.21521027193236</td><td>-56.78420864489118</td><td>--</td><td>--</td></tr>
<tr><td>5895265925746051584</td><td>213.17082359534547</td><td>-56.74540885107754</td><td>0.2986918215101751</td><td>--</td></tr>
</table></div></div>
</div> </div>
<p>You might notice that some values of <code class="docutils literal notranslate"><span class="pre">parallax</span></code> are negative. As <a class="reference external" href="https://www.cosmos.esa.int/web/gaia/archive-tips#negative%20parallax">this FAQ explains</a>, “Negative parallaxes are caused by errors in the observations.” They have “no physical meaning,” but they can be a “useful diagnostic on the quality of the astrometric solution.”</p> <p>You might notice that some values of <code class="docutils literal notranslate"><span class="pre">parallax</span></code> are negative. As <a class="reference external" href="https://www.cosmos.esa.int/web/gaia/archive-tips#negative%20parallax">this FAQ explains</a>, “Negative parallaxes are caused by errors in the observations.” They have “no physical meaning,” but they can be a “useful diagnostic on the quality of the astrometric solution.”</p>
<div class="section" id="id2"> <div class="section" id="id2">
@@ -646,7 +1093,16 @@ The modified query should fail, but notice that you dont get much useful debu
</ul> </ul>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># In this example, the WHERE clause is in the wrong place</span>
<span class="n">query</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="s2">TOP 3000</span>
<span class="s2">WHERE parallax &lt; 1</span>
<span class="s2">source_id, ref_epoch, ra, dec, parallax</span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -696,7 +1152,27 @@ Be careful to keep your Python out of your ADQL!</p>
<p><a class="reference external" href="https://www.w3schools.com/sql/sql_operators.asp">Read about SQL operators here</a> and then modify the previous query to select rows where <code class="docutils literal notranslate"><span class="pre">bp_rp</span></code> is between <code class="docutils literal notranslate"><span class="pre">-0.75</span></code> and <code class="docutils literal notranslate"><span class="pre">2</span></code>.</p> <p><a class="reference external" href="https://www.w3schools.com/sql/sql_operators.asp">Read about SQL operators here</a> and then modify the previous query to select rows where <code class="docutils literal notranslate"><span class="pre">bp_rp</span></code> is between <code class="docutils literal notranslate"><span class="pre">-0.75</span></code> and <code class="docutils literal notranslate"><span class="pre">2</span></code>.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># Here&#39;s a solution using &gt; and &lt; operators</span>
<span class="n">query</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="s2">TOP 10</span>
<span class="s2">source_id, ref_epoch, ra, dec, parallax</span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">WHERE parallax &lt; 1 </span>
<span class="s2"> AND bp_rp &gt; -0.75 AND bp_rp &lt; 2</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="c1"># And here&#39;s a solution using the BETWEEN operator</span>
<span class="n">query</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="s2">TOP 10</span>
<span class="s2">source_id, ref_epoch, ra, dec, parallax</span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">WHERE parallax &lt; 1 </span>
<span class="s2"> AND bp_rp BETWEEN -0.75 AND 2</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -754,6 +1230,11 @@ Thats not required, but it is a common style.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&#39;SELECT \nTOP 10 \nsource_id, ra, dec, pmra, pmdec\nFROM gaiadr2.gaia_source\nWHERE parallax &lt; 1\n AND bp_rp BETWEEN -0.75 AND 2\n&#39;
</pre></div>
</div>
</div>
</div> </div>
<p>But if you print it, the line breaks appear as… line breaks.</p> <p>But if you print it, the line breaks appear as… line breaks.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -762,6 +1243,16 @@ Thats not required, but it is a common style.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
TOP 10
source_id, ra, dec, pmra, pmdec
FROM gaiadr2.gaia_source
WHERE parallax &lt; 1
AND bp_rp BETWEEN -0.75 AND 2
</pre></div>
</div>
</div>
</div> </div>
<p>Notice that the format specifier has been replaced with the value of <code class="docutils literal notranslate"><span class="pre">columns</span></code>.</p> <p>Notice that the format specifier has been replaced with the value of <code class="docutils literal notranslate"><span class="pre">columns</span></code>.</p>
<p>Lets run it and see if it works:</p> <p>Lets run it and see if it works:</p>
@@ -772,6 +1263,23 @@ Thats not required, but it is a common style.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;Table length=10&gt;
name dtype unit description
--------- ------- -------- ------------------------------------------------------------------
source_id int64 Unique source identifier (unique within a particular Data Release)
ra float64 deg Right ascension
dec float64 deg Declination
pmra float64 mas / yr Proper motion in right ascension direction
pmdec float64 mas / yr Proper motion in declination direction
Jobid: None
Phase: COMPLETED
Owner: None
Output file: sync_20210315091929.xml.gz
Results: None
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -780,6 +1288,23 @@ Thats not required, but it is a common style.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=10</i>
<table id="table139985564118512" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>5895272561481374080</td><td>213.2606587905109</td><td>-56.55044401535715</td><td>0.3894438898301715</td><td>1.2299266281737415</td></tr>
<tr><td>5895261875598904576</td><td>213.5508930114549</td><td>-56.61037780154348</td><td>0.16203641364393007</td><td>-4.672602679543312</td></tr>
<tr><td>5895247444506644992</td><td>213.33215109206796</td><td>-56.975347759380995</td><td>-7.474003156859284</td><td>-3.538080792097856</td></tr>
<tr><td>5895259470417635968</td><td>213.78815034206346</td><td>-56.64585047451594</td><td>-5.287202255231853</td><td>-0.8163762113468646</td></tr>
<tr><td>5895265925746051584</td><td>213.17082359534547</td><td>-56.74540885107754</td><td>-7.880749306158471</td><td>-4.8585444120179595</td></tr>
<tr><td>5895260913525974528</td><td>213.66936020541976</td><td>-56.66655190442016</td><td>-4.7820929042428215</td><td>-1.5566420086447643</td></tr>
<tr><td>5895264212062283008</td><td>213.7755742121852</td><td>-56.51570859067397</td><td>-6.657690998559842</td><td>-1.7616494482071872</td></tr>
<tr><td>5895253457497979136</td><td>213.30929960610283</td><td>-56.78849448744587</td><td>-5.242106718924749</td><td>-0.18655636353898095</td></tr>
<tr><td>4143614130253524096</td><td>269.1749117455479</td><td>-18.53415139972117</td><td>2.6164274510804826</td><td>1.3244248889980894</td></tr>
<tr><td>4065443904433108992</td><td>273.26868565443743</td><td>-24.421651815402857</td><td>-1.663096652191022</td><td>-2.6514745376067683</td></tr>
</table></div></div>
</div> </div>
<p>Good so far.</p> <p>Good so far.</p>
<div class="section" id="id4"> <div class="section" id="id4">
@@ -788,7 +1313,29 @@ Thats not required, but it is a common style.</p>
<p>Modify <code class="docutils literal notranslate"><span class="pre">query3_base</span></code> to replace <code class="docutils literal notranslate"><span class="pre">1</span></code> with a format specifier like <code class="docutils literal notranslate"><span class="pre">{max_parallax}</span></code>. Now, when you call <code class="docutils literal notranslate"><span class="pre">format</span></code>, add a keyword argument that assigns a value to <code class="docutils literal notranslate"><span class="pre">max_parallax</span></code>, and confirm that the format specifier gets replaced with the value you provide.</p> <p>Modify <code class="docutils literal notranslate"><span class="pre">query3_base</span></code> to replace <code class="docutils literal notranslate"><span class="pre">1</span></code> with a format specifier like <code class="docutils literal notranslate"><span class="pre">{max_parallax}</span></code>. Now, when you call <code class="docutils literal notranslate"><span class="pre">format</span></code>, add a keyword argument that assigns a value to <code class="docutils literal notranslate"><span class="pre">max_parallax</span></code>, and confirm that the format specifier gets replaced with the value you provide.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">query_base</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="s2">TOP 10</span>
<span class="si">{columns}</span><span class="s2"></span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">WHERE parallax &lt; </span><span class="si">{max_parallax}</span><span class="s2"> AND </span>
<span class="s2">bp_rp BETWEEN -0.75 AND 2</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">query_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span>
<span class="n">max_parallax</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">query</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
TOP 10
source_id, ra, dec, pmra, pmdec
FROM gaiadr2.gaia_source
WHERE parallax &lt; 0.5 AND
bp_rp BETWEEN -0.75 AND 2
</pre></div> </pre></div>
</div> </div>
</div> </div>

File diff suppressed because it is too large Load Diff

View File

@@ -243,11 +243,6 @@
Outline Outline
</a> </a>
</li> </li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#installing-libraries">
Installing libraries
</a>
</li>
<li class="toc-h2 nav-item toc-entry"> <li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#reload-the-data"> <a class="reference internal nav-link" href="#reload-the-data">
Reload the data Reload the data
@@ -373,24 +368,6 @@
<li><p>Save a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> in an HDF5 file.</p></li> <li><p>Save a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> in an HDF5 file.</p></li>
</ul> </ul>
</div> </div>
<div class="section" id="installing-libraries">
<h2>Installing libraries<a class="headerlink" href="#installing-libraries" title="Permalink to this headline"></a></h2>
<p>If you are running this notebook on Colab, you can run the following cell to install the libraries well use.</p>
<p>If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface.</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"># If we&#39;re running on Colab, install libraries</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">IN_COLAB</span> <span class="o">=</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span>
<span class="k">if</span> <span class="n">IN_COLAB</span><span class="p">:</span>
<span class="o">!</span>pip install astroquery astro-gala
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="reload-the-data"> <div class="section" id="reload-the-data">
<h2>Reload the data<a class="headerlink" href="#reload-the-data" title="Permalink to this headline"></a></h2> <h2>Reload the data<a class="headerlink" href="#reload-the-data" title="Permalink to this headline"></a></h2>
<p>In the previous lesson, we ran a query on the Gaia server and downloaded data for roughly 140,000 stars. We saved the data in a FITS file so that now, picking up where we left off, we can read the data from a local file rather than running the query again.</p> <p>In the previous lesson, we ran a query on the Gaia server and downloaded data for roughly 140,000 stars. We saved the data in a FITS file so that now, picking up where we left off, we can read the data from a local file rather than running the query again.</p>
@@ -432,6 +409,19 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;Table length=140339&gt;
name dtype unit description
--------- ------- -------- ------------------------------------------------------------------
source_id int64 Unique source identifier (unique within a particular Data Release)
ra float64 deg Right ascension
dec float64 deg Declination
pmra float64 mas / yr Proper motion in right ascension direction
pmdec float64 mas / yr Proper motion in declination direction
parallax float64 mas Parallax
</pre></div>
</div>
</div>
</div> </div>
</div> </div>
<div class="section" id="selecting-rows-and-columns"> <div class="section" id="selecting-rows-and-columns">
@@ -444,6 +434,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&#39;source_id&#39;, &#39;ra&#39;, &#39;dec&#39;, &#39;pmra&#39;, &#39;pmdec&#39;, &#39;parallax&#39;]
</pre></div>
</div>
</div>
</div> </div>
<p>And select an individual column like this:</p> <p>And select an individual column like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -452,6 +447,35 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html">&lt;Column name=&apos;ra&apos; dtype=&apos;float64&apos; unit=&apos;deg&apos; description=&apos;Right ascension&apos; length=140339&gt;
<table>
<tr><td>142.48301935991023</td></tr>
<tr><td>142.25452941346344</td></tr>
<tr><td>142.64528557468074</td></tr>
<tr><td>142.57739430926034</td></tr>
<tr><td>142.58913564478618</td></tr>
<tr><td>141.81762228999614</td></tr>
<tr><td>143.18339801317677</td></tr>
<tr><td>142.9347319464589</td></tr>
<tr><td>142.26769745823267</td></tr>
<tr><td>142.89551292869012</td></tr>
<tr><td>142.2780935768316</td></tr>
<tr><td>142.06138786534987</td></tr>
<tr><td>...</td></tr>
<tr><td>143.05456487172972</td></tr>
<tr><td>144.0436496516182</td></tr>
<tr><td>144.06566578919313</td></tr>
<tr><td>144.13177563215973</td></tr>
<tr><td>143.77696341662764</td></tr>
<tr><td>142.945956347594</td></tr>
<tr><td>142.97282480557786</td></tr>
<tr><td>143.4166017695258</td></tr>
<tr><td>143.64484588686904</td></tr>
<tr><td>143.41554585481808</td></tr>
<tr><td>143.6908739159247</td></tr>
<tr><td>143.7702681295401</td></tr>
</table></div></div>
</div> </div>
<p>The result is a <code class="docutils literal notranslate"><span class="pre">Column</span></code> object that contains the data, and also the data type, units, and name of the column.</p> <p>The result is a <code class="docutils literal notranslate"><span class="pre">Column</span></code> object that contains the data, and also the data type, units, and name of the column.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -460,6 +484,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.table.column.Column
</pre></div>
</div>
</div>
</div> </div>
<p>The rows in the <code class="docutils literal notranslate"><span class="pre">Table</span></code> are numbered from 0 to <code class="docutils literal notranslate"><span class="pre">n-1</span></code>, where <code class="docutils literal notranslate"><span class="pre">n</span></code> is the number of rows. We can select the first row like this:</p> <p>The rows in the <code class="docutils literal notranslate"><span class="pre">Table</span></code> are numbered from 0 to <code class="docutils literal notranslate"><span class="pre">n-1</span></code>, where <code class="docutils literal notranslate"><span class="pre">n</span></code> is the number of rows. We can select the first row like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -468,6 +497,14 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Row index=0</i>
<table id="table139673160217120">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th><th>parallax</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th><th>mas</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>637987125186749568</td><td>142.48301935991023</td><td>21.75771616932985</td><td>-2.5168384683875766</td><td>2.941813096629439</td><td>-0.2573448962333354</td></tr>
</table></div></div>
</div> </div>
<p>As you might have guessed, the result is a <code class="docutils literal notranslate"><span class="pre">Row</span></code> object.</p> <p>As you might have guessed, the result is a <code class="docutils literal notranslate"><span class="pre">Row</span></code> object.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -476,6 +513,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.table.row.Row
</pre></div>
</div>
</div>
</div> </div>
<p>Notice that the bracket operator selects both columns and rows. You might wonder how it knows which to select. <p>Notice that the bracket operator selects both columns and rows. You might wonder how it knows which to select.
If the expression in brackets is a string, it selects a column; if the expression is an integer, it selects a row.</p> If the expression in brackets is a string, it selects a column; if the expression is an integer, it selects a row.</p>
@@ -486,6 +528,11 @@ If the expression in brackets is a string, it selects a column; if the expressio
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>142.48301935991023
</pre></div>
</div>
</div>
</div> </div>
<p>Or you can select a row and then an element from the row.</p> <p>Or you can select a row and then an element from the row.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -494,6 +541,11 @@ If the expression in brackets is a string, it selects a column; if the expressio
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>142.48301935991023
</pre></div>
</div>
</div>
</div> </div>
<p>You get the same result either way.</p> <p>You get the same result either way.</p>
</div> </div>
@@ -534,6 +586,9 @@ In that case, you might want to run the following Jupyter <a class="reference ex
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_30_0.png" src="_images/03_motion_30_0.png" />
</div>
</div> </div>
<p>The arguments to <code class="docutils literal notranslate"><span class="pre">plt.plot</span></code> are <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>, and a string that specifies the style. In this case, the letters <code class="docutils literal notranslate"><span class="pre">ko</span></code> indicate that we want a black, round marker (<code class="docutils literal notranslate"><span class="pre">k</span></code> is for black because <code class="docutils literal notranslate"><span class="pre">b</span></code> is for blue). <p>The arguments to <code class="docutils literal notranslate"><span class="pre">plt.plot</span></code> are <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>, and a string that specifies the style. In this case, the letters <code class="docutils literal notranslate"><span class="pre">ko</span></code> indicate that we want a black, round marker (<code class="docutils literal notranslate"><span class="pre">k</span></code> is for black because <code class="docutils literal notranslate"><span class="pre">b</span></code> is for blue).
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> 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>
@@ -548,7 +603,14 @@ The functions <code class="docutils literal notranslate"><span class="pre">xlabe
<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> <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 tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># x = results[&#39;ra&#39;]</span>
<span class="c1"># y = results[&#39;dec&#39;]</span>
<span class="c1"># plt.plot(x, y, &#39;ko&#39;, markersize=0.1, alpha=0.1)</span>
<span class="c1"># plt.xlabel(&#39;ra (degree ICRS)&#39;)</span>
<span class="c1"># plt.ylabel(&#39;dec (degree ICRS)&#39;);</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -648,6 +710,9 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_45_0.png" src="_images/03_motion_45_0.png" />
</div>
</div> </div>
<p>Remember that we started with a rectangle in the GD-1 frame. When transformed to the ICRS frame, its a non-rectangular region. Now, transformed back to the GD-1 frame, its a rectangle again.</p> <p>Remember that we started with a rectangle in the GD-1 frame. When transformed to the ICRS frame, its a non-rectangular region. Now, transformed back to the GD-1 frame, its a rectangle again.</p>
</div> </div>
@@ -660,6 +725,11 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.table.table.Table
</pre></div>
</div>
</div>
</div> </div>
<p>And <code class="docutils literal notranslate"><span class="pre">skycoord_gd1</span></code> is a <code class="docutils literal notranslate"><span class="pre">SkyCoord</span></code> object that contains the transformed coordinates and proper motions.</p> <p>And <code class="docutils literal notranslate"><span class="pre">skycoord_gd1</span></code> is a <code class="docutils literal notranslate"><span class="pre">SkyCoord</span></code> object that contains the transformed coordinates and proper motions.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -668,6 +738,11 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.coordinates.sky_coordinate.SkyCoord
</pre></div>
</div>
</div>
</div> </div>
<p>On one hand, this division of labor makes sense because each object provides different capabilities. But working with multiple object types can be awkward.</p> <p>On one hand, this division of labor makes sense because each object provides different capabilities. But working with multiple object types can be awkward.</p>
<p>It will be more convenient to choose one object and get all of the data into it. Well choose a Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>, for two reasons:</p> <p>It will be more convenient to choose one object and get all of the data into it. Well choose a Pandas <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>, for two reasons:</p>
@@ -693,6 +768,11 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(140339, 6)
</pre></div>
</div>
</div>
</div> </div>
<p>It also provides <code class="docutils literal notranslate"><span class="pre">head</span></code>, which displays the first few rows. <code class="docutils literal notranslate"><span class="pre">head</span></code> is useful for spot-checking large results as you go along.</p> <p>It also provides <code class="docutils literal notranslate"><span class="pre">head</span></code>, which displays the first few rows. <code class="docutils literal notranslate"><span class="pre">head</span></code> is useful for spot-checking large results as you go along.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -701,6 +781,82 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </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>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>637987125186749568</td>
<td>142.483019</td>
<td>21.757716</td>
<td>-2.516838</td>
<td>2.941813</td>
<td>-0.257345</td>
</tr>
<tr>
<th>1</th>
<td>638285195917112960</td>
<td>142.254529</td>
<td>22.476168</td>
<td>2.662702</td>
<td>-12.165984</td>
<td>0.422728</td>
</tr>
<tr>
<th>2</th>
<td>638073505568978688</td>
<td>142.645286</td>
<td>22.166932</td>
<td>18.306747</td>
<td>-7.950660</td>
<td>0.103640</td>
</tr>
<tr>
<th>3</th>
<td>638086386175786752</td>
<td>142.577394</td>
<td>22.227920</td>
<td>0.987786</td>
<td>-2.584105</td>
<td>-0.857327</td>
</tr>
<tr>
<th>4</th>
<td>638049655615392384</td>
<td>142.589136</td>
<td>22.110783</td>
<td>0.244439</td>
<td>-4.941079</td>
<td>0.099625</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p><strong>Python detail:</strong> <code class="docutils literal notranslate"><span class="pre">shape</span></code> is an attribute, so we display its value without calling it as a function; <code class="docutils literal notranslate"><span class="pre">head</span></code> is a function, so we need the parentheses.</p> <p><strong>Python detail:</strong> <code class="docutils literal notranslate"><span class="pre">shape</span></code> is an attribute, so we display its value without calling it as a function; <code class="docutils literal notranslate"><span class="pre">head</span></code> is a function, so we need the parentheses.</p>
<p>Now we can extract the columns we want from <code class="docutils literal notranslate"><span class="pre">skycoord_gd1</span></code> and add them as columns in the <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>. <code class="docutils literal notranslate"><span class="pre">phi1</span></code> and <code class="docutils literal notranslate"><span class="pre">phi2</span></code> contain the transformed coordinates.</p> <p>Now we can extract the columns we want from <code class="docutils literal notranslate"><span class="pre">skycoord_gd1</span></code> and add them as columns in the <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>. <code class="docutils literal notranslate"><span class="pre">phi1</span></code> and <code class="docutils literal notranslate"><span class="pre">phi2</span></code> contain the transformed coordinates.</p>
@@ -712,6 +868,11 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(140339, 8)
</pre></div>
</div>
</div>
</div> </div>
<p><code class="docutils literal notranslate"><span class="pre">pm_phi1_cosphi2</span></code> and <code class="docutils literal notranslate"><span class="pre">pm_phi2</span></code> contain the components of proper motion in the transformed frame.</p> <p><code class="docutils literal notranslate"><span class="pre">pm_phi1_cosphi2</span></code> and <code class="docutils literal notranslate"><span class="pre">pm_phi2</span></code> contain the components of proper motion in the transformed frame.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -722,6 +883,11 @@ The coordinates in <code class="docutils literal notranslate"><span class="pre">
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(140339, 10)
</pre></div>
</div>
</div>
</div> </div>
<p><strong>Detail:</strong> If you notice that <code class="docutils literal notranslate"><span class="pre">SkyCoord</span></code> has an attribute called <code class="docutils literal notranslate"><span class="pre">proper_motion</span></code>, you might wonder why we are not using it.</p> <p><strong>Detail:</strong> If you notice that <code class="docutils literal notranslate"><span class="pre">SkyCoord</span></code> has an attribute called <code class="docutils literal notranslate"><span class="pre">proper_motion</span></code>, you might wonder why we are not using it.</p>
<p>We could have: <code class="docutils literal notranslate"><span class="pre">proper_motion</span></code> contains the same data as <code class="docutils literal notranslate"><span class="pre">pm_phi1_cosphi2</span></code> and <code class="docutils literal notranslate"><span class="pre">pm_phi2</span></code>, but in a different format.</p> <p>We could have: <code class="docutils literal notranslate"><span class="pre">proper_motion</span></code> contains the same data as <code class="docutils literal notranslate"><span class="pre">pm_phi1_cosphi2</span></code> and <code class="docutils literal notranslate"><span class="pre">pm_phi2</span></code>, but in a different format.</p>
@@ -736,6 +902,145 @@ One of the most useful of these functions is <code class="docutils literal notra
</pre></div> </pre></div>
</div> </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>phi1</th>
<th>phi2</th>
<th>pm_phi1</th>
<th>pm_phi2</th>
</tr>
</thead>
<tbody>
<tr>
<th>count</th>
<td>1.403390e+05</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
<td>140339.000000</td>
</tr>
<tr>
<th>mean</th>
<td>6.792399e+17</td>
<td>143.823122</td>
<td>26.780285</td>
<td>-2.484404</td>
<td>-6.100777</td>
<td>0.179492</td>
<td>-50.091158</td>
<td>-1.803301</td>
<td>-0.868963</td>
<td>1.409208</td>
</tr>
<tr>
<th>std</th>
<td>3.792177e+16</td>
<td>3.697850</td>
<td>3.052592</td>
<td>5.913939</td>
<td>7.202047</td>
<td>0.759590</td>
<td>2.892344</td>
<td>3.444398</td>
<td>6.657714</td>
<td>6.518615</td>
</tr>
<tr>
<th>min</th>
<td>6.214900e+17</td>
<td>135.425699</td>
<td>19.286617</td>
<td>-106.755260</td>
<td>-138.065163</td>
<td>-15.287602</td>
<td>-54.999989</td>
<td>-8.029159</td>
<td>-115.275637</td>
<td>-161.150142</td>
</tr>
<tr>
<th>25%</th>
<td>6.443517e+17</td>
<td>140.967966</td>
<td>24.592490</td>
<td>-5.038789</td>
<td>-8.341561</td>
<td>-0.035981</td>
<td>-52.602952</td>
<td>-4.750426</td>
<td>-2.948723</td>
<td>-1.107128</td>
</tr>
<tr>
<th>50%</th>
<td>6.888060e+17</td>
<td>143.734409</td>
<td>26.746261</td>
<td>-1.834943</td>
<td>-4.689596</td>
<td>0.362708</td>
<td>-50.147362</td>
<td>-1.671502</td>
<td>0.585037</td>
<td>1.987149</td>
</tr>
<tr>
<th>75%</th>
<td>6.976579e+17</td>
<td>146.607350</td>
<td>28.990500</td>
<td>0.452893</td>
<td>-1.937809</td>
<td>0.657637</td>
<td>-47.593279</td>
<td>1.160514</td>
<td>3.001768</td>
<td>4.628965</td>
</tr>
<tr>
<th>max</th>
<td>7.974418e+17</td>
<td>152.777393</td>
<td>34.285481</td>
<td>104.319923</td>
<td>20.981070</td>
<td>0.999957</td>
<td>-44.999985</td>
<td>4.014609</td>
<td>39.802471</td>
<td>79.275199</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<div class="section" id="id1"> <div class="section" id="id1">
<h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3> <h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
@@ -746,7 +1051,17 @@ One of the most useful of these functions is <code class="docutils literal notra
</ul> </ul>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># The most noticeable issue is that some of the</span>
<span class="c1"># parallax values are negative, which is non-physical.</span>
<span class="c1"># The reason is that parallax measurements are less accurate</span>
<span class="c1"># for stars that are far away.</span>
<span class="c1"># Fortunately, we don&#39;t use the parallax measurements in</span>
<span class="c1"># the analysis (one of the reasons we used constant distance</span>
<span class="c1"># for reflex correction).</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -776,6 +1091,9 @@ Then we will use the bounds of the cluster to select stars that are more likely
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_69_0.png" src="_images/03_motion_69_0.png" />
</div>
</div> </div>
<p>Most of the proper motions are near the origin, but there are a few extreme values. <p>Most of the proper motions are near the origin, but there are a few extreme values.
Following the example in the paper, well use <code class="docutils literal notranslate"><span class="pre">xlim</span></code> and <code class="docutils literal notranslate"><span class="pre">ylim</span></code> to zoom in on the region near the origin.</p> Following the example in the paper, well use <code class="docutils literal notranslate"><span class="pre">xlim</span></code> and <code class="docutils literal notranslate"><span class="pre">ylim</span></code> to zoom in on the region near the origin.</p>
@@ -793,6 +1111,9 @@ Following the example in the paper, well use <code class="docutils literal no
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_71_0.png" src="_images/03_motion_71_0.png" />
</div>
</div> </div>
<p>There is a hint of an overdense region near (-7.5, 0), but if you didnt know where to look, you would miss it.</p> <p>There is a hint of an overdense region near (-7.5, 0), but if you didnt know where to look, you would miss it.</p>
<p>To see the cluster more clearly, we need a sample that contains a higher proportion of stars in GD-1. <p>To see the cluster more clearly, we need a sample that contains a higher proportion of stars in GD-1.
@@ -811,6 +1132,11 @@ Well do that by selecting stars close to the centerline.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>pandas.core.series.Series
</pre></div>
</div>
</div>
</div> </div>
<p>The result is a <code class="docutils literal notranslate"><span class="pre">Series</span></code>, which is the structure Pandas uses to represent columns.</p> <p>The result is a <code class="docutils literal notranslate"><span class="pre">Series</span></code>, which is the structure Pandas uses to represent columns.</p>
<p>We can use a comparison operator, <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>, to compare the values in a <code class="docutils literal notranslate"><span class="pre">Series</span></code> to a constant.</p> <p>We can use a comparison operator, <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>, to compare the values in a <code class="docutils literal notranslate"><span class="pre">Series</span></code> to a constant.</p>
@@ -824,6 +1150,11 @@ Well do that by selecting stars close to the centerline.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>pandas.core.series.Series
</pre></div>
</div>
</div>
</div> </div>
<p>The result is a <code class="docutils literal notranslate"><span class="pre">Series</span></code> of Boolean values, that is, <code class="docutils literal notranslate"><span class="pre">True</span></code> and <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p> <p>The result is a <code class="docutils literal notranslate"><span class="pre">Series</span></code> of Boolean values, that is, <code class="docutils literal notranslate"><span class="pre">True</span></code> and <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -832,6 +1163,16 @@ Well do that by selecting stars close to the centerline.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0 False
1 False
2 False
3 False
4 False
Name: phi2, dtype: bool
</pre></div>
</div>
</div>
</div> </div>
<p>To select values that fall between <code class="docutils literal notranslate"><span class="pre">phi2_min</span></code> and <code class="docutils literal notranslate"><span class="pre">phi2_max</span></code>, well use the <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> operator, which computes “logical AND”. <p>To select values that fall between <code class="docutils literal notranslate"><span class="pre">phi2_min</span></code> and <code class="docutils literal notranslate"><span class="pre">phi2_max</span></code>, well use the <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> operator, which computes “logical AND”.
The result is true where elements from both Boolean <code class="docutils literal notranslate"><span class="pre">Series</span></code> are true.</p> The result is true where elements from both Boolean <code class="docutils literal notranslate"><span class="pre">Series</span></code> are true.</p>
@@ -851,6 +1192,11 @@ The result is true where elements from both Boolean <code class="docutils litera
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>25084
</pre></div>
</div>
</div>
</div> </div>
<p>A Boolean <code class="docutils literal notranslate"><span class="pre">Series</span></code> is sometimes called a “mask” because we can use it to mask out some of the rows in a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> and select the rest, like this:</p> <p>A Boolean <code class="docutils literal notranslate"><span class="pre">Series</span></code> is sometimes called a “mask” because we can use it to mask out some of the rows in a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> and select the rest, like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -860,6 +1206,11 @@ The result is true where elements from both Boolean <code class="docutils litera
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>pandas.core.frame.DataFrame
</pre></div>
</div>
</div>
</div> </div>
<p><code class="docutils literal notranslate"><span class="pre">centerline_df</span></code> is a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> that contains only the rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code> that correspond to <code class="docutils literal notranslate"><span class="pre">True</span></code> values in <code class="docutils literal notranslate"><span class="pre">mask</span></code>. <p><code class="docutils literal notranslate"><span class="pre">centerline_df</span></code> is a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> that contains only the rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code> that correspond to <code class="docutils literal notranslate"><span class="pre">True</span></code> values in <code class="docutils literal notranslate"><span class="pre">mask</span></code>.
So it contains the stars near the centerline of GD-1.</p> So it contains the stars near the centerline of GD-1.</p>
@@ -870,6 +1221,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>25084
</pre></div>
</div>
</div>
</div> </div>
<p>And what fraction of the rows weve selected.</p> <p>And what fraction of the rows weve selected.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -878,6 +1234,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.1787386257562046
</pre></div>
</div>
</div>
</div> </div>
<p>There are about 25,000 stars in this region, about 18% of the total.</p> <p>There are about 25,000 stars in this region, about 18% of the total.</p>
</div> </div>
@@ -911,6 +1272,9 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_94_0.png" src="_images/03_motion_94_0.png" />
</div>
</div> </div>
<p>Now we can see more clearly that there is a cluster near (-7.5, 0).</p> <p>Now we can see more clearly that there is a cluster near (-7.5, 0).</p>
<p>You might notice that our figure is less dense than the one in the paper. Thats because we started with a set of stars from a relatively small region. The figure in the paper is based on a region about 10 times bigger.</p> <p>You might notice that our figure is less dense than the one in the paper. Thats because we started with a set of stars from a relatively small region. The figure in the paper is based on a region about 10 times bigger.</p>
@@ -961,6 +1325,9 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_102_0.png" src="_images/03_motion_102_0.png" />
</div>
</div> </div>
<p>Now that weve identified the bounds of the cluster in proper motion, well use it to select rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code>.</p> <p>Now that weve identified the bounds of the cluster in proper motion, well use it to select rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code>.</p>
<p>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> <p>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>
@@ -992,6 +1359,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>1049
</pre></div>
</div>
</div>
</div> </div>
<p>Now we can use this mask to select rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code>.</p> <p>Now we can use this mask to select rows from <code class="docutils literal notranslate"><span class="pre">results_df</span></code>.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -1001,6 +1373,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>1049
</pre></div>
</div>
</div>
</div> </div>
<p>These are the stars we think are likely to be in GD-1. Lets see what they look like, plotting their coordinates (not their proper motion).</p> <p>These are the stars we think are likely to be in GD-1. Lets see what they look like, plotting their coordinates (not their proper motion).</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -1014,6 +1391,9 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/03_motion_112_0.png" src="_images/03_motion_112_0.png" />
</div>
</div> </div>
<p>Now thats starting to look like a tidal stream!</p> <p>Now thats starting to look like a tidal stream!</p>
</div> </div>
@@ -1028,6 +1408,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>astropy.table.table.Table
</pre></div>
</div>
</div>
</div> </div>
<p>Then we could write the <code class="docutils literal notranslate"><span class="pre">Table</span></code> to a FITS file, as we did in the previous lesson.</p> <p>Then we could write the <code class="docutils literal notranslate"><span class="pre">Table</span></code> to a FITS file, as we did in the previous lesson.</p>
<p>But Pandas provides functions to write DataFrames in other formats; to see what they are <a class="reference external" href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html">find the functions here that begin with <code class="docutils literal notranslate"><span class="pre">to_</span></code></a>.</p> <p>But Pandas provides functions to write DataFrames in other formats; to see what they are <a class="reference external" href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html">find the functions here that begin with <code class="docutils literal notranslate"><span class="pre">to_</span></code></a>.</p>
@@ -1055,7 +1440,9 @@ So it contains the stars near the centerline of GD-1.</p>
<p>Hint: Since the file already exists, you should <em>not</em> use <code class="docutils literal notranslate"><span class="pre">mode='w'</span></code>.</p> <p>Hint: Since the file already exists, you should <em>not</em> use <code class="docutils literal notranslate"><span class="pre">mode='w'</span></code>.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">centerline_df</span><span class="o">.</span><span class="n">to_hdf</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;centerline_df&#39;</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -1070,6 +1457,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2.2084197998046875
</pre></div>
</div>
</div>
</div> </div>
<p>If you forget what the names of the Datasets in the file are, you can read them back like this:</p> <p>If you forget what the names of the Datasets in the file are, you can read them back like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -1079,6 +1471,11 @@ So it contains the stars near the centerline of GD-1.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&#39;/centerline_df&#39;, &#39;/selected_df&#39;]
</pre></div>
</div>
</div>
</div> </div>
<p><strong>Python note:</strong> We use a <code class="docutils literal notranslate"><span class="pre">with</span></code> statement here to open the file before the print statement and (automatically) close it after. Read more about <a class="reference external" href="https://book.pythontips.com/en/latest/context_managers.html">context managers</a>.</p> <p><strong>Python note:</strong> We use a <code class="docutils literal notranslate"><span class="pre">with</span></code> statement here to open the file before the print statement and (automatically) close it after. Read more about <a class="reference external" href="https://book.pythontips.com/en/latest/context_managers.html">context managers</a>.</p>
<p>The keys are the names of the Datasets. Notice that they start with <code class="docutils literal notranslate"><span class="pre">/</span></code>, which indicates that they are at the top level of the Dataset hierarchy, and not in a named “group”.</p> <p>The keys are the names of the Datasets. Notice that they start with <code class="docutils literal notranslate"><span class="pre">/</span></code>, which indicates that they are at the top level of the Dataset hierarchy, and not in a named “group”.</p>

View File

@@ -243,11 +243,6 @@
Outline Outline
</a> </a>
</li> </li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#installing-libraries">
Installing libraries
</a>
</li>
<li class="toc-h2 nav-item toc-entry"> <li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#reload-the-data"> <a class="reference internal nav-link" href="#reload-the-data">
Reload the data Reload the data
@@ -332,24 +327,6 @@ Well also see how to write the results to a CSV file.</p>
<li><p>Save data in CSV format.</p></li> <li><p>Save data in CSV format.</p></li>
</ul> </ul>
</div> </div>
<div class="section" id="installing-libraries">
<h2>Installing libraries<a class="headerlink" href="#installing-libraries" title="Permalink to this headline"></a></h2>
<p>If you are running this notebook on Colab, you can run the following cell to install the libraries well use.</p>
<p>If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface.</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"># If we&#39;re running on Colab, install libraries</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">IN_COLAB</span> <span class="o">=</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span>
<span class="k">if</span> <span class="n">IN_COLAB</span><span class="p">:</span>
<span class="o">!</span>pip install astroquery astro-gala
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="reload-the-data"> <div class="section" id="reload-the-data">
<h2>Reload the data<a class="headerlink" href="#reload-the-data" title="Permalink to this headline"></a></h2> <h2>Reload the data<a class="headerlink" href="#reload-the-data" title="Permalink to this headline"></a></h2>
<p>You can <a class="reference external" href="https://github.com/AllenDowney/AstronomicalData/raw/main/data/gd1_data.hdf">download the data from the previous lesson</a> or run the following cell, which downloads it if necessary.</p> <p>You can <a class="reference external" href="https://github.com/AllenDowney/AstronomicalData/raw/main/data/gd1_data.hdf">download the data from the previous lesson</a> or run the following cell, which downloads it if necessary.</p>
@@ -466,6 +443,9 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/04_select_16_0.png" src="_images/04_select_16_0.png" />
</div>
</div> </div>
<p>Now well 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> <p>Now well 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>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -486,6 +466,9 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/04_select_18_0.png" src="_images/04_select_18_0.png" />
</div>
</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>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 that 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>
@@ -503,6 +486,11 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(1049, 2)
</pre></div>
</div>
</div>
</div> </div>
<p>NOTE: If you are using an older version of Pandas, you might not have <code class="docutils literal notranslate"><span class="pre">to_numpy()</span></code>; you can use <code class="docutils literal notranslate"><span class="pre">values</span></code> instead, like this:</p> <p>NOTE: If you are using an older version of Pandas, you might not have <code class="docutils literal notranslate"><span class="pre">to_numpy()</span></code>; you can use <code class="docutils literal notranslate"><span class="pre">values</span></code> instead, like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">points</span> <span class="o">=</span> <span class="n">selected_df</span><span class="p">[[</span><span class="s1">&#39;pmra&#39;</span><span class="p">,</span><span class="s1">&#39;pmdec&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">values</span> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">points</span> <span class="o">=</span> <span class="n">selected_df</span><span class="p">[[</span><span class="s1">&#39;pmra&#39;</span><span class="p">,</span><span class="s1">&#39;pmdec&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">values</span>
@@ -519,6 +507,11 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;scipy.spatial.qhull.ConvexHull at 0x7ff6207866a0&gt;
</pre></div>
</div>
</div>
</div> </div>
<p><code class="docutils literal notranslate"><span class="pre">hull.vertices</span></code> contains the indices of the points that fall on the perimeter of the hull.</p> <p><code class="docutils literal notranslate"><span class="pre">hull.vertices</span></code> contains the indices of the points that fall on the perimeter of the hull.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -527,6 +520,12 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </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([ 692, 873, 141, 303, 42, 622, 45, 83, 127, 182, 1006,
971, 967, 1001, 969, 940], dtype=int32)
</pre></div>
</div>
</div>
</div> </div>
<p>We can use them as an index into the original array to select the corresponding rows.</p> <p>We can use them as an index into the original array to select the corresponding rows.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -536,6 +535,26 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </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([[ -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> </div>
<p>To plot the resulting polygon, we have to pull out the x and y coordinates.</p> <p>To plot the resulting polygon, we have to pull out the x and y coordinates.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -567,6 +586,9 @@ Well also see how to write the results to a CSV file.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/04_select_31_0.png" src="_images/04_select_31_0.png" />
</div>
</div> </div>
<p>So <code class="docutils literal notranslate"><span class="pre">pm_vertices</span></code> represents the polygon we want to select. <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> The next step is to use it as part of an ADQL query.</p>
@@ -651,6 +673,11 @@ Heres the function from Lesson 2 we used to do that.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&#39;135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862&#39;
</pre></div>
</div>
</div>
</div> </div>
<p>Here are the columns we want to select.</p> <p>Here are the columns we want to select.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -669,6 +696,17 @@ Heres the function from Lesson 2 we used to do that.</p>
</pre></div> </pre></div>
</div> </div>
</div> </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
FROM gaiadr2.gaia_source
WHERE parallax &lt; 1
AND bp_rp BETWEEN -0.75 AND 2
AND 1 = CONTAINS(POINT(ra, dec),
POLYGON(135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862))
</pre></div>
</div>
</div>
</div> </div>
<p>But dont try to run that query. <p>But dont try to run that query.
Because it selects a larger region, there are too many stars to handle in a single query. Because it selects a larger region, there are too many stars to handle in a single query.
@@ -688,6 +726,11 @@ Using <code class="docutils literal notranslate"><span class="pre">flatten</span
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&#39;[ -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]&#39;
</pre></div>
</div>
</div>
</div> </div>
<p>We just have to remove the brackets.</p> <p>We just have to remove the brackets.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -697,13 +740,29 @@ Using <code class="docutils literal notranslate"><span class="pre">flatten</span
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&#39; -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&#39;
</pre></div>
</div>
</div>
</div> </div>
<div class="section" id="exercise"> <div class="section" id="exercise">
<h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h3> <h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this headline"></a></h3>
<p>Define <code class="docutils literal notranslate"><span class="pre">query6_base</span></code>, starting with <code class="docutils literal notranslate"><span class="pre">query5_base</span></code> and 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> <p>Define <code class="docutils literal notranslate"><span class="pre">query6_base</span></code>, starting with <code class="docutils literal notranslate"><span class="pre">query5_base</span></code> and 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 tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">query6_base</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="si">{columns}</span><span class="s2"></span>
<span class="s2">FROM gaiadr2.gaia_source</span>
<span class="s2">WHERE parallax &lt; 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"> AND 1 = CONTAINS(POINT(pmra, pmdec),</span>
<span class="s2"> POLYGON(</span><span class="si">{pm_point_list}</span><span class="s2">))</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -714,7 +773,25 @@ Using <code class="docutils literal notranslate"><span class="pre">flatten</span
<p>Use <code class="docutils literal notranslate"><span class="pre">format</span></code> to format <code class="docutils literal notranslate"><span class="pre">query6_base</span></code> and define <code class="docutils literal notranslate"><span class="pre">query6</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> <p>Use <code class="docutils literal notranslate"><span class="pre">format</span></code> to format <code class="docutils literal notranslate"><span class="pre">query6_base</span></code> and define <code class="docutils literal notranslate"><span class="pre">query6</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 tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">query6</span> <span class="o">=</span> <span class="n">query6_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span>
<span class="n">point_list</span><span class="o">=</span><span class="n">point_list</span><span class="p">,</span>
<span class="n">pm_point_list</span><span class="o">=</span><span class="n">pm_point_list</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">query6</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
source_id, ra, dec, pmra, pmdec
FROM gaiadr2.gaia_source
WHERE parallax &lt; 1
AND bp_rp BETWEEN -0.75 AND 2
AND 1 = CONTAINS(POINT(ra, dec),
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.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> </pre></div>
</div> </div>
</div> </div>
@@ -729,6 +806,24 @@ Using <code class="docutils literal notranslate"><span class="pre">flatten</span
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
&lt;Table length=7345&gt;
name dtype unit description
--------- ------- -------- ------------------------------------------------------------------
source_id int64 Unique source identifier (unique within a particular Data Release)
ra float64 deg Right ascension
dec float64 deg Declination
pmra float64 mas / yr Proper motion in right ascension direction
pmdec float64 mas / yr Proper motion in declination direction
Jobid: 1616771462206O
Phase: COMPLETED
Owner: None
Output file: async_20210326111102.vot
Results: None
</pre></div>
</div>
</div>
</div> </div>
<p>And get the results.</p> <p>And get the results.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -738,6 +833,11 @@ Using <code class="docutils literal notranslate"><span class="pre">flatten</span
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>7345
</pre></div>
</div>
</div>
</div> </div>
<p>We call the results <code class="docutils literal notranslate"><span class="pre">candidate_table</span></code> because it contains stars that are good candidates for GD-1.</p> <p>We call the results <code class="docutils literal notranslate"><span class="pre">candidate_table</span></code> because it contains stars that are good candidates for GD-1.</p>
<p>For the next lesson, well need <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> again, so we should save them in a file. <p>For the next lesson, well need <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> again, so we should save them in a file.
@@ -752,6 +852,12 @@ To make one, well start with a dictionary:</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>{&#39;point_list&#39;: &#39;135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862&#39;,
&#39;pm_point_list&#39;: &#39; -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&#39;}
</pre></div>
</div>
</div>
</div> </div>
<p>And use it to initialize a <code class="docutils literal notranslate"><span class="pre">Series.</span></code></p> <p>And use it to initialize a <code class="docutils literal notranslate"><span class="pre">Series.</span></code></p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -761,6 +867,13 @@ To make one, well start with a dictionary:</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>point_list 135.306, 8.39862, 126.51, 13.4449, 163.017, 54...
pm_point_list -4.05037121,-14.75623261, -3.41981085,-14.723...
dtype: object
</pre></div>
</div>
</div>
</div> </div>
<p>Now we can save it in the usual way.</p> <p>Now we can save it in the usual way.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -787,6 +900,9 @@ To make one, well start with a dictionary:</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/04_select_68_0.png" src="_images/04_select_68_0.png" />
</div>
</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>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 lets transform the results back to the GD-1 frame. <p>So lets transform the results back to the GD-1 frame.
@@ -844,6 +960,9 @@ Heres the code we used to transform the coordinates and make a Pandas <code c
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/04_select_74_0.png" src="_images/04_select_74_0.png" />
</div>
</div> </div>
<p>Were starting to see GD-1 more clearly. <p>Were starting to see GD-1 more clearly.
We can compare this figure with this panel from Figure 1 from the original paper:</p> We can compare this figure with this panel from Figure 1 from the original paper:</p>

View File

@@ -243,11 +243,6 @@
Outline Outline
</a> </a>
</li> </li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#installing-libraries">
Installing libraries
</a>
</li>
<li class="toc-h2 nav-item toc-entry"> <li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#getting-photometry-data"> <a class="reference internal nav-link" href="#getting-photometry-data">
Getting photometry data Getting photometry data
@@ -361,24 +356,6 @@ The following figure from the paper is a color-magnitude diagram for the stars s
<li><p>Write ADQL queries involving <code class="docutils literal notranslate"><span class="pre">JOIN</span></code> operations.</p></li> <li><p>Write ADQL queries involving <code class="docutils literal notranslate"><span class="pre">JOIN</span></code> operations.</p></li>
</ul> </ul>
</div> </div>
<div class="section" id="installing-libraries">
<h2>Installing libraries<a class="headerlink" href="#installing-libraries" title="Permalink to this headline"></a></h2>
<p>If you are running this notebook on Colab, you can run the following cell to install the libraries well use.</p>
<p>If you are running this notebook on your own computer, you might have to install these libraries yourself. See the instructions in the preface.</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"># If we&#39;re running on Colab, install libraries</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">IN_COLAB</span> <span class="o">=</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span>
<span class="k">if</span> <span class="n">IN_COLAB</span><span class="p">:</span>
<span class="o">!</span>pip install astroquery
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="getting-photometry-data"> <div class="section" id="getting-photometry-data">
<h2>Getting photometry data<a class="headerlink" href="#getting-photometry-data" title="Permalink to this headline"></a></h2> <h2>Getting photometry data<a class="headerlink" href="#getting-photometry-data" title="Permalink to this headline"></a></h2>
<p>The Gaia dataset contains some photometry data, including the variable <code class="docutils literal notranslate"><span class="pre">bp_rp</span></code>, which contains BP-RP color (the difference in mean flux between the BP and RP bands). <p>The Gaia dataset contains some photometry data, including the variable <code class="docutils literal notranslate"><span class="pre">bp_rp</span></code>, which contains BP-RP color (the difference in mean flux between the BP and RP bands).
@@ -414,6 +391,13 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Retrieving table &#39;gaiadr2.panstarrs1_best_neighbour&#39;
Parsing table &#39;gaiadr2.panstarrs1_best_neighbour&#39;...
Done.
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -421,6 +405,16 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>TAP Table name: gaiadr2.gaiadr2.panstarrs1_best_neighbour
Description: Pan-STARRS1 BestNeighbour table lists each matched Gaia object with its
best neighbour in the external catalogue.
There are 1327157 objects in the filtered version of Pan-STARRS1 used
to compute this cross-match that have too early epochMean.
Num. columns: 7
</pre></div>
</div>
</div>
</div> </div>
<p>And here are the columns.</p> <p>And here are the columns.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -430,6 +424,17 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </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
original_ext_source_id
angular_distance
number_of_neighbours
number_of_mates
best_neighbour_multiplicity
gaia_astrometric_params
</pre></div>
</div>
</div>
</div> </div>
<p>Heres the <a class="reference external" href="https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_crossmatches/ssec_dm_panstarrs1_best_neighbour.html">documentation for these variables</a> .</p> <p>Heres the <a class="reference external" href="https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_crossmatches/ssec_dm_panstarrs1_best_neighbour.html">documentation for these variables</a> .</p>
<p>The ones well use are:</p> <p>The ones well use are:</p>
@@ -458,6 +463,11 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -466,6 +476,17 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=5</i>
<table id="table140523981953776" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>number_of_neighbours</th><th>number_of_mates</th><th>original_ext_source_id</th></tr></thead>
<thead><tr><th>int64</th><th>int32</th><th>int16</th><th>int64</th></tr></thead>
<tr><td>6745938972433480704</td><td>1</td><td>0</td><td>69742925668851205</td></tr>
<tr><td>6030466788955954048</td><td>1</td><td>0</td><td>69742509325691172</td></tr>
<tr><td>6756488099308169600</td><td>1</td><td>0</td><td>69742879438541228</td></tr>
<tr><td>6700154994715046016</td><td>1</td><td>0</td><td>69743055581721207</td></tr>
<tr><td>6757061941303252736</td><td>1</td><td>0</td><td>69742856540241198</td></tr>
</table></div></div>
</div> </div>
</div> </div>
<div class="section" id="the-pan-starrs-table"> <div class="section" id="the-pan-starrs-table">
@@ -477,6 +498,13 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Retrieving table &#39;gaiadr2.panstarrs1_original_valid&#39;
Parsing table &#39;gaiadr2.panstarrs1_original_valid&#39;...
Done.
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -484,6 +512,77 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>TAP Table name: gaiadr2.gaiadr2.panstarrs1_original_valid
Description: The Panoramic Survey Telescope and Rapid Response System (Pan-STARRS) is
a system for wide-field astronomical imaging developed and operated by
the Institute for Astronomy at the University of Hawaii. Pan-STARRS1
(PS1) is the first part of Pan-STARRS to be completed and is the basis
for Data Release 1 (DR1). The PS1 survey used a 1.8 meter telescope and
its 1.4 Gigapixel camera to image the sky in five broadband filters (g,
r, i, z, y).
The current table contains a filtered subsample of the 10723304629
entries listed in the original ObjectThin table.
We used only ObjectThin and MeanObject tables to extract
panstarrs1OriginalValid table, this means that objects detected only in
stack images are not included here. The main reason for us to avoid the
use of objects detected in stack images is that their astrometry is not
as good as the mean objects astrometry: “The stack positions (raStack,
decStack) have considerably larger systematic astrometric errors than
the mean epoch positions (raMean, decMean).” The astrometry for the
MeanObject positions uses Gaia DR1 as a reference catalog, while the
stack positions use 2MASS as a reference catalog.
In details, we filtered out all objects where:
- nDetections = 1
- no good quality data in Pan-STARRS, objInfoFlag 33554432 not set
- mean astrometry could not be measured, objInfoFlag 524288 set
- stack position used for mean astrometry, objInfoFlag 1048576 set
- error on all magnitudes equal to 0 or to -999;
- all magnitudes set to -999;
- error on RA or DEC greater than 1 arcsec.
The number of objects in panstarrs1OriginalValid is 2264263282.
The panstarrs1OriginalValid table contains only a subset of the columns
available in the combined ObjectThin and MeanObject tables. A
description of the original ObjectThin and MeanObjects tables can be
found at:
https://outerspace.stsci.edu/display/PANSTARRS/PS1+Database+object+and+detection+tables
Download:
http://mastweb.stsci.edu/ps1casjobs/home.aspx
Documentation:
https://outerspace.stsci.edu/display/PANSTARRS
http://pswww.ifa.hawaii.edu/pswww/
References:
The Pan-STARRS1 Surveys, Chambers, K.C., et al. 2016, arXiv:1612.05560
Pan-STARRS Data Processing System, Magnier, E. A., et al. 2016,
arXiv:1612.05240
Pan-STARRS Pixel Processing: Detrending, Warping, Stacking, Waters, C.
Z., et al. 2016, arXiv:1612.05245
Pan-STARRS Pixel Analysis: Source Detection and Characterization,
Magnier, E. A., et al. 2016, arXiv:1612.05244
Pan-STARRS Photometric and Astrometric Calibration, Magnier, E. A., et
al. 2016, arXiv:1612.05242
The Pan-STARRS1 Database and Data Products, Flewelling, H. A., et al.
2016, arXiv:1612.05243
Catalogue curator:
SSDC - ASI Space Science Data Center
https://www.ssdc.asi.it/
Num. columns: 26
</pre></div>
</div>
</div>
</div> </div>
<p>And here are the columns.</p> <p>And here are the columns.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -493,6 +592,36 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>obj_name
obj_id
ra
dec
ra_error
dec_error
epoch_mean
g_mean_psf_mag
g_mean_psf_mag_error
g_flags
r_mean_psf_mag
r_mean_psf_mag_error
r_flags
i_mean_psf_mag
i_mean_psf_mag_error
i_flags
z_mean_psf_mag
z_mean_psf_mag_error
z_flags
y_mean_psf_mag
y_mean_psf_mag_error
y_flags
n_detections
zone_id
obj_info_flag
quality_flag
</pre></div>
</div>
</div>
</div> </div>
<p>Heres the <span class="xref myst">documentation for these variables</span> .</p> <p>Heres the <span class="xref myst">documentation for these variables</span> .</p>
<p>The ones well use are:</p> <p>The ones well use are:</p>
@@ -519,6 +648,11 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -527,6 +661,18 @@ Heres the metadata for <code class="docutils literal notranslate"><span class
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=5</i>
<table id="table140523984535712" class="table-striped table-bordered table-condensed">
<thead><tr><th>obj_id</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>
<thead><tr><th></th><th></th><th>mag</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>67130655389101425</td><td>--</td><td>20.3516006469727</td></tr>
<tr><td>67553305590067819</td><td>--</td><td>19.779899597168</td></tr>
<tr><td>67551423248967849</td><td>--</td><td>19.8889007568359</td></tr>
<tr><td>67132026238911331</td><td>--</td><td>20.9062995910645</td></tr>
<tr><td>67553513677687787</td><td>--</td><td>21.2831001281738</td></tr>
</table></div></div>
</div> </div>
<p>The following figure shows how these tables are related.</p> <p>The following figure shows how these tables are related.</p>
<ul class="simple"> <ul class="simple">
@@ -565,6 +711,11 @@ As a starting place, lets go all the way back to the cone search from Lesson
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -573,6 +724,22 @@ As a starting place, lets go all the way back to the cone search from Lesson
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=10</i>
<table id="table140523908331168" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th></tr></thead>
<thead><tr><th>int64</th></tr></thead>
<tr><td>3322773965056065536</td></tr>
<tr><td>3322773758899157120</td></tr>
<tr><td>3322774068134271104</td></tr>
<tr><td>3322773930696320512</td></tr>
<tr><td>3322774377374425728</td></tr>
<tr><td>3322773724537891456</td></tr>
<tr><td>3322773724537891328</td></tr>
<tr><td>3322773930696321792</td></tr>
<tr><td>3322773724537890944</td></tr>
<tr><td>3322773930696322176</td></tr>
</table></div></div>
</div> </div>
<p>Now we can start adding features. <p>Now we can start adding features.
First, lets replace <code class="docutils literal notranslate"><span class="pre">source_id</span></code> with a format specifier, <code class="docutils literal notranslate"><span class="pre">columns</span></code>:</p> First, lets replace <code class="docutils literal notranslate"><span class="pre">source_id</span></code> with a format specifier, <code class="docutils literal notranslate"><span class="pre">columns</span></code>:</p>
@@ -599,6 +766,16 @@ First, lets replace <code class="docutils literal notranslate"><span class="p
</pre></div> </pre></div>
</div> </div>
</div> </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
FROM gaiadr2.gaia_source
WHERE 1=CONTAINS(
POINT(ra, dec),
CIRCLE(88.8, 7.4, 0.08333333))
</pre></div>
</div>
</div>
</div> </div>
<p>And lets run the query again.</p> <p>And lets run the query again.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -607,6 +784,11 @@ First, lets replace <code class="docutils literal notranslate"><span class="p
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -615,6 +797,33 @@ First, lets replace <code class="docutils literal notranslate"><span class="p
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=594</i>
<table id="table140523908331456" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>3322773965056065536</td><td>88.78178020183375</td><td>7.334936530583141</td><td>0.2980633722108194</td><td>-2.5057036964736907</td></tr>
<tr><td>3322773758899157120</td><td>88.83227057144585</td><td>7.325577341429926</td><td>--</td><td>--</td></tr>
<tr><td>3322774068134271104</td><td>88.8206092188033</td><td>7.353158142762173</td><td>-1.1065462654445488</td><td>-1.5260889445858044</td></tr>
<tr><td>3322773930696320512</td><td>88.80843339290348</td><td>7.334853162299928</td><td>2.6074384482375215</td><td>-0.9292104395445717</td></tr>
<tr><td>3322774377374425728</td><td>88.86806108182265</td><td>7.371287731275939</td><td>3.9555477866915383</td><td>-3.8676624830902435</td></tr>
<tr><td>3322773724537891456</td><td>88.81308602813434</td><td>7.32488574492059</td><td>51.34995462741039</td><td>-33.078133430952086</td></tr>
<tr><td>3322773724537891328</td><td>88.81570329208743</td><td>7.3223019772324855</td><td>1.9389988498951845</td><td>0.3110526931576576</td></tr>
<tr><td>3322773930696321792</td><td>88.8050736770331</td><td>7.332371472206583</td><td>2.264014834476311</td><td>1.0772755505138008</td></tr>
<tr><td>3322773724537890944</td><td>88.81241651540533</td><td>7.327864052479726</td><td>-0.36003627434304625</td><td>-6.393939291541333</td></tr>
<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>
<tr><td>3322962118983356032</td><td>88.76109637722949</td><td>7.380564308268047</td><td>--</td><td>--</td></tr>
<tr><td>3322963527732585984</td><td>88.78813701704823</td><td>7.456696889759524</td><td>1.1363354614104264</td><td>-2.46251296961979</td></tr>
<tr><td>3322961775385969024</td><td>88.79723215862369</td><td>7.359756552906535</td><td>2.121021366548921</td><td>-6.605711792572964</td></tr>
<tr><td>3322962084625312512</td><td>88.78286756313868</td><td>7.384598632215225</td><td>-0.09350717810996487</td><td>1.3495903680571226</td></tr>
<tr><td>3322962939322692608</td><td>88.73289357818679</td><td>7.407688975612043</td><td>-0.11002934783569704</td><td>1.002126813991455</td></tr>
<tr><td>3322963768250760576</td><td>88.7592444035961</td><td>7.469624531882018</td><td>--</td><td>--</td></tr>
<tr><td>3322963459013111808</td><td>88.80348931842845</td><td>7.438699901204871</td><td>0.800833828337078</td><td>-3.3780655466364626</td></tr>
<tr><td>3322963355935626368</td><td>88.75528507586058</td><td>7.427795463027667</td><td>--</td><td>--</td></tr>
<tr><td>3322963287216149888</td><td>88.7658164932195</td><td>7.415726370886557</td><td>2.3743092647634034</td><td>-0.5046963243400879</td></tr>
<tr><td>3322962015904143872</td><td>88.74740822271643</td><td>7.387057037713974</td><td>-0.7201178533250112</td><td>0.5565841272341593</td></tr>
</table></div></div>
</div> </div>
</div> </div>
<div class="section" id="adding-the-best-neighbor-table"> <div class="section" id="adding-the-best-neighbor-table">
@@ -666,6 +875,18 @@ Heres the complete query, including the columns we want from the Gaia and bes
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
gaia.source_id, gaia.ra, gaia.dec, gaia.pmra, gaia.pmdec, best.best_neighbour_multiplicity, best.number_of_mates
FROM gaiadr2.gaia_source AS gaia
JOIN gaiadr2.panstarrs1_best_neighbour AS best
ON gaia.source_id = best.source_id
WHERE 1=CONTAINS(
POINT(gaia.ra, gaia.dec),
CIRCLE(88.8, 7.4, 0.08333333))
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -673,6 +894,11 @@ Heres the complete query, including the columns we want from the Gaia and bes
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -681,6 +907,33 @@ Heres the complete query, including the columns we want from the Gaia and bes
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=490</i>
<table id="table140524639163968" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th><th>best_neighbour_multiplicity</th><th>number_of_mates</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th><th></th><th></th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th><th>int16</th><th>int16</th></tr></thead>
<tr><td>3322773965056065536</td><td>88.78178020183375</td><td>7.334936530583141</td><td>0.2980633722108194</td><td>-2.5057036964736907</td><td>1</td><td>0</td></tr>
<tr><td>3322774068134271104</td><td>88.8206092188033</td><td>7.353158142762173</td><td>-1.1065462654445488</td><td>-1.5260889445858044</td><td>1</td><td>0</td></tr>
<tr><td>3322773930696320512</td><td>88.80843339290348</td><td>7.334853162299928</td><td>2.6074384482375215</td><td>-0.9292104395445717</td><td>1</td><td>0</td></tr>
<tr><td>3322774377374425728</td><td>88.86806108182265</td><td>7.371287731275939</td><td>3.9555477866915383</td><td>-3.8676624830902435</td><td>1</td><td>0</td></tr>
<tr><td>3322773724537891456</td><td>88.81308602813434</td><td>7.32488574492059</td><td>51.34995462741039</td><td>-33.078133430952086</td><td>1</td><td>0</td></tr>
<tr><td>3322773724537891328</td><td>88.81570329208743</td><td>7.3223019772324855</td><td>1.9389988498951845</td><td>0.3110526931576576</td><td>1</td><td>0</td></tr>
<tr><td>3322773930696321792</td><td>88.8050736770331</td><td>7.332371472206583</td><td>2.264014834476311</td><td>1.0772755505138008</td><td>1</td><td>0</td></tr>
<tr><td>3322773724537890944</td><td>88.81241651540533</td><td>7.327864052479726</td><td>-0.36003627434304625</td><td>-6.393939291541333</td><td>1</td><td>0</td></tr>
<tr><td>3322773930696322176</td><td>88.80128682574824</td><td>7.334292036448643</td><td>--</td><td>--</td><td>1</td><td>0</td></tr>
<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>
<tr><td>3322962359501481088</td><td>88.85037722908271</td><td>7.402162717053584</td><td>2.058216493648542</td><td>-2.249255322558584</td><td>1</td><td>0</td></tr>
<tr><td>3322962393861228544</td><td>88.82108234976155</td><td>7.4044425496203</td><td>-0.916760881643629</td><td>-1.1113319053861441</td><td>1</td><td>0</td></tr>
<tr><td>3322955831151254912</td><td>88.74620347799508</td><td>7.342728619145855</td><td>0.1559833902071379</td><td>-1.750598455959734</td><td>1</td><td>0</td></tr>
<tr><td>3322962118983356032</td><td>88.76109637722949</td><td>7.380564308268047</td><td>--</td><td>--</td><td>1</td><td>0</td></tr>
<tr><td>3322963527732585984</td><td>88.78813701704823</td><td>7.456696889759524</td><td>1.1363354614104264</td><td>-2.46251296961979</td><td>1</td><td>0</td></tr>
<tr><td>3322961775385969024</td><td>88.79723215862369</td><td>7.359756552906535</td><td>2.121021366548921</td><td>-6.605711792572964</td><td>1</td><td>0</td></tr>
<tr><td>3322962084625312512</td><td>88.78286756313868</td><td>7.384598632215225</td><td>-0.09350717810996487</td><td>1.3495903680571226</td><td>1</td><td>0</td></tr>
<tr><td>3322962939322692608</td><td>88.73289357818679</td><td>7.407688975612043</td><td>-0.11002934783569704</td><td>1.002126813991455</td><td>1</td><td>0</td></tr>
<tr><td>3322963459013111808</td><td>88.80348931842845</td><td>7.438699901204871</td><td>0.800833828337078</td><td>-3.3780655466364626</td><td>1</td><td>0</td></tr>
<tr><td>3322962015904143872</td><td>88.74740822271643</td><td>7.387057037713974</td><td>-0.7201178533250112</td><td>0.5565841272341593</td><td>1</td><td>0</td></tr>
</table></div></div>
</div> </div>
<p>Notice that this result has fewer rows than the previous result. <p>Notice that this result has fewer rows than the previous result.
Thats because there are sources in the Gaia table with no corresponding source in the Pan-STARRS table.</p> Thats because there are sources in the Gaia table with no corresponding source in the Pan-STARRS table.</p>
@@ -697,10 +950,82 @@ This default is called an “inner” join because the results include only the
The result should contain 490 rows and 9 columns.</p> The result should contain 490 rows and 9 columns.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">query_base</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;SELECT </span>
<span class="si">{columns}</span><span class="s2"></span>
<span class="s2">FROM gaiadr2.gaia_source as gaia</span>
<span class="s2">JOIN gaiadr2.panstarrs1_best_neighbour as best</span>
<span class="s2"> ON gaia.source_id = best.source_id</span>
<span class="s2">JOIN gaiadr2.panstarrs1_original_valid as ps</span>
<span class="s2"> ON best.original_ext_source_id = ps.obj_id</span>
<span class="s2">WHERE 1=CONTAINS(</span>
<span class="s2"> POINT(gaia.ra, gaia.dec),</span>
<span class="s2"> CIRCLE(88.8, 7.4, 0.08333333))</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="n">column_list</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;gaia.source_id&#39;</span><span class="p">,</span>
<span class="s1">&#39;gaia.ra&#39;</span><span class="p">,</span>
<span class="s1">&#39;gaia.dec&#39;</span><span class="p">,</span>
<span class="s1">&#39;gaia.pmra&#39;</span><span class="p">,</span>
<span class="s1">&#39;gaia.pmdec&#39;</span><span class="p">,</span>
<span class="s1">&#39;best.best_neighbour_multiplicity&#39;</span><span class="p">,</span>
<span class="s1">&#39;best.number_of_mates&#39;</span><span class="p">,</span>
<span class="s1">&#39;ps.g_mean_psf_mag&#39;</span><span class="p">,</span>
<span class="s1">&#39;ps.i_mean_psf_mag&#39;</span><span class="p">]</span>
<span class="n">columns</span> <span class="o">=</span> <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">column_list</span><span class="p">)</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">query_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">query</span><span class="p">)</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="o">=</span><span class="n">query</span><span class="p">)</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_results</span><span class="p">()</span>
<span class="n">results</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
gaia.source_id, gaia.ra, gaia.dec, gaia.pmra, gaia.pmdec, best.best_neighbour_multiplicity, best.number_of_mates, ps.g_mean_psf_mag, ps.i_mean_psf_mag
FROM gaiadr2.gaia_source as gaia
JOIN gaiadr2.panstarrs1_best_neighbour as best
ON gaia.source_id = best.source_id
JOIN gaiadr2.panstarrs1_original_valid as ps
ON best.original_ext_source_id = ps.obj_id
WHERE 1=CONTAINS(
POINT(gaia.ra, gaia.dec),
CIRCLE(88.8, 7.4, 0.08333333))
INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
<div class="output text_html"><i>Table length=490</i>
<table id="table140524639164304" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th><th>best_neighbour_multiplicity</th><th>number_of_mates</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th><th></th><th></th><th></th><th>mag</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th><th>int16</th><th>int16</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>3322773965056065536</td><td>88.78178020183375</td><td>7.334936530583141</td><td>0.2980633722108194</td><td>-2.5057036964736907</td><td>1</td><td>0</td><td>19.9431991577148</td><td>17.4221992492676</td></tr>
<tr><td>3322774068134271104</td><td>88.8206092188033</td><td>7.353158142762173</td><td>-1.1065462654445488</td><td>-1.5260889445858044</td><td>1</td><td>0</td><td>18.6212005615234</td><td>16.6007995605469</td></tr>
<tr><td>3322773930696320512</td><td>88.80843339290348</td><td>7.334853162299928</td><td>2.6074384482375215</td><td>-0.9292104395445717</td><td>1</td><td>0</td><td>--</td><td>20.2203998565674</td></tr>
<tr><td>3322774377374425728</td><td>88.86806108182265</td><td>7.371287731275939</td><td>3.9555477866915383</td><td>-3.8676624830902435</td><td>1</td><td>0</td><td>18.0676002502441</td><td>16.9762001037598</td></tr>
<tr><td>3322773724537891456</td><td>88.81308602813434</td><td>7.32488574492059</td><td>51.34995462741039</td><td>-33.078133430952086</td><td>1</td><td>0</td><td>20.1907005310059</td><td>17.8700008392334</td></tr>
<tr><td>3322773724537891328</td><td>88.81570329208743</td><td>7.3223019772324855</td><td>1.9389988498951845</td><td>0.3110526931576576</td><td>1</td><td>0</td><td>22.6308002471924</td><td>19.6004009246826</td></tr>
<tr><td>3322773930696321792</td><td>88.8050736770331</td><td>7.332371472206583</td><td>2.264014834476311</td><td>1.0772755505138008</td><td>1</td><td>0</td><td>21.2119998931885</td><td>18.3528003692627</td></tr>
<tr><td>3322773724537890944</td><td>88.81241651540533</td><td>7.327864052479726</td><td>-0.36003627434304625</td><td>-6.393939291541333</td><td>1</td><td>0</td><td>20.8094005584717</td><td>18.1343002319336</td></tr>
<tr><td>3322773930696322176</td><td>88.80128682574824</td><td>7.334292036448643</td><td>--</td><td>--</td><td>1</td><td>0</td><td>19.7306003570557</td><td>--</td></tr>
<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>
<tr><td>3322962359501481088</td><td>88.85037722908271</td><td>7.402162717053584</td><td>2.058216493648542</td><td>-2.249255322558584</td><td>1</td><td>0</td><td>17.4034996032715</td><td>15.9040002822876</td></tr>
<tr><td>3322962393861228544</td><td>88.82108234976155</td><td>7.4044425496203</td><td>-0.916760881643629</td><td>-1.1113319053861441</td><td>1</td><td>0</td><td>--</td><td>--</td></tr>
<tr><td>3322955831151254912</td><td>88.74620347799508</td><td>7.342728619145855</td><td>0.1559833902071379</td><td>-1.750598455959734</td><td>1</td><td>0</td><td>18.4960994720459</td><td>17.3892993927002</td></tr>
<tr><td>3322962118983356032</td><td>88.76109637722949</td><td>7.380564308268047</td><td>--</td><td>--</td><td>1</td><td>0</td><td>18.0643997192383</td><td>16.7395000457764</td></tr>
<tr><td>3322963527732585984</td><td>88.78813701704823</td><td>7.456696889759524</td><td>1.1363354614104264</td><td>-2.46251296961979</td><td>1</td><td>0</td><td>17.8034992218018</td><td>16.1214008331299</td></tr>
<tr><td>3322961775385969024</td><td>88.79723215862369</td><td>7.359756552906535</td><td>2.121021366548921</td><td>-6.605711792572964</td><td>1</td><td>0</td><td>18.2070007324219</td><td>15.9947996139526</td></tr>
<tr><td>3322962084625312512</td><td>88.78286756313868</td><td>7.384598632215225</td><td>-0.09350717810996487</td><td>1.3495903680571226</td><td>1</td><td>0</td><td>16.7978992462158</td><td>15.1180000305176</td></tr>
<tr><td>3322962939322692608</td><td>88.73289357818679</td><td>7.407688975612043</td><td>-0.11002934783569704</td><td>1.002126813991455</td><td>1</td><td>0</td><td>17.18630027771</td><td>16.3645992279053</td></tr>
<tr><td>3322963459013111808</td><td>88.80348931842845</td><td>7.438699901204871</td><td>0.800833828337078</td><td>-3.3780655466364626</td><td>1</td><td>0</td><td>--</td><td>16.294900894165</td></tr>
<tr><td>3322962015904143872</td><td>88.74740822271643</td><td>7.387057037713974</td><td>-0.7201178533250112</td><td>0.5565841272341593</td><td>1</td><td>0</td><td>18.4706993103027</td><td>16.8038005828857</td></tr>
</table></div></div>
</div> </div>
</div> </div>
</div> </div>
@@ -735,6 +1060,13 @@ The result should contain 490 rows and 9 columns.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>point_list 135.306, 8.39862, 126.51, 13.4449, 163.017, 54...
pm_point_list -4.05037121,-14.75623261, -3.41981085,-14.723...
dtype: object
</pre></div>
</div>
</div>
</div> </div>
<p>Now we can assemble the query.</p> <p>Now we can assemble the query.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -749,6 +1081,19 @@ The result should contain 490 rows and 9 columns.</p>
</pre></div> </pre></div>
</div> </div>
</div> </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
FROM gaiadr2.gaia_source
WHERE parallax &lt; 1
AND bp_rp BETWEEN -0.75 AND 2
AND 1 = CONTAINS(POINT(ra, dec),
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.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> </div>
<p>Again, lets run it to make sure we are starting with a working query.</p> <p>Again, lets run it to make sure we are starting with a working query.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -757,6 +1102,11 @@ The result should contain 490 rows and 9 columns.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -765,6 +1115,33 @@ The result should contain 490 rows and 9 columns.</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html"><i>Table length=7345</i>
<table id="table140523982340048" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>635559124339440000</td><td>137.58671691646745</td><td>19.1965441084838</td><td>-3.770521900009566</td><td>-12.490481778113859</td></tr>
<tr><td>635860218726658176</td><td>138.5187065217173</td><td>19.09233926905897</td><td>-5.941679495793577</td><td>-11.346409129876392</td></tr>
<tr><td>635674126383965568</td><td>138.8428741026386</td><td>19.031798198627634</td><td>-3.8970011609340207</td><td>-12.702779525389634</td></tr>
<tr><td>635535454774983040</td><td>137.8377518255436</td><td>18.864006786112604</td><td>-4.335040664412791</td><td>-14.492308604905652</td></tr>
<tr><td>635497276810313600</td><td>138.0445160213759</td><td>19.00947118796605</td><td>-7.1729306406216615</td><td>-12.291499169815987</td></tr>
<tr><td>635614168640132864</td><td>139.59219748145836</td><td>18.807955539071433</td><td>-3.309602916796381</td><td>-13.708904908478631</td></tr>
<tr><td>635821843194387840</td><td>139.88094034815086</td><td>19.62185456718988</td><td>-6.544201177153814</td><td>-12.55978220563274</td></tr>
<tr><td>635551706931167104</td><td>138.04665586038192</td><td>19.248909662830798</td><td>-6.224595114220405</td><td>-12.224246333795001</td></tr>
<tr><td>635518889086133376</td><td>137.2374229207837</td><td>18.7428630711791</td><td>-3.3186800714801046</td><td>-12.710314902969365</td></tr>
<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>
<tr><td>612282738058264960</td><td>134.0445768189235</td><td>18.11915820167003</td><td>-2.5972485319419127</td><td>-13.651740929272187</td></tr>
<tr><td>612485911486166656</td><td>134.96582769047063</td><td>19.309965857307247</td><td>-4.519325315774155</td><td>-11.998725329569156</td></tr>
<tr><td>612386332668697600</td><td>135.45701048323093</td><td>18.63266345155342</td><td>-5.07684899854408</td><td>-12.436641304786672</td></tr>
<tr><td>612296172717818624</td><td>133.80060286960668</td><td>18.08186533343457</td><td>-6.112792578821885</td><td>-12.50750861370402</td></tr>
<tr><td>612250375480101760</td><td>134.64754712466774</td><td>18.122419425065015</td><td>-2.8969262278467127</td><td>-14.061676353845487</td></tr>
<tr><td>612394926899159168</td><td>135.51997060013844</td><td>18.817675531233004</td><td>-3.9968965218753763</td><td>-13.526821099431533</td></tr>
<tr><td>612288854091187712</td><td>134.07970733489358</td><td>18.15424015818678</td><td>-5.96977151283562</td><td>-11.162471664228455</td></tr>
<tr><td>612428870024913152</td><td>134.8384242853297</td><td>18.758253070693225</td><td>-4.0022333299353825</td><td>-14.247379430659198</td></tr>
<tr><td>612256418500423168</td><td>134.90752972739924</td><td>18.280596648172743</td><td>-6.109836304219565</td><td>-12.145212331165776</td></tr>
<tr><td>612429144902815104</td><td>134.77293979509543</td><td>18.73628415871413</td><td>-5.257085979310591</td><td>-13.962312685889454</td></tr>
</table></div></div>
</div> </div>
<div class="section" id="id2"> <div class="section" id="id2">
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3> <h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
@@ -774,10 +1151,82 @@ Format the query base using the column names in <code class="docutils literal no
<p>Run your query and download the results. The table you get should have 3725 rows and 9 columns.</p> <p>Run your query and download the results. The table you get should have 3725 rows and 9 columns.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">query7_base</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">SELECT </span>
<span class="si">{columns}</span><span class="s2"></span>
<span class="s2">FROM gaiadr2.gaia_source as gaia</span>
<span class="s2">JOIN gaiadr2.panstarrs1_best_neighbour as best</span>
<span class="s2"> ON gaia.source_id = best.source_id</span>
<span class="s2">JOIN gaiadr2.panstarrs1_original_valid as ps</span>
<span class="s2"> ON best.original_ext_source_id = ps.obj_id</span>
<span class="s2">WHERE parallax &lt; 1</span>
<span class="s2"> AND bp_rp BETWEEN -0.75 AND 2 </span>
<span class="s2"> AND 1 = CONTAINS(POINT(gaia.ra, gaia.dec), </span>
<span class="s2"> POLYGON(</span><span class="si">{point_list}</span><span class="s2">))</span>
<span class="s2"> AND 1 = CONTAINS(POINT(gaia.pmra, gaia.pmdec),</span>
<span class="s2"> POLYGON(</span><span class="si">{pm_point_list}</span><span class="s2">))</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="n">columns</span> <span class="o">=</span> <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">column_list</span><span class="p">)</span>
<span class="n">query7</span> <span class="o">=</span> <span class="n">query7_base</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span>
<span class="n">point_list</span><span class="o">=</span><span class="n">point_series</span><span class="p">[</span><span class="s1">&#39;point_list&#39;</span><span class="p">],</span>
<span class="n">pm_point_list</span><span class="o">=</span><span class="n">point_series</span><span class="p">[</span><span class="s1">&#39;pm_point_list&#39;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">query7</span><span class="p">)</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="o">=</span><span class="n">query7</span><span class="p">)</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_results</span><span class="p">()</span>
<span class="n">results</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>SELECT
gaia.source_id, gaia.ra, gaia.dec, gaia.pmra, gaia.pmdec, best.best_neighbour_multiplicity, best.number_of_mates, ps.g_mean_psf_mag, ps.i_mean_psf_mag
FROM gaiadr2.gaia_source as gaia
JOIN gaiadr2.panstarrs1_best_neighbour as best
ON gaia.source_id = best.source_id
JOIN gaiadr2.panstarrs1_original_valid as ps
ON best.original_ext_source_id = ps.obj_id
WHERE parallax &lt; 1
AND bp_rp BETWEEN -0.75 AND 2
AND 1 = CONTAINS(POINT(gaia.ra, gaia.dec),
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(gaia.pmra, gaia.pmdec),
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))
INFO: Query finished. [astroquery.utils.tap.core]
</pre></div>
</div>
<div class="output text_html"><i>Table length=3725</i>
<table id="table140523908446480" class="table-striped table-bordered table-condensed">
<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th><th>best_neighbour_multiplicity</th><th>number_of_mates</th><th>g_mean_psf_mag</th><th>i_mean_psf_mag</th></tr></thead>
<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th><th></th><th></th><th></th><th>mag</th></tr></thead>
<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th><th>int16</th><th>int16</th><th>float64</th><th>float64</th></tr></thead>
<tr><td>635860218726658176</td><td>138.5187065217173</td><td>19.09233926905897</td><td>-5.941679495793577</td><td>-11.346409129876392</td><td>1</td><td>0</td><td>17.8978004455566</td><td>17.5174007415771</td></tr>
<tr><td>635674126383965568</td><td>138.8428741026386</td><td>19.031798198627634</td><td>-3.8970011609340207</td><td>-12.702779525389634</td><td>1</td><td>0</td><td>19.2873001098633</td><td>17.6781005859375</td></tr>
<tr><td>635535454774983040</td><td>137.8377518255436</td><td>18.864006786112604</td><td>-4.335040664412791</td><td>-14.492308604905652</td><td>1</td><td>0</td><td>16.9237995147705</td><td>16.478099822998</td></tr>
<tr><td>635497276810313600</td><td>138.0445160213759</td><td>19.00947118796605</td><td>-7.1729306406216615</td><td>-12.291499169815987</td><td>1</td><td>0</td><td>19.9242000579834</td><td>18.3339996337891</td></tr>
<tr><td>635614168640132864</td><td>139.59219748145836</td><td>18.807955539071433</td><td>-3.309602916796381</td><td>-13.708904908478631</td><td>1</td><td>0</td><td>16.1515998840332</td><td>14.6662998199463</td></tr>
<tr><td>635598607974369792</td><td>139.20920023089508</td><td>18.624132868942702</td><td>-6.124445176881091</td><td>-12.833824027100611</td><td>1</td><td>0</td><td>16.5223999023438</td><td>16.1375007629395</td></tr>
<tr><td>635737661835496576</td><td>139.93327552473934</td><td>19.167962454651423</td><td>-7.119403303682826</td><td>-12.687947497633793</td><td>1</td><td>0</td><td>14.5032997131348</td><td>13.9849004745483</td></tr>
<tr><td>635850945892748672</td><td>139.86542888472115</td><td>20.011312663154804</td><td>-3.786655365804428</td><td>-14.28415600718206</td><td>1</td><td>0</td><td>16.5174999237061</td><td>16.0450000762939</td></tr>
<tr><td>635600532119713664</td><td>139.22869949616816</td><td>18.685939084485494</td><td>-3.9742788217925122</td><td>-12.342426623384245</td><td>1</td><td>0</td><td>20.4505996704102</td><td>19.5177001953125</td></tr>
<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>
<tr><td>612241781249124608</td><td>134.3755835065194</td><td>18.129179169751275</td><td>-2.831807894848964</td><td>-13.902118573613597</td><td>1</td><td>0</td><td>20.2343997955322</td><td>18.6518001556396</td></tr>
<tr><td>612332147361443072</td><td>134.14584721363653</td><td>18.45685585044513</td><td>-6.234287981021865</td><td>-11.500464195695072</td><td>1</td><td>0</td><td>21.3848991394043</td><td>20.3076000213623</td></tr>
<tr><td>612426744016802432</td><td>134.68522805061076</td><td>18.77090626983678</td><td>-3.7691372464459554</td><td>-12.889167493118862</td><td>1</td><td>0</td><td>17.8281002044678</td><td>17.4281005859375</td></tr>
<tr><td>612331739340341760</td><td>134.12176196902254</td><td>18.42768872157865</td><td>-3.9894012386388735</td><td>-12.60504410507441</td><td>1</td><td>0</td><td>21.8656997680664</td><td>19.5223007202148</td></tr>
<tr><td>612282738058264960</td><td>134.0445768189235</td><td>18.11915820167003</td><td>-2.5972485319419127</td><td>-13.651740929272187</td><td>1</td><td>0</td><td>22.5151996612549</td><td>19.9743995666504</td></tr>
<tr><td>612386332668697600</td><td>135.45701048323093</td><td>18.63266345155342</td><td>-5.07684899854408</td><td>-12.436641304786672</td><td>1</td><td>0</td><td>19.3792991638184</td><td>17.9923000335693</td></tr>
<tr><td>612296172717818624</td><td>133.80060286960668</td><td>18.08186533343457</td><td>-6.112792578821885</td><td>-12.50750861370402</td><td>1</td><td>0</td><td>17.4944000244141</td><td>16.926700592041</td></tr>
<tr><td>612250375480101760</td><td>134.64754712466774</td><td>18.122419425065015</td><td>-2.8969262278467127</td><td>-14.061676353845487</td><td>1</td><td>0</td><td>15.3330001831055</td><td>14.6280002593994</td></tr>
<tr><td>612394926899159168</td><td>135.51997060013844</td><td>18.817675531233004</td><td>-3.9968965218753763</td><td>-13.526821099431533</td><td>1</td><td>0</td><td>16.4414005279541</td><td>15.8212003707886</td></tr>
<tr><td>612256418500423168</td><td>134.90752972739924</td><td>18.280596648172743</td><td>-6.109836304219565</td><td>-12.145212331165776</td><td>1</td><td>0</td><td>20.8715991973877</td><td>19.9612007141113</td></tr>
</table></div></div>
</div> </div>
</div> </div>
</div> </div>
@@ -790,6 +1239,35 @@ Format the query base using the column names in <code class="docutils literal no
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_html">&lt;MaskedColumn name=&apos;best_neighbour_multiplicity&apos; dtype=&apos;int16&apos; description=&apos;Number of neighbours with same probability as best neighbour&apos; length=3725&gt;
<table>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>...</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
</table></div></div>
</div> </div>
<p>It looks like most of the values are <code class="docutils literal notranslate"><span class="pre">1</span></code>, which is good; that means that for each candidate star we have identified exactly one source in Pan-STARRS that is likely to be the same star.</p> <p>It looks like most of the values are <code class="docutils literal notranslate"><span class="pre">1</span></code>, which is good; that means that for each candidate star we have identified exactly one source in Pan-STARRS that is likely to be the same star.</p>
<p>To check whether there are any values other than <code class="docutils literal notranslate"><span class="pre">1</span></code>, we can convert this column to a Pandas <code class="docutils literal notranslate"><span class="pre">Series</span></code> and use <code class="docutils literal notranslate"><span class="pre">describe</span></code>, which we saw in in Lesson 3.</p> <p>To check whether there are any values other than <code class="docutils literal notranslate"><span class="pre">1</span></code>, we can convert this column to a Pandas <code class="docutils literal notranslate"><span class="pre">Series</span></code> and use <code class="docutils literal notranslate"><span class="pre">describe</span></code>, which we saw in in Lesson 3.</p>
@@ -802,6 +1280,19 @@ Format the query base using the column names in <code class="docutils literal no
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>count 3725.0
mean 1.0
std 0.0
min 1.0
25% 1.0
50% 1.0
75% 1.0
max 1.0
dtype: float64
</pre></div>
</div>
</div>
</div> </div>
<p>In fact, <code class="docutils literal notranslate"><span class="pre">1</span></code> is the only value in the <code class="docutils literal notranslate"><span class="pre">Series</span></code>, so every candidate star has a single best match.</p> <p>In fact, <code class="docutils literal notranslate"><span class="pre">1</span></code> is the only value in the <code class="docutils literal notranslate"><span class="pre">Series</span></code>, so every candidate star has a single best match.</p>
<p>Similarly, <code class="docutils literal notranslate"><span class="pre">number_of_mates</span></code> indicates the number of <em>other</em> stars in Gaia that match with the same star in Pan-STARRS.</p> <p>Similarly, <code class="docutils literal notranslate"><span class="pre">number_of_mates</span></code> indicates the number of <em>other</em> stars in Gaia that match with the same star in Pan-STARRS.</p>
@@ -812,6 +1303,19 @@ Format the query base using the column names in <code class="docutils literal no
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>count 3725.0
mean 0.0
std 0.0
min 0.0
25% 0.0
50% 0.0
75% 0.0
max 0.0
dtype: float64
</pre></div>
</div>
</div>
</div> </div>
<p>All values in this column are <code class="docutils literal notranslate"><span class="pre">0</span></code>, which means that for each match we found in Pan-STARRS, there are no other stars in Gaia that also match.</p> <p>All values in this column are <code class="docutils literal notranslate"><span class="pre">0</span></code>, which means that for each match we found in Pan-STARRS, there are no other stars in Gaia that also match.</p>
<p><strong>Detail:</strong> The table also contains <code class="docutils literal notranslate"><span class="pre">number_of_neighbors</span></code> which is the number of stars in Pan-STARRS that match in terms of position, before using other criteria to choose the most likely match. But we are more interested in the final match, using both criteria.</p> <p><strong>Detail:</strong> The table also contains <code class="docutils literal notranslate"><span class="pre">number_of_neighbors</span></code> which is the number of stars in Pan-STARRS that match in terms of position, before using other criteria to choose the most likely match. But we are more interested in the final match, using both criteria.</p>
@@ -877,6 +1381,9 @@ Format the query base using the column names in <code class="docutils literal no
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/05_join_72_0.png" src="_images/05_join_72_0.png" />
</div>
</div> </div>
<p>The result is similar to what we saw in the previous lesson, except that have fewer stars now, because we did not find photometry data for all of the candidate sources.</p> <p>The result is similar to what we saw in the previous lesson, except that have fewer stars now, because we did not find photometry data for all of the candidate sources.</p>
</div> </div>
@@ -903,6 +1410,11 @@ The HDF file should already exist, so well add <code class="docutils literal
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>3.5835609436035156
</pre></div>
</div>
</div>
</div> </div>
</div> </div>
<div class="section" id="summary"> <div class="section" id="summary">
@@ -933,6 +1445,11 @@ We wont cover all of them, but one other important one is <a class="reference
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.7606849670410156
</pre></div>
</div>
</div>
</div> </div>
<p>We can see the first few lines like this:</p> <p>We can see the first few lines like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -952,6 +1469,15 @@ We wont cover all of them, but one other important one is <a class="reference
</pre></div> </pre></div>
</div> </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,best_neighbour_multiplicity,number_of_mates,g_mean_psf_mag,i_mean_psf_mag,phi1,phi2,pm_phi1,pm_phi2
0,635860218726658176,138.5187065217173,19.09233926905897,-5.941679495793577,-11.346409129876392,1,0,17.8978004455566,17.5174007415771,-59.247329893833296,-2.016078400820631,-7.527126084640531,1.7487794924176672
1,635674126383965568,138.8428741026386,19.031798198627634,-3.8970011609340207,-12.702779525389634,1,0,19.2873001098633,17.6781005859375,-59.13339098769217,-2.306900745179831,-7.560607655557415,-0.7417999555980248
</pre></div>
</div>
</div>
</div> </div>
<p>The CSV file contains the names of the columns, but not the data types.</p> <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> <p>We can read the CSV file back like this:</p>
@@ -969,6 +1495,92 @@ We wont cover all of them, but one other important one is <a class="reference
</pre></div> </pre></div>
</div> </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>best_neighbour_multiplicity</th>
<th>number_of_mates</th>
<th>g_mean_psf_mag</th>
<th>i_mean_psf_mag</th>
<th>phi1</th>
<th>phi2</th>
<th>pm_phi1</th>
<th>pm_phi2</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>635860218726658176</td>
<td>138.518707</td>
<td>19.092339</td>
<td>-5.941679</td>
<td>-11.346409</td>
<td>1</td>
<td>0</td>
<td>17.8978</td>
<td>17.517401</td>
<td>-59.247330</td>
<td>-2.016078</td>
<td>-7.527126</td>
<td>1.748779</td>
</tr>
<tr>
<th>1</th>
<td>635674126383965568</td>
<td>138.842874</td>
<td>19.031798</td>
<td>-3.897001</td>
<td>-12.702780</td>
<td>1</td>
<td>0</td>
<td>19.2873</td>
<td>17.678101</td>
<td>-59.133391</td>
<td>-2.306901</td>
<td>-7.560608</td>
<td>-0.741800</td>
</tr>
<tr>
<th>2</th>
<td>635535454774983040</td>
<td>137.837752</td>
<td>18.864007</td>
<td>-4.335041</td>
<td>-14.492309</td>
<td>1</td>
<td>0</td>
<td>16.9238</td>
<td>16.478100</td>
<td>-59.785300</td>
<td>-1.594569</td>
<td>-9.357536</td>
<td>-1.218492</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -976,6 +1588,96 @@ We wont cover all of them, but one other important one is <a class="reference
</pre></div> </pre></div>
</div> </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>best_neighbour_multiplicity</th>
<th>number_of_mates</th>
<th>g_mean_psf_mag</th>
<th>i_mean_psf_mag</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>635860218726658176</td>
<td>138.518707</td>
<td>19.092339</td>
<td>-5.941679</td>
<td>-11.346409</td>
<td>1</td>
<td>0</td>
<td>17.8978</td>
<td>17.517401</td>
<td>-59.247330</td>
<td>-2.016078</td>
<td>-7.527126</td>
<td>1.748779</td>
</tr>
<tr>
<th>1</th>
<td>1</td>
<td>635674126383965568</td>
<td>138.842874</td>
<td>19.031798</td>
<td>-3.897001</td>
<td>-12.702780</td>
<td>1</td>
<td>0</td>
<td>19.2873</td>
<td>17.678101</td>
<td>-59.133391</td>
<td>-2.306901</td>
<td>-7.560608</td>
<td>-0.741800</td>
</tr>
<tr>
<th>2</th>
<td>2</td>
<td>635535454774983040</td>
<td>137.837752</td>
<td>18.864007</td>
<td>-4.335041</td>
<td>-14.492309</td>
<td>1</td>
<td>0</td>
<td>16.9238</td>
<td>16.478100</td>
<td>-59.785300</td>
<td>-1.594569</td>
<td>-9.357536</td>
<td>-1.218492</td>
</tr>
</tbody>
</table>
</div></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> <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> </div>

View File

@@ -412,6 +412,9 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_12_0.png" src="_images/06_photo_12_0.png" />
</div>
</div> </div>
<p>Our figure does not look exactly like the one in the paper because we are working with a smaller region of the sky, so we dont have as many stars. But we can see an overdense region in the lower left that contains stars with the photometry we expect for GD-1.</p> <p>Our figure does not look exactly like the one in the paper because we are working with a smaller region of the sky, so we dont have as many stars. But we can see an overdense region in the lower left that contains stars with the photometry we expect for GD-1.</p>
<p>In the next section well use an isochrone to specify a polygon that contains this overdense regioin.</p> <p>In the next section well use an isochrone to specify a polygon that contains this overdense regioin.</p>
@@ -456,6 +459,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reading in: MIST_iso_5fd2532653c27.iso.cmd
</pre></div>
</div>
</div>
</div> </div>
<p>The result is an <code class="docutils literal notranslate"><span class="pre">ISOCMD</span></code> object.</p> <p>The result is an <code class="docutils literal notranslate"><span class="pre">ISOCMD</span></code> object.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -464,6 +472,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>read_mist_models.ISOCMD
</pre></div>
</div>
</div>
</div> </div>
<p>It contains a list of arrays, one for each isochrone.</p> <p>It contains a list of arrays, one for each isochrone.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -472,6 +485,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>list
</pre></div>
</div>
</div>
</div> </div>
<p>We only got one isochrone.</p> <p>We only got one isochrone.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -480,6 +498,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>1
</pre></div>
</div>
</div>
</div> </div>
<p>So we can select it like this:</p> <p>So we can select it like this:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -496,6 +519,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>numpy.ndarray
</pre></div>
</div>
</div>
</div> </div>
<p>But its an unusual NumPy array, because it contains names for the columns.</p> <p>But its an unusual NumPy array, because it contains names for the columns.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -504,6 +532,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>dtype([(&#39;EEP&#39;, &#39;&lt;i4&#39;), (&#39;isochrone_age_yr&#39;, &#39;&lt;f8&#39;), (&#39;initial_mass&#39;, &#39;&lt;f8&#39;), (&#39;star_mass&#39;, &#39;&lt;f8&#39;), (&#39;log_Teff&#39;, &#39;&lt;f8&#39;), (&#39;log_g&#39;, &#39;&lt;f8&#39;), (&#39;log_L&#39;, &#39;&lt;f8&#39;), (&#39;[Fe/H]_init&#39;, &#39;&lt;f8&#39;), (&#39;[Fe/H]&#39;, &#39;&lt;f8&#39;), (&#39;PS_g&#39;, &#39;&lt;f8&#39;), (&#39;PS_r&#39;, &#39;&lt;f8&#39;), (&#39;PS_i&#39;, &#39;&lt;f8&#39;), (&#39;PS_z&#39;, &#39;&lt;f8&#39;), (&#39;PS_y&#39;, &#39;&lt;f8&#39;), (&#39;PS_w&#39;, &#39;&lt;f8&#39;), (&#39;PS_open&#39;, &#39;&lt;f8&#39;), (&#39;phase&#39;, &#39;&lt;f8&#39;)])
</pre></div>
</div>
</div>
</div> </div>
<p>Which means we can select columns using the bracket operator:</p> <p>Which means we can select columns using the bracket operator:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -512,6 +545,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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., 0., 0., ..., 6., 6., 6.])
</pre></div>
</div>
</div>
</div> </div>
<p>We can use <code class="docutils literal notranslate"><span class="pre">phase</span></code> to select the part of the isochrone for stars in the main sequence and red giant phases.</p> <p>We can use <code class="docutils literal notranslate"><span class="pre">phase</span></code> to select the part of the isochrone for stars in the main sequence and red giant phases.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -521,6 +559,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>354
</pre></div>
</div>
</div>
</div> </div>
<div class="cell docutils container"> <div class="cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
@@ -529,6 +572,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>354
</pre></div>
</div>
</div>
</div> </div>
<p>The other two columns well use are <code class="docutils literal notranslate"><span class="pre">PS_g</span></code> and <code class="docutils literal notranslate"><span class="pre">PS_i</span></code>, which contain simulated photometry data for stars with the given age and metallicity, based on a model of the Pan-STARRS sensors.</p> <p>The other two columns well use are <code class="docutils literal notranslate"><span class="pre">PS_g</span></code> and <code class="docutils literal notranslate"><span class="pre">PS_i</span></code>, which contain simulated photometry data for stars with the given age and metallicity, based on a model of the Pan-STARRS sensors.</p>
<p>Well use these columns to superimpose the isochrone on the color-magnitude diagram, but first we have to use a <a class="reference external" href="https://en.wikipedia.org/wiki/Distance_modulus">distance modulus</a> to scale the isochrone based on the estimated distance of GD-1.</p> <p>Well use these columns to superimpose the isochrone on the color-magnitude diagram, but first we have to use a <a class="reference external" href="https://en.wikipedia.org/wiki/Distance_modulus">distance modulus</a> to scale the isochrone based on the estimated distance of GD-1.</p>
@@ -544,6 +592,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>14.4604730134524
</pre></div>
</div>
</div>
</div> </div>
<p>Now we can compute the scaled magnitude and color of the isochrone.</p> <p>Now we can compute the scaled magnitude and color of the isochrone.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -562,6 +615,9 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_42_0.png" src="_images/06_photo_42_0.png" />
</div>
</div> </div>
<p>The theoretical isochrone passes through the overdense region where we expect to find stars in GD-1.</p> <p>The theoretical isochrone passes through the overdense region where we expect to find stars in GD-1.</p>
<p>Lets save this result so we can reload it later without repeating the steps in this section.</p> <p>Lets save this result so we can reload it later without repeating the steps in this section.</p>
@@ -578,6 +634,58 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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>mag_g</th>
<th>color_g_i</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>28.294743</td>
<td>2.195021</td>
</tr>
<tr>
<th>1</th>
<td>28.189718</td>
<td>2.166076</td>
</tr>
<tr>
<th>2</th>
<td>28.051761</td>
<td>2.129312</td>
</tr>
<tr>
<th>3</th>
<td>27.916194</td>
<td>2.093721</td>
</tr>
<tr>
<th>4</th>
<td>27.780024</td>
<td>2.058585</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p>And then save it.</p> <p>And then save it.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -609,6 +717,58 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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>mag_g</th>
<th>color_g_i</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>28.294743</td>
<td>2.195021</td>
</tr>
<tr>
<th>1</th>
<td>28.189718</td>
<td>2.166076</td>
</tr>
<tr>
<th>2</th>
<td>28.051761</td>
<td>2.129312</td>
</tr>
<tr>
<th>3</th>
<td>27.916194</td>
<td>2.093721</td>
</tr>
<tr>
<th>4</th>
<td>27.780024</td>
<td>2.058585</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p>Heres what the isochrone looks like on the color-magnitude diagram.</p> <p>Heres what the isochrone looks like on the color-magnitude diagram.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -618,6 +778,9 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_52_0.png" src="_images/06_photo_52_0.png" />
</div>
</div> </div>
<p>In the bottom half of the figure, the isochrone passes through the overdense region where the stars are likely to belong to GD-1.</p> <p>In the bottom half of the figure, the isochrone passes through the overdense region where the stars are likely to belong to GD-1.</p>
<p>In the top half, the isochrone passes through other regions where the stars have higher magnitude and metallicity than we expect for stars in GD-1.</p> <p>In the top half, the isochrone passes through other regions where the stars have higher magnitude and metallicity than we expect for stars in GD-1.</p>
@@ -632,6 +795,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>117
</pre></div>
</div>
</div>
</div> </div>
<p>We can use it to select the corresponding rows in <code class="docutils literal notranslate"><span class="pre">iso_df</span></code>:</p> <p>We can use it to select the corresponding rows in <code class="docutils literal notranslate"><span class="pre">iso_df</span></code>:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -641,6 +809,58 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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>mag_g</th>
<th>color_g_i</th>
</tr>
</thead>
<tbody>
<tr>
<th>94</th>
<td>21.411746</td>
<td>0.692171</td>
</tr>
<tr>
<th>95</th>
<td>21.322466</td>
<td>0.670238</td>
</tr>
<tr>
<th>96</th>
<td>21.233380</td>
<td>0.648449</td>
</tr>
<tr>
<th>97</th>
<td>21.144427</td>
<td>0.626924</td>
</tr>
<tr>
<th>98</th>
<td>21.054549</td>
<td>0.605461</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p>Now, to select the stars in the overdense region, we have to define a polygon that includes stars near the isochrone.</p> <p>Now, to select the stars in the overdense region, we have to define a polygon that includes stars near the isochrone.</p>
<p>The original paper uses the following formulas to define the left and right boundaries.</p> <p>The original paper uses the following formulas to define the left and right boundaries.</p>
@@ -676,6 +896,9 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_62_0.png" src="_images/06_photo_62_0.png" />
</div>
</div> </div>
</div> </div>
<div class="section" id="which-points-are-in-the-polygon"> <div class="section" id="which-points-are-in-the-polygon">
@@ -711,6 +934,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(234,)
</pre></div>
</div>
</div>
</div> </div>
<p>And a corresponding loop with the elements of <code class="docutils literal notranslate"><span class="pre">g</span></code> in forward and reverse order.</p> <p>And a corresponding loop with the elements of <code class="docutils literal notranslate"><span class="pre">g</span></code> in forward and reverse order.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -720,6 +948,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(234,)
</pre></div>
</div>
</div>
</div> </div>
<p>Heres what the loop looks like.</p> <p>Heres what the loop looks like.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -729,6 +962,9 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_70_0.png" src="_images/06_photo_70_0.png" />
</div>
</div> </div>
<p>To make a <code class="docutils literal notranslate"><span class="pre">Polygon</span></code>, it will be convenient to put <code class="docutils literal notranslate"><span class="pre">color_loop</span></code> and <code class="docutils literal notranslate"><span class="pre">mag_loop</span></code> into a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>:</p> <p>To make a <code class="docutils literal notranslate"><span class="pre">Polygon</span></code>, it will be convenient to put <code class="docutils literal notranslate"><span class="pre">color_loop</span></code> and <code class="docutils literal notranslate"><span class="pre">mag_loop</span></code> into a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -740,6 +976,58 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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>color_loop</th>
<th>mag_loop</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0.632171</td>
<td>21.411746</td>
</tr>
<tr>
<th>1</th>
<td>0.610238</td>
<td>21.322466</td>
</tr>
<tr>
<th>2</th>
<td>0.588449</td>
<td>21.233380</td>
</tr>
<tr>
<th>3</th>
<td>0.566924</td>
<td>21.144427</td>
</tr>
<tr>
<th>4</th>
<td>0.545461</td>
<td>21.054549</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p>Now we can pass <code class="docutils literal notranslate"><span class="pre">loop_df</span></code> to <code class="docutils literal notranslate"><span class="pre">Polygon</span></code>:</p> <p>Now we can pass <code class="docutils literal notranslate"><span class="pre">loop_df</span></code> to <code class="docutils literal notranslate"><span class="pre">Polygon</span></code>:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -751,6 +1039,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.patches.Polygon at 0x7f439d33fdf0&gt;
</pre></div>
</div>
</div>
</div> </div>
<p>The result is a <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> object , which provides <code class="docutils literal notranslate"><span class="pre">contains_points</span></code>, which figures out which points are inside the polygon.</p> <p>The result is a <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> object , which provides <code class="docutils literal notranslate"><span class="pre">contains_points</span></code>, which figures out which points are inside the polygon.</p>
<p>To test it, well create a list with two points, one inside the polygon and one outside.</p> <p>To test it, well create a list with two points, one inside the polygon and one outside.</p>
@@ -770,6 +1063,11 @@ The input can be an Astropy <code class="docutils literal notranslate"><span cla
</pre></div> </pre></div>
</div> </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([ True, False])
</pre></div>
</div>
</div>
</div> </div>
<p>The result is an array of Boolean values.</p> <p>The result is an array of Boolean values.</p>
<p>We are almost ready to select stars whose photometry data falls in this polygon. But first we need to do some data cleaning.</p> <p>We are almost ready to select stars whose photometry data falls in this polygon. But first we need to do some data cleaning.</p>
@@ -805,6 +1103,58 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </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>color</th>
<th>mag</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0.3804</td>
<td>17.8978</td>
</tr>
<tr>
<th>1</th>
<td>1.6092</td>
<td>19.2873</td>
</tr>
<tr>
<th>2</th>
<td>0.4457</td>
<td>16.9238</td>
</tr>
<tr>
<th>3</th>
<td>1.5902</td>
<td>19.9242</td>
</tr>
<tr>
<th>4</th>
<td>1.4853</td>
<td>16.1516</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<p>Which we can pass to <code class="docutils literal notranslate"><span class="pre">contains_points</span></code>:</p> <p>Which we can pass to <code class="docutils literal notranslate"><span class="pre">contains_points</span></code>:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -814,6 +1164,11 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </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([False, False, False, ..., False, False, False])
</pre></div>
</div>
</div>
</div> </div>
<p>The result is a Boolean array. We can use <code class="docutils literal notranslate"><span class="pre">sum</span></code> to see how many stars fall in the polygon.</p> <p>The result is a Boolean array. We can use <code class="docutils literal notranslate"><span class="pre">sum</span></code> to see how many stars fall in the polygon.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -822,6 +1177,11 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>454
</pre></div>
</div>
</div>
</div> </div>
<p>Now we can use <code class="docutils literal notranslate"><span class="pre">inside</span></code> as a mask to select stars that fall inside the polygon.</p> <p>Now we can use <code class="docutils literal notranslate"><span class="pre">inside</span></code> as a mask to select stars that fall inside the polygon.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -844,6 +1204,9 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_91_0.png" src="_images/06_photo_91_0.png" />
</div>
</div> </div>
<p>It looks like the selected stars are, in fact, inside the polygon, which means they have photometry data consistent with GD-1.</p> <p>It looks like the selected stars are, in fact, inside the polygon, which means they have photometry data consistent with GD-1.</p>
<p>Finally, we can plot the coordinates of the selected stars:</p> <p>Finally, we can plot the coordinates of the selected stars:</p>
@@ -862,6 +1225,9 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/06_photo_93_0.png" src="_images/06_photo_93_0.png" />
</div>
</div> </div>
<p>This example includes two new Matplotlib commands:</p> <p>This example includes two new Matplotlib commands:</p>
<ul class="simple"> <ul class="simple">
@@ -890,6 +1256,11 @@ Well put color and magnitude data from <code class="docutils literal notransl
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>3.6441001892089844
</pre></div>
</div>
</div>
</div> </div>
</div> </div>
<div class="section" id="summary"> <div class="section" id="summary">

View File

@@ -406,7 +406,36 @@
</ol> </ol>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <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> </pre></div>
</div> </div>
</div> </div>
@@ -471,6 +500,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_13_0.png" src="_images/07_plot_13_0.png" />
</div>
</div> </div>
</div> </div>
<div class="section" id="annotations"> <div class="section" id="annotations">
@@ -492,7 +524,23 @@
<p>And here is some <a class="reference external" href="https://matplotlib.org/3.3.1/tutorials/text/annotations.html#plotting-guide-annotation">additional information about text and arrows</a>.</p> <p>And here is some <a class="reference external" href="https://matplotlib.org/3.3.1/tutorials/text/annotations.html#plotting-guide-annotation">additional information about text and arrows</a>.</p>
<div class="cell tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># plt.axvline(-55, ls=&#39;--&#39;, color=&#39;gray&#39;, </span>
<span class="c1"># alpha=0.4, dashes=(6,4), lw=2)</span>
<span class="c1"># plt.text(-60, 5.5, &#39;Previously\nundetected&#39;, </span>
<span class="c1"># fontsize=&#39;small&#39;, ha=&#39;right&#39;, va=&#39;top&#39;);</span>
<span class="c1"># arrowprops=dict(color=&#39;gray&#39;, shrink=0.05, width=1.5, </span>
<span class="c1"># headwidth=6, headlength=8, alpha=0.4)</span>
<span class="c1"># plt.annotate(&#39;Spur&#39;, xy=(-33, 2), xytext=(-35, 5.5),</span>
<span class="c1"># arrowprops=arrowprops,</span>
<span class="c1"># fontsize=&#39;small&#39;)</span>
<span class="c1"># plt.annotate(&#39;Gap&#39;, xy=(-22, -1), xytext=(-25, -5.5),</span>
<span class="c1"># arrowprops=arrowprops,</span>
<span class="c1"># fontsize=&#39;small&#39;)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -519,7 +567,9 @@
<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> <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 tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># plt.gca().tick_params(top=True, right=True)</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
@@ -536,6 +586,11 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>10.0
</pre></div>
</div>
</div>
</div> </div>
<p>And sets it to a new value:</p> <p>And sets it to a new value:</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -560,6 +615,36 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&#39;Solarize_Light2&#39;,
&#39;_classic_test_patch&#39;,
&#39;bmh&#39;,
&#39;classic&#39;,
&#39;dark_background&#39;,
&#39;fast&#39;,
&#39;fivethirtyeight&#39;,
&#39;ggplot&#39;,
&#39;grayscale&#39;,
&#39;seaborn&#39;,
&#39;seaborn-bright&#39;,
&#39;seaborn-colorblind&#39;,
&#39;seaborn-dark&#39;,
&#39;seaborn-dark-palette&#39;,
&#39;seaborn-darkgrid&#39;,
&#39;seaborn-deep&#39;,
&#39;seaborn-muted&#39;,
&#39;seaborn-notebook&#39;,
&#39;seaborn-paper&#39;,
&#39;seaborn-pastel&#39;,
&#39;seaborn-poster&#39;,
&#39;seaborn-talk&#39;,
&#39;seaborn-ticks&#39;,
&#39;seaborn-white&#39;,
&#39;seaborn-whitegrid&#39;,
&#39;tableau-colorblind10&#39;]
</pre></div>
</div>
</div>
</div> </div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">seaborn-paper</span></code>, <code class="docutils literal notranslate"><span class="pre">seaborn-talk</span></code> and <code class="docutils literal notranslate"><span class="pre">seaborn-poster</span></code> are particularly intended to prepare versions of a figure with text sizes and other features that work well in papers, talks, and posters.</p> <p>Note that <code class="docutils literal notranslate"><span class="pre">seaborn-paper</span></code>, <code class="docutils literal notranslate"><span class="pre">seaborn-talk</span></code> and <code class="docutils literal notranslate"><span class="pre">seaborn-poster</span></code> are particularly intended to prepare versions of a figure with text sizes and other features that work well in papers, talks, and posters.</p>
<p>To use any of these style sheets, run <code class="docutils literal notranslate"><span class="pre">plt.style.use</span></code> like this:</p> <p>To use any of these style sheets, run <code class="docutils literal notranslate"><span class="pre">plt.style.use</span></code> like this:</p>
@@ -674,6 +759,14 @@
</pre></div> </pre></div>
</div> </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([[-8.9, -2.2],
[-8.9, 1. ],
[-6.9, 1. ],
[-6.9, -2.2]])
</pre></div>
</div>
</div>
</div> </div>
<p>The following function takes a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> as a parameter, plots the proper motion for each star, and adds a shaded <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> to show the region we selected.</p> <p>The following function takes a <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> as a parameter, plots the proper motion for each star, and adds a shaded <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> to show the region we selected.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -707,6 +800,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_53_0.png" src="_images/07_plot_53_0.png" />
</div>
</div> </div>
</div> </div>
<div class="section" id="upper-left"> <div class="section" id="upper-left">
@@ -745,6 +841,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_59_0.png" src="_images/07_plot_59_0.png" />
</div>
</div> </div>
</div> </div>
<div class="section" id="lower-right"> <div class="section" id="lower-right">
@@ -781,6 +880,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_63_0.png" src="_images/07_plot_63_0.png" />
</div>
</div> </div>
<p>And heres how we read it back.</p> <p>And heres how we read it back.</p>
<div class="cell docutils container"> <div class="cell docutils container">
@@ -791,6 +893,58 @@
</pre></div> </pre></div>
</div> </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>color_loop</th>
<th>mag_loop</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>0.632171</td>
<td>21.411746</td>
</tr>
<tr>
<th>1</th>
<td>0.610238</td>
<td>21.322466</td>
</tr>
<tr>
<th>2</th>
<td>0.588449</td>
<td>21.233380</td>
</tr>
<tr>
<th>3</th>
<td>0.566924</td>
<td>21.144427</td>
</tr>
<tr>
<th>4</th>
<td>0.545461</td>
<td>21.054549</td>
</tr>
</tbody>
</table>
</div></div></div>
</div> </div>
<div class="section" id="id3"> <div class="section" id="id3">
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3> <h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h3>
@@ -798,7 +952,11 @@
<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> <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 tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># poly = Polygon(loop_df, 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> </pre></div>
</div> </div>
</div> </div>
@@ -837,6 +995,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_69_0.png" src="_images/07_plot_69_0.png" />
</div>
</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>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>As an exercise, 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>
@@ -872,6 +1033,9 @@
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="cell_output docutils container">
<img alt="_images/07_plot_72_0.png" src="_images/07_plot_72_0.png" />
</div>
</div> </div>
<p>This is looking more and more like the figure in the paper.</p> <p>This is looking more and more like the figure in the paper.</p>
<div class="section" id="id4"> <div class="section" id="id4">
@@ -879,7 +1043,27 @@
<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> <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 tag_hide-cell docutils container"> <div class="cell tag_hide-cell docutils container">
<div class="cell_input docutils container"> <div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution goes here</span> <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_df)</span>
<span class="c1"># plt.subplot2grid(shape, (1, 0), colspan=3)</span>
<span class="c1"># plot_second_selection(winner_df)</span>
<span class="c1"># plt.subplot2grid(shape, (1, 3), colspan=2) # CHANGED</span>
<span class="c1"># plot_cmd(candidate_df)</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> </pre></div>
</div> </div>
</div> </div>

BIN
_images/04_select_16_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
_images/04_select_18_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 36 KiB

BIN
_images/04_select_74_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
_images/05_join_72_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_images/06_photo_12_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
_images/06_photo_42_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_images/06_photo_52_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_images/06_photo_62_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
_images/06_photo_70_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
_images/06_photo_91_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
_images/06_photo_93_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
_images/07_plot_13_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
_images/07_plot_53_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
_images/07_plot_59_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
_images/07_plot_63_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
_images/07_plot_69_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

BIN
_images/07_plot_72_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

View File

@@ -1,5 +1,48 @@
{ {
"cells": [ "cells": [
{
"cell_type": "raw",
"metadata": {
"tags": [
"remove-cell"
]
},
"source": [
"---\n",
"title: \"Basic queries\"\n",
"teaching: 3000\n",
"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",
"- \"Use queries to download data.\"\n",
"- \"Develop, test, and debug a query incrementally.\"\n",
"keypoints:\n",
"- \"If you can't download an entire dataset (or it's not practical) use queries to select the data you need.\"\n",
"\n",
"- \"Read the metadata and the documentation to make sure you understand the tables, their columns, and what they mean.\"\n",
"\n",
"- \"Develop queries incrementally: start with something simple, test it, and add a little bit at a time.\"\n",
"\n",
"- \"Use ADQL features like `TOP` and `COUNT` to test before you run a query that might return a lot of data.\"\n",
"\n",
"- \"If you know your query will return fewer than 3000 rows, you can \n",
"run it synchronously, which might complete faster (but it doesn't seem to make much difference). If it might return more than 3000 rows, you should run it asynchronously.\"\n",
"\n",
"- \"ADQL and SQL are not case-sensitive, so you don't have to \n",
"capitalize the keywords, but you should.\"\n",
"\n",
"- \"ADQL and SQL don't require you to break a query into multiple \n",
"lines, but you should.\"\n",
"\n",
"---\n",
"\n",
"{% include links.md %}\n"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@@ -90,7 +133,9 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"tags": [] "tags": [
"remove-cell"
]
}, },
"source": [ "source": [
"## Installing libraries\n", "## Installing libraries\n",
@@ -104,7 +149,9 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": { "metadata": {
"tags": [] "tags": [
"remove-cell"
]
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -133,7 +180,24 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Created TAP+ (v1.2.1) - Connection:\n",
"\tHost: gea.esac.esa.int\n",
"\tUse HTTPS: True\n",
"\tPort: 443\n",
"\tSSL Port: 443\n",
"Created TAP+ (v1.2.1) - Connection:\n",
"\tHost: geadata.esac.esa.int\n",
"\tUse HTTPS: True\n",
"\tPort: 443\n",
"\tSSL Port: 443\n"
]
}
],
"source": [ "source": [
"from astroquery.gaia import Gaia" "from astroquery.gaia import Gaia"
] ]
@@ -164,7 +228,17 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO: Retrieving tables... [astroquery.utils.tap.core]\n",
"INFO: Parsing tables... [astroquery.utils.tap.core]\n",
"INFO: Done. [astroquery.utils.tap.core]\n"
]
}
],
"source": [ "source": [
"tables = Gaia.load_tables(only_names=True)" "tables = Gaia.load_tables(only_names=True)"
] ]
@@ -180,9 +254,153 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": { "metadata": {
"tags": [] "tags": [
"hide-output",
"truncate-output"
]
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"external.apassdr9\n",
"external.gaiadr2_geometric_distance\n",
"external.gaiaedr3_distance\n",
"external.galex_ais\n",
"external.ravedr5_com\n",
"external.ravedr5_dr5\n",
"external.ravedr5_gra\n",
"external.ravedr5_on\n",
"external.sdssdr13_photoprimary\n",
"external.skymapperdr1_master\n",
"external.skymapperdr2_master\n",
"external.tmass_xsc\n",
"public.hipparcos\n",
"public.hipparcos_newreduction\n",
"public.hubble_sc\n",
"public.igsl_source\n",
"public.igsl_source_catalog_ids\n",
"public.tycho2\n",
"public.dual\n",
"tap_config.coord_sys\n",
"tap_config.properties\n",
"tap_schema.columns\n",
"tap_schema.key_columns\n",
"tap_schema.keys\n",
"tap_schema.schemas\n",
"tap_schema.tables\n",
"gaiaedr3.gaia_source\n",
"gaiaedr3.agn_cross_id\n",
"gaiaedr3.commanded_scan_law\n",
"gaiaedr3.dr2_neighbourhood\n",
"gaiaedr3.frame_rotator_source\n",
"gaiaedr3.allwise_best_neighbour\n",
"gaiaedr3.allwise_neighbourhood\n",
"gaiaedr3.apassdr9_best_neighbour\n",
"gaiaedr3.apassdr9_join\n",
"gaiaedr3.apassdr9_neighbourhood\n",
"gaiaedr3.gsc23_best_neighbour\n",
"gaiaedr3.gsc23_join\n",
"gaiaedr3.gsc23_neighbourhood\n",
"gaiaedr3.hipparcos2_best_neighbour\n",
"gaiaedr3.hipparcos2_neighbourhood\n",
"gaiaedr3.panstarrs1_best_neighbour\n",
"gaiaedr3.panstarrs1_join\n",
"gaiaedr3.panstarrs1_neighbourhood\n",
"gaiaedr3.ravedr5_best_neighbour\n",
"gaiaedr3.ravedr5_join\n",
"gaiaedr3.ravedr5_neighbourhood\n",
"gaiaedr3.sdssdr13_best_neighbour\n",
"gaiaedr3.sdssdr13_join\n",
"gaiaedr3.sdssdr13_neighbourhood\n",
"gaiaedr3.skymapperdr2_best_neighbour\n",
"gaiaedr3.skymapperdr2_join\n",
"gaiaedr3.skymapperdr2_neighbourhood\n",
"gaiaedr3.tmass_psc_xsc_best_neighbour\n",
"gaiaedr3.tmass_psc_xsc_join\n",
"gaiaedr3.tmass_psc_xsc_neighbourhood\n",
"gaiaedr3.tycho2tdsc_merge_best_neighbour\n",
"gaiaedr3.tycho2tdsc_merge_neighbourhood\n",
"gaiaedr3.urat1_best_neighbour\n",
"gaiaedr3.urat1_neighbourhood\n",
"gaiaedr3.gaia_source_simulation\n",
"gaiaedr3.gaia_universe_model\n",
"gaiaedr3.tycho2tdsc_merge\n",
"gaiadr1.aux_qso_icrf2_match\n",
"gaiadr1.ext_phot_zero_point\n",
"gaiadr1.allwise_best_neighbour\n",
"gaiadr1.allwise_neighbourhood\n",
"gaiadr1.gsc23_best_neighbour\n",
"gaiadr1.gsc23_neighbourhood\n",
"gaiadr1.ppmxl_best_neighbour\n",
"gaiadr1.ppmxl_neighbourhood\n",
"gaiadr1.sdss_dr9_best_neighbour\n",
"gaiadr1.sdss_dr9_neighbourhood\n",
"gaiadr1.tmass_best_neighbour\n",
"gaiadr1.tmass_neighbourhood\n",
"gaiadr1.ucac4_best_neighbour\n",
"gaiadr1.ucac4_neighbourhood\n",
"gaiadr1.urat1_best_neighbour\n",
"gaiadr1.urat1_neighbourhood\n",
"gaiadr1.cepheid\n",
"gaiadr1.phot_variable_time_series_gfov\n",
"gaiadr1.phot_variable_time_series_gfov_statistical_parameters\n",
"gaiadr1.rrlyrae\n",
"gaiadr1.variable_summary\n",
"gaiadr1.allwise_original_valid\n",
"gaiadr1.gsc23_original_valid\n",
"gaiadr1.ppmxl_original_valid\n",
"gaiadr1.sdssdr9_original_valid\n",
"gaiadr1.tmass_original_valid\n",
"gaiadr1.ucac4_original_valid\n",
"gaiadr1.urat1_original_valid\n",
"gaiadr1.gaia_source\n",
"gaiadr1.tgas_source\n",
"gaiadr2.aux_allwise_agn_gdr2_cross_id\n",
"gaiadr2.aux_iers_gdr2_cross_id\n",
"gaiadr2.aux_sso_orbit_residuals\n",
"gaiadr2.aux_sso_orbits\n",
"gaiadr2.dr1_neighbourhood\n",
"gaiadr2.allwise_best_neighbour\n",
"gaiadr2.allwise_neighbourhood\n",
"gaiadr2.apassdr9_best_neighbour\n",
"gaiadr2.apassdr9_neighbourhood\n",
"gaiadr2.gsc23_best_neighbour\n",
"gaiadr2.gsc23_neighbourhood\n",
"gaiadr2.hipparcos2_best_neighbour\n",
"gaiadr2.hipparcos2_neighbourhood\n",
"gaiadr2.panstarrs1_best_neighbour\n",
"gaiadr2.panstarrs1_neighbourhood\n",
"gaiadr2.ppmxl_best_neighbour\n",
"gaiadr2.ppmxl_neighbourhood\n",
"gaiadr2.ravedr5_best_neighbour\n",
"gaiadr2.ravedr5_neighbourhood\n",
"gaiadr2.sdssdr9_best_neighbour\n",
"gaiadr2.sdssdr9_neighbourhood\n",
"gaiadr2.tmass_best_neighbour\n",
"gaiadr2.tmass_neighbourhood\n",
"gaiadr2.tycho2_best_neighbour\n",
"gaiadr2.tycho2_neighbourhood\n",
"gaiadr2.urat1_best_neighbour\n",
"gaiadr2.urat1_neighbourhood\n",
"gaiadr2.sso_observation\n",
"gaiadr2.sso_source\n",
"gaiadr2.vari_cepheid\n",
"gaiadr2.vari_classifier_class_definition\n",
"gaiadr2.vari_classifier_definition\n",
"gaiadr2.vari_classifier_result\n",
"gaiadr2.vari_long_period_variable\n",
"gaiadr2.vari_rotation_modulation\n",
"gaiadr2.vari_rrlyrae\n",
"gaiadr2.vari_short_timescale\n",
"gaiadr2.vari_time_series_statistics\n",
"gaiadr2.panstarrs1_original_valid\n",
"gaiadr2.gaia_source\n",
"gaiadr2.ruwe\n"
]
}
],
"source": [ "source": [
"for table in tables:\n", "for table in tables:\n",
" print(table.name)" " print(table.name)"
@@ -207,7 +425,27 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Retrieving table 'gaiadr2.gaia_source'\n",
"Parsing table 'gaiadr2.gaia_source'...\n",
"Done.\n"
]
},
{
"data": {
"text/plain": [
"<astroquery.utils.tap.model.taptable.TapTableMeta at 0x7f50edd2aeb0>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"meta = Gaia.load_table('gaiadr2.gaia_source')\n", "meta = Gaia.load_table('gaiadr2.gaia_source')\n",
"meta" "meta"
@@ -226,7 +464,21 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TAP Table name: gaiadr2.gaiadr2.gaia_source\n",
"Description: This table has an entry for every Gaia observed source as listed in the\n",
"Main Database accumulating catalogue version from which the catalogue\n",
"release has been generated. It contains the basic source parameters,\n",
"that is only final data (no epoch data) and no spectra (neither final\n",
"nor epoch).\n",
"Num. columns: 96\n"
]
}
],
"source": [ "source": [
"print(meta)" "print(meta)"
] ]
@@ -244,9 +496,115 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 6,
"metadata": { "metadata": {
"tags": [] "tags": [
"hide-output",
"truncate-output"
]
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"solution_id\n",
"designation\n",
"source_id\n",
"random_index\n",
"ref_epoch\n",
"ra\n",
"ra_error\n",
"dec\n",
"dec_error\n",
"parallax\n",
"parallax_error\n",
"parallax_over_error\n",
"pmra\n",
"pmra_error\n",
"pmdec\n",
"pmdec_error\n",
"ra_dec_corr\n",
"ra_parallax_corr\n",
"ra_pmra_corr\n",
"ra_pmdec_corr\n",
"dec_parallax_corr\n",
"dec_pmra_corr\n",
"dec_pmdec_corr\n",
"parallax_pmra_corr\n",
"parallax_pmdec_corr\n",
"pmra_pmdec_corr\n",
"astrometric_n_obs_al\n",
"astrometric_n_obs_ac\n",
"astrometric_n_good_obs_al\n",
"astrometric_n_bad_obs_al\n",
"astrometric_gof_al\n",
"astrometric_chi2_al\n",
"astrometric_excess_noise\n",
"astrometric_excess_noise_sig\n",
"astrometric_params_solved\n",
"astrometric_primary_flag\n",
"astrometric_weight_al\n",
"astrometric_pseudo_colour\n",
"astrometric_pseudo_colour_error\n",
"mean_varpi_factor_al\n",
"astrometric_matched_observations\n",
"visibility_periods_used\n",
"astrometric_sigma5d_max\n",
"frame_rotator_object_type\n",
"matched_observations\n",
"duplicated_source\n",
"phot_g_n_obs\n",
"phot_g_mean_flux\n",
"phot_g_mean_flux_error\n",
"phot_g_mean_flux_over_error\n",
"phot_g_mean_mag\n",
"phot_bp_n_obs\n",
"phot_bp_mean_flux\n",
"phot_bp_mean_flux_error\n",
"phot_bp_mean_flux_over_error\n",
"phot_bp_mean_mag\n",
"phot_rp_n_obs\n",
"phot_rp_mean_flux\n",
"phot_rp_mean_flux_error\n",
"phot_rp_mean_flux_over_error\n",
"phot_rp_mean_mag\n",
"phot_bp_rp_excess_factor\n",
"phot_proc_mode\n",
"bp_rp\n",
"bp_g\n",
"g_rp\n",
"radial_velocity\n",
"radial_velocity_error\n",
"rv_nb_transits\n",
"rv_template_teff\n",
"rv_template_logg\n",
"rv_template_fe_h\n",
"phot_variable_flag\n",
"l\n",
"b\n",
"ecl_lon\n",
"ecl_lat\n",
"priam_flags\n",
"teff_val\n",
"teff_percentile_lower\n",
"teff_percentile_upper\n",
"a_g_val\n",
"a_g_percentile_lower\n",
"a_g_percentile_upper\n",
"e_bp_min_rp_val\n",
"e_bp_min_rp_percentile_lower\n",
"e_bp_min_rp_percentile_upper\n",
"flame_flags\n",
"radius_val\n",
"radius_percentile_lower\n",
"radius_percentile_upper\n",
"lum_val\n",
"lum_percentile_lower\n",
"lum_percentile_upper\n",
"datalink_url\n",
"epoch_photometry_url\n"
]
}
],
"source": [ "source": [
"for column in meta.columns:\n", "for column in meta.columns:\n",
" print(column.name)" " print(column.name)"
@@ -279,9 +637,118 @@
"hide-cell" "hide-cell"
] ]
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Retrieving table 'gaiadr2.panstarrs1_original_valid'\n",
"Parsing table 'gaiadr2.panstarrs1_original_valid'...\n",
"Done.\n",
"TAP Table name: gaiadr2.gaiadr2.panstarrs1_original_valid\n",
"Description: The Panoramic Survey Telescope and Rapid Response System (Pan-STARRS) is\n",
"a system for wide-field astronomical imaging developed and operated by\n",
"the Institute for Astronomy at the University of Hawaii. Pan-STARRS1\n",
"(PS1) is the first part of Pan-STARRS to be completed and is the basis\n",
"for Data Release 1 (DR1). The PS1 survey used a 1.8 meter telescope and\n",
"its 1.4 Gigapixel camera to image the sky in five broadband filters (g,\n",
"r, i, z, y).\n",
"\n",
"The current table contains a filtered subsample of the 10723304629\n",
"entries listed in the original ObjectThin table.\n",
"We used only ObjectThin and MeanObject tables to extract\n",
"panstarrs1OriginalValid table, this means that objects detected only in\n",
"stack images are not included here. The main reason for us to avoid the\n",
"use of objects detected in stack images is that their astrometry is not\n",
"as good as the mean objects astrometry: “The stack positions (raStack,\n",
"decStack) have considerably larger systematic astrometric errors than\n",
"the mean epoch positions (raMean, decMean).” The astrometry for the\n",
"MeanObject positions uses Gaia DR1 as a reference catalog, while the\n",
"stack positions use 2MASS as a reference catalog.\n",
"\n",
"In details, we filtered out all objects where:\n",
"\n",
"- nDetections = 1\n",
"\n",
"- no good quality data in Pan-STARRS, objInfoFlag 33554432 not set\n",
"\n",
"- mean astrometry could not be measured, objInfoFlag 524288 set\n",
"\n",
"- stack position used for mean astrometry, objInfoFlag 1048576 set\n",
"\n",
"- error on all magnitudes equal to 0 or to -999;\n",
"\n",
"- all magnitudes set to -999;\n",
"\n",
"- error on RA or DEC greater than 1 arcsec.\n",
"\n",
"The number of objects in panstarrs1OriginalValid is 2264263282.\n",
"\n",
"The panstarrs1OriginalValid table contains only a subset of the columns\n",
"available in the combined ObjectThin and MeanObject tables. A\n",
"description of the original ObjectThin and MeanObjects tables can be\n",
"found at:\n",
"https://outerspace.stsci.edu/display/PANSTARRS/PS1+Database+object+and+detection+tables\n",
"\n",
"Download:\n",
"http://mastweb.stsci.edu/ps1casjobs/home.aspx\n",
"Documentation:\n",
"https://outerspace.stsci.edu/display/PANSTARRS\n",
"http://pswww.ifa.hawaii.edu/pswww/\n",
"References:\n",
"The Pan-STARRS1 Surveys, Chambers, K.C., et al. 2016, arXiv:1612.05560\n",
"Pan-STARRS Data Processing System, Magnier, E. A., et al. 2016,\n",
"arXiv:1612.05240\n",
"Pan-STARRS Pixel Processing: Detrending, Warping, Stacking, Waters, C.\n",
"Z., et al. 2016, arXiv:1612.05245\n",
"Pan-STARRS Pixel Analysis: Source Detection and Characterization,\n",
"Magnier, E. A., et al. 2016, arXiv:1612.05244\n",
"Pan-STARRS Photometric and Astrometric Calibration, Magnier, E. A., et\n",
"al. 2016, arXiv:1612.05242\n",
"The Pan-STARRS1 Database and Data Products, Flewelling, H. A., et al.\n",
"2016, arXiv:1612.05243\n",
"\n",
"Catalogue curator:\n",
"SSDC - ASI Space Science Data Center\n",
"https://www.ssdc.asi.it/\n",
"Num. columns: 26\n",
"obj_name\n",
"obj_id\n",
"ra\n",
"dec\n",
"ra_error\n",
"dec_error\n",
"epoch_mean\n",
"g_mean_psf_mag\n",
"g_mean_psf_mag_error\n",
"g_flags\n",
"r_mean_psf_mag\n",
"r_mean_psf_mag_error\n",
"r_flags\n",
"i_mean_psf_mag\n",
"i_mean_psf_mag_error\n",
"i_flags\n",
"z_mean_psf_mag\n",
"z_mean_psf_mag_error\n",
"z_flags\n",
"y_mean_psf_mag\n",
"y_mean_psf_mag_error\n",
"y_flags\n",
"n_detections\n",
"zone_id\n",
"obj_info_flag\n",
"quality_flag\n"
]
}
],
"source": [ "source": [
"# Solution goes here" "# Solution\n",
"\n",
"meta2 = Gaia.load_table('gaiadr2.panstarrs1_original_valid')\n",
"print(meta2)\n",
"\n",
"for column in meta2.columns:\n",
" print(column.name)"
] ]
}, },
{ {
@@ -342,7 +809,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"<astroquery.utils.tap.model.job.Job at 0x7f50edd2adc0>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"job = Gaia.launch_job(query1)\n", "job = Gaia.launch_job(query1)\n",
"job" "job"
@@ -361,7 +839,26 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<Table length=10>\n",
" name dtype unit description n_bad\n",
"--------- ------- ---- ------------------------------------------------------------------ -----\n",
"source_id int64 Unique source identifier (unique within a particular Data Release) 0\n",
" ra float64 deg Right ascension 0\n",
" dec float64 deg Declination 0\n",
" parallax float64 mas Parallax 2\n",
"Jobid: None\n",
"Phase: COMPLETED\n",
"Owner: None\n",
"Output file: sync_20210315090602.xml.gz\n",
"Results: None\n"
]
}
],
"source": [ "source": [
"print(job)" "print(job)"
] ]
@@ -379,7 +876,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"astropy.table.table.Table"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"results = job.get_results()\n", "results = job.get_results()\n",
"type(results)" "type(results)"
@@ -411,7 +919,50 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/html": [
"<i>Table length=10</i>\n",
"<table id=\"table139985564118224\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>parallax</th></tr></thead>\n",
"<thead><tr><th></th><th>deg</th><th>deg</th><th>mas</th></tr></thead>\n",
"<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>\n",
"<tr><td>5887983246081387776</td><td>227.978818386372</td><td>-53.64996962450103</td><td>1.0493172163332998</td></tr>\n",
"<tr><td>5887971250213117952</td><td>228.32280834041364</td><td>-53.66270726203726</td><td>0.29455652682279093</td></tr>\n",
"<tr><td>5887991866047288704</td><td>228.1582047014091</td><td>-53.454724911639794</td><td>-0.5789179941669236</td></tr>\n",
"<tr><td>5887968673232040832</td><td>228.07420888099884</td><td>-53.8064612895961</td><td>0.41030970779603076</td></tr>\n",
"<tr><td>5887979844465854720</td><td>228.42547805195946</td><td>-53.48882284470035</td><td>-0.23379683441525864</td></tr>\n",
"<tr><td>5887978607515442688</td><td>228.23831627636855</td><td>-53.56328249482688</td><td>-0.9252161956789068</td></tr>\n",
"<tr><td>5887978298278520704</td><td>228.26015640396173</td><td>-53.607284412896476</td><td>--</td></tr>\n",
"<tr><td>5887995581231772928</td><td>228.12871598211902</td><td>-53.373625663608316</td><td>-0.3325818206439385</td></tr>\n",
"<tr><td>5887982043490374016</td><td>227.985260087594</td><td>-53.683444499055575</td><td>0.02878111976456593</td></tr>\n",
"<tr><td>5887982971205433856</td><td>227.89884570686218</td><td>-53.67430215342567</td><td>--</td></tr>\n",
"</table>"
],
"text/plain": [
"<Table length=10>\n",
" source_id ra dec parallax \n",
" deg deg mas \n",
" int64 float64 float64 float64 \n",
"------------------- ------------------ ------------------- --------------------\n",
"5887983246081387776 227.978818386372 -53.64996962450103 1.0493172163332998\n",
"5887971250213117952 228.32280834041364 -53.66270726203726 0.29455652682279093\n",
"5887991866047288704 228.1582047014091 -53.454724911639794 -0.5789179941669236\n",
"5887968673232040832 228.07420888099884 -53.8064612895961 0.41030970779603076\n",
"5887979844465854720 228.42547805195946 -53.48882284470035 -0.23379683441525864\n",
"5887978607515442688 228.23831627636855 -53.56328249482688 -0.9252161956789068\n",
"5887978298278520704 228.26015640396173 -53.607284412896476 --\n",
"5887995581231772928 228.12871598211902 -53.373625663608316 -0.3325818206439385\n",
"5887982043490374016 227.985260087594 -53.683444499055575 0.02878111976456593\n",
"5887982971205433856 227.89884570686218 -53.67430215342567 --"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"results" "results"
] ]
@@ -446,7 +997,23 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Solution goes here" "# Solution\n",
"\n",
"# Let's add\n",
"#\n",
"# radial_velocity : Radial velocity (double, Velocity[km/s] )\n",
"#\n",
"# Spectroscopic radial velocity in the solar barycentric \n",
"# reference frame.\n",
"#\n",
"# The radial velocity provided is the median value of the \n",
"# radial velocity measurements at all epochs.\n",
"\n",
"query = \"\"\"SELECT \n",
"TOP 10\n",
"source_id, ra, dec, parallax, radial_velocity\n",
"FROM gaiadr2.gaia_source\n",
"\"\"\""
] ]
}, },
{ {
@@ -501,7 +1068,25 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO: Query finished. [astroquery.utils.tap.core]\n"
]
},
{
"data": {
"text/plain": [
"<astroquery.utils.tap.model.job.Job at 0x7f50edd40f40>"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"job = Gaia.launch_job_async(query2)\n", "job = Gaia.launch_job_async(query2)\n",
"job" "job"
@@ -518,7 +1103,50 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 20,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/html": [
"<i>Table length=10</i>\n",
"<table id=\"table139986226873968\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>parallax</th><th>radial_velocity</th></tr></thead>\n",
"<thead><tr><th></th><th>deg</th><th>deg</th><th>mas</th><th>km / s</th></tr></thead>\n",
"<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>\n",
"<tr><td>5895270396817359872</td><td>213.08433715252883</td><td>-56.64104701005694</td><td>2.041947005434917</td><td>--</td></tr>\n",
"<tr><td>5895272561481374080</td><td>213.2606587905109</td><td>-56.55044401535715</td><td>0.15693467895110133</td><td>--</td></tr>\n",
"<tr><td>5895247410183786368</td><td>213.38479712976664</td><td>-56.97008551185148</td><td>-0.19017525742552605</td><td>--</td></tr>\n",
"<tr><td>5895249226912448000</td><td>213.41587389088238</td><td>-56.849596577635786</td><td>--</td><td>--</td></tr>\n",
"<tr><td>5895261875598904576</td><td>213.5508930114549</td><td>-56.61037780154348</td><td>-0.29471722363529257</td><td>--</td></tr>\n",
"<tr><td>5895258302187834624</td><td>213.87631129557286</td><td>-56.678537259039906</td><td>0.6468437015289753</td><td>--</td></tr>\n",
"<tr><td>5895247444506644992</td><td>213.33215109206796</td><td>-56.975347759380995</td><td>0.390215490234287</td><td>--</td></tr>\n",
"<tr><td>5895259470417635968</td><td>213.78815034206346</td><td>-56.64585047451594</td><td>0.953377710788918</td><td>--</td></tr>\n",
"<tr><td>5895264899260932352</td><td>213.21521027193236</td><td>-56.78420864489118</td><td>--</td><td>--</td></tr>\n",
"<tr><td>5895265925746051584</td><td>213.17082359534547</td><td>-56.74540885107754</td><td>0.2986918215101751</td><td>--</td></tr>\n",
"</table>"
],
"text/plain": [
"<Table length=10>\n",
" source_id ra ... parallax radial_velocity\n",
" deg ... mas km / s \n",
" int64 float64 ... float64 float64 \n",
"------------------- ------------------ ... -------------------- ---------------\n",
"5895270396817359872 213.08433715252883 ... 2.041947005434917 --\n",
"5895272561481374080 213.2606587905109 ... 0.15693467895110133 --\n",
"5895247410183786368 213.38479712976664 ... -0.19017525742552605 --\n",
"5895249226912448000 213.41587389088238 ... -- --\n",
"5895261875598904576 213.5508930114549 ... -0.29471722363529257 --\n",
"5895258302187834624 213.87631129557286 ... 0.6468437015289753 --\n",
"5895247444506644992 213.33215109206796 ... 0.390215490234287 --\n",
"5895259470417635968 213.78815034206346 ... 0.953377710788918 --\n",
"5895264899260932352 213.21521027193236 ... -- --\n",
"5895265925746051584 213.17082359534547 ... 0.2986918215101751 --"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"results = job.get_results()\n", "results = job.get_results()\n",
"results" "results"
@@ -561,7 +1189,16 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Solution goes here" "# Solution\n",
"\n",
"# In this example, the WHERE clause is in the wrong place\n",
"\n",
"query = \"\"\"SELECT \n",
"TOP 3000\n",
"WHERE parallax < 1\n",
"source_id, ref_epoch, ra, dec, parallax\n",
"FROM gaiadr2.gaia_source\n",
"\"\"\""
] ]
}, },
{ {
@@ -616,7 +1253,27 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Solution goes here" "# Solution\n",
"\n",
"# Here's a solution using > and < operators\n",
"\n",
"query = \"\"\"SELECT \n",
"TOP 10\n",
"source_id, ref_epoch, ra, dec, parallax\n",
"FROM gaiadr2.gaia_source\n",
"WHERE parallax < 1 \n",
" AND bp_rp > -0.75 AND bp_rp < 2\n",
"\"\"\"\n",
"\n",
"# And here's a solution using the BETWEEN operator\n",
"\n",
"query = \"\"\"SELECT \n",
"TOP 10\n",
"source_id, ref_epoch, ra, dec, parallax\n",
"FROM gaiadr2.gaia_source\n",
"WHERE parallax < 1 \n",
" AND bp_rp BETWEEN -0.75 AND 2\n",
"\"\"\""
] ]
}, },
{ {
@@ -712,7 +1369,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"'SELECT \\nTOP 10 \\nsource_id, ra, dec, pmra, pmdec\\nFROM gaiadr2.gaia_source\\nWHERE parallax < 1\\n AND bp_rp BETWEEN -0.75 AND 2\\n'"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"query3" "query3"
] ]
@@ -728,7 +1396,21 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 28,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SELECT \n",
"TOP 10 \n",
"source_id, ra, dec, pmra, pmdec\n",
"FROM gaiadr2.gaia_source\n",
"WHERE parallax < 1\n",
" AND bp_rp BETWEEN -0.75 AND 2\n",
"\n"
]
}
],
"source": [ "source": [
"print(query3)" "print(query3)"
] ]
@@ -748,7 +1430,27 @@
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<Table length=10>\n",
" name dtype unit description \n",
"--------- ------- -------- ------------------------------------------------------------------\n",
"source_id int64 Unique source identifier (unique within a particular Data Release)\n",
" ra float64 deg Right ascension\n",
" dec float64 deg Declination\n",
" pmra float64 mas / yr Proper motion in right ascension direction\n",
" pmdec float64 mas / yr Proper motion in declination direction\n",
"Jobid: None\n",
"Phase: COMPLETED\n",
"Owner: None\n",
"Output file: sync_20210315091929.xml.gz\n",
"Results: None\n"
]
}
],
"source": [ "source": [
"job = Gaia.launch_job(query3)\n", "job = Gaia.launch_job(query3)\n",
"print(job)" "print(job)"
@@ -758,7 +1460,50 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 30, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/html": [
"<i>Table length=10</i>\n",
"<table id=\"table139985564118512\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>source_id</th><th>ra</th><th>dec</th><th>pmra</th><th>pmdec</th></tr></thead>\n",
"<thead><tr><th></th><th>deg</th><th>deg</th><th>mas / yr</th><th>mas / yr</th></tr></thead>\n",
"<thead><tr><th>int64</th><th>float64</th><th>float64</th><th>float64</th><th>float64</th></tr></thead>\n",
"<tr><td>5895272561481374080</td><td>213.2606587905109</td><td>-56.55044401535715</td><td>0.3894438898301715</td><td>1.2299266281737415</td></tr>\n",
"<tr><td>5895261875598904576</td><td>213.5508930114549</td><td>-56.61037780154348</td><td>0.16203641364393007</td><td>-4.672602679543312</td></tr>\n",
"<tr><td>5895247444506644992</td><td>213.33215109206796</td><td>-56.975347759380995</td><td>-7.474003156859284</td><td>-3.538080792097856</td></tr>\n",
"<tr><td>5895259470417635968</td><td>213.78815034206346</td><td>-56.64585047451594</td><td>-5.287202255231853</td><td>-0.8163762113468646</td></tr>\n",
"<tr><td>5895265925746051584</td><td>213.17082359534547</td><td>-56.74540885107754</td><td>-7.880749306158471</td><td>-4.8585444120179595</td></tr>\n",
"<tr><td>5895260913525974528</td><td>213.66936020541976</td><td>-56.66655190442016</td><td>-4.7820929042428215</td><td>-1.5566420086447643</td></tr>\n",
"<tr><td>5895264212062283008</td><td>213.7755742121852</td><td>-56.51570859067397</td><td>-6.657690998559842</td><td>-1.7616494482071872</td></tr>\n",
"<tr><td>5895253457497979136</td><td>213.30929960610283</td><td>-56.78849448744587</td><td>-5.242106718924749</td><td>-0.18655636353898095</td></tr>\n",
"<tr><td>4143614130253524096</td><td>269.1749117455479</td><td>-18.53415139972117</td><td>2.6164274510804826</td><td>1.3244248889980894</td></tr>\n",
"<tr><td>4065443904433108992</td><td>273.26868565443743</td><td>-24.421651815402857</td><td>-1.663096652191022</td><td>-2.6514745376067683</td></tr>\n",
"</table>"
],
"text/plain": [
"<Table length=10>\n",
" source_id ra ... pmdec \n",
" deg ... mas / yr \n",
" int64 float64 ... float64 \n",
"------------------- ------------------ ... --------------------\n",
"5895272561481374080 213.2606587905109 ... 1.2299266281737415\n",
"5895261875598904576 213.5508930114549 ... -4.672602679543312\n",
"5895247444506644992 213.33215109206796 ... -3.538080792097856\n",
"5895259470417635968 213.78815034206346 ... -0.8163762113468646\n",
"5895265925746051584 213.17082359534547 ... -4.8585444120179595\n",
"5895260913525974528 213.66936020541976 ... -1.5566420086447643\n",
"5895264212062283008 213.7755742121852 ... -1.7616494482071872\n",
"5895253457497979136 213.30929960610283 ... -0.18655636353898095\n",
"4143614130253524096 269.1749117455479 ... 1.3244248889980894\n",
"4065443904433108992 273.26868565443743 ... -2.6514745376067683"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"results = job.get_results()\n", "results = job.get_results()\n",
"results" "results"
@@ -790,9 +1535,35 @@
"hide-cell" "hide-cell"
] ]
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SELECT \n",
"TOP 10\n",
"source_id, ra, dec, pmra, pmdec\n",
"FROM gaiadr2.gaia_source\n",
"WHERE parallax < 0.5 AND \n",
"bp_rp BETWEEN -0.75 AND 2\n",
"\n"
]
}
],
"source": [ "source": [
"# Solution goes here" "# Solution\n",
"\n",
"query_base = \"\"\"SELECT \n",
"TOP 10\n",
"{columns}\n",
"FROM gaiadr2.gaia_source\n",
"WHERE parallax < {max_parallax} AND \n",
"bp_rp BETWEEN -0.75 AND 2\n",
"\"\"\"\n",
"\n",
"query = query_base.format(columns=columns,\n",
" max_parallax=0.5)\n",
"print(query)"
] ]
}, },
{ {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long