e375ba1b22e90e32eddad1697557585c2e9d0229,book_figures/chapter7/fig_spec_reconstruction.py,,,#,21

Before Change



//------------------------------------------------------------
// Plot the sequence of reconstructions
fig = plt.figure(figsize=(8, 8))
fig.subplots_adjust(hspace=0)

for i, n in enumerate([0, 4, 8, 20]):
    ax = fig.add_subplot(411 + i)
    ax.plot(wavelengths, spec, "-", c="gray")

After Change



// Adjust font sizes for text
import matplotlib
matplotlib.rc("font", size=8)


//------------------------------------------------------------
// Download data
data = sdss_corrected_spectra.fetch_sdss_corrected_spectra()
spectra = sdss_corrected_spectra.reconstruct_spectra(data)
wavelengths = sdss_corrected_spectra.compute_wavelengths(data)

//------------------------------------------------------------
// Compute PCA components

// Eigenvalues can be computed using PCA as in the commented code below:

//from sklearn.decomposition import PCA
//pca = PCA()
//pca.fit(spectra)
//evals = pca.explained_variance_ratio_
//evals_cs = evals.cumsum()

//  because the spectra have been reconstructed from masked values, this
//  is not exactly correct in this case: we"ll use the values computed
//  in the file compute_sdss_pca.py
evals = data["evals"] ** 2
evals_cs = evals.cumsum()
evals_cs /= evals_cs[-1]
evecs = data["evecs"]
spec_mean = spectra.mean(0)

//------------------------------------------------------------
// Find the coefficients of a particular spectrum
spec = spectra[1]
coeff = np.dot(evecs, spec - spec_mean)

//------------------------------------------------------------
// Plot the sequence of reconstructions
fig = plt.figure(figsize=(5, 5))
fig.subplots_adjust(hspace=0, top=0.95, bottom=0.1, left=0.12, right=0.93)

for i, n in enumerate([0, 4, 8, 20]):
    ax = fig.add_subplot(411 + i)
    ax.plot(wavelengths, spec, "-", c="gray")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 5

Non-data size: 6

Instances


Project Name: astroML/astroML
Commit Name: e375ba1b22e90e32eddad1697557585c2e9d0229
Time: 2013-06-10
Author: vanderplas@astro.washington.edu
File Name: book_figures/chapter7/fig_spec_reconstruction.py
Class Name:
Method Name:


Project Name: astroML/astroML
Commit Name: 4ea4d80185237cfef0c06331cc66a5f5effe76d7
Time: 2013-06-09
Author: vanderplas@astro.washington.edu
File Name: book_figures/chapter5/fig_bayes_blocks.py
Class Name:
Method Name:


Project Name: astroML/astroML
Commit Name: 37bbaac45d9448d74e365ddf3188b0fa0fa316cb
Time: 2013-06-09
Author: vanderplas@astro.washington.edu
File Name: book_figures/chapter6/fig_GMM_density_estimation.py
Class Name:
Method Name:


Project Name: astroML/astroML
Commit Name: 37bbaac45d9448d74e365ddf3188b0fa0fa316cb
Time: 2013-06-09
Author: vanderplas@astro.washington.edu
File Name: book_figures/chapter6/fig_density_estimation.py
Class Name:
Method Name:


Project Name: astroML/astroML
Commit Name: e375ba1b22e90e32eddad1697557585c2e9d0229
Time: 2013-06-10
Author: vanderplas@astro.washington.edu
File Name: book_figures/chapter7/fig_PCA_reconstruction.py
Class Name:
Method Name: