Exemple #1
0
def main():

    ##
    # Read arguments
    opts = pycymatch_opts.get_opts().parse_args()

    ##
    # Check input files
    for file in opts.input_files:
        errors.file_name_error(file)

    pycymatch_extra.h_line()

    ##
    # Read mock halo catalogue
    mock = pycymatch_io.read_mock(opts)

    ##
    # Read observed catalogue
    obs = pycymatch_io.read_obs(opts)

    pycymatch_extra.h_line()

    ##
    # Find Matches
    matches = pycymatch_match2.find_matches(mock, obs, 2.0 * opts.delta_z,
                                            opts)
    pycymatch_io.print_matches(mock[matches[2]], obs, matches[0], matches[1],
                               opts)

    ##
    # Define completeness and purity of sample
    c_matrix = pycymatch_cp.get_completeness(mock, matches, opts)
    p_matrix = pycymatch_cp.get_purity(obs, matches, opts)

    ##
    # Define mass-observable matrix for matched objects
    matrix, hm_matrix, ranges = pycymatch_match2.mo_matrix(mock, obs, matches,
                                                           opts)

    pycymatch_extra.h_line()

    ##
    # Make plots
    pycymatch_plot.make_plots(matrix, hm_matrix, ranges, opts)
    pycymatch_plot.plot_complete(c_matrix[0], 'mass', opts)
    pycymatch_plot.plot_complete(c_matrix[1], 'ngal', opts)
    pycymatch_plot.plot_pure(p_matrix, opts)

    ##
    # Save matrix to file
    pycymatch_io.print_matrix(matrix, hm_matrix, ranges, opts)

    pycymatch_extra.h_line()
Exemple #2
0
def main():

    ##
    # Read arguments
    opts = get_opts().parse_args()

    ##
    # Check input files
    for file in opts.input_files:
        errors.file_name_error(file)

    h_line()

    ##
    # Read mock halo catalogue
    mock = read_mock(opts)

    ##
    # Read observed catalogue
    obs = read_obs(opts)

    h_line()

    ##
    # Find Matches
    matches = find_matches(mock, obs, 2.0 * opts.delta_z, opts)
    print_matches(mock[matches[2]], obs, matches[0], matches[1], opts)

    ##
    # Define completeness and purity of sample
    c_matrix = get_completeness(mock, matches, opts)
    p_matrix = get_purity(obs, matches, opts)

    ##
    # Define mass-observable matrix for matched objects
    matrix, hm_matrix, ranges = mo_matrix(mock, obs, matches, opts)

    h_line()

    ##
    # Make plots
    make_plots(matrix, hm_matrix, ranges, opts)
    plot_complete(c_matrix[0], 'mass', opts)
    plot_complete(c_matrix[1], 'ngal', opts)
    plot_pure(p_matrix, opts)

    ##
    # Save matrix to file
    print_matrix(matrix, hm_matrix, ranges, opts)

    h_line()
                  callback = opt_callback, default = range(0, 6),
                  help = c_col_help)

(opts, args) = parser.parse_args()
    
if not opts.cluster_file:
    parser.error('Cluster file name not provided.')
if not opts.mock_file:
    parser.error('Mock file name not provided.')
    
#############
# READ DATA #
#############

#make sure files exit
errors.file_name_error(opts.mock_file)
errors.file_name_error(opts.cluster_file)

print '================================================================='

#read mock catalogue  
print 'Reading file:', opts.mock_file,        
mock = np.genfromtxt(opts.mock_file, dtype="S", unpack = True)[opts.m_cols]
dtypes = [('id', 'S22'), ('cen', 'i4'), ('ra', 'f8'), ('dec', 'f8'),
          ('z', 'f8'), ('rich', 'f8'), ('mass', 'f8'), ('r200', 'f8'),
          ('minra', 'f8'), ('maxra', 'f8'), ('mindec', 'f8'), ('maxdec', 'f8')]
mock = np.core.records.fromarrays(mock, dtype = dtypes)
mock.rich = np.log10(mock.rich)
print '\tComplete:', len(mock)

#read cluster catalogue
Exemple #4
0
parser = optparse.OptionParser()
options.single_input(parser)
options.single_output(parser)
options.catcut(parser)
(opts, args) = parser.parse_args()

if not opts.input_file:
    parser.error('Input filename not provided.')
if (not opts.ra_bin) or (not opts.dec_bin):
    parser.error('Number of RA or Dec bins not provided.')
if (opts.ra_bin == 1) and (opts.dec_bin == 1):
    parser.error('Number of RA or Dec bins must be greater than one.')

#Check for errors

errors.file_name_error(opts.input_file)

#Read catalogue

print 'Reading data from ' + opts.input_file
if opts.input_type == 'fits':
    catalogue = fileio.read_fits(opts.input_file)
else:
    catalogue = fileio.read_ascii(opts.input_file)

id = np.array(catalogue[opts.id_col - 1, :])
ra = np.array(catalogue[opts.ra_col - 1, :], dtype="float")
dec = np.array(catalogue[opts.dec_col - 1, :], dtype="float")
z = np.array(catalogue[opts.z_col - 1, :], dtype="float")
if opts.mode == 'phot':
    dz = np.array(catalogue[opts.dz_col - 1, :], dtype="float")
Exemple #5
0
  
if not opts.input_file:
    parser.error('Input file name not provided.')
if not opts.output_file:
    opts.output_file = opts.input_file + '_clusters.dat'
if not opts.link_r:
    parser.error('Transverse linking length not provided.')
if not opts.link_z:
    parser.error('Line-of-sight linking length not provided.')
    
#############
# READ DATA #
#############

#make sure files exit
errors.file_name_error(opts.input_file)

#read input file
print 'Reading file:', opts.input_file
data = np.genfromtxt(opts.input_file, unpack = True, dtype="S")

################
# SET DEFAULTS #
################

all_gal_z = np.array(data[opts.z_col - 1]).astype('float')

#set redshift limits
if not opts.z_min or not opts.z_max:
    if not opts.z_min: opts.z_min = np.min(all_gal_z)
    if not opts.z_max: opts.z_max = np.max(all_gal_z)
Exemple #6
0
from functions import errors
from pymemmatch_lib.pymemmatch_opts import get_opts
from pycymatch_lib.pycymatch_extra import h_line
from pymemmatch_lib.pymemmatch_match import mo_matrix
from pymemmatch_lib.pymemmatch_io import *
from pycymatch_lib.pycymatch_plot import *

# READ ARGUMENTS

opts = get_opts().parse_args()

# READ DATA

# - check files
for file in opts.input_files:
    errors.file_name_error(file)

h_line()

# - read mock catalogue
mock = read_mock(opts)

# - read observed catalogue
obs = read_obs(opts)

h_line()

# FIND MATCHES

matrix, x_range, z_range = mo_matrix(mock, obs, opts)
Exemple #7
0
                  default=range(0, 6),
                  help=c_col_help)

(opts, args) = parser.parse_args()

if not opts.cluster_file:
    parser.error('Cluster file name not provided.')
if not opts.mock_file:
    parser.error('Mock file name not provided.')

#############
# READ DATA #
#############

#make sure files exit
errors.file_name_error(opts.mock_file)
errors.file_name_error(opts.cluster_file)

print '================================================================='

#read mock catalogue
print 'Reading file:', opts.mock_file,
mock = np.genfromtxt(opts.mock_file, dtype="S", unpack=True)[opts.m_cols]
dtypes = [('id', 'S22'), ('cen', 'i4'), ('ra', 'f8'), ('dec', 'f8'),
          ('z', 'f8'), ('rich', 'f8'), ('mass', 'f8'), ('r200', 'f8'),
          ('minra', 'f8'), ('maxra', 'f8'), ('mindec', 'f8'), ('maxdec', 'f8')]
mock = np.core.records.fromarrays(mock, dtype=dtypes)
mock.rich = np.log10(mock.rich)
print '\tComplete'

#read cluster catalogue
Exemple #8
0
from functions import errors
from pymemmatch_lib.pymemmatch_opts import get_opts
from pycymatch_lib.pycymatch_extra import h_line
from pymemmatch_lib.pymemmatch_match import mo_matrix
from pymemmatch_lib.pymemmatch_io import *
from pycymatch_lib.pycymatch_plot import *

# READ ARGUMENTS

opts = get_opts().parse_args()

# READ DATA

# - check files
for file in opts.input_files:
    errors.file_name_error(file)

h_line()

# - read mock catalogue
mock = read_mock(opts)

# - read observed catalogue
obs = read_obs(opts)

h_line()

# FIND MATCHES

matrix, x_range, z_range = mo_matrix(mock, obs, opts)