diff --git a/01_query.html b/01_query.html index 645405e..c454f1a 100644 --- a/01_query.html +++ b/01_query.html @@ -119,12 +119,12 @@
Read the documentation 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?
-# Solution
@@ -1091,7 +1091,7 @@ The modified query should fail, but notice that you don’t get much useful debu
While you are debugging, use TOP to limit the number of rows in the result. That will make each test run faster, which reduces your development time.
Launching test queries synchronously might make them start faster, too.
# Solution
diff --git a/02_coords.html b/02_coords.html
index 3c9a764..42ef623 100644
--- a/02_coords.html
+++ b/02_coords.html
@@ -119,12 +119,12 @@
When you are debugging queries like this, you can use TOP to limit the size of the results, but then you still don’t know how big the results will be.
An alternative is to use COUNT, which asks for the number of rows that would be selected, but it does not return them.
In the previous query, replace TOP 10 source_id with COUNT(source_id) and run the query again. How many stars has Gaia identified in the cone we searched?
# Solution
@@ -1671,7 +1671,7 @@ These are the coordinates shown in the figure from the paper, above.
Transform it to the ICRS frame.
Hint: Because ICRS is built into Astropy, you can specify it by name, icrs (as we did with galactic).
# Solution
diff --git a/03_motion.html b/03_motion.html
index e992366..1d31b53 100644
--- a/03_motion.html
+++ b/03_motion.html
@@ -119,12 +119,12 @@
import pandas as pd
filename = 'gd1_data.hdf'
-
centerline_df = pd.read_hdf(filename, 'centerline_df')
selected_df = pd.read_hdf(filename, 'selected_df')
<scipy.spatial.qhull.ConvexHull at 0x7f712e3b6dc0>
+<scipy.spatial.qhull.ConvexHull at 0x7fd95de628b0>
flatten# Solution
query6 = query6_base.format(columns=columns,
- point_list=point_list,
- pm_point_list=pm_point_list)
+ point_list=point_list,
+ pm_point_list=pm_point_list)
print(query6)
We call the results candidate_table because it contains stars that are good candidates for GD-1.
For the next lesson, we’ll need point_list and pm_point_list again, so we should save them in a file.
+There are several ways we could do that, but since we are already storing data in an HDF file, let’s do the same with these variables.
We’ve seen how to save a DataFrame in an HDF file.
+We can do the same thing with a Pandas Series.
+To make one, we’ll start with a dictionary:
d = dict(point_list=point_list, pm_point_list=pm_point_list)
+d
+{'point_list': '135.306, 8.39862, 126.51, 13.4449, 163.017, 54.2424, 172.933, 46.4726, 135.306, 8.39862',
+ 'pm_point_list': ' -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'}
+And use it to initialize a Series.
point_series = pd.Series(d)
+point_series
+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
+Now we can save it in the usual way.
+filename = 'gd1_data.hdf'
+point_series.to_hdf(filename, 'point_series')
+
+
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.
@@ -927,7 +970,7 @@ Here’s the code we used to transform the coordinates and make a Pandas
+
We’re starting to see GD-1 more clearly. @@ -985,7 +1028,7 @@ We can compare this figure with this panel from Figure 1 from the original paper
This is the fifth in a series of notebooks related to astronomy data.
As a continuing example, we will replicate part of the analysis in a recent paper, “Off the beaten path: Gaia reveals GD-1 stars outside of the main stream” by Adrian M. Price-Whelan and Ana Bonaca.
Picking up where we left off, the next step in the analysis is to select candidate stars based on photometry data.
@@ -380,16 +385,38 @@ We use this variable to select stars with panstarrs1_best_neighbour.
meta = Gaia.load_table('gaiadr2.panstarrs1_best_neighbour')
-print(meta)
+from astroquery.gaia import Gaia
+
+meta = Gaia.load_table('gaiadr2.panstarrs1_best_neighbour')
Retrieving table 'gaiadr2.panstarrs1_best_neighbour'
+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
+Retrieving table 'gaiadr2.panstarrs1_best_neighbour'
Parsing table 'gaiadr2.panstarrs1_best_neighbour'...
Done.
-TAP Table name: gaiadr2.gaiadr2.panstarrs1_best_neighbour
+
+
+print(meta)
+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 1 327 157 objects in the filtered version of Pan-STARRS1 used
@@ -442,9 +469,7 @@ gaia_astrometric_params
from astroquery.gaia import Gaia
-
-job = Gaia.launch_job_async(query=query)
+job = Gaia.launch_job_async(query=query)
| source_id | number_of_neighbours | number_of_mates | original_ext_source_id | |
|---|---|---|---|---|
| int64 | int32 | int16 | int64 | |
| 6745938972433480704 | 1 | 0 | 69742925668851205 |
| obj_id | g_mean_psf_mag | i_mean_psf_mag | ||
|---|---|---|---|---|
| mag | ||||
| int64 | float64 | float64 |
| source_id | ra | dec | pmra | pmdec |
|---|---|---|---|---|
| deg | deg | mas / yr | mas / yr | |
| int64 | float64 | float64 | float64 | float64 |
| 3322773965056065536 | 88.78178020183375 | 7.334936530583141 | 0.2980633722108194 | -2.5057036964736907 |
| 3322773758899157120 | 88.83227057144585 | 7.325577341429926 | -- | -- |
| 3322774068134271104 | 88.8206092188033 | 7.353158142762173 | -1.1065462654445488 | -1.5260889445858044 |
| 3322773930696320512 | 88.80843339290348 | 7.334853162299928 | 2.6074384482375215 | -0.9292104395445717 |
| 3322774377374425728 | 88.86806108182265 | 7.371287731275939 | 3.9555477866915383 | -3.8676624830902435 |
| source_id |
|---|
| int64 |
| 3322773965056065536 |
| 3322773758899157120 |
| 3322774068134271104 |
| 3322773930696320512 |
| 3322774377374425728 |
| 3322773724537891456 |
| 3322773724537891328 |
| 3322773930696321792 |
| 3322773724537890944 |
| 3322773930696322176 |
Now we can start adding features. @@ -770,7 +809,7 @@ WHERE 1=CONTAINS(