A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey)
Project description
Author: Behrouz Safari
License: MIT
sdss
A python package for retrieving and analysing data from SDSS (Sloan Digital Sky Survey)
Installation
Install the latest version of sdss from PyPI:
pip install sdss
Requirements are numpy, requests, Pillow, matplotlib, pandas and astropy. Versions before 1.0.0 are not dependent on astropy.
Quick start
Let's create a Region:
from sdss import Region
ra = 179.689293428354
dec = -0.454379056007667
reg = Region(ra, dec, fov=0.033)
To see the image:
reg.show()
To see the image in three gri filter bands (green, red, infrared) separately:
reg.show3b()
To find nearest objects:
df_obj = reg.nearest_objects()
To find nearest objects with spectrum:
df_sp = reg.nearest_spects()
Photometry example
Let's download a frame, in fits and jpg, retrieve all of its objects and then plot our target image.
import matplotlib.pyplot as plt
from sdss.photometry import *
objid = 1237646587710014999
zip_adr = 'data/' + frame_filename(objid) + '.fits.bz2'
fits_adr = zip_adr[:-4]
jpg_adr = fits_adr.replace('-r-', '-irg-').replace('fits', 'jpg')
zip_url = obj_frame_url(objid, 'r')
download_file(zip_url, 'data/')
unzip(zip_adr)
jpg_url = obj_frame_url(objid, 'irg', jpg=True)
download_file(jpg_url, 'data/')
df = get_df(objid)
df = df_radec2pixel(df=df, fits_file=fits_adr)
img = obj_from_jpg(jpg_file=jpg_adr, df=df, objid=objid)
fig, ax = plt.subplots()
ax.imshow(img)
plt.show()
See more examples at astrodatascience.net
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.