├── astroML ├── tests │ ├── __init__.py │ ├── test_pickle_results.py │ └── test_filters.py ├── stats │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── clustering │ ├── tests │ │ ├── __init__.py │ │ └── test_MST_clustering.py │ └── __init__.py ├── linear_model │ ├── tests │ │ ├── __init__.py │ │ ├── test_TLS.py │ │ └── test_kernel_regression.py │ ├── __init__.py │ ├── TLS.py │ └── kernel_regression.py ├── time_series │ ├── tests │ │ ├── __init__.py │ │ └── test_generate.py │ └── __init__.py ├── dimensionality │ ├── tests │ │ ├── __init__.py │ │ └── test_iterative_PCA.py │ └── __init__.py ├── density_estimation │ ├── tests │ │ ├── __init__.py │ │ ├── test_empirical.py │ │ ├── test_density.py │ │ ├── test_hist_binwidth.py │ │ ├── test_xdeconv.py │ │ └── test_bayesian_blocks.py │ ├── __init__.py │ └── gauss_mixture.py ├── classification │ └── __init__.py ├── plotting │ ├── tests │ │ ├── __init__.py │ │ └── test_devectorize.py │ ├── __init__.py │ ├── settings.py │ └── ellipse.py ├── __init__.py ├── datasets │ ├── tools │ │ ├── __init__.py │ │ ├── sql_query.py │ │ └── download.py │ ├── __init__.py │ ├── generated.py │ ├── rrlyrae_templates.py │ ├── hogg2010test.py │ └── sdss_spectrum.py └── py3k_compat.py ├── astroML_fig_tests ├── .gitignore ├── __init__.py └── baseline │ └── book_figures │ ├── chapter4 │ ├── fig_GMM_1D_1.png │ ├── fig_chi2_eval_1.png │ ├── fig_anderson_darling_1.png │ ├── fig_benjamini_method_1.png │ ├── fig_lyndenbell_gals_1.png │ ├── fig_lyndenbell_setup_1.png │ ├── fig_lyndenbell_toy_1.png │ ├── fig_bootstrap_gaussian_1.png │ ├── fig_jackknife_gaussian_1.png │ └── fig_classification_example_1.png │ ├── chapter1 │ ├── fig_S82_hess_1.png │ ├── fig_mercator_1.png │ ├── fig_SDSS_sspp_1.png │ ├── fig_dr7_quasar_1.png │ ├── fig_projections_1.png │ ├── fig_LINEAR_sample_1.png │ ├── fig_SDSS_imaging_1.png │ ├── fig_SDSS_specgals_1.png │ ├── fig_sdss_spectrum_1.png │ ├── fig_SSPP_metallicity_1.png │ ├── fig_moving_objects_1.png │ ├── fig_sdss_S82standards_1.png │ ├── fig_S82_scatter_contour_1.png │ └── fig_moving_objects_multicolor_1.png │ ├── chapter10 │ ├── fig_mincomp_1.png │ ├── fig_LINEAR_BIC_1.png │ ├── fig_LINEAR_LS_1.png │ ├── fig_LINEAR_SVM_1.png │ ├── fig_LINEAR_SVM_2.png │ ├── fig_LS_example_1.png │ ├── fig_chirp2_PSD_1.png │ ├── fig_powerlaw_1.png │ ├── fig_sampling_1.png │ ├── fig_wavelets_1.png │ ├── fig_FFT_aliasing_1.png │ ├── fig_FFT_aliasing_2.png │ ├── fig_FFT_sampling_1.png │ ├── fig_arrival_time_1.png │ ├── fig_fft_example_1.png │ ├── fig_wavelet_PSD_1.png │ ├── fig_LINEAR_GMMBayes_1.png │ ├── fig_LINEAR_GMMBayes_2.png │ ├── fig_LS_comparison_1.png │ ├── fig_autocorrelation_1.png │ ├── fig_wiener_filter_1.png │ ├── fig_wiener_kernel_1.png │ ├── fig_LINEAR_clustering_1.png │ ├── fig_LINEAR_clustering_2.png │ ├── fig_LS_double_eclipse_1.png │ ├── fig_LS_sg_comparison_1.png │ ├── fig_LS_sg_comparison_2.png │ ├── fig_LS_sg_comparison_3.png │ ├── fig_line_wavelet_PSD_1.png │ ├── fig_matchedfilt_burst_1.png │ ├── fig_matchedfilt_chirp_1.png │ ├── fig_mincomp_procedure_1.png │ ├── fig_LIGO_power_spectrum_1.png │ ├── fig_convolution_diagram_1.png │ ├── fig_gaussian_reconstruct_1.png │ ├── fig_matchedfilt_chirp2_1.png │ └── fig_rrlyrae_reconstruct_1.png │ ├── chapter3 │ ├── fig_prob_sum_1.png │ ├── fig_flux_errors_1.png │ ├── fig_robust_pca_1.png │ ├── fig_central_limit_1.png │ ├── fig_correlations_1.png │ ├── fig_kurtosis_skew_1.png │ ├── fig_uniform_mean_1.png │ ├── fig_beta_distribution_1.png │ ├── fig_bivariate_gaussian_1.png │ ├── fig_cauchy_median_mean_1.png │ ├── fig_chi2_distribution_1.png │ ├── fig_clone_distribution_1.png │ ├── fig_contingency_table_1.png │ ├── fig_gamma_distribution_1.png │ ├── fig_binomial_distribution_1.png │ ├── fig_cauchy_distribution_1.png │ ├── fig_fisher_f_distribution_1.png │ ├── fig_gaussian_distribution_1.png │ ├── fig_laplace_distribution_1.png │ ├── fig_poisson_distribution_1.png │ ├── fig_uniform_distribution_1.png │ ├── fig_weibull_distribution_1.png │ ├── fig_conditional_probability_1.png │ ├── fig_student_t_distribution_1.png │ └── fig_transform_distribution_1.png │ ├── chapter6 │ ├── fig_kernels_1.png │ ├── fig_GMM_clone_1.png │ ├── fig_XD_example_1.png │ ├── fig_great_wall_1.png │ ├── fig_stellar_XD_1.png │ ├── fig_stellar_XD_2.png │ ├── fig_GMM_nclusters_1.png │ ├── fig_corr_diagram_1.png │ ├── fig_EM_metallicity_1.png │ ├── fig_great_wall_GMM_1.png │ ├── fig_great_wall_KDE_1.png │ ├── fig_great_wall_MST_1.png │ ├── fig_hist_to_kernel_1.png │ ├── fig_hist_to_kernel_2.png │ ├── fig_density_estimation_1.png │ ├── fig_kmeans_metallicity_1.png │ ├── fig_correlation_function_1.png │ ├── fig_meanshift_metallicity_1.png │ └── fig_GMM_density_estimation_1.png │ ├── chapter7 │ ├── fig_PCA_LLE_1.png │ ├── fig_PCA_LLE_2.png │ ├── fig_eigenvalues_1.png │ ├── fig_svd_visual_1.png │ ├── fig_PCA_rotation_1.png │ ├── fig_spec_examples_1.png │ ├── fig_S_manifold_PCA_1.png │ ├── fig_PCA_reconstruction_1.png │ ├── fig_spec_decompositions_1.png │ └── fig_spec_reconstruction_1.png │ ├── chapter8 │ ├── fig_gp_mu_z_1.png │ ├── fig_cross_val_A_1.png │ ├── fig_cross_val_B_1.png │ ├── fig_cross_val_C_1.png │ ├── fig_cross_val_D_1.png │ ├── fig_gp_example_1.png │ ├── fig_huber_func_1.png │ ├── fig_huber_loss_1.png │ ├── fig_lasso_ridge_1.png │ ├── fig_linreg_inline_1.png │ ├── fig_linreg_inline_2.png │ ├── fig_nonlinear_mu_z_1.png │ ├── fig_rbf_ridge_mu_z_1.png │ ├── fig_regression_mu_z_1.png │ ├── fig_outlier_rejection_1.png │ └── fig_total_least_squares_1.png │ ├── chapter9 │ ├── fig_bayes_DB_1.png │ ├── fig_ROC_curve_1.png │ ├── fig_bayes_DB_2d_1.png │ ├── fig_photoz_tree_1.png │ ├── fig_rrlyrae_knn_1.png │ ├── fig_rrlyrae_lda_1.png │ ├── fig_rrlyrae_qda_1.png │ ├── fig_rrlyrae_svm_1.png │ ├── fig_svm_diagram_1.png │ ├── fig_photoz_basic_1.png │ ├── fig_photoz_forest_1.png │ ├── fig_photoz_bagging_1.png │ ├── fig_photoz_boosting_1.png │ ├── fig_rrlyrae_GMMbayes_1.png │ ├── fig_rrlyrae_forest_1.png │ ├── fig_rrlyrae_logreg_1.png │ ├── fig_rrlyrae_treevis_1.png │ ├── fig_star_quasar_ROC_1.png │ ├── fig_rrlyrae_kernelsvm_1.png │ ├── fig_rrlyrae_naivebayes_1.png │ ├── fig_simple_naivebayes_1.png │ ├── fig_discriminant_function_1.png │ └── fig_rrlyrae_decisiontree_1.png │ ├── appendix │ ├── fig_kd_dualtree_1.png │ ├── fig_LIGO_wavelets_1.png │ ├── fig_ball_dualtree_1.png │ ├── fig_gauss_kernel_1.png │ ├── fig_sdss_filters_1.png │ ├── fig_LIGO_bandpower_1.png │ ├── fig_broadcast_visual_1.png │ ├── fig_fft_text_example_1.png │ ├── fig_neural_network_1.png │ ├── fig_plotting_examples_1.png │ ├── fig_plotting_examples_2.png │ ├── fig_plotting_examples_3.png │ └── fig_plotting_examples_4.png │ ├── chapter5 │ ├── fig_cauchy_mcmc_1.png │ ├── fig_lutz_kelker_1.png │ ├── fig_bayes_blocks_1.png │ ├── fig_hist_binsize_1.png │ ├── fig_gaussgauss_mcmc_1.png │ ├── fig_malmquist_bias_1.png │ ├── fig_odds_ratio_coin_1.png │ ├── fig_posterior_cauchy_1.png │ ├── fig_likelihood_cauchy_1.png │ ├── fig_likelihood_uniform_1.png │ ├── fig_odds_ratio_cauchy_1.png │ ├── fig_outlier_likelihood_1.png │ ├── fig_poisson_comparison_1.png │ ├── fig_poisson_continuous_1.png │ ├── fig_poisson_likelihood_1.png │ ├── fig_posterior_binomial_1.png │ ├── fig_posterior_gaussian_1.png │ ├── fig_signal_background_1.png │ ├── fig_likelihood_gaussgauss_1.png │ ├── fig_likelihood_gaussian_1.png │ ├── fig_likelihood_gausslin_1.png │ ├── fig_model_comparison_hist_1.png │ ├── fig_model_comparison_mcmc_1.png │ ├── fig_outlier_distribution_1.png │ ├── fig_outlier_marginalized_1.png │ ├── fig_posterior_gaussgauss_1.png │ └── fig_distribution_gaussgauss_1.png │ └── chapter2 │ ├── fig_sort_scaling_1.png │ ├── fig_balltree_example_1.png │ ├── fig_kdtree_example_1.png │ ├── fig_quadtree_example_1.png │ └── fig_search_scaling_1.png ├── doc ├── sphinxext │ ├── numpy_ext │ │ └── __init__.py │ ├── MANIFEST.in │ ├── gen_rst.py │ ├── README.txt │ ├── gen_paper_rst.py │ └── gen_figure_rst.py ├── logos │ ├── Logo.gif │ ├── favicon.ico │ └── plot_logo.py ├── _static │ └── text_cover.png ├── documents │ └── DMbookTOC.pdf ├── images │ └── blank_image.png ├── themes │ └── astroML │ │ └── theme.conf ├── _templates │ ├── function.rst │ └── class.rst ├── user_guide │ ├── clustering.rst │ ├── time_series.rst │ ├── regression.rst │ ├── classification.rst │ ├── dimensionality.rst │ ├── index.rst │ ├── resources.rst │ └── introduction.rst ├── development │ ├── authors.rst │ └── index.rst └── includes │ └── big_toc_css.rst ├── paper_figures ├── contents.txt ├── CIDU2012 │ ├── contents.txt │ ├── README.rst │ ├── fig_spec_examples.py │ ├── fig_LS_sg_comparison.py │ └── fig_great_wall_MST.py └── README.rst ├── book_figures ├── chapter10 │ ├── 10022663.npz │ ├── 10025796.npz │ ├── 1009459.npz │ ├── 11375941.npz │ ├── 14752041.npz │ ├── 18525697.npz │ ├── periods.db │ ├── periods_LS.db │ ├── arrival_time_MCMC.npy │ ├── README.rst │ ├── contents.txt │ ├── compute_periods.py │ └── fig_gaussian_reconstruct.py ├── chapter4 │ ├── lumfunc_red.npz │ ├── lumfunc_blue.npz │ ├── README.rst │ └── contents.txt ├── chapter2 │ ├── contents.txt │ └── README.rst ├── contents.txt ├── appendix │ ├── README.rst │ └── contents.txt ├── chapter9 │ ├── README.rst │ ├── contents.txt │ ├── fig_discriminant_function.py │ └── fig_bayes_DB.py ├── chapter1 │ ├── README.rst │ ├── contents.txt │ ├── fig_dr7_quasar.py │ ├── fig_sdss_spectrum.py │ ├── fig_S82_scatter_contour.py │ ├── fig_sdss_S82standards.py │ ├── fig_moving_objects.py │ └── fig_SDSS_specgals.py ├── chapter6 │ ├── README.rst │ ├── contents.txt │ └── fig_kernels.py ├── chapter5 │ ├── README.rst │ └── contents.txt ├── chapter7 │ ├── README.rst │ └── contents.txt ├── chapter8 │ ├── README.rst │ ├── contents.txt │ └── fig_huber_func.py ├── chapter3 │ ├── README.rst │ ├── contents.txt │ ├── fig_prob_sum.py │ └── fig_contingency_table.py ├── color_plates.txt ├── README.rst └── README ├── MANIFEST.in ├── examples ├── README.rst ├── learning │ └── README.rst ├── algorithms │ ├── README.rst │ ├── plot_spectrum_sum_of_norms.py │ ├── plot_crossmatch.py │ └── fig_volume_ratio.py └── datasets │ ├── README.rst │ ├── plot_wmap_raw.py │ ├── plot_great_wall.py │ ├── plot_rrlyrae_mags.py │ ├── plot_corrected_spectra.py │ ├── plot_dr7_quasar.py │ ├── plot_sdss_spectrum.py │ ├── plot_sdss_galaxy_colors.py │ ├── plot_sdss_filters.py │ ├── plot_sdss_line_ratios.py │ ├── plot_nasa_atlas.py │ ├── plot_sdss_specgals.py │ └── plot_sdss_imaging.py ├── .gitignore ├── CHANGES.rst ├── Makefile ├── .travis.yml ├── CITATION ├── LICENSE.rst ├── TODO.txt ├── compare_images.py └── setup.py /astroML/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/stats/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/clustering/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/linear_model/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/time_series/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML_fig_tests/.gitignore: -------------------------------------------------------------------------------- 1 | results -------------------------------------------------------------------------------- /doc/sphinxext/numpy_ext/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/dimensionality/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /paper_figures/contents.txt: -------------------------------------------------------------------------------- 1 | CIDU2012 2 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /astroML/classification/__init__.py: -------------------------------------------------------------------------------- 1 | from .gmm_bayes import GMMBayes 2 | -------------------------------------------------------------------------------- /doc/sphinxext/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include tests *.py 2 | include *.txt 3 | -------------------------------------------------------------------------------- /astroML/dimensionality/__init__.py: -------------------------------------------------------------------------------- 1 | from .iterative_pca import iterative_pca 2 | -------------------------------------------------------------------------------- /astroML/plotting/tests/__init__.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | matplotlib.use('Agg') 3 | -------------------------------------------------------------------------------- /astroML_fig_tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Automated tests for the astroML figures 3 | """ 4 | -------------------------------------------------------------------------------- /doc/logos/Logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/doc/logos/Logo.gif -------------------------------------------------------------------------------- /doc/logos/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/doc/logos/favicon.ico -------------------------------------------------------------------------------- /astroML/clustering/__init__.py: -------------------------------------------------------------------------------- 1 | from .mst_clustering import HierarchicalClustering, get_graph_segments 2 | -------------------------------------------------------------------------------- /doc/_static/text_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/doc/_static/text_cover.png -------------------------------------------------------------------------------- /doc/documents/DMbookTOC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/doc/documents/DMbookTOC.pdf -------------------------------------------------------------------------------- /doc/images/blank_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/doc/images/blank_image.png -------------------------------------------------------------------------------- /book_figures/chapter10/10022663.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/10022663.npz -------------------------------------------------------------------------------- /book_figures/chapter10/10025796.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/10025796.npz -------------------------------------------------------------------------------- /book_figures/chapter10/1009459.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/1009459.npz -------------------------------------------------------------------------------- /book_figures/chapter10/11375941.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/11375941.npz -------------------------------------------------------------------------------- /book_figures/chapter10/14752041.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/14752041.npz -------------------------------------------------------------------------------- /book_figures/chapter10/18525697.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/18525697.npz -------------------------------------------------------------------------------- /book_figures/chapter10/periods.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/periods.db -------------------------------------------------------------------------------- /doc/themes/astroML/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = astroMLstyle.css 4 | pygments_style = tango 5 | -------------------------------------------------------------------------------- /book_figures/chapter10/periods_LS.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/periods_LS.db -------------------------------------------------------------------------------- /book_figures/chapter4/lumfunc_red.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter4/lumfunc_red.npz -------------------------------------------------------------------------------- /book_figures/chapter4/lumfunc_blue.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter4/lumfunc_blue.npz -------------------------------------------------------------------------------- /book_figures/chapter10/arrival_time_MCMC.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/book_figures/chapter10/arrival_time_MCMC.npy -------------------------------------------------------------------------------- /doc/_templates/function.rst: -------------------------------------------------------------------------------- 1 | {{ fullname }} 2 | {{ underline }} 3 | 4 | .. currentmodule:: {{ module }} 5 | 6 | .. autofunction:: {{ objname }} 7 | 8 | 9 | -------------------------------------------------------------------------------- /book_figures/chapter2/contents.txt: -------------------------------------------------------------------------------- 1 | fig_search_scaling.py 2 | fig_sort_scaling.py 3 | fig_quadtree_example.py 4 | fig_kdtree_example.py 5 | fig_balltree_example.py 6 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_GMM_1D_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_GMM_1D_1.png -------------------------------------------------------------------------------- /book_figures/contents.txt: -------------------------------------------------------------------------------- 1 | chapter1 2 | chapter2 3 | chapter3 4 | chapter4 5 | chapter5 6 | chapter6 7 | chapter7 8 | chapter8 9 | chapter9 10 | chapter10 11 | appendix 12 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_S82_hess_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_S82_hess_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_mercator_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_mercator_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_mincomp_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_mincomp_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_prob_sum_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_prob_sum_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_kernels_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_kernels_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_LLE_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_LLE_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_LLE_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_LLE_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_gp_mu_z_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_gp_mu_z_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_bayes_DB_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_bayes_DB_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_kd_dualtree_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_kd_dualtree_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_sspp_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_sspp_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_dr7_quasar_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_dr7_quasar_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_projections_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_projections_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_BIC_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_BIC_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_LS_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_LS_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_SVM_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_SVM_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_SVM_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_SVM_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_chirp2_PSD_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_chirp2_PSD_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_powerlaw_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_powerlaw_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_sampling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_sampling_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_wavelets_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_wavelets_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_flux_errors_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_flux_errors_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_robust_pca_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_robust_pca_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_chi2_eval_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_chi2_eval_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_cauchy_mcmc_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_cauchy_mcmc_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_lutz_kelker_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_lutz_kelker_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_clone_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_clone_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_XD_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_XD_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_stellar_XD_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_stellar_XD_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_stellar_XD_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_stellar_XD_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_eigenvalues_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_eigenvalues_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_svd_visual_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_svd_visual_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_A_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_A_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_B_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_B_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_C_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_C_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_D_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_cross_val_D_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_gp_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_gp_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_huber_func_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_huber_func_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_huber_loss_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_huber_loss_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_lasso_ridge_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_lasso_ridge_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_ROC_curve_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_ROC_curve_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_bayes_DB_2d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_bayes_DB_2d_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_tree_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_tree_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_knn_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_knn_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_lda_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_lda_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_qda_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_qda_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_svm_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_svm_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_svm_diagram_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_svm_diagram_1.png -------------------------------------------------------------------------------- /paper_figures/CIDU2012/contents.txt: -------------------------------------------------------------------------------- 1 | fig_rbf_ridge_mu_z.py 2 | fig_XD_example.py 3 | fig_spec_examples.py 4 | fig_spec_decompositions.py 5 | fig_LS_sg_comparison.py 6 | fig_great_wall_MST.py 7 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_LIGO_wavelets_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_LIGO_wavelets_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_ball_dualtree_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_ball_dualtree_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_gauss_kernel_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_gauss_kernel_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_sdss_filters_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_sdss_filters_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_LINEAR_sample_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_LINEAR_sample_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_imaging_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_imaging_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_specgals_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_SDSS_specgals_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_sdss_spectrum_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_sdss_spectrum_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_aliasing_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_aliasing_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_aliasing_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_aliasing_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_sampling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_FFT_sampling_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_arrival_time_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_arrival_time_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_fft_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_fft_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_wavelet_PSD_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_wavelet_PSD_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter2/fig_sort_scaling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter2/fig_sort_scaling_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_central_limit_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_central_limit_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_correlations_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_correlations_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_kurtosis_skew_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_kurtosis_skew_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_uniform_mean_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_uniform_mean_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_bayes_blocks_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_bayes_blocks_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_hist_binsize_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_hist_binsize_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_nclusters_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_nclusters_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_corr_diagram_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_corr_diagram_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_rotation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_rotation_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_examples_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_examples_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_linreg_inline_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_linreg_inline_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_linreg_inline_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_linreg_inline_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_basic_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_basic_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_forest_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_forest_1.png -------------------------------------------------------------------------------- /book_figures/appendix/README.rst: -------------------------------------------------------------------------------- 1 | Appendix 2 | -------- 3 | There are several appendices, covering topics from the efficient use of 4 | Python code to the practical use of Fourier transforms. 5 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_LIGO_bandpower_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_LIGO_bandpower_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_broadcast_visual_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_broadcast_visual_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_fft_text_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_fft_text_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_neural_network_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_neural_network_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_SSPP_metallicity_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_SSPP_metallicity_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_moving_objects_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_moving_objects_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_GMMBayes_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_GMMBayes_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_GMMBayes_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_GMMBayes_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_comparison_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_comparison_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_autocorrelation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_autocorrelation_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_wiener_filter_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_wiener_filter_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_wiener_kernel_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_wiener_kernel_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter2/fig_balltree_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter2/fig_balltree_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter2/fig_kdtree_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter2/fig_kdtree_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter2/fig_quadtree_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter2/fig_quadtree_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter2/fig_search_scaling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter2/fig_search_scaling_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_anderson_darling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_anderson_darling_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_benjamini_method_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_benjamini_method_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_gals_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_gals_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_setup_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_setup_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_toy_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_lyndenbell_toy_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_gaussgauss_mcmc_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_gaussgauss_mcmc_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_malmquist_bias_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_malmquist_bias_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_odds_ratio_coin_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_odds_ratio_coin_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_cauchy_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_cauchy_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_EM_metallicity_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_EM_metallicity_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_GMM_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_GMM_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_KDE_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_KDE_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_MST_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_great_wall_MST_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_hist_to_kernel_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_hist_to_kernel_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_hist_to_kernel_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_hist_to_kernel_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_S_manifold_PCA_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_S_manifold_PCA_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_nonlinear_mu_z_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_nonlinear_mu_z_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_rbf_ridge_mu_z_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_rbf_ridge_mu_z_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_regression_mu_z_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_regression_mu_z_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_bagging_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_bagging_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_boosting_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_photoz_boosting_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_GMMbayes_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_GMMbayes_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_forest_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_forest_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_logreg_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_logreg_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_treevis_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_treevis_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_star_quasar_ROC_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_star_quasar_ROC_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_3.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/appendix/fig_plotting_examples_4.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_sdss_S82standards_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_sdss_S82standards_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_clustering_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_clustering_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_clustering_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LINEAR_clustering_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_double_eclipse_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_double_eclipse_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_2.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LS_sg_comparison_3.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_line_wavelet_PSD_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_line_wavelet_PSD_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_burst_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_burst_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_chirp_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_chirp_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_mincomp_procedure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_mincomp_procedure_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_beta_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_beta_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_bivariate_gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_bivariate_gaussian_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_cauchy_median_mean_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_cauchy_median_mean_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_chi2_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_chi2_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_clone_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_clone_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_contingency_table_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_contingency_table_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_gamma_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_gamma_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_bootstrap_gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_bootstrap_gaussian_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_jackknife_gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_jackknife_gaussian_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_cauchy_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_cauchy_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_uniform_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_uniform_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_odds_ratio_cauchy_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_odds_ratio_cauchy_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_likelihood_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_likelihood_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_comparison_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_comparison_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_continuous_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_continuous_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_likelihood_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_poisson_likelihood_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_binomial_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_binomial_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_gaussian_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_signal_background_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_signal_background_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_density_estimation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_density_estimation_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_kmeans_metallicity_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_kmeans_metallicity_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_reconstruction_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_PCA_reconstruction_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_outlier_rejection_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_outlier_rejection_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_kernelsvm_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_kernelsvm_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_naivebayes_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_naivebayes_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_simple_naivebayes_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_simple_naivebayes_1.png -------------------------------------------------------------------------------- /book_figures/chapter4/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 4: Classical Statistical Inference 2 | ------------------------------------------ 3 | This chapter develops the classical or "frequentist" approach to statistics. 4 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_S82_scatter_contour_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_S82_scatter_contour_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_LIGO_power_spectrum_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_LIGO_power_spectrum_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_convolution_diagram_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_convolution_diagram_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_gaussian_reconstruct_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_gaussian_reconstruct_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_chirp2_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_matchedfilt_chirp2_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter10/fig_rrlyrae_reconstruct_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter10/fig_rrlyrae_reconstruct_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_binomial_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_binomial_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_cauchy_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_cauchy_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_fisher_f_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_fisher_f_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_gaussian_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_gaussian_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_laplace_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_laplace_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_poisson_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_poisson_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_uniform_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_uniform_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_weibull_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_weibull_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gaussgauss_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gaussgauss_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gaussian_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gausslin_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_likelihood_gausslin_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_model_comparison_hist_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_model_comparison_hist_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_model_comparison_mcmc_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_model_comparison_mcmc_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_marginalized_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_outlier_marginalized_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_gaussgauss_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_posterior_gaussgauss_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_correlation_function_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_correlation_function_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_meanshift_metallicity_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_meanshift_metallicity_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_decompositions_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_decompositions_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_reconstruction_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter7/fig_spec_reconstruction_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter8/fig_total_least_squares_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter8/fig_total_least_squares_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_discriminant_function_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_discriminant_function_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_decisiontree_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter9/fig_rrlyrae_decisiontree_1.png -------------------------------------------------------------------------------- /book_figures/chapter2/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 2: Fast Computation and Massive Datasets 2 | ------------------------------------------------ 3 | This chapter discusses computational strategies for large datasets. 4 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_conditional_probability_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_conditional_probability_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_student_t_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_student_t_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter3/fig_transform_distribution_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter3/fig_transform_distribution_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter4/fig_classification_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter4/fig_classification_example_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter5/fig_distribution_gaussgauss_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter5/fig_distribution_gaussgauss_1.png -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_density_estimation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter6/fig_GMM_density_estimation_1.png -------------------------------------------------------------------------------- /book_figures/chapter9/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 9: Classification 2 | ------------------------- 3 | This chapter covers supervised classification of data, using a number of 4 | generative and discriminative classifiers. 5 | -------------------------------------------------------------------------------- /astroML/linear_model/__init__.py: -------------------------------------------------------------------------------- 1 | from .linear_regression import \ 2 | LinearRegression, PolynomialRegression, BasisFunctionRegression 3 | from .kernel_regression import NadarayaWatson 4 | from .TLS import TLS_logL 5 | -------------------------------------------------------------------------------- /astroML_fig_tests/baseline/book_figures/chapter1/fig_moving_objects_multicolor_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwcraig/astroML/master/astroML_fig_tests/baseline/book_figures/chapter1/fig_moving_objects_multicolor_1.png -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.rst 2 | include *.py 3 | recursive-include examples *.py *.rst 4 | recursive-include book_figures *.py *.rst 5 | recursive-include paper_figures *.py *.rst 6 | recursive-include astroML *.py 7 | include LICENSE -------------------------------------------------------------------------------- /book_figures/chapter1/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 1: Introduction 2 | ----------------------- 3 | This chapter consists of introductory figures, including several of the 4 | datasets available in astroML, and some strategies for data visualization. 5 | -------------------------------------------------------------------------------- /book_figures/chapter10/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 10: Time Series Analysis 2 | -------------------------------- 3 | This chapter covers the analysis of both periodic and non-periodic time series, 4 | for both regularly and irregularly spaced data. 5 | -------------------------------------------------------------------------------- /doc/_templates/class.rst: -------------------------------------------------------------------------------- 1 | {{ fullname }} 2 | {{ underline }} 3 | 4 | .. currentmodule:: {{ module }} 5 | 6 | .. autoclass:: {{ objname }} 7 | 8 | {% block methods %} 9 | .. automethod:: __init__ 10 | {% endblock %} 11 | 12 | 13 | -------------------------------------------------------------------------------- /paper_figures/CIDU2012/README.rst: -------------------------------------------------------------------------------- 1 | CIDU 2012: Introduction to astroML 2 | ---------------------------------- 3 | These figures are from the introduction to the astroML package presented at 4 | the Conference for Intelligent Data Understanding (CIDU) 2012. 5 | -------------------------------------------------------------------------------- /astroML/plotting/__init__.py: -------------------------------------------------------------------------------- 1 | from .hist_tools import hist 2 | from .scatter_contour import scatter_contour 3 | from .mcmc import plot_mcmc 4 | from .ellipse import plot_tissot_ellipse 5 | from .multiaxes import MultiAxes 6 | from .settings import setup_text_plots 7 | -------------------------------------------------------------------------------- /book_figures/chapter6/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 6: Searching for Structure in Point Data 2 | ------------------------------------------------ 3 | This chapter covers high-dimensional point statistics, including density 4 | estimation, clustering, and correlation functions. 5 | -------------------------------------------------------------------------------- /book_figures/chapter5/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 5: Bayesian Statistical Inference 2 | ----------------------------------------- 3 | This chapter develops the fundamentals of Bayesian statistical inference, 4 | and finishes with some examples of computing statistics in this manner. 5 | -------------------------------------------------------------------------------- /book_figures/chapter7/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 7: Dimensionality and its Reduction 2 | ------------------------------------------- 3 | This chapter covers dimensionality reduction, from linear methods such as 4 | PCA, NMF, and ICA, to nonlinear methods such as LLE and Isomap. 5 | -------------------------------------------------------------------------------- /doc/user_guide/clustering.rst: -------------------------------------------------------------------------------- 1 | .. _astroML_clustering: 2 | 3 | Unsupervised Learning: Clustering 4 | ================================= 5 | More information will be here soon - check for updates! 6 | 7 | Some examples of clustering can be found in :ref:`book_fig_chapter6` 8 | -------------------------------------------------------------------------------- /paper_figures/README.rst: -------------------------------------------------------------------------------- 1 | Paper Figures 2 | ------------- 3 | 4 | In the spirit of `reprodicible research `_, 5 | this page lists the source code for figures from published papers which 6 | use datasets and routines available in astroML. 7 | -------------------------------------------------------------------------------- /doc/user_guide/time_series.rst: -------------------------------------------------------------------------------- 1 | .. _astroML_time_series: 2 | 3 | Time Series Analysis 4 | ==================== 5 | More information will be here soon - check for updates! 6 | 7 | Some examples of approaches to time-series analysis can be found in 8 | :ref:`book_fig_chapter10` 9 | -------------------------------------------------------------------------------- /book_figures/chapter8/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 8: Regression and Model Fitting 2 | --------------------------------------- 3 | This chapter covers linear and nonlinear regression and model fitting, 4 | including strategies which are robust to data error and the presence of 5 | outliers. 6 | -------------------------------------------------------------------------------- /doc/user_guide/regression.rst: -------------------------------------------------------------------------------- 1 | .. _astroML_regression: 2 | 3 | Supervised Learning: Regression 4 | =============================== 5 | More information will be here soon - check for updates! 6 | 7 | Some examples of regression problems can be found in 8 | :ref:`book_fig_chapter8` 9 | -------------------------------------------------------------------------------- /examples/README.rst: -------------------------------------------------------------------------------- 1 | General astroML Examples 2 | ------------------------ 3 | 4 | This section contains several example plots which do not appear in the 5 | textbook. Currently there are only a few examples here: for more, please 6 | see the :ref:`text book figures `. 7 | -------------------------------------------------------------------------------- /examples/learning/README.rst: -------------------------------------------------------------------------------- 1 | Machine Learning and Data Modeling 2 | ---------------------------------- 3 | These scripts show some of the machine learning and data modeling tools 4 | available in astroML. For more examples, see the 5 | :ref:`figures ` from the textbook. 6 | -------------------------------------------------------------------------------- /book_figures/chapter7/contents.txt: -------------------------------------------------------------------------------- 1 | fig_spec_examples.py 2 | fig_PCA_rotation.py 3 | fig_svd_visual.py 4 | fig_spec_decompositions.py 5 | fig_eigenvalues.py 6 | fig_spec_reconstruction.py 7 | fig_PCA_reconstruction.py 8 | fig_S_manifold_PCA.py 9 | fig_PCA_LLE.py 10 | 11 | #fig_volume_ratio.py 12 | -------------------------------------------------------------------------------- /doc/user_guide/classification.rst: -------------------------------------------------------------------------------- 1 | .. _astroML_classification: 2 | 3 | Supervised Learning: Classification 4 | =================================== 5 | More information will be here soon - check for updates! 6 | 7 | Some examples of classification problems can be found in 8 | :ref:`book_fig_chapter9` 9 | -------------------------------------------------------------------------------- /examples/algorithms/README.rst: -------------------------------------------------------------------------------- 1 | Data Processing Algorithms 2 | -------------------------- 3 | These figures and examples show some of the data processing and algorithmic 4 | tools enabled by astroML and other Python packages. For more examples, 5 | see the :ref:`figures ` from the textbook. 6 | -------------------------------------------------------------------------------- /astroML/time_series/__init__.py: -------------------------------------------------------------------------------- 1 | from .ACF import ACF_scargle, ACF_EK 2 | from .periodogram import lomb_scargle, lomb_scargle_bootstrap, \ 3 | lomb_scargle_AIC, lomb_scargle_BIC, multiterm_periodogram, \ 4 | search_frequencies, MultiTermFit 5 | from .generate import generate_power_law, generate_damped_RW 6 | -------------------------------------------------------------------------------- /book_figures/chapter4/contents.txt: -------------------------------------------------------------------------------- 1 | fig_chi2_eval.py 2 | fig_GMM_1D.py 3 | fig_bootstrap_gaussian.py 4 | fig_jackknife_gaussian.py 5 | fig_classification_example.py 6 | fig_benjamini_method.py 7 | fig_anderson_darling.py 8 | fig_lyndenbell_setup.py 9 | fig_lyndenbell_toy.py 10 | fig_lyndenbell_gals.py 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.pyc 3 | *.so 4 | 5 | *.tgz 6 | *.pkl 7 | *.pdf 8 | *.png 9 | 10 | astroML.tgz 11 | build 12 | dist 13 | MANIFEST 14 | doc/_build 15 | doc/examples/ 16 | doc/book_figures/ 17 | doc/paper_figures/ 18 | doc/modules/generated/ 19 | book_figures/*/*.pkl 20 | 21 | # Vim temporaries 22 | .*.sw[op] 23 | -------------------------------------------------------------------------------- /astroML/stats/__init__.py: -------------------------------------------------------------------------------- 1 | from ._binned_statistic import (binned_statistic, binned_statistic_2d, 2 | binned_statistic_dd) 3 | 4 | from ._point_statistics import \ 5 | mean_sigma, sigmaG, median_sigmaG, fit_bivariate_normal 6 | 7 | from .random import bivariate_normal, trunc_exp, linear 8 | -------------------------------------------------------------------------------- /doc/user_guide/dimensionality.rst: -------------------------------------------------------------------------------- 1 | .. _astroML_dimensionality: 2 | 3 | Unsupervised Learning: Dimensionality Reduction 4 | =============================================== 5 | More information will be here soon - check for updates! 6 | 7 | Some examples of dimensionality reduction can be found in 8 | :ref:`book_fig_chapter7` 9 | -------------------------------------------------------------------------------- /book_figures/chapter3/README.rst: -------------------------------------------------------------------------------- 1 | Chapter 3: Probability and Statistical Distributions 2 | ---------------------------------------------------- 3 | This chapter discusses basic foundational principles, including probability 4 | and basic descriptive statistics. It also introduces several important 5 | probability distribution functions. 6 | -------------------------------------------------------------------------------- /doc/development/authors.rst: -------------------------------------------------------------------------------- 1 | Authors 2 | ======= 3 | 4 | Package Author 5 | -------------- 6 | * Jake Vanderplas http://jakevdp.github.com 7 | 8 | Code Contribution 9 | ----------------- 10 | * Morgan Fouesneau https://github.com/mfouesneau 11 | * Julian Taylor http://github.com/juliantaylor 12 | -------------------------------------------------------------------------------- /astroML/density_estimation/__init__.py: -------------------------------------------------------------------------------- 1 | from .density_estimation import KDE, KNeighborsDensity 2 | from .xdeconv import XDGMM 3 | from .histtools import\ 4 | scotts_bin_width, freedman_bin_width, knuth_bin_width, histogram 5 | from .bayesian_blocks import bayesian_blocks 6 | from .empirical import FunctionDistribution, EmpiricalDistribution 7 | from .gauss_mixture import GaussianMixture1D 8 | -------------------------------------------------------------------------------- /book_figures/appendix/contents.txt: -------------------------------------------------------------------------------- 1 | fig_broadcast_visual.py 2 | fig_plotting_examples.py 3 | fig_plotting_examples.py 4 | fig_plotting_examples.py 5 | fig_plotting_examples.py 6 | fig_sdss_filters.py 7 | fig_fft_text_example.py 8 | 9 | #fig_gauss_kernel.py 10 | #fig_neural_network.py 11 | #fig_ball_dualtree.py 12 | #fig_kd_dualtree.py 13 | #fig_LIGO_bandpower.py 14 | #fig_LIGO_wavelets.py 15 | -------------------------------------------------------------------------------- /doc/development/index.rst: -------------------------------------------------------------------------------- 1 | .. title:: Development: contents 2 | 3 | .. 4 | We are putting the title as a raw HTML so that it doesn't appear in 5 | the contents 6 | 7 | .. raw:: html 8 | 9 |

Development: contents

10 | 11 | .. _user_guide: 12 | 13 | .. include:: ../includes/big_toc_css.rst 14 | 15 | .. toctree:: 16 | :numbered: 17 | 18 | contribution 19 | authors 20 | -------------------------------------------------------------------------------- /book_figures/chapter8/contents.txt: -------------------------------------------------------------------------------- 1 | fig_linreg_inline.py 2 | fig_regression_mu_z.py 3 | fig_lasso_ridge.py 4 | fig_rbf_ridge_mu_z.py 5 | fig_nonlinear_mu_z.py 6 | fig_total_least_squares.py 7 | fig_huber_func.py 8 | fig_huber_loss.py 9 | fig_outlier_rejection.py 10 | fig_gp_example.py 11 | fig_gp_mu_z.py 12 | fig_cross_val_A.py 13 | fig_cross_val_B.py 14 | fig_cross_val_C.py 15 | fig_cross_val_D.py 16 | 17 | -------------------------------------------------------------------------------- /book_figures/chapter1/contents.txt: -------------------------------------------------------------------------------- 1 | fig_SDSS_imaging.py 2 | fig_sdss_spectrum.py 3 | fig_SDSS_specgals.py 4 | fig_dr7_quasar.py 5 | fig_SDSS_sspp.py 6 | fig_sdss_S82standards.py 7 | fig_LINEAR_sample.py 8 | fig_moving_objects.py 9 | fig_S82_scatter_contour.py 10 | fig_S82_hess.py 11 | fig_SSPP_metallicity.py 12 | fig_moving_objects_multicolor.py 13 | fig_mercator.py 14 | fig_projections.py 15 | fig_healpix_ex.py 16 | -------------------------------------------------------------------------------- /astroML/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.4-git' 2 | 3 | __citation__ = """@INPROCEEDINGS{astroML, 4 | author={{Vanderplas}, J.T. and {Connolly}, A.J. 5 | and {Ivezi{\'c}}, {\v Z}. and {Gray}, A.}, 6 | booktitle={Conference on Intelligent Data Understanding (CIDU)}, 7 | title={Introduction to astroML: Machine learning for astrophysics}, 8 | month={Oct.}, 9 | pages={47 -54}, 10 | doi={10.1109/CIDU.2012.6382200}, 11 | year={2012} 12 | }""" 13 | -------------------------------------------------------------------------------- /book_figures/chapter6/contents.txt: -------------------------------------------------------------------------------- 1 | fig_hist_to_kernel.py 2 | fig_kernels.py 3 | fig_great_wall_KDE.py 4 | fig_great_wall.py 5 | fig_density_estimation.py 6 | fig_EM_metallicity.py 7 | fig_great_wall_GMM.py 8 | fig_GMM_density_estimation.py 9 | fig_GMM_nclusters.py 10 | fig_GMM_clone.py 11 | fig_XD_example.py 12 | fig_stellar_XD.py 13 | fig_kmeans_metallicity.py 14 | fig_meanshift_metallicity.py 15 | fig_great_wall_MST.py 16 | fig_corr_diagram.py 17 | fig_correlation_function.py 18 | -------------------------------------------------------------------------------- /book_figures/color_plates.txt: -------------------------------------------------------------------------------- 1 | # List the figures in color panels 2 | 3 | chapter1/fig_SSPP_metallicity.py 4 | chapter1/fig_moving_objects_multicolor.py 5 | chapter1/fig_healpix_ex.py 6 | chapter6/fig_great_wall_MST.py 7 | chapter7/fig_S_manifold_PCA.py 8 | chapter7/fig_PCA_components.py 9 | chapter7/fig_spec_LLE.py 10 | chapter9/fig_ROC_curve.py 11 | chapter9/fig_star_quasar_ROC.py 12 | chapter10/fig_wavelet_PSD.py 13 | chapter10/fig_LINEAR_clustering.py 14 | appendix/fig_sdss_filters.py 15 | -------------------------------------------------------------------------------- /astroML/linear_model/tests/test_TLS.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose 3 | 4 | from ..TLS import TLS_logL 5 | 6 | 7 | def test_TLS_likelihood_diagonal(rseed=0): 8 | """Test Total-Least-Squares fit with diagonal covariance""" 9 | np.random.seed(rseed) 10 | 11 | X = np.random.rand(10, 2) 12 | dX1 = 0.1 * np.ones((10, 2)) 13 | dX2 = 0.1 * np.array([np.eye(2) for i in range(10)]) 14 | v = np.random.random(2) 15 | 16 | assert_allclose(TLS_logL(v, X, dX1), 17 | TLS_logL(v, X, dX2)) 18 | -------------------------------------------------------------------------------- /astroML/linear_model/tests/test_kernel_regression.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose 3 | from astroML.linear_model import NadarayaWatson 4 | 5 | 6 | def test_NW_simple(): 7 | X = np.arange(11.) 8 | y = X + 1 9 | dy = 1 10 | 11 | # by symmetry, NW regression should get these exactly correct 12 | Xfit = np.array([4, 5, 6])[:, None] 13 | y_true = np.ravel(Xfit + 1) 14 | 15 | clf = NadarayaWatson(h=0.5).fit(X[:, None], y, dy) 16 | y_fit = clf.predict(Xfit) 17 | 18 | assert_allclose(y_fit, y_true) 19 | -------------------------------------------------------------------------------- /book_figures/README.rst: -------------------------------------------------------------------------------- 1 | Textbook Figures 2 | ---------------- 3 | 4 | This section makes available the source code used to generate every figure 5 | in the book `Statistics, Data Mining, and Machine Learning in Astronomy`. 6 | Many of the figures are fairly self-explanatory, though some will be less 7 | so without the book as a reference. The table of contents of the book 8 | can be seen :download:`here(pdf) <../documents/DMbookTOC.pdf>`. 9 | 10 | Figure Contents 11 | ~~~~~~~~~~~~~~~ 12 | Each chapter links to a page with thumbnails of the figures from the chapter. 13 | -------------------------------------------------------------------------------- /astroML/time_series/tests/test_generate.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_ 3 | from astroML.time_series import generate_power_law 4 | 5 | 6 | def check_generate_args(N, dt, beta, generate_complex): 7 | x = generate_power_law(N, dt, beta, generate_complex) 8 | 9 | assert_(bool(generate_complex) == np.iscomplexobj(x)) 10 | assert_(len(x) == N) 11 | 12 | 13 | def test_generate_args(): 14 | dt = 0.1 15 | beta = 2 16 | for N in [10, 11]: 17 | for generate_complex in [True, False]: 18 | yield (check_generate_args, N, dt, beta, generate_complex) 19 | -------------------------------------------------------------------------------- /doc/user_guide/index.rst: -------------------------------------------------------------------------------- 1 | .. title:: User guide: contents 2 | 3 | .. 4 | We are putting the title as a raw HTML so that it doesn't appear in 5 | the contents 6 | 7 | .. raw:: html 8 | 9 |

User guide: contents

10 | 11 | .. _user_guide: 12 | 13 | .. include:: ../includes/big_toc_css.rst 14 | 15 | .. toctree:: 16 | :numbered: 17 | :maxdepth: 2 18 | 19 | introduction 20 | installation 21 | datasets 22 | density_estimation 23 | clustering 24 | correlation_functions 25 | dimensionality 26 | regression 27 | classification 28 | time_series 29 | ../modules/classes 30 | resources 31 | -------------------------------------------------------------------------------- /book_figures/chapter9/contents.txt: -------------------------------------------------------------------------------- 1 | fig_bayes_DB.py 2 | fig_simple_naivebayes.py 3 | fig_rrlyrae_naivebayes.py 4 | fig_rrlyrae_lda.py 5 | fig_rrlyrae_qda.py 6 | fig_rrlyrae_GMMbayes.py 7 | fig_rrlyrae_knn.py 8 | fig_rrlyrae_logreg.py 9 | fig_svm_diagram.py 10 | fig_rrlyrae_svm.py 11 | fig_rrlyrae_kernelsvm.py 12 | fig_rrlyrae_treevis.py 13 | fig_rrlyrae_decisiontree.py 14 | fig_photoz_tree.py 15 | fig_photoz_forest.py 16 | fig_photoz_boosting.py 17 | fig_ROC_curve.py 18 | fig_star_quasar_ROC.py 19 | 20 | #fig_discriminant_function.py 21 | #fig_gauss_kernel.py 22 | #fig_neural_network.py 23 | #fig_photoz_basic.py 24 | #fig_photoz_bagging.py 25 | #fig_bayes_DB_2d.py 26 | 27 | -------------------------------------------------------------------------------- /astroML/plotting/settings.py: -------------------------------------------------------------------------------- 1 | def setup_text_plots(fontsize=8, usetex=True): 2 | """ 3 | This function adjusts matplotlib settings so that all figures in the 4 | textbook have a uniform format and look. 5 | """ 6 | import matplotlib 7 | matplotlib.rc('legend', fontsize=fontsize, handlelength=3) 8 | matplotlib.rc('axes', titlesize=fontsize) 9 | matplotlib.rc('axes', labelsize=fontsize) 10 | matplotlib.rc('xtick', labelsize=fontsize) 11 | matplotlib.rc('ytick', labelsize=fontsize) 12 | matplotlib.rc('text', usetex=usetex) 13 | matplotlib.rc('font', size=fontsize, family='serif', 14 | style='normal', variant='normal', 15 | stretch='normal', weight='normal') 16 | -------------------------------------------------------------------------------- /book_figures/chapter3/contents.txt: -------------------------------------------------------------------------------- 1 | fig_prob_sum.py 2 | fig_conditional_probability.py 3 | fig_contingency_table.py 4 | fig_transform_distribution.py 5 | fig_flux_errors.py 6 | fig_kurtosis_skew.py 7 | fig_uniform_distribution.py 8 | fig_gaussian_distribution.py 9 | fig_binomial_distribution.py 10 | fig_poisson_distribution.py 11 | fig_cauchy_distribution.py 12 | fig_cauchy_median_mean.py 13 | fig_laplace_distribution.py 14 | fig_chi2_distribution.py 15 | fig_student_t_distribution.py 16 | fig_fisher_f_distribution.py 17 | fig_beta_distribution.py 18 | fig_gamma_distribution.py 19 | fig_weibull_distribution.py 20 | fig_central_limit.py 21 | fig_uniform_mean.py 22 | fig_bivariate_gaussian.py 23 | fig_robust_pca.py 24 | fig_correlations.py 25 | fig_clone_distribution.py 26 | 27 | -------------------------------------------------------------------------------- /examples/datasets/README.rst: -------------------------------------------------------------------------------- 1 | Data set Examples 2 | ----------------- 3 | These plots show some of the data set loaders available in astroML, and some 4 | of the ways that astronomical data can be visualized and processed using 5 | open source python tools. The dataset loaders are in the submodule 6 | :mod:`astroML.datasets`, and start with the word ``fetch_``. 7 | 8 | The first time a dataset loader is called, it will attempt to download the 9 | dataset from the web and store it locally on disk. The default location 10 | is ``~/astroML_data``, but this location can be changed by specifying an 11 | alternative directory in the ``ASTROML_DATA`` environment variable. On 12 | subsequent calls, the cached version of the data is used. 13 | 14 | For more examples, see the :ref:`figures ` from the textbook. 15 | -------------------------------------------------------------------------------- /astroML/dimensionality/tests/test_iterative_PCA.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_array_almost_equal 3 | from astroML.dimensionality import iterative_pca 4 | 5 | 6 | def test_iterative_PCA(n_samples=50, n_features=40): 7 | np.random.seed(0) 8 | 9 | # construct some data that is well-approximated 10 | # by two principal components 11 | x = np.linspace(0, np.pi, n_features) 12 | x0 = np.linspace(0, np.pi, n_samples) 13 | X = np.sin(x) * np.cos(0.5 * (x - x0[:, None])) 14 | 15 | # mask 10% of the pixels 16 | M = (np.random.random(X.shape) > 0.9) 17 | 18 | # reconstruct and check accuracy 19 | for norm in (None, 'L1', 'L2'): 20 | X_recons = iterative_pca(X, M, n_ev=2, n_iter=10, norm=norm) 21 | 22 | assert_array_almost_equal(X, X_recons, decimal=2) 23 | -------------------------------------------------------------------------------- /book_figures/chapter5/contents.txt: -------------------------------------------------------------------------------- 1 | fig_odds_ratio_coin.py 2 | fig_malmquist_bias.py 3 | fig_lutz_kelker.py 4 | fig_likelihood_gaussian.py 5 | fig_posterior_gaussian.py 6 | fig_distribution_gaussgauss.py 7 | fig_likelihood_gaussgauss.py 8 | fig_posterior_gaussgauss.py 9 | fig_posterior_binomial.py 10 | fig_likelihood_cauchy.py 11 | fig_posterior_cauchy.py 12 | fig_likelihood_uniform.py 13 | fig_likelihood_gausslin.py 14 | fig_poisson_continuous.py 15 | fig_poisson_likelihood.py 16 | fig_poisson_comparison.py 17 | fig_outlier_likelihood.py 18 | fig_outlier_marginalized.py 19 | fig_odds_ratio_cauchy.py 20 | fig_hist_binsize.py 21 | fig_bayes_blocks.py 22 | fig_cauchy_mcmc.py 23 | fig_model_comparison_hist.py 24 | fig_model_comparison_mcmc.py 25 | fig_gaussgauss_mcmc.py 26 | fig_signal_background.py 27 | 28 | #fig_outlier_distribution.py 29 | -------------------------------------------------------------------------------- /CHANGES.rst: -------------------------------------------------------------------------------- 1 | 0.3 2 | === 3 | - Add support for Python 3 4 | - Add continuous integration via Travis 5 | - Bug: correctly account for errors in Ridge/Lasso regression 6 | - Add figure tests in ``compare_images.py`` 7 | 8 | 0.2 9 | === 10 | - Documentation and example updates 11 | - Moved from using ``pyfits`` to using ``astropy.io.fits`` 12 | - Fix the prior for the Bayesian Blocks algorithm 13 | 14 | 0.1.1 15 | ===== 16 | *Bug fixes, January 2013* 17 | - Fixed errors in dataset downloaders: they failed on some platforms 18 | - Added citation information to the website 19 | - Updated figures to reflect those submitted for publication 20 | - Performance improvement in ``freedman_bin_width`` 21 | - Fix setup issue when sklearn is not installed 22 | - Enhancements to ``devectorize_axes`` function 23 | 24 | 0.1 25 | === 26 | *Initial release, October 2012* 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PYTHON ?= python 2 | NOSETESTS ?= nosetests 3 | 4 | SOURCES = Makefile setup.py README.rst astroML 5 | 6 | VERSION = 0.2-git 7 | 8 | all: build install test 9 | 10 | build: 11 | $(PYTHON) setup.py build 12 | 13 | install: 14 | $(PYTHON) setup.py install 15 | 16 | clean: 17 | $(PYTHON) setup.py clean 18 | 19 | inplace: 20 | $(PYTHON) setup.py build_ext -i 21 | 22 | test-code: inplace 23 | $(NOSETESTS) -s astroML 24 | 25 | test-doc: 26 | $(NOSETESTS) -s --with-doctest --doctest-tests --doctest-extension=rst \ 27 | --doctest-extension=inc --doctest-fixtures=_fixture doc/ doc/modules/ 28 | 29 | test-figures: 30 | $(NOSETESTS) astroML_fig_tests 31 | 32 | test-coverage: 33 | rm -rf coverage .coverage 34 | $(NOSETESTS) -s --with-coverage --cover-html --cover-html-dir=coverage \ 35 | --cover-package=sklearn astroML 36 | 37 | test: test-code 38 | -------------------------------------------------------------------------------- /book_figures/chapter10/contents.txt: -------------------------------------------------------------------------------- 1 | fig_rrlyrae_reconstruct.py 2 | fig_convolution_diagram.py 3 | fig_FFT_aliasing.py 4 | fig_FFT_sampling.py 5 | fig_fft_example.py 6 | fig_LIGO_power_spectrum.py 7 | fig_wavelet_PSD.py 8 | fig_line_wavelet_PSD.py 9 | fig_wavelets.py 10 | fig_wiener_filter.py 11 | fig_wiener_kernel.py 12 | fig_mincomp_procedure.py 13 | fig_mincomp.py 14 | fig_sampling.py 15 | fig_LS_example.py 16 | fig_LS_sg_comparison.py 17 | fig_LINEAR_LS.py 18 | fig_LS_double_eclipse.py 19 | fig_LINEAR_BIC.py 20 | fig_LINEAR_clustering.py 21 | fig_LINEAR_clustering.py # twice on purpose 22 | fig_LINEAR_GMMBayes.py 23 | fig_LINEAR_SVM.py 24 | fig_arrival_time.py 25 | fig_matchedfilt_burst.py 26 | fig_matchedfilt_chirp.py 27 | fig_matchedfilt_chirp2.py 28 | fig_chirp2_PSD.py 29 | fig_powerlaw.py 30 | fig_autocorrelation.py 31 | 32 | #fig_LS_comparison.py 33 | #fig_LIGO_bandpower.py 34 | #fig_LIGO_wavelets.py 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - 2.7 5 | - 3.4 6 | 7 | env: 8 | - DEPS="numpy scipy scikit-learn astropy nose matplotlib pymc" 9 | 10 | install: 11 | - conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION 12 | - source activate testenv 13 | - conda install --yes $DEPS 14 | - pip install astroML_addons 15 | - python setup.py install 16 | 17 | before_install: 18 | # then install python version to test 19 | - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-2.2.2-Linux-x86_64.sh -O miniconda.sh; fi 20 | - chmod +x miniconda.sh 21 | - ./miniconda.sh -b 22 | - export PATH=/home/travis/anaconda/bin:$PATH 23 | # miniconda is not always up-to-date with conda. 24 | - conda update --yes conda 25 | 26 | script: 27 | - nosetests astroML 28 | -------------------------------------------------------------------------------- /doc/includes/big_toc_css.rst: -------------------------------------------------------------------------------- 1 | .. 2 | File to ..include in a document with a big table of content, to give 3 | it 'style' 4 | 5 | .. raw:: html 6 | 7 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /astroML/tests/test_pickle_results.py: -------------------------------------------------------------------------------- 1 | import os 2 | from astroML.decorators import pickle_results 3 | 4 | 5 | def test_pickle_results(): 6 | filename = 'tmp.pkl' 7 | 8 | @pickle_results('tmp.pkl') 9 | def foo(x): 10 | foo.called = True 11 | return x * x 12 | 13 | # cleanup if necessary 14 | if os.path.exists(filename): 15 | os.remove(filename) 16 | 17 | # initial calculation: function should be executed 18 | foo.called = False 19 | assert foo(4) == 16 20 | assert foo.called is True 21 | 22 | # recalculation: function should not be executed 23 | foo.called = False 24 | assert foo(4) == 16 25 | assert foo.called is False 26 | 27 | # recalculation with different input: function should be executed 28 | foo.called = False 29 | assert foo(5) == 25 30 | assert foo.called is True 31 | 32 | # cleanup 33 | assert os.path.exists(filename) 34 | os.remove(filename) 35 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/test_empirical.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose 3 | from scipy.stats import norm 4 | from astroML.density_estimation import\ 5 | EmpiricalDistribution, FunctionDistribution 6 | 7 | 8 | def test_empirical_distribution(N=1000, rseed=0): 9 | np.random.seed(rseed) 10 | X = norm.rvs(0, 1, size=N) 11 | dist = EmpiricalDistribution(X) 12 | X2 = dist.rvs(N) 13 | 14 | meanX = X.mean() 15 | meanX2 = X2.mean() 16 | 17 | stdX = X.std() 18 | stdX2 = X2.std() 19 | 20 | assert_allclose([meanX, stdX], [meanX2, stdX2], atol=3 / np.sqrt(N)) 21 | 22 | 23 | def test_function_distribution(N=1000, rseed=0): 24 | f = norm(0, 1).pdf 25 | # go from -10 to 10 to check interpolation in presence of zeros 26 | dist = FunctionDistribution(f, -10, 10) 27 | 28 | np.random.seed(rseed) 29 | X = dist.rvs(N) 30 | 31 | meanX = X.mean() 32 | stdX = X.std() 33 | 34 | assert_allclose([meanX, stdX], [0, 1], atol=3 / np.sqrt(N)) 35 | -------------------------------------------------------------------------------- /book_figures/README: -------------------------------------------------------------------------------- 1 | This is the directory which holds code to generate figures. The layout is as 2 | follows: 3 | 4 | The chapter directories should be called 5 | chapter1/ 6 | chapter2/ 7 | chapter3/ 8 | etc. 9 | 10 | Inside each chapter directory are plotting scripts, which must be of the form 11 | 12 | fig_*.py 13 | 14 | The `*` should be a concise & unique descriptor of the file (it will be used 15 | as the image file name). Each chapter should also have a file called 16 | `contents.txt` in which each line is the name of a file in the directory. 17 | Comments are marked with a #. This will control the order that the figures 18 | are created on the page. 19 | 20 | Additionally, each directory can have a header file `header.rst` which gives 21 | information about the chapter. If this does not exist, then a basic header 22 | will be created. 23 | 24 | Summary: 25 | to add a new figure: 26 | create a script called chapter*/fig_*.py, where the *'s are suitably replaced 27 | in the contents.txt file of the directory, add `fig_*py` to the list in the 28 | appropriate place. -------------------------------------------------------------------------------- /astroML/datasets/tools/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | tools for the dataset loaders 3 | """ 4 | 5 | from .download import download_with_progress_bar 6 | from .sql_query import sql_query 7 | from .cas_query import * 8 | from .sdss_fits import sdss_fits_url, sdss_fits_filename, SDSSfits 9 | 10 | 11 | def get_data_home(data_home=None): 12 | """Get the home data directory. 13 | 14 | By default the data dir is set to a folder named 'astroML_data' 15 | in the user home folder. 16 | 17 | Alternatively, it can be set by the 'ASTROML_DATA' environment 18 | variable or programatically by giving an explit folder path. The 19 | '~' symbol is expanded to the user home folder. 20 | 21 | If the folder does not already exist, it is automatically created. 22 | """ 23 | import os 24 | if data_home is None: 25 | data_home = os.environ.get('ASTROML_DATA', 26 | os.path.join('~', 'astroML_data')) 27 | data_home = os.path.expanduser(data_home) 28 | if not os.path.exists(data_home): 29 | os.makedirs(data_home) 30 | return data_home 31 | -------------------------------------------------------------------------------- /astroML/plotting/ellipse.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def plot_tissot_ellipse(longitude, latitude, radius, ax=None, **kwargs): 5 | """Plot Tissot Ellipse/Tissot Indicatrix 6 | 7 | Parameters 8 | ---------- 9 | longitude : float or array_like 10 | longitude of ellipse centers (radians) 11 | latitude : float or array_like 12 | latitude of ellipse centers (radians) 13 | radius : float or array_like 14 | radius of ellipses 15 | ax : Axes object (optional) 16 | matplotlib axes instance on which to draw ellipses. 17 | 18 | Other Parameters 19 | ---------------- 20 | other keyword arguments will be passed to matplotlib.patches.Ellipse. 21 | """ 22 | # Import here so that testing with Agg will work 23 | from matplotlib import pyplot as plt 24 | from matplotlib.patches import Ellipse 25 | 26 | if ax is None: 27 | ax = plt.gca() 28 | 29 | for long, lat, rad in np.broadcast(longitude, latitude, radius): 30 | el = Ellipse((long, lat), radius / np.cos(lat), radius, **kwargs) 31 | ax.add_patch(el) 32 | -------------------------------------------------------------------------------- /astroML/datasets/tools/sql_query.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tools to perform a SQL queries to an online server. 3 | Default values are provided for http://cas.sdss.org 4 | """ 5 | from ...py3k_compat import urlencode, urlopen 6 | 7 | PUBLIC_URL = 'http://cas.sdss.org/public/en/tools/search/x_sql.aspx' 8 | DEFAULT_FMT = 'csv' 9 | 10 | 11 | def remove_sql_comments(sql): 12 | """Strip SQL comments starting with --""" 13 | return ' \n'.join(map(lambda x: x.split('--')[0], sql.split('\n'))) 14 | 15 | 16 | def sql_query(sql_str, url=PUBLIC_URL, format='csv'): 17 | """Execute query 18 | 19 | Parameters 20 | ---------- 21 | sql_str : string 22 | valid sql query 23 | 24 | url: string (optional) 25 | query url. Default is http://cas.sdss.org query script 26 | 27 | format: string (default='csv') 28 | query output format 29 | 30 | Returns 31 | ------- 32 | F: file object 33 | results of the query 34 | """ 35 | sql_str = remove_sql_comments(sql_str) 36 | params = urlencode(dict(cmd=sql_str, format=format)) 37 | return urlopen(url + '?%s' % params) 38 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/test_density.py: -------------------------------------------------------------------------------- 1 | """ 2 | Test density estimation techniques 3 | """ 4 | import numpy as np 5 | from numpy.testing import assert_allclose 6 | from scipy.stats import norm 7 | from astroML.density_estimation import KDE, KNeighborsDensity 8 | 9 | 10 | def check_1D_density(clf, X, X2, true_dens, atol): 11 | clf.fit(X) 12 | dens = clf.eval(X2) 13 | 14 | assert_allclose(dens, true_dens, atol=atol) 15 | 16 | 17 | def test_1D_density(): 18 | np.random.seed(0) 19 | dist = norm(0, 1) 20 | 21 | X = dist.rvs((5000, 1)) 22 | X2 = np.linspace(-5, 5, 10).reshape((10, 1)) 23 | true_dens = dist.pdf(X2[:, 0]) * X.shape[0] 24 | 25 | classifiers = [KDE('gaussian', h=0.1), 26 | KDE('tophat', h=0.2), 27 | KDE('exponential', h=0.1), 28 | KDE('quadratic', h=0.2), 29 | KNeighborsDensity(method='simple', n_neighbors=250), 30 | KNeighborsDensity(method='bayesian', n_neighbors=250)] 31 | 32 | for clf in classifiers: 33 | yield (check_1D_density, clf, X, X2, true_dens, 100) 34 | -------------------------------------------------------------------------------- /astroML/plotting/tests/test_devectorize.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | matplotlib.use('Agg') # don't display plots 3 | 4 | import numpy as np 5 | from numpy.testing import assert_ 6 | from matplotlib import image 7 | import matplotlib.pyplot as plt 8 | 9 | from astroML.py3k_compat import BytesIO 10 | from astroML.plotting.tools import devectorize_axes 11 | 12 | 13 | def test_devectorize_axes(): 14 | np.random.seed(0) 15 | 16 | x, y = np.random.random((2, 1000)) 17 | 18 | # save vectorized version 19 | fig = plt.figure() 20 | ax = fig.add_subplot(111) 21 | ax.scatter(x, y) 22 | output = BytesIO() 23 | fig.savefig(output) 24 | output.seek(0) 25 | im1 = image.imread(output) 26 | plt.close() 27 | 28 | # save devectorized version 29 | fig = plt.figure() 30 | ax = fig.add_subplot(111) 31 | ax.scatter(x, y) 32 | devectorize_axes(ax, dpi=200) 33 | output = BytesIO() 34 | fig.savefig(output) 35 | output.seek(0) 36 | im2 = image.imread(output) 37 | plt.close() 38 | 39 | assert_(im1.shape == im2.shape) 40 | assert_((im1 != im2).sum() < 0.1 * im1.size) 41 | -------------------------------------------------------------------------------- /astroML/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Astronomy Datasets 3 | ------------------ 4 | """ 5 | 6 | from .tools import get_data_home 7 | from .sdss_S82standards import fetch_sdss_S82standards 8 | from .dr7_quasar import fetch_dr7_quasar 9 | from .moving_objects import fetch_moving_objects 10 | from .sdss_galaxy_colors import fetch_sdss_galaxy_colors 11 | from .sdss_spectrum import fetch_sdss_spectrum 12 | from .sdss_corrected_spectra import fetch_sdss_corrected_spectra 13 | from .nasa_atlas import fetch_nasa_atlas 14 | from .sdss_sspp import fetch_sdss_sspp 15 | from .sdss_specgals import fetch_sdss_specgals, fetch_great_wall 16 | from .imaging_sample import fetch_imaging_sample 17 | from .wmap_temperatures import fetch_wmap_temperatures 18 | from .rrlyrae_mags import fetch_rrlyrae_mags, fetch_rrlyrae_combined 19 | from .LINEAR_sample import fetch_LINEAR_sample, fetch_LINEAR_geneva 20 | from .LIGO_bigdog import fetch_LIGO_bigdog, fetch_LIGO_large 21 | from .generated import generate_mu_z 22 | from .hogg2010test import fetch_hogg2010test 23 | from .rrlyrae_templates import fetch_rrlyrae_templates 24 | from .sdss_filters import fetch_sdss_filter, fetch_vega_spectrum 25 | -------------------------------------------------------------------------------- /astroML/py3k_compat.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compatibility utilities for Python 2 & 3 3 | """ 4 | 5 | import sys 6 | py3k = (sys.version_info[0] == 3) 7 | 8 | #---------------------------------------------------------------------- 9 | # urllib stuff 10 | 11 | if py3k: 12 | from urllib.request import urlopen 13 | from urllib.error import HTTPError 14 | from urllib.parse import urlencode 15 | else: 16 | from urllib2 import urlopen 17 | from urllib2 import HTTPError 18 | from urllib import urlencode 19 | 20 | def url_content_length(fhandle): 21 | if py3k: 22 | length = dict(fhandle.info())['Content-Length'] 23 | else: 24 | length = fhandle.info().getheader('Content-Length') 25 | return int(length.strip()) 26 | 27 | 28 | #---------------------------------------------------------------------- 29 | # pickle stuff 30 | if py3k: 31 | from pickle import load, dump 32 | else: 33 | from cPickle import load, dump 34 | 35 | #---------------------------------------------------------------------- 36 | # StringIO 37 | if py3k: 38 | from io import StringIO, BytesIO 39 | else: 40 | from cStringIO import StringIO 41 | from cStringIO import StringIO as BytesIO 42 | -------------------------------------------------------------------------------- /examples/datasets/plot_wmap_raw.py: -------------------------------------------------------------------------------- 1 | """ 2 | WMAP plotting with HEALPix 3 | -------------------------- 4 | This example uses the :func:`astromL.datasets.fetch_wmap_temperatures` 5 | functionality to download and plot the raw WMAP 7-year data. The 6 | visualization requires the `healpy `_ 7 | package to be installed. 8 | """ 9 | # Author: Jake VanderPlas 10 | # License: BSD 11 | # The figure is an example from astroML: see http://astroML.github.com 12 | import numpy as np 13 | from matplotlib import pyplot as plt 14 | 15 | # warning: due to a bug in healpy, importing it before pylab can cause 16 | # a segmentation fault in some circumstances. 17 | import healpy as hp 18 | 19 | from astroML.datasets import fetch_wmap_temperatures 20 | 21 | #------------------------------------------------------------ 22 | # Fetch the wmap data 23 | wmap_unmasked = fetch_wmap_temperatures(masked=False) 24 | 25 | #------------------------------------------------------------ 26 | # plot the unmasked map 27 | fig = plt.figure(1) 28 | hp.mollview(wmap_unmasked, min=-1, max=1, title='Raw WMAP data', 29 | fig=1, cmap=plt.cm.jet, unit=r'$\Delta$T (mK)') 30 | plt.show() 31 | -------------------------------------------------------------------------------- /astroML/tests/test_filters.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose 3 | from astroML.filters import savitzky_golay, wiener_filter 4 | 5 | 6 | def test_savitzky_golay(): 7 | y = np.zeros(100) 8 | y[::2] = 1 9 | f = savitzky_golay(y, window_size=3, order=1) 10 | assert_allclose(f, (2 - y) / 3.) 11 | 12 | 13 | def test_savitzky_golay_fft(): 14 | y = np.random.normal(size=100) 15 | 16 | for width in [3, 5]: 17 | for order in range(width - 1): 18 | f1 = savitzky_golay(y, width, order, use_fft=False) 19 | f2 = savitzky_golay(y, width, order, use_fft=True) 20 | assert_allclose(f1, f2) 21 | 22 | 23 | def test_wiener_filter_simple(): 24 | t = np.linspace(0, 1, 256) 25 | h = np.zeros_like(t) 26 | h[::2] = 1000 27 | s = wiener_filter(t, h) 28 | assert_allclose(s, np.mean(h)) 29 | 30 | 31 | def test_wienter_filter_spike(): 32 | np.random.seed(0) 33 | N = 2048 34 | dt = 0.05 35 | 36 | t = dt * np.arange(N) 37 | h = np.exp(-0.5 * ((t - 20.) / 1.0) ** 2) + 10 38 | hN = h + np.random.normal(0, 0.05, size=h.shape) 39 | h_smooth = wiener_filter(t, hN) 40 | 41 | assert_allclose(h, h_smooth, atol=0.03) 42 | -------------------------------------------------------------------------------- /examples/datasets/plot_great_wall.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS "Great Wall" 3 | ----------------- 4 | Plotting the SDSS "great wall", a filament of galaxies visible by-eye in the 5 | projected locations of the SDSS spectroscopic galaxy sample. 6 | This follows a similar procedure to [1]_, 7 | 8 | References 9 | ---------- 10 | .. [1] http://adsabs.harvard.edu/abs/2008ApJ...674L..13C 11 | """ 12 | # Author: Jake VanderPlas 13 | # License: BSD 14 | # The figure is an example from astroML: see http://astroML.github.com 15 | import numpy as np 16 | from matplotlib import pyplot as plt 17 | 18 | from astroML.datasets import fetch_great_wall 19 | from astroML.density_estimation import KDE, KNeighborsDensity 20 | 21 | #------------------------------------------------------------ 22 | # Fetch the great wall data 23 | X = fetch_great_wall() 24 | 25 | #------------------------------------------------------------ 26 | # Plot the results 27 | fig = plt.figure(figsize=(8, 4)) 28 | 29 | # First plot: scatter the points 30 | ax = plt.subplot(111, aspect='equal') 31 | ax.scatter(X[:, 1], X[:, 0], s=1, lw=0, c='k') 32 | 33 | ax.set_xlim(-300, 200) 34 | ax.set_ylim(-375, -175) 35 | 36 | ax.set_xlabel('y (Mpc)') 37 | ax.set_ylabel('x (MPC)') 38 | 39 | plt.show() 40 | -------------------------------------------------------------------------------- /CITATION: -------------------------------------------------------------------------------- 1 | If you make use of any of these datasets, tools, or examples in a scientific 2 | publication, please consider citing astroML. You may reference the following 3 | paper: 4 | 5 | - Introduction to astroML: Machine learning for astrophysics 6 | 7 | http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6382200&tag=1 8 | 9 | Bibtex entry: 10 | 11 | @INPROCEEDINGS{astroML, 12 | author={{Vanderplas}, J.T. and {Connolly}, A.J. 13 | and {Ivezi{\'c}}, {\v Z}. and {Gray}, A.}, 14 | booktitle={Conference on Intelligent Data Understanding (CIDU)}, 15 | title={Introduction to astroML: Machine learning for astrophysics}, 16 | month={oct.}, 17 | pages={47 -54}, 18 | doi={10.1109/CIDU.2012.6382200}, 19 | year={2012} 20 | } 21 | 22 | You may also reference the accompanying textbook: 23 | 24 | 25 | Statistics, Data Mining, and Machine Learning for Astronomy 26 | http://press.princeton.edu/titles/10159.html 27 | 28 | Bibtex entry: 29 | 30 | @BOOK{astroMLText, 31 | title={Statistics, Data Mining and Machine Learning in Astronomy}, 32 | author={{Ivezi{\'c}}, {\v Z}. and {Connolly}, A.J. 33 | and {Vanderplas}, J.T. and {Gray}, A.}, 34 | publisher={Princeton University Press}, 35 | location={Princeton, NJ}, 36 | year={2014} 37 | } 38 | 39 | -------------------------------------------------------------------------------- /examples/datasets/plot_rrlyrae_mags.py: -------------------------------------------------------------------------------- 1 | """ 2 | RR-Lyrae Magnitudes 3 | ------------------- 4 | This example downloads and plots the colors of RR Lyrae stars along with those 5 | of the non-variable stars. Several of the classification examples in the 6 | book figures use this dataset. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure is an example from astroML: see http://astroML.github.com 11 | import numpy as np 12 | from matplotlib import pyplot as plt 13 | 14 | from astroML.datasets import fetch_rrlyrae_combined 15 | 16 | #---------------------------------------------------------------------- 17 | # get data and split into training & testing sets 18 | X, y = fetch_rrlyrae_combined() 19 | 20 | X = X[-5000:] 21 | y = y[-5000:] 22 | 23 | stars = (y == 0) 24 | rrlyrae = (y == 1) 25 | 26 | #------------------------------------------------------------ 27 | # plot the results 28 | ax = plt.axes() 29 | 30 | ax.plot(X[stars, 0], X[stars, 1], '.', ms=5, c='b', label='stars') 31 | ax.plot(X[rrlyrae, 0], X[rrlyrae, 1], '.', ms=5, c='r', label='RR-Lyrae') 32 | 33 | ax.legend(loc=3) 34 | 35 | ax.set_xlabel('$u-g$') 36 | ax.set_ylabel('$g-r$') 37 | 38 | ax.set_xlim(0.7, 1.4) 39 | ax.set_ylim(-0.2, 0.4) 40 | 41 | plt.show() 42 | -------------------------------------------------------------------------------- /LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013, Jacob Vanderplas 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /examples/datasets/plot_corrected_spectra.py: -------------------------------------------------------------------------------- 1 | """ 2 | Corrected Spectra 3 | ----------------- 4 | The script examples/datasets/compute_sdss_pca.py uses an iterative PCA 5 | technique to reconstruct masked regions of SDSS spectra. Several of the 6 | resulting spectra are shown below. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure is an example from astroML: see http://astroML.github.com 11 | import numpy as np 12 | import matplotlib.pyplot as plt 13 | 14 | from astroML.datasets import sdss_corrected_spectra 15 | 16 | #------------------------------------------------------------ 17 | # Fetch the data 18 | data = sdss_corrected_spectra.fetch_sdss_corrected_spectra() 19 | spectra = sdss_corrected_spectra.reconstruct_spectra(data) 20 | lam = sdss_corrected_spectra.compute_wavelengths(data) 21 | 22 | #------------------------------------------------------------ 23 | # Plot several spectra 24 | fig = plt.figure(figsize=(8, 8)) 25 | 26 | fig.subplots_adjust(hspace=0) 27 | 28 | for i in range(5): 29 | ax = fig.add_subplot(511 + i) 30 | ax.plot(lam, spectra[i], '-k') 31 | 32 | if i < 4: 33 | ax.xaxis.set_major_formatter(plt.NullFormatter()) 34 | else: 35 | ax.set_xlabel('wavelength $(\AA)$') 36 | 37 | ax.yaxis.set_major_formatter(plt.NullFormatter()) 38 | ax.set_ylabel('flux') 39 | 40 | plt.show() 41 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/test_hist_binwidth.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose, assert_ 3 | from astroML.density_estimation import \ 4 | scotts_bin_width, freedman_bin_width, knuth_bin_width, histogram 5 | 6 | 7 | def test_scotts_bin_width(N=10000, rseed=0): 8 | np.random.seed(rseed) 9 | X = np.random.normal(size=N) 10 | delta = scotts_bin_width(X) 11 | 12 | assert_allclose(delta, 3.5 * np.std(X) / N ** (1. / 3)) 13 | 14 | 15 | def test_freedman_bin_width(N=10000, rseed=0): 16 | np.random.seed(rseed) 17 | X = np.random.normal(size=N) 18 | delta = freedman_bin_width(X) 19 | 20 | indices = np.argsort(X) 21 | i25 = indices[N / 4 - 1] 22 | i75 = indices[(3 * N) / 4 - 1] 23 | 24 | assert_allclose(delta, 2 * (X[i75] - X[i25]) / N ** (1. / 3)) 25 | 26 | 27 | def test_knuth_bin_width(N=10000, rseed=0): 28 | np.random.seed(0) 29 | X = np.random.normal(size=N) 30 | dx, bins = knuth_bin_width(X, return_bins=True) 31 | assert_allclose(len(bins), 59) 32 | 33 | 34 | def test_histogram(N=1000, rseed=0): 35 | np.random.seed(0) 36 | x = np.random.normal(0, 1, N) 37 | 38 | for bins in [30, np.linspace(-5, 5, 31), 39 | 'knuth', 'scotts', 'freedman']: 40 | counts, bins = histogram(x, bins) 41 | assert_(counts.sum() == len(x)) 42 | assert_(len(counts) == len(bins) - 1) 43 | -------------------------------------------------------------------------------- /examples/datasets/plot_dr7_quasar.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Data Release 7 Quasar catalog 3 | ---------------------------------- 4 | 5 | This demonstrates how to fetch and visualize the colors from the SDSS DR7 6 | quasar sample. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure is an example from astroML: see http://astroML.github.com 11 | import numpy as np 12 | from matplotlib import pyplot as plt 13 | 14 | from astroML.plotting import MultiAxes 15 | from astroML.datasets import fetch_dr7_quasar 16 | 17 | data = fetch_dr7_quasar() 18 | 19 | colors = np.empty((len(data), 5)) 20 | 21 | colors[:, 0] = data['mag_u'] - data['mag_g'] 22 | colors[:, 1] = data['mag_g'] - data['mag_r'] 23 | colors[:, 2] = data['mag_r'] - data['mag_i'] 24 | colors[:, 3] = data['mag_i'] - data['mag_z'] 25 | colors[:, 4] = data['mag_z'] - data['mag_J'] 26 | 27 | labels = ['u-g', 'g-r', 'r-i', 'i-z', 'z-J'] 28 | 29 | bins = [np.linspace(-0.4, 1.0, 100), 30 | np.linspace(-0.4, 1.0, 100), 31 | np.linspace(-0.3, 0.6, 100), 32 | np.linspace(-0.4, 0.7, 100), 33 | np.linspace(0, 2.2, 100)] 34 | 35 | ax = MultiAxes(5, wspace=0.05, hspace=0.05, 36 | fig=plt.figure(figsize=(10, 10))) 37 | ax.density(colors, bins) 38 | ax.set_labels(labels) 39 | ax.set_locators(plt.MaxNLocator(5)) 40 | plt.suptitle('SDSS DR7 Quasar Colors', fontsize=18) 41 | 42 | plt.show() 43 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_spectrum.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Spectrum Example 3 | --------------------- 4 | This example shows how to fetch and plot a spectrum from the SDSS database 5 | using the plate, MJD, and fiber numbers. The code below sends a query to 6 | the SDSS server for the given plate, fiber, and mjd, downloads the spectrum, 7 | and plots the result. 8 | """ 9 | # Author: Jake VanderPlas 10 | # License: BSD 11 | # The figure is an example from astroML: see http://astroML.github.com 12 | from matplotlib import pyplot as plt 13 | from astroML.datasets import fetch_sdss_spectrum 14 | 15 | #------------------------------------------------------------ 16 | # Fetch single spectrum 17 | plate = 1615 18 | mjd = 53166 19 | fiber = 513 20 | 21 | spec = fetch_sdss_spectrum(plate, mjd, fiber) 22 | 23 | #------------------------------------------------------------ 24 | # Plot the resulting spectrum 25 | ax = plt.axes() 26 | ax.plot(spec.wavelength(), spec.spectrum, '-k', label='spectrum') 27 | ax.plot(spec.wavelength(), spec.error, '-', color='gray', label='error') 28 | 29 | ax.legend(loc=4) 30 | 31 | ax.set_title('Plate = %(plate)i, MJD = %(mjd)i, Fiber = %(fiber)i' % locals()) 32 | 33 | ax.text(0.05, 0.95, 'z = %.2f' % spec.z, size=16, 34 | ha='left', va='top', transform=ax.transAxes) 35 | 36 | ax.set_xlabel(r'$\lambda (\AA)$') 37 | ax.set_ylabel('Flux') 38 | 39 | ax.set_ylim(-10, 300) 40 | 41 | plt.show() 42 | -------------------------------------------------------------------------------- /astroML/clustering/tests/test_MST_clustering.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_, assert_allclose 3 | from astroML.clustering import HierarchicalClustering, get_graph_segments 4 | 5 | 6 | def test_simple_clustering(): 7 | np.random.seed(0) 8 | N = 10 9 | X = np.random.random((N, 2)) 10 | model = HierarchicalClustering(8, edge_cutoff=0.5) 11 | model.fit(X) 12 | 13 | assert_(model.n_components_ == N / 2) 14 | assert_(np.sum(model.full_tree_.toarray() > 0) == N - 1) 15 | assert_(np.sum(model.cluster_graph_.toarray() > 0) == N / 2) 16 | assert_allclose(np.unique(model.labels_), np.arange(N / 2)) 17 | 18 | 19 | def test_cluster_cutoff(): 20 | np.random.seed(0) 21 | N = 100 22 | X = np.random.random((N, 2)) 23 | model = HierarchicalClustering(8, edge_cutoff=0.9, min_cluster_size=10) 24 | model.fit(X) 25 | 26 | assert_allclose(np.unique(model.labels_), 27 | np.arange(-1, model.n_components_)) 28 | 29 | 30 | def test_graph_segments(): 31 | np.random.seed(0) 32 | N = 4 33 | X = np.random.random((N, 2)) 34 | G = np.zeros([N, N]) 35 | G[0, 1] = 1 36 | G[2, 1] = 1 37 | G[2, 3] = 1 38 | 39 | ind = np.array([[0, 2, 2], 40 | [1, 1, 3]]) 41 | xseg_check = X[ind, 0] 42 | yseg_check = X[ind, 1] 43 | 44 | xseg, yseg = get_graph_segments(X, G) 45 | 46 | assert_allclose(xseg, xseg_check) 47 | assert_allclose(yseg, yseg_check) 48 | -------------------------------------------------------------------------------- /astroML/density_estimation/gauss_mixture.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.mixture import GMM 3 | 4 | 5 | class GaussianMixture1D(object): 6 | """ 7 | Simple class to work with 1D mixtures of Gaussians 8 | 9 | Parameters 10 | ---------- 11 | means : array_like 12 | means of component distributions (default = 0) 13 | sigmas : array_like 14 | standard deviations of component distributions (default = 1) 15 | weights : array_like 16 | weight of component distributions (default = 1) 17 | """ 18 | def __init__(self, means=0, sigmas=1, weights=1): 19 | data = np.array([t for t in np.broadcast(means, sigmas, weights)]) 20 | 21 | self._gmm = GMM(data.shape[0]) 22 | self._gmm.fit = None # disable fit method for safety 23 | 24 | self._gmm.means_ = data[:, :1] 25 | self._gmm.covars_ = data[:, 1:2] ** 2 26 | self._gmm.weights = data[:, 2] / data[:, 2].sum() 27 | 28 | def sample(self, size): 29 | """Random sample""" 30 | return self._gmm.sample(size) 31 | 32 | def pdf(self, x): 33 | """Compute probability distribution""" 34 | logprob, responsibilities = self._gmm.eval(x) 35 | return np.exp(logprob) 36 | 37 | def pdf_individual(self, x): 38 | """Compute probability distribution of each component""" 39 | logprob, responsibilities = self._gmm.eval(x) 40 | return responsibilities * np.exp(logprob[:, np.newaxis]) 41 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | ================= 2 | AstroML todo list 3 | ================= 4 | 5 | plot_figures: make book title correct! 194 times... 6 | 7 | examples: cleanup 8 | - datasets 9 | - tools shown in CIDU 10 | - plotting/histograms 11 | 12 | Core Package 13 | ------------ 14 | XD code:https://twitter.com/ 15 | - include mixing matrix (in original paper) 16 | - submit to scikit-learn? 17 | 18 | Bayesian Blocks code: 19 | - other priors 20 | - other fitness functions 21 | 22 | KDE: 23 | - build-in cross-validation 24 | - KDE with errors 25 | 26 | Web Page 27 | -------- 28 | - add index of CIDU plots to web page 29 | - chapter/figures order in index 30 | - modify gen_rst to use thumbnails on index page, full size on code page. 31 | - Think about suggested exercises with our code and data 32 | 33 | Lomb-scargle: 34 | - optimize with extirpolation 35 | - write documentation 36 | - write tests 37 | 38 | Extreme Deconvolution: 39 | - regularization (look at how GMM does this) 40 | - optimize linear algebra 41 | - allow for automatic treatment of diagonal variance 42 | - allow for covariance_type argument as in GMM 43 | - better documentation 44 | - tests 45 | - submit to scikit-learn? 46 | 47 | Utilities: 48 | - look through code examples; find often-used subroutines 49 | 50 | Misc: 51 | - clean up MCMC log(sigma) priors (use @pymc.deterministic) 52 | 53 | Website: 54 | - Link to code and instructions for installation 55 | - List and link to dependencies 56 | - Show thumbnails on figure index 57 | 58 | -------------------------------------------------------------------------------- /doc/logos/plot_logo.py: -------------------------------------------------------------------------------- 1 | """ 2 | NASA Sloan Atlas 3 | ---------------- 4 | 5 | This shows some visualizations of the data from the NASA SDSS Atlas 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | import numpy as np 11 | from matplotlib import pyplot as plt 12 | from matplotlib.font_manager import FontProperties 13 | 14 | from astroML.datasets import fetch_nasa_atlas 15 | 16 | data = fetch_nasa_atlas() 17 | 18 | #------------------------------------------------------------ 19 | # plot the RA/DEC in an area-preserving projection 20 | 21 | RA = data['RA'] 22 | DEC = data['DEC'] 23 | 24 | # convert coordinates to degrees 25 | RA -= 180 26 | RA *= np.pi / 180 27 | DEC *= np.pi / 180 28 | 29 | fig = plt.figure(figsize=(8, 2), facecolor='w') 30 | ax = fig.add_axes([0.56, 0.1, 0.4, 0.8], projection='mollweide') 31 | plt.scatter(RA, DEC, s=1, lw=0, c=data['Z'], cmap=plt.cm.copper) 32 | plt.grid(True) 33 | ax.xaxis.set_major_formatter(plt.NullFormatter()) 34 | ax.yaxis.set_major_formatter(plt.NullFormatter()) 35 | 36 | font = {'family' : 'neuropol X', 37 | 'color' : '#222222', 38 | 'weight' : 'normal', 39 | 'size' : 135, 40 | } 41 | fig.text(0.5, 0.5, 'astroML', ha='center', va='center', 42 | fontdict=font) 43 | #size=135, 44 | #fontproperties=FontProperties(['neuropol X bold', 'neuropol X'])) 45 | 46 | plt.savefig('logo.png') 47 | 48 | plt.show() 49 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/test_xdeconv.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose 3 | from astroML.density_estimation import XDGMM 4 | 5 | 6 | def test_XDGMM_1D_gaussian(N=100, sigma=0.1): 7 | np.random.seed(0) 8 | mu = 0 9 | V = 1 10 | 11 | X = np.random.normal(mu, V, size=(N, 1)) 12 | X += np.random.normal(0, sigma, size=(N, 1)) 13 | Xerr = sigma ** 2 * np.ones((N, 1, 1)) 14 | 15 | xdgmm = XDGMM(1).fit(X, Xerr) 16 | 17 | # because of sample variance, results will be similar 18 | # but not identical. We'll use a fudge factor of 0.1 19 | assert_allclose(mu, xdgmm.mu[0], atol=0.1) 20 | assert_allclose(V, xdgmm.V[0], atol=0.1) 21 | 22 | 23 | def check_single_gaussian(N=100, D=3, sigma=0.1): 24 | np.random.seed(0) 25 | mu = np.random.random(D) 26 | V = np.random.random((D, D)) 27 | V = np.dot(V, V.T) 28 | 29 | X = np.random.multivariate_normal(mu, V, size=N) 30 | Xerr = np.zeros((N, D, D)) 31 | Xerr[:, range(D), range(D)] = sigma ** 2 32 | 33 | X += np.random.normal(0, sigma, X.shape) 34 | 35 | xdgmm = XDGMM(1) 36 | xdgmm.fit(X, Xerr) 37 | 38 | # because of sample variance, results will be similar 39 | # but not identical. We'll use a fudge factor of 0.1 40 | assert_allclose(mu, xdgmm.mu[0], atol=0.1) 41 | assert_allclose(V, xdgmm.V[0], atol=0.1) 42 | 43 | 44 | def test_single_gaussian(N=100, sigma=0.1): 45 | for D in (1, 2, 3): 46 | yield (check_single_gaussian, N, D, sigma) 47 | -------------------------------------------------------------------------------- /doc/user_guide/resources.rst: -------------------------------------------------------------------------------- 1 | Other Resources 2 | =============== 3 | 4 | **Scikit-learn astronomy tutorial:** ``_ 5 | This is an online tutorial which introduces the scikit-learn interface and 6 | the fundamental ideas of machine learning, and applies them within the 7 | context of astronomical data analysis. It includes several videos of the 8 | tutorial being presented at conferences. 9 | 10 | **Scikit-learn documentation:** ``_ 11 | The scikit-learn documentation is extensive, and features detailed 12 | information on many of the routines used in the astroML examples. 13 | 14 | **Matplotlib documentation:** ``_ 15 | Matplotlib enables all the plots on this website, and its website includes 16 | extensive documentation and examples. See especially the example gallery. 17 | 18 | **IPython documentation:** ``_ 19 | IPython is is an enhanced interactive python interpreter, and also 20 | provides a framework for parallel computing and cross-platform sharing 21 | of code and results. It is an essential tool for any scientific 22 | python user. 23 | 24 | **Python scientific lecture notes:** ``_ 25 | These notes cover some of the basics of scientific python, including 26 | numpy, scipy, and matplotlib. From there they move into an in-depth 27 | exploration of more advanced and specialized topics in scientific 28 | computing. 29 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_galaxy_colors.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Galaxy Colors 3 | ------------------ 4 | The function :func:`fetch_sdss_galaxy_colors` used below actually queries 5 | the SDSS CASjobs server for the colors of the 50,000 galaxies. Below we 6 | extract the :math:`u - g` and :math:`g - r` colors for 5000 stars, and 7 | scatter-plot the results 8 | """ 9 | # Author: Jake VanderPlas 10 | # License: BSD 11 | # The figure is an example from astroML: see http://astroML.github.com 12 | import numpy as np 13 | from matplotlib import pyplot as plt 14 | 15 | from sklearn.neighbors import KNeighborsRegressor 16 | 17 | from astroML.datasets import fetch_sdss_galaxy_colors 18 | 19 | #------------------------------------------------------------ 20 | # Download data 21 | data = fetch_sdss_galaxy_colors() 22 | data = data[::10] # truncate for plotting 23 | 24 | # Extract colors and spectral class 25 | ug = data['u'] - data['g'] 26 | gr = data['g'] - data['r'] 27 | spec_class = data['specClass'] 28 | 29 | stars = (spec_class == 2) 30 | qsos = (spec_class == 3) 31 | 32 | #------------------------------------------------------------ 33 | # Prepare plot 34 | fig = plt.figure() 35 | ax = fig.add_subplot(111) 36 | 37 | ax.set_xlim(-0.5, 2.5) 38 | ax.set_ylim(-0.5, 1.5) 39 | 40 | ax.plot(ug[stars], gr[stars], '.', ms=4, c='b', label='stars') 41 | ax.plot(ug[qsos], gr[qsos], '.', ms=4, c='r', label='qsos') 42 | 43 | ax.legend(loc=2) 44 | 45 | ax.set_xlabel('$u-g$') 46 | ax.set_ylabel('$g-r$') 47 | 48 | plt.show() 49 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_filters.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Filters 3 | ------------ 4 | Download and plot the five SDSS filter bands along with a Vega spectrum. 5 | This data is available on the SDSS website (filters) and on the STSci 6 | website (Vega). 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure is an example from astroML: see http://astroML.github.com 11 | from matplotlib import pyplot as plt 12 | from astroML.datasets import fetch_sdss_filter, fetch_vega_spectrum 13 | 14 | #------------------------------------------------------------ 15 | # Set up figure and axes 16 | fig = plt.figure() 17 | ax = fig.add_subplot(111) 18 | 19 | #---------------------------------------------------------------------- 20 | # Fetch and plot the Vega spectrum 21 | spec = fetch_vega_spectrum() 22 | lam = spec[0] 23 | spectrum = spec[1] / 2.1 / spec[1].max() 24 | ax.plot(lam, spectrum, '-k', lw=2) 25 | 26 | #------------------------------------------------------------ 27 | # Fetch and plot the five filters 28 | text_kwargs = dict(fontsize=20, ha='center', va='center', alpha=0.5) 29 | 30 | for f, c, loc in zip('ugriz', 'bgrmk', [3500, 4600, 6100, 7500, 8800]): 31 | data = fetch_sdss_filter(f) 32 | ax.fill(data[0], data[1], ec=c, fc=c, alpha=0.4) 33 | ax.text(loc, 0.02, f, color=c, **text_kwargs) 34 | 35 | ax.set_xlim(3000, 11000) 36 | 37 | ax.set_title('SDSS Filters and Reference Spectrum') 38 | ax.set_xlabel('Wavelength (Angstroms)') 39 | ax.set_ylabel('normalized flux / filter transmission') 40 | 41 | plt.show() 42 | -------------------------------------------------------------------------------- /examples/algorithms/plot_spectrum_sum_of_norms.py: -------------------------------------------------------------------------------- 1 | """ 2 | Linear Sum of Gaussians 3 | ----------------------- 4 | 5 | Fitting a spectrum with a linear sum of gaussians. 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | from matplotlib import pyplot as plt 11 | from astroML.datasets import fetch_vega_spectrum 12 | from astroML.sum_of_norms import sum_of_norms, norm 13 | 14 | # Fetch the data 15 | x, y = fetch_vega_spectrum() 16 | 17 | # truncate the spectrum 18 | mask = (x >= 2000) & (x < 10000) 19 | x = x[mask] 20 | y = y[mask] 21 | 22 | for n_gaussians in (10, 50, 100): 23 | # compute the best-fit linear combination 24 | w_best, rms, locs, widths = sum_of_norms(x, y, n_gaussians, 25 | spacing='linear', 26 | full_output=True) 27 | 28 | norms = w_best * norm(x[:, None], locs, widths) 29 | 30 | # plot the results 31 | plt.figure() 32 | plt.plot(x, y, '-k', label='input spectrum') 33 | ylim = plt.ylim() 34 | 35 | plt.plot(x, norms, ls='-', c='#FFAAAA') 36 | plt.plot(x, norms.sum(1), '-r', label='sum of gaussians') 37 | plt.ylim(-0.1 * ylim[1], ylim[1]) 38 | 39 | plt.legend(loc=0) 40 | 41 | plt.text(0.97, 0.8, 42 | "rms error = %.2g" % rms, 43 | ha='right', va='top', transform=plt.gca().transAxes) 44 | plt.title("Fit to a Spectrum with a Sum of %i Gaussians" % n_gaussians) 45 | 46 | plt.show() 47 | -------------------------------------------------------------------------------- /astroML/datasets/generated.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from ..cosmology import Cosmology 3 | from ..density_estimation import FunctionDistribution 4 | from ..utils import check_random_state 5 | 6 | 7 | def redshift_distribution(z, z0): 8 | return (z / z0) ** 2 * np.exp(-1.5 * (z / z0)) 9 | 10 | 11 | def generate_mu_z(size=1000, z0=0.3, dmu_0=0.1, dmu_1=0.02, 12 | random_state=None, **kwargs): 13 | """Generate a dataset of distance modulus vs redshift. 14 | 15 | Parameters 16 | ---------- 17 | size : int or tuple 18 | size of generated data 19 | z0 : float 20 | parameter in redshift distribution: 21 | p(z) ~ (z / z0)^2 exp[-1.5 (z / z0)] 22 | dmu_0, dmu_1 : float 23 | specify the error in mu, dmu = dmu_0 + dmu_1 * mu 24 | random_state : None, int, or np.random.RandomState instance 25 | random seed or random number generator 26 | **kwargs : 27 | additional keyword arguments are passed to the Cosmology function 28 | 29 | Returns 30 | ------- 31 | z, mu, dmu : ndarrays 32 | arrays of shape `size` 33 | """ 34 | random_state = check_random_state(random_state) 35 | cosmo = Cosmology(**kwargs) 36 | 37 | zdist = FunctionDistribution(redshift_distribution, func_args=dict(z0=z0), 38 | xmin=0.1 * z0, xmax=10 * z0, 39 | random_state=random_state) 40 | 41 | z_sample = zdist.rvs(size) 42 | mu_sample = np.reshape([cosmo.mu(z) for z in z_sample.ravel()], size) 43 | dmu = dmu_0 + dmu_1 * mu_sample 44 | mu_sample = random_state.normal(mu_sample, dmu) 45 | 46 | return z_sample, mu_sample, dmu 47 | -------------------------------------------------------------------------------- /astroML/linear_model/TLS.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from scipy import optimize 3 | 4 | 5 | def TLS_logL(v, X, dX): 6 | """Compute the total least squares log-likelihood 7 | 8 | This uses Hogg et al eq. 29-32 9 | 10 | Parameters 11 | ---------- 12 | v : ndarray 13 | The normal vector to the linear best fit. shape=(D,). 14 | Note that the magnitude |v| is a stand-in for the intercept. 15 | X : ndarray 16 | The input data. shape = [N, D] 17 | dX : ndarray 18 | The covariance of the errors for each point. 19 | For diagonal errors, the shape = (N, D) and the entries are 20 | dX[i] = [sigma_x1, sigma_x2 ... sigma_xD] 21 | For full covariance, the shape = (N, D, D) and the entries are 22 | dX[i] = Cov(X[i], X[i]), the full error covariance. 23 | 24 | Returns 25 | ------- 26 | logL : float 27 | The log-likelihood of the model v given the data. 28 | 29 | Notes 30 | ----- 31 | This implementation follows Hogg 2010, arXiv 1008.4686 32 | """ 33 | # check inputs 34 | X, dX, v = map(np.asarray, (X, dX, v)) 35 | N, D = X.shape 36 | assert v.shape == (D,) 37 | assert dX.shape in ((N, D), (N, D, D)) 38 | 39 | v_norm = np.linalg.norm(v) 40 | v_hat = v / v_norm 41 | 42 | # eq. 30 43 | Delta = np.dot(X, v_hat) - v_norm 44 | 45 | # eq. 31 46 | if dX.ndim == 2: 47 | # diagonal covariance 48 | Sig2 = np.sum(dX * v_hat ** 2, 1) 49 | else: 50 | # full covariance 51 | Sig2 = np.dot(np.dot(v_hat, dX), v_hat) 52 | 53 | return (-0.5 * np.sum(np.log(2 * np.pi * Sig2)) 54 | - np.sum(0.5 * Delta ** 2 / Sig2)) 55 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_line_ratios.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Line-ratio Diagrams 3 | ------------------------ 4 | This shows how to plot line-ratio diagrams for the SDSS spectra. These 5 | diagrams are often called BPT plots [1]_, Osterbrock diagrams [2]_, 6 | or Kewley diagrams [3]_. The location of the dividing line is taken from 7 | from Kewley et al 2001. 8 | 9 | References 10 | ~~~~~~~~~~ 11 | .. [1] Baldwin, J. A.; Phillips, M. M.; Terlevich, R. (1981) 12 | http://adsabs.harvard.edu/abs/1981PASP...93....5B 13 | .. [2] Osterbrock, D. E.; De Robertis, M. M. (1985) 14 | http://adsabs.harvard.edu/abs/1985PASP...97.1129O 15 | .. [3] Kewley, L. J. `et al.` (2001) 16 | http://adsabs.harvard.edu/abs/2001ApJ...556..121K 17 | """ 18 | # Author: Jake VanderPlas 19 | # License: BSD 20 | # The figure is an example from astroML: see http://astroML.github.com 21 | import numpy as np 22 | from matplotlib import pyplot as plt 23 | 24 | from astroML.datasets import fetch_sdss_corrected_spectra 25 | from astroML.datasets.tools.sdss_fits import log_OIII_Hb_NII 26 | 27 | data = fetch_sdss_corrected_spectra() 28 | 29 | i = np.where((data['lineindex_cln'] == 4) | (data['lineindex_cln'] == 5)) 30 | 31 | plt.scatter(data['log_NII_Ha'][i], data['log_OIII_Hb'][i], 32 | c=data['lineindex_cln'][i], s=9, lw=0) 33 | 34 | NII = np.linspace(-2.0, 0.35) 35 | plt.plot(NII, log_OIII_Hb_NII(NII), '-k') 36 | plt.plot(NII, log_OIII_Hb_NII(NII, 0.1), '--k') 37 | plt.plot(NII, log_OIII_Hb_NII(NII, -0.1), '--k') 38 | plt.xlim(-2.0, 1.0) 39 | plt.ylim(-1.2, 1.5) 40 | 41 | plt.xlabel(r'$\mathrm{log([NII]/H\alpha)}$', fontsize='large') 42 | plt.ylabel(r'$\mathrm{log([OIII]/H\beta)}$', fontsize='large') 43 | plt.show() 44 | -------------------------------------------------------------------------------- /examples/algorithms/plot_crossmatch.py: -------------------------------------------------------------------------------- 1 | """ 2 | Catalog cross-matching 3 | ---------------------- 4 | This plots the cross-matched samples between the SDSS imaging data and 5 | the SDSS Stripe 82 standard stars. 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | import os 11 | import sys 12 | from time import time 13 | 14 | import numpy as np 15 | from matplotlib import pyplot as plt 16 | 17 | from astroML.datasets import fetch_imaging_sample, fetch_sdss_S82standards 18 | from astroML.crossmatch import crossmatch_angular 19 | from astroML.plotting import hist 20 | 21 | # get imaging data 22 | image_data = fetch_imaging_sample() 23 | imX = np.empty((len(image_data), 2), dtype=np.float64) 24 | imX[:, 0] = image_data['ra'] 25 | imX[:, 1] = image_data['dec'] 26 | 27 | # get standard stars 28 | standards_data = fetch_sdss_S82standards() 29 | stX = np.empty((len(standards_data), 2), dtype=np.float64) 30 | stX[:, 0] = standards_data['RA'] 31 | stX[:, 1] = standards_data['DEC'] 32 | 33 | # crossmatch catalogs 34 | max_radius = 1. / 3600 # 1 arcsec 35 | dist, ind = crossmatch_angular(imX, stX, max_radius) 36 | match = ~np.isinf(dist) 37 | 38 | dist_match = dist[match] 39 | dist_match *= 3600 40 | 41 | ax = plt.axes() 42 | hist(dist_match, bins='knuth', ax=ax, 43 | histtype='stepfilled', ec='k', fc='#AAAAAA') 44 | ax.set_xlabel('radius of match (arcsec)') 45 | ax.set_ylabel('N(r, r+dr)') 46 | ax.text(0.95, 0.95, 47 | "Total objects: %i\nNumber with match: %i" % (imX.shape[0], 48 | np.sum(match)), 49 | ha='right', va='top', transform=ax.transAxes) 50 | ax.set_xlim(0, 0.2) 51 | 52 | plt.show() 53 | -------------------------------------------------------------------------------- /book_figures/chapter3/fig_prob_sum.py: -------------------------------------------------------------------------------- 1 | """ 2 | Sum of Probabilities 3 | -------------------- 4 | Figure 3.1. 5 | 6 | A representation of the sum of probabilities shown in eq.3.1. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure produced by this code is published in the textbook 11 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 12 | # For more information, see http://astroML.github.com 13 | # To report a bug or issue, use the following forum: 14 | # https://groups.google.com/forum/#!forum/astroml-general 15 | from matplotlib import pyplot as plt 16 | 17 | #---------------------------------------------------------------------- 18 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 19 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 20 | # result in an error if LaTeX is not installed on your system. In that case, 21 | # you can set usetex to False. 22 | from astroML.plotting import setup_text_plots 23 | setup_text_plots(fontsize=8, usetex=True) 24 | 25 | # create plot 26 | fig = plt.figure(figsize=(5, 3.75), facecolor='w') 27 | ax = plt.axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False) 28 | 29 | # draw intersecting circles 30 | ax.add_patch(plt.Circle((1.5, 0.2), 2.2, fc='gray', ec='black', alpha=0.5)) 31 | ax.add_patch(plt.Circle((-1.5, 0.2), 2.2, fc='gray', ec='black', alpha=0.5)) 32 | 33 | # add text 34 | text_kwargs = dict(ha='center', va='center', fontsize=12) 35 | ax.text(-1.6, 0.2, "$p(A)$", **text_kwargs) 36 | ax.text(1.6, 0.2, "$p(B)$", **text_kwargs) 37 | ax.text(0.0, 0.2, "$p(A \cap B)$", **text_kwargs) 38 | ax.text(0, -2.3, "$p(A \cup B) = p(A) + p(B) - p(A \cap B)$", **text_kwargs) 39 | 40 | ax.set_xlim(-4, 4) 41 | ax.set_ylim(-3, 3) 42 | 43 | plt.show() 44 | -------------------------------------------------------------------------------- /book_figures/chapter9/fig_discriminant_function.py: -------------------------------------------------------------------------------- 1 | """ 2 | Example of a Discriminant Function 3 | ---------------------------------- 4 | This plot shows a simple example of a discriminant function between 5 | two sets of points 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure produced by this code is published in the textbook 10 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 11 | # For more information, see http://astroML.github.com 12 | # To report a bug or issue, use the following forum: 13 | # https://groups.google.com/forum/#!forum/astroml-general 14 | import numpy as np 15 | from matplotlib import pyplot as plt 16 | 17 | #---------------------------------------------------------------------- 18 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 19 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 20 | # result in an error if LaTeX is not installed on your system. In that case, 21 | # you can set usetex to False. 22 | from astroML.plotting import setup_text_plots 23 | setup_text_plots(fontsize=8, usetex=True) 24 | 25 | #------------------------------------------------------------ 26 | # create some toy data 27 | np.random.seed(0) 28 | cluster_1 = np.random.normal([1, 0.5], 0.5, size=(10, 2)) 29 | cluster_2 = np.random.normal([-1, -0.5], 0.5, size=(10, 2)) 30 | 31 | #------------------------------------------------------------ 32 | # plot the data and boundary 33 | fig = plt.figure(figsize=(5, 3.75)) 34 | ax = fig.add_subplot(111, xticks=[], yticks=[]) 35 | ax.scatter(cluster_1[:, 0], cluster_1[:, 1], c='k', s=30) 36 | ax.scatter(cluster_2[:, 0], cluster_2[:, 1], c='w', s=30) 37 | ax.plot([0, 1], [1.5, -1.5], '-k', lw=2) 38 | 39 | ax.set_xlim(-2, 2.5) 40 | ax.set_ylim(-2, 2) 41 | 42 | plt.show() 43 | -------------------------------------------------------------------------------- /astroML/linear_model/kernel_regression.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from .linear_regression import gaussian_basis 3 | from sklearn.metrics import pairwise_kernels 4 | 5 | 6 | class NadarayaWatson(object): 7 | """Nadaraya-Watson Kernel Regression 8 | 9 | This is basically a gaussian-weighted moving average of points 10 | 11 | Parameters 12 | ---------- 13 | kernel : string 14 | kernel is either "gaussian", or one of the kernels available in 15 | sklearn.metrics.pairwise. 16 | h : float or array_like 17 | width of kernel. If array, its length must be the number of 18 | dimensions in the training data 19 | 20 | Additional keyword arguments are passed to the kernel. 21 | """ 22 | def __init__(self, kernel='gaussian', h=None, **kwargs): 23 | self.kernel = kernel 24 | self.h = h 25 | self.kwargs = kwargs 26 | 27 | def fit(self, X, y, dy=1): 28 | self.X = np.asarray(X) 29 | self.y = np.asarray(y) 30 | self.dy = np.atleast_1d(dy) 31 | return self 32 | 33 | def predict(self, X): 34 | X = np.asarray(X) 35 | if X.ndim != 2: 36 | raise ValueError('X must be two-dimensional') 37 | 38 | if X.shape[1] != self.X.shape[1]: 39 | raise ValueError('dimensions of X do not match training dimension') 40 | 41 | if self.kernel == 'gaussian': 42 | # wrangle gaussian into scikit-learn's 'rbf' kernel 43 | h = np.asarray(self.h) 44 | gamma = 0.5 / h / h 45 | K = pairwise_kernels(X, self.X, metric='rbf', gamma=gamma) 46 | 47 | else: 48 | K = pairwise_kernels(X, self.X, metric=self.kernel, **self.kwargs) 49 | 50 | K /= self.dy ** 2 51 | 52 | return (K * self.y).sum(1) / K.sum(1) 53 | -------------------------------------------------------------------------------- /astroML/datasets/rrlyrae_templates.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tarfile 3 | 4 | import numpy as np 5 | 6 | from . import get_data_home 7 | from .tools import download_with_progress_bar 8 | 9 | DATA_URL = ("http://www.astro.washington.edu/users/bsesar/" 10 | "S82_RRLyr/RRLyr_ugriz_templates.tar.gz") 11 | 12 | 13 | def fetch_rrlyrae_templates(data_home=None, download_if_missing=True): 14 | """Loader for RR-Lyrae template data 15 | 16 | These are the light-curve templates from Sesar et al 2010, ApJ 708:717 17 | 18 | Parameters 19 | ---------- 20 | data_home : optional, default=None 21 | Specify another download and cache folder for the datasets. By default 22 | all scikit learn data is stored in '~/astroML_data' subfolders. 23 | 24 | download_if_missing : optional, default=True 25 | If False, raise a IOError if the data is not locally available 26 | instead of trying to download the data from the source site. 27 | 28 | Returns 29 | ------- 30 | data : numpy record array 31 | record array containing the templates 32 | """ 33 | data_home = get_data_home(data_home) 34 | if not os.path.exists(data_home): 35 | os.makedirs(data_home) 36 | 37 | data_file = os.path.join(data_home, os.path.basename(DATA_URL)) 38 | 39 | if not os.path.exists(data_file): 40 | if not download_if_missing: 41 | raise IOError('data not present on disk. ' 42 | 'set download_if_missing=True to download') 43 | 44 | databuffer = download_with_progress_bar(DATA_URL) 45 | open(data_file, 'wb').write(databuffer) 46 | 47 | data = tarfile.open(data_file) 48 | 49 | return dict([(name.strip('.dat'), 50 | np.loadtxt(data.extractfile(name))) 51 | for name in data.getnames()]) 52 | -------------------------------------------------------------------------------- /astroML/datasets/hogg2010test.py: -------------------------------------------------------------------------------- 1 | """ 2 | Data from Hogg et al 2010; useful for testing robust regression methods 3 | """ 4 | import numpy as np 5 | 6 | 7 | def fetch_hogg2010test(structured=False): 8 | """Fetch the Hogg et al 2010 test data 9 | """ 10 | data = np.array([[1, 201, 592, 61, 9, -0.84], 11 | [2, 244, 401, 25, 4, 0.31], 12 | [3, 47, 583, 38, 11, 0.64], 13 | [4, 287, 402, 15, 7, -0.27], 14 | [5, 203, 495, 21, 5, -0.33], 15 | [6, 58, 173, 15, 9, 0.67], 16 | [7, 210, 479, 27, 4, -0.02], 17 | [8, 202, 504, 14, 4, -0.05], 18 | [9, 198, 510, 30, 11, -0.84], 19 | [10, 158, 416, 16, 7, -0.69], 20 | [11, 165, 393, 14, 5, 0.30], 21 | [12, 201, 442, 25, 5, -0.46], 22 | [13, 157, 317, 52, 5, -0.03], 23 | [14, 131, 311, 16, 6, 0.50], 24 | [15, 166, 400, 34, 6, 0.73], 25 | [16, 160, 337, 31, 5, -0.52], 26 | [17, 186, 423, 42, 9, 0.90], 27 | [18, 125, 334, 26, 8, 0.40], 28 | [19, 218, 533, 16, 6, -0.78], 29 | [20, 146, 344, 22, 5, -0.56]]) 30 | dtype = [("ID", np.int32), 31 | ("x", np.float64), 32 | ("y", np.float64), 33 | ("sigma_x", np.float64), 34 | ("sigma_y", np.float64), 35 | ("rho_xy", np.float64)] 36 | 37 | recarray = np.empty(data.shape[0], dtype=dtype) 38 | recarray['ID'] = data[:, 0] 39 | recarray['x'] = data[:, 1] 40 | recarray['y'] = data[:, 2] 41 | recarray['sigma_x'] = data[:, 4] 42 | recarray['sigma_y'] = data[:, 3] 43 | recarray['rho_xy'] = data[:, 5] 44 | 45 | return recarray 46 | -------------------------------------------------------------------------------- /book_figures/chapter3/fig_contingency_table.py: -------------------------------------------------------------------------------- 1 | """ 2 | A 2x2 Contingency Table 3 | ----------------------- 4 | Figure 3.3. 5 | 6 | A contingency table showing p(T|D). 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure produced by this code is published in the textbook 11 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 12 | # For more information, see http://astroML.github.com 13 | # To report a bug or issue, use the following forum: 14 | # https://groups.google.com/forum/#!forum/astroml-general 15 | from matplotlib import pyplot as plt 16 | 17 | #---------------------------------------------------------------------- 18 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 19 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 20 | # result in an error if LaTeX is not installed on your system. In that case, 21 | # you can set usetex to False. 22 | from astroML.plotting import setup_text_plots 23 | setup_text_plots(fontsize=8, usetex=True) 24 | 25 | fig = plt.figure(figsize=(2, 2), facecolor='w') 26 | ax = fig.add_axes((0, 0, 1, 1), xticks=[], yticks=[], frameon=False) 27 | 28 | for i in [-1, 0, 1]: 29 | ax.plot([i, i], [-1, 1], '-k') 30 | ax.plot([-1, 1], [i, i], '-k') 31 | 32 | kwds = dict(ha='center', va='center', size=11) 33 | 34 | ax.text(-0.5, 1.15, '0', **kwds) 35 | ax.text(0.5, 1.15, '1', **kwds) 36 | ax.text(0, 1.25, 'T', **kwds) 37 | 38 | ax.text(-1.15, 0.5, '0', **kwds) 39 | ax.text(-1.15, -0.5, '1', **kwds) 40 | ax.text(-1.25, 0, 'D', **kwds) 41 | 42 | kwds['size'] = 14 43 | 44 | ax.text(0.5, 0.5, '$\epsilon_{fP}$', **kwds) 45 | ax.text(-0.5, 0.5, '$1 - \epsilon_{fP}$', **kwds) 46 | ax.text(-0.5, -0.5, '$\epsilon_{fN}$', **kwds) 47 | ax.text(0.5, -0.5, '$1 - \epsilon_{fN}$', **kwds) 48 | 49 | ax.set_xlim(-1.5, 1.2) 50 | ax.set_ylim(-1.2, 1.5) 51 | 52 | plt.show() 53 | -------------------------------------------------------------------------------- /doc/sphinxext/gen_rst.py: -------------------------------------------------------------------------------- 1 | import os 2 | from example_builder import ExampleBuilder 3 | 4 | RST_TEMPLATE = """ 5 | 6 | .. _%(sphinx_tag)s: 7 | 8 | %(docstring)s 9 | 10 | %(image_list)s 11 | 12 | .. raw:: html 13 | 14 | 21 |
22 | 23 | .. literalinclude:: %(stdout)s 24 | 25 | .. raw:: html 26 | 27 |
28 | 35 |
36 | 37 | .. literalinclude:: %(fname)s 38 | :lines: %(end_line)s- 39 | 40 | .. raw:: html 41 | 42 |
43 |
44 | 45 | :download:`[download source: %(fname)s] <%(fname)s>` 46 | 47 | .. raw:: html 48 | 49 |
50 | 51 | """ 52 | 53 | def main(app): 54 | target_dir = os.path.join(app.builder.srcdir, 'examples') 55 | source_dir = os.path.abspath(app.builder.srcdir + '/../' + 'examples') 56 | 57 | try: 58 | plot_gallery = eval(app.builder.config.plot_gallery) 59 | except TypeError: 60 | plot_gallery = bool(app.builder.config.plot_gallery) 61 | 62 | if not os.path.exists(source_dir): 63 | os.makedirs(source_dir) 64 | if not os.path.exists(target_dir): 65 | os.makedirs(target_dir) 66 | 67 | EB = ExampleBuilder(source_dir, target_dir, 68 | execute_files=plot_gallery, 69 | dir_info_file='README.rst', 70 | sphinx_tag_base='example', 71 | template_example=RST_TEMPLATE) 72 | EB.run() 73 | 74 | 75 | def setup(app): 76 | app.connect('builder-inited', main) 77 | app.add_config_value('plot_gallery', True, 'html') 78 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_dr7_quasar.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS DR7 Quasars 3 | ---------------- 4 | Figure 1.4. 5 | 6 | The r-i color vs. redshift diagram for the first 10,000 entries from the 7 | SDSS Data Release 7 Quasar Catalog. The color variation is due to emission 8 | lines entering and exiting the r and i band wavelength windows. 9 | """ 10 | # Author: Jake VanderPlas 11 | # License: BSD 12 | # The figure produced by this code is published in the textbook 13 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 14 | # For more information, see http://astroML.github.com 15 | # To report a bug or issue, use the following forum: 16 | # https://groups.google.com/forum/#!forum/astroml-general 17 | from matplotlib import pyplot as plt 18 | from astroML.datasets import fetch_dr7_quasar 19 | 20 | #---------------------------------------------------------------------- 21 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 22 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 23 | # result in an error if LaTeX is not installed on your system. In that case, 24 | # you can set usetex to False. 25 | from astroML.plotting import setup_text_plots 26 | setup_text_plots(fontsize=8, usetex=True) 27 | 28 | #------------------------------------------------------------ 29 | # Fetch the quasar data 30 | data = fetch_dr7_quasar() 31 | 32 | # select the first 10000 points 33 | data = data[:10000] 34 | 35 | r = data['mag_r'] 36 | i = data['mag_i'] 37 | z = data['redshift'] 38 | 39 | #------------------------------------------------------------ 40 | # Plot the quasar data 41 | fig, ax = plt.subplots(figsize=(5, 3.75)) 42 | ax.plot(z, r - i, marker='.', markersize=2, linestyle='none', color='black') 43 | 44 | ax.set_xlim(0, 5) 45 | ax.set_ylim(-0.5, 1.0) 46 | 47 | ax.set_xlabel(r'${\rm redshift}$') 48 | ax.set_ylabel(r'${\rm r-i}$') 49 | 50 | plt.show() 51 | -------------------------------------------------------------------------------- /doc/sphinxext/README.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | numpydoc -- Numpy's Sphinx extensions 3 | ===================================== 4 | 5 | Numpy's documentation uses several custom extensions to Sphinx. These 6 | are shipped in this ``numpydoc`` package, in case you want to make use 7 | of them in third-party projects. 8 | 9 | The following extensions are available: 10 | 11 | - ``numpydoc``: support for the Numpy docstring format in Sphinx, and add 12 | the code description directives ``np-function``, ``np-cfunction``, etc. 13 | that support the Numpy docstring syntax. 14 | 15 | - ``numpydoc.traitsdoc``: For gathering documentation about Traits attributes. 16 | 17 | - ``numpydoc.plot_directives``: Adaptation of Matplotlib's ``plot::`` 18 | directive. Note that this implementation may still undergo severe 19 | changes or eventually be deprecated. 20 | 21 | - ``numpydoc.only_directives``: (DEPRECATED) 22 | 23 | - ``numpydoc.autosummary``: (DEPRECATED) An ``autosummary::`` directive. 24 | Available in Sphinx 0.6.2 and (to-be) 1.0 as ``sphinx.ext.autosummary``, 25 | and it the Sphinx 1.0 version is recommended over that included in 26 | Numpydoc. 27 | 28 | 29 | numpydoc 30 | ======== 31 | 32 | Numpydoc inserts a hook into Sphinx's autodoc that converts docstrings 33 | following the Numpy/Scipy format to a form palatable to Sphinx. 34 | 35 | Options 36 | ------- 37 | 38 | The following options can be set in conf.py: 39 | 40 | - numpydoc_use_plots: bool 41 | 42 | Whether to produce ``plot::`` directives for Examples sections that 43 | contain ``import matplotlib``. 44 | 45 | - numpydoc_show_class_members: bool 46 | 47 | Whether to show all members of a class in the Methods and Attributes 48 | sections automatically. 49 | 50 | - numpydoc_edit_link: bool (DEPRECATED -- edit your HTML template instead) 51 | 52 | Whether to insert an edit link after docstrings. 53 | -------------------------------------------------------------------------------- /book_figures/chapter8/fig_huber_func.py: -------------------------------------------------------------------------------- 1 | """ 2 | Huber Loss Function 3 | ------------------- 4 | Figure 8.7 5 | 6 | The Huber loss function for various values of c. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure produced by this code is published in the textbook 11 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 12 | # For more information, see http://astroML.github.com 13 | # To report a bug or issue, use the following forum: 14 | # https://groups.google.com/forum/#!forum/astroml-general 15 | import numpy as np 16 | from matplotlib import pyplot as plt 17 | 18 | #---------------------------------------------------------------------- 19 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 20 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 21 | # result in an error if LaTeX is not installed on your system. In that case, 22 | # you can set usetex to False. 23 | from astroML.plotting import setup_text_plots 24 | setup_text_plots(fontsize=8, usetex=True) 25 | 26 | 27 | #------------------------------------------------------------ 28 | # Define the Huber loss 29 | def Phi(t, c): 30 | t = abs(t) 31 | flag = (t > c) 32 | return (~flag) * (0.5 * t ** 2) - (flag) * c * (0.5 * c - t) 33 | 34 | #------------------------------------------------------------ 35 | # Plot for several values of c 36 | fig = plt.figure(figsize=(5, 3.75)) 37 | ax = fig.add_subplot(111) 38 | 39 | x = np.linspace(-10, 10, 100) 40 | 41 | for c in (1, 2, 3, 5, 1000): 42 | y = Phi(x, c) 43 | ax.plot(x, y, '-k') 44 | 45 | if c > 10: 46 | s = r'\infty' 47 | else: 48 | s = str(c) 49 | 50 | ax.text(x[6], y[6], '$c=%s$' % s, 51 | ha='center', va='center', 52 | bbox=dict(boxstyle='round', ec='k', fc='w')) 53 | 54 | ax.set_xlabel('$t$') 55 | ax.set_ylabel(r'$\Phi(t)$') 56 | 57 | plt.show() 58 | -------------------------------------------------------------------------------- /astroML/density_estimation/tests/test_bayesian_blocks.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from numpy.testing import assert_allclose, assert_ 3 | from astroML.density_estimation import bayesian_blocks 4 | 5 | 6 | def test_single_change_point(): 7 | np.random.seed(0) 8 | x = np.concatenate([np.random.random(100), 9 | 1 + np.random.random(200)]) 10 | 11 | bins = bayesian_blocks(x) 12 | 13 | assert_(len(bins) == 3) 14 | assert_allclose(bins[1], 1, rtol=0.02) 15 | 16 | 17 | def test_duplicate_events(): 18 | t = np.random.random(100) 19 | t[80:] = t[:20] 20 | 21 | x = np.ones_like(t) 22 | x[:20] += 1 23 | 24 | bins1 = bayesian_blocks(t) 25 | bins2 = bayesian_blocks(t[:80], x[:80]) 26 | 27 | assert_allclose(bins1, bins2) 28 | 29 | 30 | def test_measures_fitness_homoscedastic(): 31 | np.random.seed(0) 32 | t = np.linspace(0, 1, 11) 33 | x = np.exp(-0.5 * (t - 0.5) ** 2 / 0.01 ** 2) 34 | sigma = 0.05 35 | x = np.random.normal(x, sigma) 36 | 37 | bins = bayesian_blocks(t, x, sigma, fitness='measures') 38 | 39 | assert_allclose(bins, [0, 0.45, 0.55, 1]) 40 | 41 | 42 | def test_measures_fitness_heteroscedastic(): 43 | np.random.seed(1) 44 | t = np.linspace(0, 1, 11) 45 | x = np.exp(-0.5 * (t - 0.5) ** 2 / 0.01 ** 2) 46 | sigma = 0.02 + 0.02 * np.random.random(len(x)) 47 | x = np.random.normal(x, sigma) 48 | 49 | bins = bayesian_blocks(t, x, sigma, fitness='measures') 50 | 51 | assert_allclose(bins, [0, 0.45, 0.55, 1]) 52 | 53 | 54 | def test_regular_events(): 55 | np.random.seed(0) 56 | dt = 0.01 57 | steps = np.concatenate([np.unique(np.random.randint(0, 500, 100)), 58 | np.unique(np.random.randint(500, 1000, 200))]) 59 | t = dt * steps 60 | 61 | bins = bayesian_blocks(t, fitness='regular_events', dt=dt) 62 | 63 | assert_(len(bins) == 3) 64 | assert_allclose(bins[1], 5, rtol=0.05) 65 | -------------------------------------------------------------------------------- /compare_images.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compare Image Tests 3 | ------------------- 4 | 5 | This script compares all the mis-matching images found when running 6 | 7 | $ nosetests astroML_fig_tests 8 | 9 | The result of running this script is an html page comparing each output file 10 | to the baseline result, showing only the ones with a mismatch above the 11 | threshold specified in astroML_fig_tests. 12 | """ 13 | 14 | 15 | import os 16 | 17 | TABLE = """ 18 | 19 | 20 | {rows} 21 |
22 | 23 | """ 24 | 25 | ROW = """ 26 | 27 | {0} 28 | actual 29 | baseline 30 | 31 | 32 | 33 | 34 | 35 | 36 | """ 37 | 38 | baseline = "astroML_fig_tests/baseline/book_figures" 39 | results = "astroML_fig_tests/results/book_figures" 40 | 41 | figlist = [] 42 | 43 | for chapter in os.listdir(results): 44 | if not os.path.isdir(os.path.join(results,chapter)): 45 | continue 46 | for pyfile in os.listdir(os.path.join(results,chapter)): 47 | if pyfile.endswith('failed-diff.png'): 48 | root = pyfile.split('-failed-diff')[0] 49 | figlist.append((os.path.join("book_figures", chapter, root + ".py"), 50 | os.path.join(results, chapter, pyfile), 51 | os.path.join(results, chapter, root + '.png'), 52 | os.path.join(baseline, chapter, root + '.png'))) 53 | 54 | 55 | outfile = "_compare_images.html" 56 | 57 | with open(outfile, 'w') as f: 58 | f.write(TABLE.format(rows = '\n'.join([ROW.format(*figs, width="90%") 59 | for figs in figlist]))) 60 | 61 | import webbrowser 62 | webbrowser.open_new("file://localhost" + os.path.abspath(outfile)) 63 | 64 | -------------------------------------------------------------------------------- /astroML/datasets/tools/download.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | import sys 4 | 5 | from ...py3k_compat import urlopen, BytesIO, url_content_length 6 | 7 | 8 | def bytes_to_string(nbytes): 9 | if nbytes < 1024: 10 | return '%ib' % nbytes 11 | 12 | nbytes /= 1024. 13 | if nbytes < 1024: 14 | return '%.1fkb' % nbytes 15 | 16 | nbytes /= 1024. 17 | if nbytes < 1024: 18 | return '%.2fMb' % nbytes 19 | 20 | nbytes /= 1024. 21 | return '%.1fGb' % nbytes 22 | 23 | 24 | def download_with_progress_bar(data_url, return_buffer=False): 25 | """Download a file, showing progress 26 | 27 | Parameters 28 | ---------- 29 | data_url : string 30 | web address 31 | return_buffer : boolean (optional) 32 | if true, return a BytesIO buffer rather than a string 33 | 34 | Returns 35 | ------- 36 | s : string 37 | content of the file 38 | """ 39 | num_units = 40 40 | 41 | fhandle = urlopen(data_url) 42 | content_length = url_content_length(fhandle) 43 | 44 | chunk_size = content_length // num_units 45 | 46 | print("Downloading %s" % data_url) 47 | nchunks = 0 48 | buf = BytesIO() 49 | content_length_str = bytes_to_string(content_length) 50 | 51 | while True: 52 | next_chunk = fhandle.read(chunk_size) 53 | nchunks += 1 54 | 55 | if next_chunk: 56 | buf.write(next_chunk) 57 | s = ('[' + nchunks * '=' 58 | + (num_units - 1 - nchunks) * ' ' 59 | + '] %s / %s \r' % (bytes_to_string(buf.tell()), 60 | content_length_str)) 61 | else: 62 | sys.stdout.write('\n') 63 | break 64 | 65 | sys.stdout.write(s) 66 | sys.stdout.flush() 67 | 68 | buf.seek(0) 69 | if return_buffer: 70 | return buf 71 | else: 72 | return buf.getvalue() 73 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_sdss_spectrum.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Spectrum Example 3 | --------------------- 4 | Figure 1.2. 5 | 6 | An example of an SDSS spectrum (the specific flux plotted as a function of 7 | wavelength) loaded from the SDSS SQL server in real time using Python tools 8 | provided here (this spectrum is uniquely described by SDSS parameters 9 | plate=1615, fiber=513, and mjd=53166). 10 | """ 11 | # Author: Jake VanderPlas 12 | # License: BSD 13 | # The figure produced by this code is published in the textbook 14 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 15 | # For more information, see http://astroML.github.com 16 | # To report a bug or issue, use the following forum: 17 | # https://groups.google.com/forum/#!forum/astroml-general 18 | from matplotlib import pyplot as plt 19 | from astroML.datasets import fetch_sdss_spectrum 20 | 21 | #---------------------------------------------------------------------- 22 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 23 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 24 | # result in an error if LaTeX is not installed on your system. In that case, 25 | # you can set usetex to False. 26 | from astroML.plotting import setup_text_plots 27 | setup_text_plots(fontsize=8, usetex=True) 28 | 29 | #------------------------------------------------------------ 30 | # Fetch single spectrum 31 | plate = 1615 32 | mjd = 53166 33 | fiber = 513 34 | 35 | spec = fetch_sdss_spectrum(plate, mjd, fiber) 36 | 37 | #------------------------------------------------------------ 38 | # Plot the resulting spectrum 39 | fig, ax = plt.subplots(figsize=(5, 3.75)) 40 | ax.plot(spec.wavelength(), spec.spectrum, '-k', lw=1) 41 | 42 | ax.set_xlim(3000, 10000) 43 | ax.set_ylim(25, 300) 44 | 45 | ax.set_xlabel(r'$\lambda {(\rm \AA)}$') 46 | ax.set_ylabel('Flux') 47 | ax.set_title('Plate = %(plate)i, MJD = %(mjd)i, Fiber = %(fiber)i' % locals()) 48 | 49 | plt.show() 50 | -------------------------------------------------------------------------------- /doc/sphinxext/gen_paper_rst.py: -------------------------------------------------------------------------------- 1 | import os 2 | from example_builder import ExampleBuilder 3 | 4 | 5 | RST_TEMPLATE = """ 6 | 7 | .. _%(sphinx_tag)s: 8 | 9 | %(docstring)s 10 | 11 | %(image_list)s 12 | 13 | .. raw:: html 14 | 15 | 22 |
23 | 24 | .. literalinclude:: %(stdout)s 25 | 26 | .. raw:: html 27 | 28 |
29 | 36 |
37 | 38 | .. literalinclude:: %(fname)s 39 | :lines: %(end_line)s- 40 | 41 | .. raw:: html 42 | 43 |
44 |
45 | 46 | :download:`[download source: %(fname)s] <%(fname)s>` 47 | 48 | .. raw:: html 49 | 50 |
51 | 52 | """ 53 | 54 | def main(app): 55 | target_dir = os.path.join(app.builder.srcdir, 'paper_figures') 56 | source_dir = os.path.abspath(app.builder.srcdir + '/../' + 'paper_figures') 57 | 58 | try: 59 | plot_gallery = eval(app.builder.config.plot_gallery) 60 | except TypeError: 61 | plot_gallery = bool(app.builder.config.plot_gallery) 62 | 63 | if not os.path.exists(source_dir): 64 | os.makedirs(source_dir) 65 | if not os.path.exists(target_dir): 66 | os.makedirs(target_dir) 67 | 68 | EB = ExampleBuilder(source_dir, target_dir, 69 | execute_files=plot_gallery, 70 | contents_file='contents.txt', 71 | dir_info_file='README.rst', 72 | sphinx_tag_base='paper_fig', 73 | template_example=RST_TEMPLATE) 74 | EB.run() 75 | 76 | 77 | def setup(app): 78 | app.connect('builder-inited', main) 79 | #app.add_config_value('plot_gallery', True, 'html') 80 | -------------------------------------------------------------------------------- /examples/datasets/plot_nasa_atlas.py: -------------------------------------------------------------------------------- 1 | """ 2 | NASA Sloan Atlas 3 | ---------------- 4 | 5 | This shows some visualizations of the data from the NASA SDSS Atlas 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | import numpy as np 11 | from matplotlib import pyplot as plt 12 | 13 | from astroML.datasets import fetch_nasa_atlas 14 | 15 | data = fetch_nasa_atlas() 16 | 17 | #------------------------------------------------------------ 18 | # plot the RA/DEC in an area-preserving projection 19 | 20 | RA = data['RA'] 21 | DEC = data['DEC'] 22 | 23 | # convert coordinates to degrees 24 | RA -= 180 25 | RA *= np.pi / 180 26 | DEC *= np.pi / 180 27 | 28 | ax = plt.axes(projection='mollweide') 29 | plt.scatter(RA, DEC, s=1, c=data['Z'], cmap=plt.cm.copper, 30 | edgecolors='none', linewidths=0) 31 | plt.grid(True) 32 | 33 | plt.title('NASA Atlas Galaxy Locations') 34 | cb = plt.colorbar(cax=plt.axes([0.05, 0.1, 0.9, 0.05]), 35 | orientation='horizontal', 36 | ticks=np.linspace(0, 0.05, 6)) 37 | cb.set_label('redshift') 38 | 39 | 40 | #------------------------------------------------------------ 41 | # plot the r vs u-r color-magnitude diagram 42 | 43 | absmag = data['ABSMAG'] 44 | 45 | u = absmag[:, 2] 46 | r = absmag[:, 4] 47 | 48 | plt.figure() 49 | ax = plt.axes() 50 | plt.scatter(u - r, r, s=1, lw=0, c=data['Z'], cmap=plt.cm.copper) 51 | plt.colorbar(ticks=np.linspace(0, 0.05, 6)).set_label('redshift') 52 | 53 | plt.xlim(0, 3.5) 54 | plt.ylim(-10, -24) 55 | 56 | plt.xlabel('u-r') 57 | plt.ylabel('r') 58 | 59 | #------------------------------------------------------------ 60 | # plot a histogram of the redshift 61 | from astroML.plotting import hist 62 | 63 | plt.figure() 64 | hist(data['Z'], bins='knuth', 65 | histtype='stepfilled', ec='k', fc='#F5CCB0') 66 | plt.xlabel('z') 67 | plt.ylabel('N(z)') 68 | 69 | plt.show() 70 | -------------------------------------------------------------------------------- /paper_figures/CIDU2012/fig_spec_examples.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS spectra Examples 3 | --------------------- 4 | Plot 15 random SDSS spectra from the sample 5 | """ 6 | # Author: Jake VanderPlas 7 | # License: BSD 8 | # The figure is an example from astroML: see http://astroML.github.com 9 | import os 10 | import numpy as np 11 | from matplotlib import pyplot as plt 12 | 13 | from sklearn.decomposition import RandomizedPCA 14 | from astroML.datasets import sdss_corrected_spectra 15 | 16 | #---------------------------------------------------------------------- 17 | # Use pre-computed PCA to reconstruct spectra 18 | data = sdss_corrected_spectra.fetch_sdss_corrected_spectra() 19 | spectra = sdss_corrected_spectra.reconstruct_spectra(data) 20 | lam = sdss_corrected_spectra.compute_wavelengths(data) 21 | 22 | #------------------------------------------------------------ 23 | # select random spectra 24 | np.random.seed(5) 25 | nrows = 5 26 | ncols = 3 27 | ind = np.random.randint(spectra.shape[0], size=nrows * ncols) 28 | spec_sample = spectra[ind] 29 | 30 | #---------------------------------------------------------------------- 31 | # Plot the results 32 | fig = plt.figure(figsize=(10, 8)) 33 | 34 | fig.subplots_adjust(left=0.05, right=0.95, wspace=0.05, 35 | bottom=0.1, top=0.95, hspace=0.05) 36 | 37 | for i in range(ncols): 38 | for j in range(nrows): 39 | ax = fig.add_subplot(nrows, ncols, ncols * j + 1 + i) 40 | ax.plot(lam, spec_sample[ncols * j + i], '-k', lw=1) 41 | 42 | ax.yaxis.set_major_formatter(plt.NullFormatter()) 43 | ax.xaxis.set_major_locator(plt.MultipleLocator(1000)) 44 | if j < nrows - 1: 45 | ax.xaxis.set_major_formatter(plt.NullFormatter()) 46 | else: 47 | plt.xlabel(r'wavelength $(\AA)$') 48 | 49 | ax.set_xlim(3000, 7999) 50 | ylim = ax.get_ylim() 51 | dy = 0.05 * (ylim[1] - ylim[0]) 52 | ax.set_ylim(ylim[0] - dy, ylim[1] + dy) 53 | 54 | plt.show() 55 | -------------------------------------------------------------------------------- /book_figures/chapter6/fig_kernels.py: -------------------------------------------------------------------------------- 1 | """ 2 | Example Kernels 3 | --------------- 4 | Figure 6.2 5 | 6 | A comparison of the three kernels used for density estimation in figure 6.3: 7 | the Gaussian kernel (eq. 6.2), the top-hat kernel (eq. 6.3), and the 8 | exponential kernel (eq. 6.4). 9 | """ 10 | # Author: Jake VanderPlas 11 | # License: BSD 12 | # The figure produced by this code is published in the textbook 13 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 14 | # For more information, see http://astroML.github.com 15 | # To report a bug or issue, use the following forum: 16 | # https://groups.google.com/forum/#!forum/astroml-general 17 | import numpy as np 18 | from matplotlib import pyplot as plt 19 | 20 | #---------------------------------------------------------------------- 21 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 22 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 23 | # result in an error if LaTeX is not installed on your system. In that case, 24 | # you can set usetex to False. 25 | from astroML.plotting import setup_text_plots 26 | setup_text_plots(fontsize=8, usetex=True) 27 | 28 | #------------------------------------------------------------ 29 | # Compute Kernels. 30 | x = np.linspace(-5, 5, 10000) 31 | dx = x[1] - x[0] 32 | 33 | gauss = (1. / np.sqrt(2 * np.pi)) * np.exp(-0.5 * x ** 2) 34 | 35 | exp = 0.5 * np.exp(-abs(x)) 36 | 37 | tophat = 0.5 * np.ones_like(x) 38 | tophat[abs(x) > 1] = 0 39 | 40 | #------------------------------------------------------------ 41 | # Plot the kernels 42 | fig = plt.figure(figsize=(5, 3.75)) 43 | ax = fig.add_subplot(111) 44 | 45 | ax.plot(x, gauss, '-', c='black', lw=3, label='Gaussian') 46 | ax.plot(x, exp, '-', c='#666666', lw=2, label='Exponential') 47 | ax.plot(x, tophat, '-', c='#999999', lw=1, label='Top-hat') 48 | 49 | ax.legend(loc=1) 50 | 51 | ax.set_xlabel('$u$') 52 | ax.set_ylabel('$K(u)$') 53 | 54 | ax.set_xlim(-5, 5) 55 | ax.set_ylim(0, 0.6001) 56 | plt.show() 57 | -------------------------------------------------------------------------------- /doc/sphinxext/gen_figure_rst.py: -------------------------------------------------------------------------------- 1 | import os 2 | from example_builder import ExampleBuilder 3 | 4 | 5 | RST_TEMPLATE = """ 6 | 7 | .. _%(sphinx_tag)s: 8 | 9 | %(docstring)s 10 | 11 | %(image_list)s 12 | 13 | .. raw:: html 14 | 15 | 22 |
23 | 24 | .. literalinclude:: %(stdout)s 25 | 26 | .. raw:: html 27 | 28 |
29 | 36 |
37 | 38 | .. literalinclude:: %(fname)s 39 | :lines: %(end_line)s- 40 | 41 | .. raw:: html 42 | 43 |
44 |
45 | 46 | :download:`[download source: %(fname)s] <%(fname)s>` 47 | 48 | .. raw:: html 49 | 50 |
51 | 52 | """ 53 | 54 | def main(app): 55 | target_dir = os.path.join(app.builder.srcdir, 'book_figures') 56 | source_dir = os.path.abspath(app.builder.srcdir + '/../' + 'book_figures') 57 | 58 | try: 59 | plot_gallery = eval(app.builder.config.plot_gallery) 60 | except TypeError: 61 | plot_gallery = bool(app.builder.config.plot_gallery) 62 | 63 | if not os.path.exists(source_dir): 64 | os.makedirs(source_dir) 65 | if not os.path.exists(target_dir): 66 | os.makedirs(target_dir) 67 | 68 | EB = ExampleBuilder(source_dir, target_dir, 69 | execute_files=plot_gallery, 70 | contents_file='contents.txt', 71 | dir_info_file='README.rst', 72 | dir_footer_file='FOOTER.rst', 73 | sphinx_tag_base='book_fig', 74 | template_example=RST_TEMPLATE) 75 | EB.run() 76 | 77 | 78 | def setup(app): 79 | app.connect('builder-inited', main) 80 | #app.add_config_value('plot_gallery', True, 'html') 81 | -------------------------------------------------------------------------------- /paper_figures/CIDU2012/fig_LS_sg_comparison.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generalized vs Standard Lomb-Scargle 3 | ------------------------------------ 4 | """ 5 | # Author: Jake VanderPlas 6 | # License: BSD 7 | # The figure is an example from astroML: see http://astroML.github.com 8 | import numpy as np 9 | from matplotlib import pyplot as plt 10 | 11 | from astroML.time_series import lomb_scargle 12 | 13 | #------------------------------------------------------------ 14 | # Generate data where y is positive 15 | np.random.seed(0) 16 | N = 30 17 | P = 0.3 18 | 19 | t = P / 2 * np.random.random(N) + P * np.random.randint(100, size=N) 20 | y = 10 + np.sin(2 * np.pi * t / P) 21 | dy = 0.5 + 0.5 * np.random.random(N) 22 | y_obs = y + np.random.normal(dy) 23 | 24 | omega_0 = 2 * np.pi / P 25 | 26 | #------------------------------------------------------------ 27 | # Compute the Lomb-Scargle Periodogram 28 | sig = np.array([0.1, 0.01, 0.001]) 29 | omega = np.linspace(17, 22, 1000) 30 | P_S = lomb_scargle(t, y, dy, omega, generalized=False) 31 | P_G, z = lomb_scargle(t, y, dy, omega, generalized=True, significance=sig) 32 | 33 | #------------------------------------------------------------ 34 | # Plot the results 35 | fig = plt.figure() 36 | 37 | # First panel: input data 38 | ax = fig.add_subplot(211) 39 | ax.errorbar(t, y_obs, dy, fmt='.k', lw=1, ecolor='gray') 40 | ax.plot([-2, 32], [10, 10], ':k', lw=1) 41 | 42 | ax.set_xlim(-2, 32) 43 | ax.set_xlabel('$t$') 44 | ax.set_ylabel('$y(t)$') 45 | 46 | # Second panel: periodogram 47 | ax = fig.add_subplot(212) 48 | ax.plot(omega, P_S, '--k', lw=1, label='standard') 49 | ax.plot(omega, P_G, '-k', lw=1, label='generalized') 50 | ax.legend(loc=2, prop=dict(size=14)) 51 | 52 | # plot the significance lines. 53 | xlim = (omega[0], omega[-1]) 54 | for zi, pi in zip(z, sig): 55 | ax.plot(xlim, (zi, zi), ':k', lw=1) 56 | ax.text(xlim[-1] - 0.001, zi - 0.02, "$%.1g$" % pi, ha='right', va='top') 57 | 58 | ax.set_xlabel('$\omega$') 59 | ax.set_ylabel('$P_{LS}(\omega)$') 60 | ax.set_ylim(0, 1.1) 61 | plt.show() 62 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_S82_scatter_contour.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Stripe 82 Standard Stars 3 | ----------------------------- 4 | Figure 1.9. 5 | 6 | Scatter plot with contours over dense regions.This is a color-color diagram 7 | of the entire set of SDSS Stripe 82 standard stars; cf. figure 1.6. 8 | """ 9 | # Author: Jake VanderPlas 10 | # License: BSD 11 | # The figure produced by this code is published in the textbook 12 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 13 | # For more information, see http://astroML.github.com 14 | # To report a bug or issue, use the following forum: 15 | # https://groups.google.com/forum/#!forum/astroml-general 16 | from matplotlib import pyplot as plt 17 | 18 | from astroML.plotting import scatter_contour 19 | from astroML.datasets import fetch_sdss_S82standards 20 | 21 | #---------------------------------------------------------------------- 22 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 23 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 24 | # result in an error if LaTeX is not installed on your system. In that case, 25 | # you can set usetex to False. 26 | from astroML.plotting import setup_text_plots 27 | setup_text_plots(fontsize=8, usetex=True) 28 | 29 | #------------------------------------------------------------ 30 | # Fetch the Stripe 82 standard star catalog 31 | 32 | data = fetch_sdss_S82standards() 33 | 34 | g = data['mmu_g'] 35 | r = data['mmu_r'] 36 | i = data['mmu_i'] 37 | 38 | #------------------------------------------------------------ 39 | # plot the results 40 | fig, ax = plt.subplots(figsize=(5, 3.75)) 41 | scatter_contour(g - r, r - i, threshold=200, log_counts=True, ax=ax, 42 | histogram2d_args=dict(bins=40), 43 | plot_args=dict(marker=',', linestyle='none', color='black'), 44 | contour_args=dict(cmap=plt.cm.bone)) 45 | 46 | ax.set_xlabel(r'${\rm g - r}$') 47 | ax.set_ylabel(r'${\rm r - i}$') 48 | 49 | ax.set_xlim(-0.6, 2.5) 50 | ax.set_ylim(-0.6, 2.5) 51 | 52 | plt.show() 53 | -------------------------------------------------------------------------------- /book_figures/chapter10/compute_periods.py: -------------------------------------------------------------------------------- 1 | """ 2 | Compute periods for the LINEAR data 3 | ----------------------------------- 4 | """ 5 | from __future__ import print_function 6 | 7 | from time import time 8 | import numpy as np 9 | from astroML.datasets import fetch_LINEAR_sample 10 | from astroML.time_series import lomb_scargle, multiterm_periodogram, \ 11 | search_frequencies 12 | 13 | import sqlite3 14 | 15 | Ngrid = 50000 16 | DATABASE = 'periods.db' 17 | 18 | data = fetch_LINEAR_sample() 19 | 20 | # set up a database to hold periods 21 | con = sqlite3.connect(DATABASE) 22 | 23 | with con: 24 | cur = con.cursor() 25 | 26 | try: 27 | cur.execute("CREATE TABLE Periods(id INT, omega FLOAT)") 28 | except: 29 | pass 30 | 31 | for count, id in enumerate(data.ids): 32 | # only compute period if it hasn't been computed before 33 | cur.execute("SELECT * from Periods WHERE id = %i" % id) 34 | res = cur.fetchall() 35 | 36 | if len(res) > 0: 37 | print(res[0]) 38 | 39 | else: 40 | print("computing period for id = {0} ({1} / {2})" 41 | "".format(id, count + 1, len(data.ids)))) 42 | 43 | lc = data[id] 44 | 45 | t0 = time() 46 | omega, power = search_frequencies(lc[:, 0], lc[:, 1], lc[:, 2], 47 | LS_func=multiterm_periodogram, 48 | n_save=5, n_retry=5, 49 | n_eval=10000, 50 | LS_kwargs=dict(n_terms=5)) 51 | omega_best = omega[np.argmax(power)] 52 | t1 = time() 53 | print(" - execution time: %.2g sec" % (t1 - t0)) 54 | 55 | # insert value and commit to disk 56 | cur.execute("INSERT INTO Periods VALUES(%i, %f)" 57 | % (id, omega_best)) 58 | con.commit() 59 | 60 | con.close() 61 | 62 | #cur.execute("SELECT * from Periods") 63 | #print(cur.fetchall()) 64 | -------------------------------------------------------------------------------- /examples/algorithms/fig_volume_ratio.py: -------------------------------------------------------------------------------- 1 | """ 2 | Curse of Dimensionality: Volume Ratio 3 | ------------------------------------- 4 | 5 | This figure shows the ratio of the volume of a unit hypercube to the volume 6 | of an inscribed hypersphere. The curse of dimensionality is illustrated in 7 | the fact that this ratio approaches zero as the number of dimensions 8 | approaches infinity. 9 | """ 10 | # Author: Jake VanderPlas 11 | # License: BSD 12 | # The figure produced by this code is published in the textbook 13 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 14 | # For more information, see http://astroML.github.com 15 | # To report a bug or issue, use the following forum: 16 | # https://groups.google.com/forum/#!forum/astroml-general 17 | import numpy as np 18 | from matplotlib import pyplot as plt 19 | from scipy.special import gamma, gammaln 20 | 21 | #---------------------------------------------------------------------- 22 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 23 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 24 | # result in an error if LaTeX is not installed on your system. In that case, 25 | # you can set usetex to False. 26 | from astroML.plotting import setup_text_plots 27 | setup_text_plots(fontsize=8, usetex=True) 28 | 29 | dims = np.arange(0, 51) 30 | 31 | # log of volume of a sphere with r = 1 32 | log_V_sphere = (np.log(2) + 0.5 * dims * np.log(np.pi) 33 | - np.log(dims) - gammaln(0.5 * dims)) 34 | 35 | log_V_cube = dims * np.log(2) 36 | 37 | # compute the log of f_k to avoid overflow errors 38 | log_f_k = log_V_sphere - log_V_cube 39 | 40 | fig, ax = plt.subplots(figsize=(5, 3.75)) 41 | ax.semilogy(dims, np.exp(log_V_cube), '-k', 42 | label='side-2 hypercube') 43 | ax.semilogy(dims, np.exp(log_V_sphere), '--k', 44 | label='inscribed unit hypersphere') 45 | 46 | ax.set_xlim(0, 50) 47 | ax.set_ylim(1E-13, 1E15) 48 | 49 | ax.set_xlabel('Number of Dimensions') 50 | ax.set_ylabel('Hyper-Volume') 51 | ax.legend(loc=3) 52 | 53 | plt.show() 54 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_sdss_S82standards.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Stripe 82 Standard Stars 3 | ----------------------------- 4 | Figure 1.6. 5 | 6 | The g-r vs. r-i color-color diagram for the first 10,000 entries in the 7 | Stripe 82 Standard Star Catalog. The region with the highest point density 8 | is dominated by main sequence stars. The thin extension toward the lower-left 9 | corner is dominated by the so-called blue horizontal branch stars and white 10 | dwarf stars. 11 | """ 12 | # Author: Jake VanderPlas 13 | # License: BSD 14 | # The figure produced by this code is published in the textbook 15 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 16 | # For more information, see http://astroML.github.com 17 | # To report a bug or issue, use the following forum: 18 | # https://groups.google.com/forum/#!forum/astroml-general 19 | from matplotlib import pyplot as plt 20 | from astroML.datasets import fetch_sdss_S82standards 21 | 22 | #---------------------------------------------------------------------- 23 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 24 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 25 | # result in an error if LaTeX is not installed on your system. In that case, 26 | # you can set usetex to False. 27 | from astroML.plotting import setup_text_plots 28 | setup_text_plots(fontsize=8, usetex=True) 29 | 30 | #------------------------------------------------------------ 31 | # Fetch the stripe 82 data 32 | data = fetch_sdss_S82standards() 33 | 34 | # select the first 10000 points 35 | data = data[:10000] 36 | 37 | # select the mean magnitudes for g, r, i 38 | g = data['mmu_g'] 39 | r = data['mmu_r'] 40 | i = data['mmu_i'] 41 | 42 | #------------------------------------------------------------ 43 | # Plot the g-r vs r-i colors 44 | fig, ax = plt.subplots(figsize=(5, 3.75)) 45 | ax.plot(g - r, r - i, marker='.', markersize=2, 46 | color='black', linestyle='none') 47 | 48 | ax.set_xlim(-0.6, 2.0) 49 | ax.set_ylim(-0.6, 2.5) 50 | 51 | ax.set_xlabel(r'${\rm g - r}$') 52 | ax.set_ylabel(r'${\rm r - i}$') 53 | 54 | plt.show() 55 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_specgals.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Spectroscopic Galaxy Sample 3 | -------------------------------- 4 | This figure shows photometric colors of the SDSS spectroscopic galaxy 5 | sample. 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | import numpy as np 11 | from matplotlib import pyplot as plt 12 | 13 | from astroML.datasets import fetch_sdss_specgals 14 | 15 | data = fetch_sdss_specgals() 16 | 17 | #------------------------------------------------------------ 18 | # plot the RA/DEC in an area-preserving projection 19 | 20 | RA = data['ra'] 21 | DEC = data['dec'] 22 | 23 | # convert coordinates to degrees 24 | RA -= 180 25 | RA *= np.pi / 180 26 | DEC *= np.pi / 180 27 | 28 | ax = plt.axes(projection='mollweide') 29 | 30 | ax = plt.axes() 31 | ax.grid() 32 | plt.scatter(RA, DEC, s=1, lw=0, c=data['z'], cmap=plt.cm.copper, 33 | vmin=0, vmax=0.4) 34 | 35 | plt.title('SDSS DR8 Spectroscopic Galaxies') 36 | cb = plt.colorbar(cax=plt.axes([0.05, 0.1, 0.9, 0.05]), 37 | orientation='horizontal', 38 | ticks=np.linspace(0, 0.4, 9)) 39 | cb.set_label('redshift') 40 | 41 | 42 | #------------------------------------------------------------ 43 | # plot the r vs u-r color-magnitude diagram 44 | u = data['modelMag_u'] 45 | r = data['modelMag_r'] 46 | rPetro = data['petroMag_r'] 47 | 48 | plt.figure() 49 | ax = plt.axes() 50 | plt.scatter(u - r, rPetro, s=1, lw=0, c=data['z'], cmap=plt.cm.copper, 51 | vmin=0, vmax=0.4) 52 | plt.colorbar(ticks=np.linspace(0, 0.4, 9)).set_label('redshift') 53 | 54 | plt.xlim(0.5, 5.5) 55 | plt.ylim(18, 12.5) 56 | 57 | plt.xlabel('u-r') 58 | plt.ylabel('rPetrosian') 59 | 60 | #------------------------------------------------------------ 61 | # plot a histogram of the redshift 62 | from astroML.plotting import hist 63 | 64 | plt.figure() 65 | hist(data['z'], bins='knuth', 66 | histtype='stepfilled', ec='k', fc='#F5CCB0') 67 | plt.xlim(0, 0.4) 68 | plt.xlabel('z (redshift)') 69 | plt.ylabel('dN/dz(z)') 70 | 71 | plt.show() 72 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_moving_objects.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Moving Object Data 3 | ----------------------- 4 | Figure 1.8. 5 | 6 | The orbital semimajor axis vs. the orbital inclination angle diagram for the 7 | first 10,000 catalog entries from the SDSS Moving Object Catalog (after 8 | applying several quality cuts). The gaps at approximately 2.5, 2.8, and 3.3 AU 9 | are called the Kirkwood gaps and are due to orbital resonances with Jupiter. 10 | The several distinct clumps are called asteroid families and represent remnants 11 | from collisions of larger asteroids. 12 | """ 13 | # Author: Jake VanderPlas 14 | # License: BSD 15 | # The figure produced by this code is published in the textbook 16 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 17 | # For more information, see http://astroML.github.com 18 | # To report a bug or issue, use the following forum: 19 | # https://groups.google.com/forum/#!forum/astroml-general 20 | from matplotlib import pyplot as plt 21 | from astroML.datasets import fetch_moving_objects 22 | 23 | #---------------------------------------------------------------------- 24 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 25 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 26 | # result in an error if LaTeX is not installed on your system. In that case, 27 | # you can set usetex to False. 28 | from astroML.plotting import setup_text_plots 29 | setup_text_plots(fontsize=8, usetex=True) 30 | 31 | #------------------------------------------------------------ 32 | # Fetch the moving object data 33 | data = fetch_moving_objects(Parker2008_cuts=True) 34 | 35 | # Use only the first 10000 points 36 | data = data[:10000] 37 | 38 | a = data['aprime'] 39 | sini = data['sin_iprime'] 40 | 41 | #------------------------------------------------------------ 42 | # Plot the results 43 | fig, ax = plt.subplots(figsize=(5, 3.75)) 44 | ax.plot(a, sini, '.', markersize=2, color='black') 45 | 46 | ax.set_xlim(2.0, 3.6) 47 | ax.set_ylim(-0.01, 0.31) 48 | 49 | ax.set_xlabel('Semimajor Axis (AU)') 50 | ax.set_ylabel('Sine of Inclination Angle') 51 | 52 | plt.show() 53 | -------------------------------------------------------------------------------- /examples/datasets/plot_sdss_imaging.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Imaging 3 | ============ 4 | This example shows how to load the magnitude data from the SDSS imaging 5 | catalog, and plot colors and magnitudes of the stars and galaxies. 6 | """ 7 | # Author: Jake VanderPlas 8 | # License: BSD 9 | # The figure is an example from astroML: see http://astroML.github.com 10 | import numpy as np 11 | from matplotlib import pyplot as plt 12 | from astroML.datasets import fetch_imaging_sample 13 | 14 | #------------------------------------------------------------ 15 | # Get the star/galaxy data 16 | data = fetch_imaging_sample() 17 | 18 | objtype = data['type'] 19 | 20 | stars = data[objtype == 6][:5000] 21 | galaxies = data[objtype == 3][:5000] 22 | 23 | #------------------------------------------------------------ 24 | # Plot the stars and galaxies 25 | plot_kwargs = dict(color='k', linestyle='none', marker='.', markersize=1) 26 | 27 | fig = plt.figure() 28 | 29 | ax1 = fig.add_subplot(221) 30 | ax1.plot(galaxies['gRaw'] - galaxies['rRaw'], 31 | galaxies['rRaw'], 32 | **plot_kwargs) 33 | 34 | ax2 = fig.add_subplot(223, sharex=ax1) 35 | ax2.plot(galaxies['gRaw'] - galaxies['rRaw'], 36 | galaxies['rRaw'] - galaxies['iRaw'], 37 | **plot_kwargs) 38 | 39 | ax3 = fig.add_subplot(222, sharey=ax1) 40 | ax3.plot(stars['gRaw'] - stars['rRaw'], 41 | stars['rRaw'], 42 | **plot_kwargs) 43 | 44 | ax4 = fig.add_subplot(224, sharex=ax3, sharey=ax2) 45 | ax4.plot(stars['gRaw'] - stars['rRaw'], 46 | stars['rRaw'] - stars['iRaw'], 47 | **plot_kwargs) 48 | 49 | # set labels and titles 50 | ax1.set_ylabel('$r$') 51 | ax2.set_ylabel('$r-i$') 52 | ax2.set_xlabel('$g-r$') 53 | ax4.set_xlabel('$g-r$') 54 | ax1.set_title('Galaxies') 55 | ax3.set_title('Stars') 56 | 57 | # set axis limits 58 | ax2.set_xlim(-0.5, 3) 59 | ax3.set_ylim(22.5, 14) 60 | ax4.set_xlim(-0.5, 3) 61 | ax4.set_ylim(-1, 2) 62 | 63 | # adjust tick spacings on all axes 64 | for ax in (ax1, ax2, ax3, ax4): 65 | ax.xaxis.set_major_locator(plt.MultipleLocator(1)) 66 | ax.yaxis.set_major_locator(plt.MultipleLocator(1)) 67 | 68 | plt.show() 69 | -------------------------------------------------------------------------------- /book_figures/chapter9/fig_bayes_DB.py: -------------------------------------------------------------------------------- 1 | """ 2 | Bayes Decision Boundary 3 | ----------------------- 4 | Figure 9.1 5 | 6 | An illustration of a decision boundary between two Gaussian distributions. 7 | """ 8 | # Author: Jake VanderPlas 9 | # License: BSD 10 | # The figure produced by this code is published in the textbook 11 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 12 | # For more information, see http://astroML.github.com 13 | # To report a bug or issue, use the following forum: 14 | # https://groups.google.com/forum/#!forum/astroml-general 15 | import numpy as np 16 | from matplotlib import pyplot as plt 17 | from scipy.stats import norm 18 | 19 | #---------------------------------------------------------------------- 20 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 21 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 22 | # result in an error if LaTeX is not installed on your system. In that case, 23 | # you can set usetex to False. 24 | from astroML.plotting import setup_text_plots 25 | setup_text_plots(fontsize=8, usetex=True) 26 | 27 | #------------------------------------------------------------ 28 | # Compute the two PDFs 29 | x = np.linspace(-3, 7, 1000) 30 | pdf1 = norm(0, 1).pdf(x) 31 | pdf2 = norm(3, 1.5).pdf(x) 32 | x_bound = x[np.where(pdf1 < pdf2)][0] 33 | 34 | #------------------------------------------------------------ 35 | # Plot the pdfs and decision boundary 36 | fig = plt.figure(figsize=(5, 3.75)) 37 | ax = fig.add_subplot(111) 38 | ax.plot(x, pdf1, '-k', lw=1) 39 | ax.fill_between(x, pdf1, color='gray', alpha=0.5) 40 | 41 | ax.plot(x, pdf2, '-k', lw=1) 42 | ax.fill_between(x, pdf2, color='gray', alpha=0.5) 43 | 44 | # plot decision boundary 45 | ax.plot([x_bound, x_bound], [0, 0.5], '--k') 46 | 47 | ax.text(x_bound + 0.2, 0.49, "decision boundary", 48 | ha='left', va='top', rotation=90) 49 | 50 | ax.text(0, 0.2, '$g_1(x)$', ha='center', va='center') 51 | 52 | ax.text(3, 0.1, '$g_2(x)$', ha='center', va='center') 53 | 54 | ax.set_xlim(-2, 7) 55 | ax.set_ylim(0, 0.5) 56 | 57 | ax.set_xlabel('$x$') 58 | ax.set_ylabel('$p(x)$') 59 | 60 | plt.show() 61 | -------------------------------------------------------------------------------- /astroML/datasets/sdss_spectrum.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | import os 4 | 5 | import numpy as np 6 | 7 | from .tools import get_data_home, download_with_progress_bar,\ 8 | SDSSfits, sdss_fits_url, sdss_fits_filename 9 | 10 | 11 | def fetch_sdss_spectrum(plate, mjd, fiber, data_home=None, 12 | download_if_missing=True, 13 | cache_to_disk=True): 14 | """Fetch an SDSS spectrum from the Data Archive Server 15 | 16 | Parameters 17 | ---------- 18 | plate: integer 19 | plate number of desired spectrum 20 | mjd: integer 21 | mean julian date of desired spectrum 22 | fiber: integer 23 | fiber number of desired spectrum 24 | 25 | Other Parameters 26 | ---------------- 27 | data_home: string (optional) 28 | directory in which to cache downloaded fits files. If not 29 | specified, it will be set to ~/astroML_data 30 | download_if_missing: boolean (default = True) 31 | download the fits file if it is not cached locally 32 | cache_to_disk: boolean (default = True) 33 | cache downloaded file to data_home 34 | 35 | Returns 36 | ------- 37 | spec: :class:`astroML.tools.SDSSfits` object 38 | An object wrapper for the fits data 39 | """ 40 | data_home = get_data_home(data_home) 41 | 42 | target_url = sdss_fits_url(plate, mjd, fiber) 43 | target_file = os.path.join(data_home, 'SDSSspec', '%04i' % plate, 44 | sdss_fits_filename(plate, mjd, fiber)) 45 | 46 | if not os.path.exists(target_file): 47 | if not download_if_missing: 48 | raise IOError("SDSS colors training data not found") 49 | 50 | buf = download_with_progress_bar(target_url, return_buffer=True) 51 | 52 | if cache_to_disk: 53 | print("caching to %s" % target_file) 54 | if not os.path.exists(os.path.dirname(target_file)): 55 | os.makedirs(os.path.dirname(target_file)) 56 | fhandler = open(target_file, 'wb') 57 | fhandler.write(buf.read()) 58 | buf.seek(0) 59 | else: 60 | buf = target_file 61 | 62 | return SDSSfits(buf) 63 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | 3 | DESCRIPTION = "tools for machine learning and data mining in Astronomy" 4 | LONG_DESCRIPTION = open('README.rst').read() 5 | NAME = "astroML" 6 | AUTHOR = "Jake VanderPlas" 7 | AUTHOR_EMAIL = "vanderplas@astro.washington.edu" 8 | MAINTAINER = "Jake VanderPlas" 9 | MAINTAINER_EMAIL = "vanderplas@astro.washington.edu" 10 | URL = 'http://astroML.github.com' 11 | DOWNLOAD_URL = 'http://github.com/astroML/astroML' 12 | LICENSE = 'BSD' 13 | 14 | import astroML 15 | VERSION = astroML.__version__ 16 | 17 | setup(name=NAME, 18 | version=VERSION, 19 | description=DESCRIPTION, 20 | long_description=LONG_DESCRIPTION, 21 | author=AUTHOR, 22 | author_email=AUTHOR_EMAIL, 23 | maintainer=MAINTAINER, 24 | maintainer_email=MAINTAINER_EMAIL, 25 | url=URL, 26 | download_url=DOWNLOAD_URL, 27 | license=LICENSE, 28 | packages=['astroML', 29 | 'astroML.tests', 30 | 'astroML.clustering', 31 | 'astroML.clustering.tests', 32 | 'astroML.classification', 33 | 'astroML.linear_model', 34 | 'astroML.datasets', 35 | 'astroML.datasets.tools', 36 | 'astroML.density_estimation', 37 | 'astroML.density_estimation.tests', 38 | 'astroML.time_series', 39 | 'astroML.time_series.tests', 40 | 'astroML.dimensionality', 41 | 'astroML.dimensionality.tests', 42 | 'astroML.plotting', 43 | 'astroML.plotting.tests', 44 | 'astroML.stats', 45 | 'astroML.stats.tests', 46 | ], 47 | classifiers=[ 48 | 'Development Status :: 4 - Beta', 49 | 'Environment :: Console', 50 | 'Intended Audience :: Science/Research', 51 | 'License :: OSI Approved :: BSD License', 52 | 'Natural Language :: English', 53 | 'Programming Language :: Python :: 2.6', 54 | 'Programming Language :: Python :: 2.7', 55 | 'Programming Language :: Python :: 3.3', 56 | 'Programming Language :: Python :: 3.4', 57 | 'Topic :: Scientific/Engineering :: Astronomy'], 58 | ) 59 | -------------------------------------------------------------------------------- /book_figures/chapter1/fig_SDSS_specgals.py: -------------------------------------------------------------------------------- 1 | """ 2 | SDSS Spectroscopic Galaxy Sample 3 | -------------------------------- 4 | Figure 1.3. 5 | 6 | The r vs. u-r color-magnitude diagram for the first 10,000 entries in the 7 | catalog of spectroscopically observed galaxies from the Sloan Digital Sky 8 | Survey (SDSS). Note two "clouds" of points with different morphologies 9 | separated by u-r ~ 2.3. The abrupt decrease of the point density for 10 | r > 17.7 (the bottom of the diagram) is due to the selection function for 11 | the spectroscopic galaxy sample from SDSS. This example shows how to fetch 12 | photometric data from the SDSS spectroscopic sample and plot a simple 13 | color-magnitude diagram. 14 | """ 15 | # Author: Jake VanderPlas 16 | # License: BSD 17 | # The figure produced by this code is published in the textbook 18 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 19 | # For more information, see http://astroML.github.com 20 | # To report a bug or issue, use the following forum: 21 | # https://groups.google.com/forum/#!forum/astroml-general 22 | import numpy as np 23 | from matplotlib import pyplot as plt 24 | from astroML.datasets import fetch_sdss_specgals 25 | 26 | #---------------------------------------------------------------------- 27 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 28 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 29 | # result in an error if LaTeX is not installed on your system. In that case, 30 | # you can set usetex to False. 31 | from astroML.plotting import setup_text_plots 32 | setup_text_plots(fontsize=8, usetex=True) 33 | 34 | #------------------------------------------------------------ 35 | # Fetch spectroscopic galaxy data 36 | data = fetch_sdss_specgals() 37 | data = data[:10000] 38 | 39 | u = data['modelMag_u'] 40 | r = data['modelMag_r'] 41 | rPetro = data['petroMag_r'] 42 | 43 | #------------------------------------------------------------ 44 | # Plot the galaxy colors and magnitudes 45 | fig, ax = plt.subplots(figsize=(5, 3.75)) 46 | ax.plot(u - r, rPetro, '.k', markersize=2) 47 | 48 | ax.set_xlim(1, 4.5) 49 | ax.set_ylim(18.1, 13.5) 50 | 51 | ax.set_xlabel(r'$\mathrm{u - r}$') 52 | ax.set_ylabel(r'$\mathrm{r_{petrosian}}$') 53 | 54 | plt.show() 55 | -------------------------------------------------------------------------------- /book_figures/chapter10/fig_gaussian_reconstruct.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fourier Reconstruction of a Gaussian 3 | ------------------------------------ 4 | This figure demonstrates Fourier decomposition of a Gaussian 5 | """ 6 | # Author: Jake VanderPlas 7 | # License: BSD 8 | # The figure produced by this code is published in the textbook 9 | # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) 10 | # For more information, see http://astroML.github.com 11 | # To report a bug or issue, use the following forum: 12 | # https://groups.google.com/forum/#!forum/astroml-general 13 | import numpy as np 14 | from matplotlib import pyplot as plt 15 | 16 | from scipy.stats import norm 17 | 18 | #---------------------------------------------------------------------- 19 | # This function adjusts matplotlib settings for a uniform feel in the textbook. 20 | # Note that with usetex=True, fonts are rendered with LaTeX. This may 21 | # result in an error if LaTeX is not installed on your system. In that case, 22 | # you can set usetex to False. 23 | from astroML.plotting import setup_text_plots 24 | setup_text_plots(fontsize=8, usetex=True) 25 | 26 | x = np.linspace(-50, 50, 10000) 27 | y = norm.pdf(x, 0, 1) 28 | 29 | fig = plt.figure(figsize=(5, 3.75)) 30 | fig.subplots_adjust(hspace=0) 31 | 32 | kvals = [20, 30, 50] 33 | subplots = [311, 312, 313] 34 | 35 | for (k, subplot) in zip(kvals, subplots): 36 | ax = fig.add_subplot(subplot) 37 | 38 | # Use FFT to fit a truncated Fourier series 39 | y_fft = np.fft.fft(y) 40 | y_fft[k + 1:-k] = 0 41 | y_fit = np.fft.ifft(y_fft).real 42 | 43 | ax.plot(x, y, color='gray') 44 | ax.plot(x, y_fit, color='black') 45 | 46 | if k == 1: 47 | ax.text(0.01, 0.95, "1 mode", ha='left', va='top', 48 | transform=ax.transAxes) 49 | else: 50 | ax.text(0.01, 0.95, "%i modes" % k, ha='left', va='top', 51 | transform=ax.transAxes) 52 | 53 | if subplot == subplots[-1]: 54 | ax.set_xlabel('phase') 55 | else: 56 | ax.xaxis.set_major_formatter(plt.NullFormatter()) 57 | 58 | if subplot == subplots[1]: 59 | ax.set_ylabel('amplitude') 60 | ax.yaxis.set_major_formatter(plt.NullFormatter()) 61 | 62 | ax.set_xlim(-5, 5) 63 | ax.set_ylim(-0.05, 0.5) 64 | 65 | 66 | plt.show() 67 | -------------------------------------------------------------------------------- /paper_figures/CIDU2012/fig_great_wall_MST.py: -------------------------------------------------------------------------------- 1 | """ 2 | Euclidean Minimum Spanning Tree 3 | ------------------------------- 4 | """ 5 | # Author: Jake VanderPlas 6 | # License: BSD 7 | # The figure is an example from astroML: see http://astroML.github.com 8 | import numpy as np 9 | from matplotlib import pyplot as plt 10 | 11 | from scipy.interpolate import interp1d 12 | from sklearn.neighbors import kneighbors_graph 13 | 14 | try: 15 | from scipy.sparse.csgraph import minimum_spanning_tree 16 | except: 17 | raise ValueError("scipy v0.11 or greater required " 18 | "for minimum spanning tree") 19 | 20 | from astroML.datasets import fetch_great_wall 21 | from astroML.cosmology import Cosmology 22 | 23 | #------------------------------------------------------------ 24 | # get data 25 | X = fetch_great_wall() 26 | 27 | xmin, xmax = (-375, -175) 28 | ymin, ymax = (-300, 200) 29 | 30 | #------------------------------------------------------------ 31 | # generate a sparse graph using the k nearest neighbors of each point 32 | G = kneighbors_graph(X, n_neighbors=10, mode='distance') 33 | 34 | #------------------------------------------------------------ 35 | # Compute the minimum spanning tree of this graph 36 | T = minimum_spanning_tree(G, overwrite=True) 37 | 38 | #------------------------------------------------------------ 39 | # Get the x, y coordinates of the beginning and end of each line segment 40 | T = T.tocoo() 41 | 42 | dist = T.data 43 | p1 = T.row 44 | p2 = T.col 45 | 46 | A = X[p1].T 47 | B = X[p2].T 48 | 49 | x_coords = np.vstack([A[0], B[0]]) 50 | y_coords = np.vstack([A[1], B[1]]) 51 | 52 | #---------------------------------------------------------------------- 53 | # Plot the results 54 | fig = plt.figure() 55 | fig.subplots_adjust(hspace=0, left=0.1, right=0.95, bottom=0.1, top=0.9) 56 | 57 | ax = fig.add_subplot(211, aspect='equal') 58 | ax.scatter(X[:, 1], X[:, 0], s=1, lw=0, c='k') 59 | ax.set_xlim(ymin, ymax) 60 | ax.set_ylim(xmin, xmax) 61 | ax.xaxis.set_major_formatter(plt.NullFormatter()) 62 | ax.set_ylabel('x (Mpc)') 63 | 64 | ax = fig.add_subplot(212, aspect='equal') 65 | ax.plot(y_coords, x_coords, c='k', lw=1) 66 | ax.set_xlim(ymin, ymax) 67 | ax.set_ylim(xmin, xmax) 68 | ax.set_xlabel('y (Mpc)') 69 | ax.set_ylabel('x (Mpc)') 70 | 71 | plt.show() 72 | -------------------------------------------------------------------------------- /doc/user_guide/introduction.rst: -------------------------------------------------------------------------------- 1 | .. _introduction: 2 | 3 | Introduction 4 | ============ 5 | 6 | .. _philosopy: 7 | 8 | Philosophy 9 | ---------- 10 | astroML is a Python module built within the framework of Python's Scipy 11 | ecosystem, designed as a repository for fast and well-tested code for 12 | the analysis of astronomical data. It is envisioned to be a community 13 | resource, with the development and submission of new algorithms, data sets, 14 | and examples provided by `GitHub's `_ collaborative 15 | coding interface. 16 | 17 | astroML is designed to be a resource for both researchers and students of 18 | astronomy and Python. Rather than focusing on re-developing fast algorithms, 19 | astroML makes use of the large collection of well-tested routines available 20 | in `numpy `_, 21 | `scipy `_, 22 | `scikit-learn `_, 23 | `matplotlib `_, and other packages. 24 | 25 | astroML strives to bring the astronomical community closer to the ideals of 26 | `Reproducible Research `_, 27 | in which research papers are accompanied by well-written code to duplicate, 28 | check, and extend the results. 29 | 30 | .. _textbook: 31 | 32 | Textbook 33 | -------- 34 | 35 | .. image:: ../_static/text_cover.png 36 | :width: 150 px 37 | :align: right 38 | :target: http://www.amazon.com/Statistics-Mining-Machine-Learning-Astronomy/dp/0691151687/ 39 | 40 | The astroML package is used to create all of the examples and figures in the 41 | book **Statistics, Data Mining, and Machine Learning in Astronomy**, 42 | by Zeljko Ivezic, Andrew Connolly, Jacob Vanderplas, and Alex Gray, 43 | published by Princeton University Press 44 | (`view on Amazon `_). 45 | These figures can be seen in the :ref:`book_fig_root` section, along with 46 | the full Python scripts used to generate them. 47 | 48 | The text contains detailed theoretical background of many of the 49 | tools and methods available in astroML, and also many of the tools 50 | available in `scikit-learn `_ 51 | which are used in the examples here. The on-line documentation at this site 52 | is growing, but we recommend refering to the text for more details. 53 | --------------------------------------------------------------------------------