<p>BTW if anyone wants a quick and fast query to solution do the following:</p>
<p>Go to <a href="https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx" rel="nofollow noreferrer">https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx</a>. Paste a query like this:</p>
<pre><code>SELECT
   s.specobjid, s.ra, s.dec, s.z
FROM SpecObj as s
WHERE
   s.z &gt; 0 AND s.z &lt; .18 AND s.ra &gt; 0 AND s.ra &lt; 50 AND s.dec &gt; 0 AND s.dec &lt; 30
</code></pre>
<p>Then after downloading a csv file use the following code to make a nice heatmap plot in the x and y direction.</p>
<pre><code>import astropy.cosmology
from scipy.stats.kde import gaussian_kde
import astropy.coordinates
import astropy.units as u
import numpy as np

data = np.genfromtxt('your_csv_file'), delimiter=',')
sdss_low_redshift = np.array([np.array([i[1], i[2], i[3]]) for i in data])
comoving_dist = astropy.cosmology.WMAP9.comoving_distance(sdss_low_redshift[:, 2])
c = astropy.coordinates.SkyCoord(ra=sdss_low_redshift[:, 0]*u.degree, dec=sdss_low_redshift[:, 1]*u.degree, distance=comoving_dist*u.mpc)
sdss_pos = np.stack([np.array([i.x.value, i.y.value, i.z.value]) for i in c.cartesian])
# Removing nans
mask = np.all(np.isnan(sdss_pos) | np.equal(sdss_pos, 0), axis=1)
sdss_pos = sdss_pos[~mask]


