Example #1
0
def main(args=None):

    parser = argparse.ArgumentParser(description="SkyPy pipeline driver")
    parser.add_argument('--version', action='version', version=skypy_version)
    parser.add_argument('config', help='Config file name')
    parser.add_argument('-f',
                        '--format',
                        required=False,
                        choices=['fits', 'hdf5'],
                        help='Table file format')
    parser.add_argument('-o',
                        '--overwrite',
                        action='store_true',
                        help='Whether to overwrite existing files')

    # get system args if none passed
    if args is None:
        args = sys.argv[1:]

    args = parser.parse_args(args or ['--help'])

    pipeline = Pipeline.read(args.config)
    pipeline.execute()
    pipeline.write(file_format=args.format, overwrite=args.overwrite)
    return (0)
Example #2
0
def test_pipeline_read():

    # Test reading config from a file
    filename = get_pkg_data_filename('data/test_config.yml')
    pipeline = Pipeline.read(filename)
    pipeline.execute()
    assert isinstance(pipeline['test_int'], int)
    assert isinstance(pipeline['test_float'], float)
    assert isinstance(pipeline['test_str'], str)
    assert isinstance(pipeline['cosmology'], Cosmology)
    assert isinstance(pipeline['test_table_1'], Table)
    assert isinstance(pipeline['test_table_1']['test_column_3'], Column)
Example #3
0
def setup(options):
    module_name = options['pipeline', 'current_module']

    filename = options.get_string(option_section, 'pipeline')
    pipeline = Pipeline.read(filename)

    for parameter_name, parameter_value in pipeline.parameters.items():
        register_new_parameter(options,
                               module_name,
                               parameter_name,
                               *parameter_expand(parameter_value))

    results = options.get_string(option_section, 'results')

    results_map = {}
    for line in results.splitlines():
        section_name, skypy_label = tuple(map(str.strip, line.split('=')))
        section, _, name = section_name.partition('--')
        results_map[section, name] = skypy_label

    return module_name, pipeline, results_map
Example #4
0
# SDSS Photometry
# ---------------
#
# Here we compare the apparent magnitude distributions of our simulated
# galaxies with data from a :math:`10 \, \mathrm{deg^2}` region of the Sloan
# Digital Sky Survey [3]_. The binned SDSS magnitude distributions were
# generated from a query of the DR7 data release and can be downloaded
# :download:`here <../../../examples/galaxies/sdss_dered_10deg2.ecsv>`.

from astropy.table import Table, vstack
from matplotlib import pyplot as plt
import numpy as np
from skypy.pipeline import Pipeline

# Execute SkyPy galaxy photometry simulation pipeline
pipeline = Pipeline.read("sdss_photometry.yml")
pipeline.execute()
skypy_galaxies = vstack([pipeline['blue_galaxies'], pipeline['red_galaxies']])

# SDSS magnitude distributions for a 10 degree^2 region
sdss_data = Table.read("sdss_dered_10deg2.ecsv", format='ascii.ecsv')

# Plot magnitude distributions for SkyPy simulation and SDSS data
bins = np.linspace(14.95, 25.05, 102)
plt.hist(skypy_galaxies['mag_r'],
         bins=bins,
         alpha=0.5,
         color='r',
         label='SkyPy-r')
plt.hist(skypy_galaxies['mag_u'],
         bins=bins,
Example #5
0
from astropy.table import Table
from astropy.utils.data import download_file

from skypy.pipeline import Pipeline

# survey parameters
cosmology = FlatLambdaCDM(Om0=0.3, H0=70)
survey_area = u.Quantity('2.38 deg2')

# download catalogue
alhambra = download_file(
    'http://svo2.cab.inta-csic.es/vocats/alhambra/download/alhambra.csv.gz',
    cache=True)

# simulate with SkyPy
sim = Pipeline.read('fig_9.yml')
sim.execute()


# the model
def schechter_SF(M, z):
    M_star = -21.00 - 1.03 * (z - 0.5)
    phi_star = 10.**(-2.51 - 0.01 * (z - 0.5))
    alpha = -1.29
    M = np.reshape(M, (-1, 1))
    return 0.4 * np.log(10) * phi_star * 10.**(
        -0.4 * (M - M_star) * (alpha + 1)) * np.exp(-10.**(-0.4 *
                                                           (M - M_star)))


# four redshift bins