def load_astro_dataset():
    """
    The BUPA dataset can be obtained from
    http://www.cs.huji.ac.il/~shais/datasets/ClassificationDatasets.html
    See description of this dataset at
    http://www.cs.huji.ac.il/~shais/datasets/bupa/bupa.names
    """
    quasars = fetch_dr7_quasar()
    stars = fetch_sdss_sspp()
    quasars = quasars[::5]
    stars = stars[::5]

    Nqso = len(quasars)
    #print 'Numero quasars: ',Nqso
    Nstars = len(stars)
    #print 'Numero estrellas: ',Nstars
    X = empty((Nqso + Nstars, 4), dtype=float)

    X[:Nqso, 0] = quasars['mag_u'] - quasars['mag_g']
    X[:Nqso, 1] = quasars['mag_g'] - quasars['mag_r']
    X[:Nqso, 2] = quasars['mag_r'] - quasars['mag_i']
    X[:Nqso, 3] = quasars['mag_i'] - quasars['mag_z']

    X[Nqso:, 0] = stars['upsf'] - stars['gpsf']
    X[Nqso:, 1] = stars['gpsf'] - stars['rpsf']
    X[Nqso:, 2] = stars['rpsf'] - stars['ipsf']
    X[Nqso:, 3] = stars['ipsf'] - stars['zpsf']

    y = zeros(Nqso + Nstars, dtype=int)
    y[:Nqso] = 1
    y[y == 0] = -1
    #print 'Salida', y
    stars = map(tuple, stars)
    quasars = map(tuple, quasars)
    stars = array(stars)
    quasars = array(quasars)

    #print "Tamano Astro: ", len(X)
    return X, y
Exemple #2
0
# -*- coding: utf-8 -*-
"""
Created on Tue Aug  7 15:30:22 2018

@author: zyv57124
"""

import numpy as np
from astroML.datasets import fetch_LINEAR_geneva
from astroML.datasets import fetch_dr7_quasar
from astroML.datasets import fetch_sdss_sspp

quasars = fetch_dr7_quasar()
stars = fetch_sdss_sspp()

np.save('quasars.npy', quasars)
np.save('stars.npy', stars)

#----------------------------------------------------------------------
# This function adjusts matplotlib settings for a uniform feel in the textbook.
# Note that with usetex=True, fonts are rendered with LaTeX.  This may
# result in an error if LaTeX is not installed on your system.  In that case,
# you can set usetex to False.
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)

#------------------------------------------------------------
# Fetch data and split into training and test samples
from astroML.datasets import fetch_dr7_quasar
from astroML.datasets import fetch_sdss_sspp

quasars = fetch_dr7_quasar()
stars = fetch_sdss_sspp()

# Truncate data for speed
quasars = quasars[::5]
stars = stars[::5]

# stack colors into matrix X
Nqso = len(quasars)
Nstars = len(stars)
X = np.empty((Nqso + Nstars, 4), dtype=float)

X[:Nqso, 0] = quasars['mag_u'] - quasars['mag_g']
X[:Nqso, 1] = quasars['mag_g'] - quasars['mag_r']
X[:Nqso, 2] = quasars['mag_r'] - quasars['mag_i']
X[:Nqso, 3] = quasars['mag_i'] - quasars['mag_z']
Exemple #4
0
SDSS Data Release 7 Quasar catalog
----------------------------------

This demonstrates how to fetch and visualize the colors from the SDSS DR7
quasar sample.
"""
# Author: Jake VanderPlas <*****@*****.**>
# License: BSD
#   The figure is an example from astroML: see http://astroML.github.com
import numpy as np
from matplotlib import pyplot as plt

from astroML.plotting import MultiAxes
from astroML.datasets import fetch_dr7_quasar

data = fetch_dr7_quasar()

colors = np.empty((len(data), 5))

colors[:, 0] = data['mag_u'] - data['mag_g']
colors[:, 1] = data['mag_g'] - data['mag_r']
colors[:, 2] = data['mag_r'] - data['mag_i']
colors[:, 3] = data['mag_i'] - data['mag_z']
colors[:, 4] = data['mag_z'] - data['mag_J']

labels = ['u-g', 'g-r', 'r-i', 'i-z', 'z-J']

bins = [
    np.linspace(-0.4, 1.0, 100),
    np.linspace(-0.4, 1.0, 100),
    np.linspace(-0.3, 0.6, 100),
Exemple #5
0
#   To report a bug or issue, use the following forum:
#    https://groups.google.com/forum/#!forum/astroml-general
from matplotlib import pyplot as plt
from astroML.datasets import fetch_dr7_quasar

#----------------------------------------------------------------------
# This function adjusts matplotlib settings for a uniform feel in the textbook.
# Note that with usetex=True, fonts are rendered with LaTeX.  This may
# result in an error if LaTeX is not installed on your system.  In that case,
# you can set usetex to False.
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)

#------------------------------------------------------------
# Fetch the quasar data
data = fetch_dr7_quasar()

# select the first 10000 points
data = data[:10000]

r = data['mag_r']
i = data['mag_i']
z = data['redshift']

#------------------------------------------------------------
# Plot the quasar data
fig, ax = plt.subplots(figsize=(5, 3.75))
ax.plot(z, r - i, marker='.', markersize=2, linestyle='none', color='black')

ax.set_xlim(0, 5)
ax.set_ylim(-0.5, 1.0)