def plot_sdss_filters(): Xref = fetch_vega_spectrum() Xref[:, 1] /= 2.1 * Xref[:, 1].max() #---------------------------------------------------------------------- # Plot filters in color with a single spectrum fig, ax = plt.subplots() ax.plot(Xref[:, 0], Xref[:, 1], '-k', lw=2) for f, c in zip('ugriz', 'bgrmk'): X = fetch_filter(f) ax.fill(X[:, 0], X[:, 1], ec=c, fc=c, alpha=0.4) kwargs = dict(fontsize=20, ha='center', va='center', alpha=0.5) ax.text(3500, 0.02, 'u', color='b', **kwargs) ax.text(4600, 0.02, 'g', color='g', **kwargs) ax.text(6100, 0.02, 'r', color='r', **kwargs) ax.text(7500, 0.02, 'i', color='m', **kwargs) ax.text(8800, 0.02, 'z', color='k', **kwargs) ax.set_xlim(3000, 11000) ax.set_title('SDSS Filters and Reference Spectrum') ax.set_xlabel('Wavelength (Angstroms)') ax.set_ylabel('normalized flux / filter transmission')
def plot_sdss_filters(): Xref = fetch_vega_spectrum() Xref[:, 1] /= 2.1 * Xref[:, 1].max() #---------------------------------------------------------------------- # Plot filters in color with a single spectrum fig, ax = plt.subplots() ax.plot(Xref[:, 0], Xref[:, 1], '-k', lw=2) for f,c in zip('ugriz', 'bgrmk'): X = fetch_filter(f) ax.fill(X[:, 0], X[:, 1], ec=c, fc=c, alpha=0.4) kwargs = dict(fontsize=20, ha='center', va='center', alpha=0.5) ax.text(3500, 0.02, 'u', color='b', **kwargs) ax.text(4600, 0.02, 'g', color='g', **kwargs) ax.text(6100, 0.02, 'r', color='r', **kwargs) ax.text(7500, 0.02, 'i', color='m', **kwargs) ax.text(8800, 0.02, 'z', color='k', **kwargs) ax.set_xlim(3000, 11000) ax.set_title('SDSS Filters and Reference Spectrum') ax.set_xlabel('Wavelength (Angstroms)') ax.set_ylabel('normalized flux / filter transmission')
def plot_redshifts(): Xref = fetch_vega_spectrum() Xref[:, 1] /= 2.1 * Xref[:, 1].max() #---------------------------------------------------------------------- # Plot filters in gray with several redshifted spectra fig, ax = plt.subplots() redshifts = [0.0, 0.4, 0.8] colors = 'bgr' for z, c in zip(redshifts, colors): plt.plot((1. + z) * Xref[:, 0], Xref[:, 1], color=c) ax.add_patch(Arrow(4200, 0.47, 1300, 0, lw=0, width=0.05, color='r')) ax.add_patch(Arrow(5800, 0.47, 1250, 0, lw=0, width=0.05, color='r')) ax.text(3800, 0.49, 'z = 0.0', fontsize=14, color=colors[0]) ax.text(5500, 0.49, 'z = 0.4', fontsize=14, color=colors[1]) ax.text(7300, 0.49, 'z = 0.8', fontsize=14, color=colors[2]) for f in 'ugriz': X = fetch_filter(f) ax.fill(X[:, 0], X[:, 1], ec='k', fc='k', alpha=0.2) kwargs = dict(fontsize=20, color='gray', ha='center', va='center') ax.text(3500, 0.02, 'u', **kwargs) ax.text(4600, 0.02, 'g', **kwargs) ax.text(6100, 0.02, 'r', **kwargs) ax.text(7500, 0.02, 'i', **kwargs) ax.text(8800, 0.02, 'z', **kwargs) ax.set_xlim(3000, 11000) ax.set_ylim(0, 0.55) ax.set_title('Redshifting of a Spectrum') ax.set_xlabel('Observed Wavelength (Angstroms)') ax.set_ylabel('normalized flux / filter transmission')
print "Successfully fetched olivetti faces data" #------------------------------------------------------------ # SDSS galaxy data: this will be stored in notebooks/datasets/data sys.path.append(os.path.abspath('notebooks')) from datasets import fetch_sdss_galaxy_mags colors = fetch_sdss_galaxy_mags() print "Successfully fetched SDSS galaxy data" #------------------------------------------------------------ # SDSS filters & vega spectrum: stored in notebooks/figures/downloads from figures.sdss_filters import fetch_filter, fetch_vega_spectrum spectrum = fetch_vega_spectrum() print "Successfully fetched vega spectrum" filters = [fetch_filter(f) for f in 'ugriz'] print "Successfully fetched SDSS filters" ########NEW FILE######## __FILENAME__ = galaxy_mags # This download script comes from astroML: http://astroml.github.com import os import urllib import numpy as np #---------------------------------------------------------------------- # Tools for querying the SDSS database using SQL PUBLIC_URL = 'http://cas.sdss.org/public/en/tools/search/x_sql.asp' DEFAULT_FMT = 'csv'
The data are only a few megabytes, but conference wireless is often not very reliable... """ import os import sys from sklearn import datasets #------------------------------------------------------------ # Faces data: this will be stored in the scikit_learn_data # sub-directory of your home folder faces = datasets.fetch_olivetti_faces() print "Successfully fetched olivetti faces data" #------------------------------------------------------------ # SDSS galaxy data: this will be stored in notebooks/datasets/data sys.path.append(os.path.abspath('notebooks')) from datasets import fetch_sdss_galaxy_mags colors = fetch_sdss_galaxy_mags() print "Successfully fetched SDSS galaxy data" #------------------------------------------------------------ # SDSS filters & vega spectrum: stored in notebooks/figures/downloads from figures.sdss_filters import fetch_filter, fetch_vega_spectrum spectrum = fetch_vega_spectrum() print "Successfully fetched vega spectrum" filters = [fetch_filter(f) for f in 'ugriz'] print "Successfully fetched SDSS filters"