x, y = sdss_pos[:, 2], sdss_pos[:, 1]
heatmap, xedges, yedges = np.histogram2d(x, y, bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

plt.clf()
plt.figure(figsize=(8, 6))
plt.gca().set_aspect('equal')
plt.imshow(heatmap.T, extent=extent, origin='lower', cmap=plt.get_cmap('nipy_spectral'))
</code></pre>
<p>I wish there were more tutorials like this around took me more time than I expected to figure it out. Hopefully, this helps someone!</p>

CC BY-SA 4.0
2021-02-26T00:36:13.853Z
Gotcha, what line do you get the error I should be able to help out if you need it
kauii8
CC BY-SA 4.0
2021-02-26T00:48:44.490Z
I've posted the entire thing as a temporary answer below. I will have a more modern version of astropy available in about an hour
uhoh
CC BY-SA 4.0
2021-02-26T01:05:47.163Z
Gotcha looks like those warnings should be fine it's likely due to the fact there are nans in the dataset. Do the warnings cause the image not to show?
kauii8
CC BY-SA 4.0
2021-02-26T01:12:26.430Z
oic, in addition to not importing matplotlib your script doesn't contain `plt.show()` and that's the only reason nothing happened! Plotting the log10 of the data I get this: https://i.sstatic.net/OiBIr.png which means everything seems okay and I'm on my way! (it's early here and my morning coffee is just starting to kick in)
uhoh
CC BY-SA 4.0
2021-02-25T15:24:14.523Z
2021-02-25T15:24:14.523Z
kauii8
<p>SDSS DR12 <a href="http://www.sdss.org/dr12/data_access/#CatalogData" rel="nofollow">Catalog Data</a>
looks like a good starting point,
apparently pretty open to those willing and able to figure it out.
Their
<a href="http://compute.sciserver.org/dashboard/Home/Index" rel="nofollow">SciServer Compute</a>
site hosts Jupyter notebooks to query CasJobs in SQL.</p>

<p>The Large Scale Structure galaxy catalog under
<a href="http://www.sdss.org/dr12/data_access/vac/#BOSSValue-AddedCatalogs" rel="nofollow">BOSS value added catalogs</a>
may also be relevant.</p>

CC BY-SA 3.0
2016-07-16T02:38:28.213Z
Wow - thank you for that concise yet excellent introduction! It says ["The Schema Browser can be intimidating, but it is easy to use. "](http://skyserver.sdss.org/dr12/en/help/howto/search/introduction.aspx) that summarizes the 5 minutes it took to start customizing my own searches! I used [this page](http://skyserver.sdss.org/dr12/en/help/howto/search/query2.aspx) and [this page](http://skyserver.sdss.org/dr12/en/help/howto/search/commonsearch.aspx) to get started. [This page](http://skyserver.sdss.org/dr12/en/help/docs/realquery.aspx) has additional help with SQL use.
uhoh
CC BY-SA 3.0
2016-07-15T22:07:20.757Z
2016-07-15T22:07:20.757Z
Mike G
<p>Of course the <a href="http://phys.org/news/2016-07-biggest-galactic-dark-energy.html" rel="nofollow noreferrer">newly announced SDSS-III data and maps</a> from the <a href="https://i.sstatic.net/ZR16m.jpg" rel="nofollow noreferrer">Sloan Digital Sky Survey</a> with 1.2 million objects, along with all previous data sets are openly available, and I'm sure there are many tools to access, work with, and view the data.</p>

<p>What would be the simplest way to extract a list of coordinates of galaxies in order to just try to visualize it on my own? There may be visualization tools also, if you want to add a link that would be great, but this question is about getting a list of coordinates so I can look at density or even try to plot one dot per galaxy in some slice. </p>

<p>I'm guessing the coordinates might be available in RA, dec, and redshift, and possibly also some calculated/inferred x, y, z. </p>

<p>I use python, but I'm not familiar with <a href="http://www.astropy.org/" rel="nofollow noreferrer">AstroPy</a> yet, so if it can be done, albeit inefficiently and/or inaccurately by my writing a straightforward python script on my laptop, that would be the most helpful answer.</p>

<p><strong>edit:</strong> if doing this in AstroPy is failry easy, I do have an Anaconda installation, and therefore already have at least a basic AstroPy installation. </p>

<p>Here is a graphic (below), <a href="http://phys.org/news/2016-07-biggest-galactic-dark-energy.html" rel="nofollow noreferrer">from here in Phys.org</a> attributed there to Daniel Eisenstein and SDSS-III.</p>

<p><a href="https://i.sstatic.net/ZR16m.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZR16m.jpg" alt="enter image description here"></a></p>

<p>Another graphic (below), <a href="http://phys.org/news/2016-07-biggest-galactic-dark-energy.html" rel="nofollow noreferrer">from here in Phys.org</a> attributed there to Jeremy Tinker and SDSS-III.</p>

<p><a href="https://i.sstatic.net/9E8Pl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9E8Pl.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-11-07T12:29:54.690Z
Did you succeed? I would also be interested in x,y,z or spherical coordinates with depth data.
Erich Schubert
CC BY-SA 3.0
2017-11-07T20:19:10.163Z
@ErichSchubert Didn't go as far as I'd hoped, distracted by other things at the time. I'll see what I can find out; ping me if I don't get back to you in a week or so. Thanks for the reminder!
uhoh
<galaxy-cluster><python><sky-survey><astropy><sloan-dss>
Are 3D coordinate data from Sloan DSS-III available & easily accessible to non-pros?
uhoh
# Are 3D coordinate data from Sloan DSS-III available & easily accessible to non-pros?

(Asked by: username_0 on 2016-07-15)

Of course the [newly announced SDSS-III data and maps](http://phys.org/news/2016-07-biggest-galactic-dark-energy.html) from the [Sloan Digital Sky Survey](https://i.sstatic.net/ZR16m.jpg) with 1.2 million objects, along with all previous data sets are openly available, and I'm sure there are many tools to access, work with, and view the data.

What would be the simplest way to extract a list of coordinates of galaxies in order to just try to visualize it on my own? There may be visualization tools also, if you want to add a link that would be great, but this question is about getting a list of coordinates so I can look at density or even try to plot one dot per galaxy in some slice.

I'm guessing the coordinates might be available in RA, dec, and redshift, and possibly also some calculated/inferred x, y, z.

I use python, but I'm not familiar with [AstroPy](http://www.astropy.org/) yet, so if it can be done, albeit inefficiently and/or inaccurately by my writing a straightforward python script on my laptop, that would be the most helpful answer.

**edit:** if doing this in AstroPy is failry easy, I do have an Anaconda installation, and therefore already have at least a basic AstroPy installation.

Here is a graphic (below), [from here in Phys.org](http://phys.org/news/2016-07-biggest-galactic-dark-energy.html) attributed there to Daniel Eisenstein and SDSS-III.

[![enter image description here](https://i.sstatic.net/ZR16m.jpg)](https://i.sstatic.net/ZR16m.jpg)

Another graphic (below), [from here in Phys.org](http://phys.org/news/2016-07-biggest-galactic-dark-energy.html) attributed there to Jeremy Tinker and SDSS-III.

[![enter image description here](https://i.sstatic.net/9E8Pl.png)](https://i.sstatic.net/9E8Pl.png)

**Tags:** galaxy-cluster, python, sky-survey, astropy, sloan-dss

> **Comments:**
> **username_1**: Did you succeed? I would also be interested in x,y,z or spherical coordinates with depth data.  
> **username_0**: @ErichSchubert Didn't go as far as I'd hoped, distracted by other things at the time. I'll see what I can find out; ping me if I don't get back to you in a week or so. Thanks for the reminder!  

---

## 2 answers

### Answer by username_2 on 2021-02-25. Score: 3 | Accepted answer

BTW if anyone wants a quick and fast query to solution do the following:
Go to https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx. Paste a query like this:
SELECT
   s.specobjid, s.ra, s.dec, s.z
FROM SpecObj as s
WHERE
   s.z > 0 AND s.z < .18 AND s.ra > 0 AND s.ra < 50 AND s.dec > 0 AND s.dec < 30

Then after downloading a csv file use the following code to make a nice heatmap plot in the x and y direction.
import astropy.cosmology
from scipy.stats.kde import gaussian_kde
import astropy.coordinates
import astropy.units as u
import numpy as np

data = np.genfromtxt('your_csv_file'), delimiter=',')
sdss_low_redshift = np.array([np.array([i[1], i[2], i[3]]) for i in data])
comoving_dist = astropy.cosmology.WMAP9.comoving_distance(sdss_low_redshift[:, 2])
c = astropy.coordinates.SkyCoord(ra=sdss_low_redshift[:, 0]*u.degree, dec=sdss_low_redshift[:, 1]*u.degree, distance=comoving_dist*u.mpc)
sdss_pos = np.stack([np.array([i.x.value, i.y.value, i.z.value]) for i in c.cartesian])
# Removing nans
mask = np.all(np.isnan(sdss_pos) | np.equal(sdss_pos, 0), axis=1)
sdss_pos = sdss_pos[~mask]


x, y = sdss_pos[:, 2], sdss_pos[:, 1]
heatmap, xedges, yedges = np.histogram2d(x, y, bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

plt.clf()
plt.figure(figsize=(8, 6))
plt.gca().set_aspect('equal')
plt.imshow(heatmap.T, extent=extent, origin='lower', cmap=plt.get_cmap('nipy_spectral'))

I wish there were more tutorials like this around took me more time than I expected to figure it out. Hopefully, this helps someone!

> **Comments:**
> **username_2**: Gotcha, what line do you get the error I should be able to help out if you need it  
> **username_0**: I've posted the entire thing as a temporary answer below. I will have a more modern version of astropy available in about an hour  
> **username_2**: Gotcha looks like those warnings should be fine it's likely due to the fact there are nans in the dataset. Do the warnings cause the image not to show?  
> **username_0**: oic, in addition to not importing matplotlib your script doesn't contain `plt.show()` and that's the only reason nothing happened! Plotting the log10 of the data I get this: https://i.sstatic.net/OiBIr.png which means everything seems okay and I'm on my way! (it's early here and my morning coffee is just starting to kick in)  

---

### Answer by username_3 on 2016-07-15. Score: 3

SDSS DR12 [Catalog Data](http://www.sdss.org/dr12/data_access/#CatalogData)
looks like a good starting point,
apparently pretty open to those willing and able to figure it out.
Their
[SciServer Compute](http://compute.sciserver.org/dashboard/Home/Index)
site hosts Jupyter notebooks to query CasJobs in SQL.

The Large Scale Structure galaxy catalog under
[BOSS value added catalogs](http://www.sdss.org/dr12/data_access/vac/#BOSSValue-AddedCatalogs)
may also be relevant.

> **Comments:**
> **username_0**: Wow - thank you for that concise yet excellent introduction! It says ["The Schema Browser can be intimidating, but it is easy to use. "](http://skyserver.sdss.org/dr12/en/help/howto/search/introduction.aspx) that summarizes the 5 minutes it took to start customizing my own searches! I used [this page](http://skyserver.sdss.org/dr12/en/help/howto/search/query2.aspx) and [this page](http://skyserver.sdss.org/dr12/en/help/howto/search/commonsearch.aspx) to get started. [This page](http://skyserver.sdss.org/dr12/en/help/docs/realquery.aspx) has additional help with SQL use.  

---

