예제 #1
0
# Import trough catalog
path_troughcat = '/data2/brouwer/MergedCatalogues/trough_catalogues'
troughcatname = '/trough_catalog_gama_absmag_masked.fits'

# Full directory & name of the trough catalogue
troughcatfile = '%s/%s' % (path_troughcat, troughcatname)
troughcat = pyfits.open(troughcatfile, memmap=True)[1].data

# List of the observables of all sources in the KiDS catalogue
Ptheta = troughcat['Ptheta5']
Wtheta = poly_func_weights(Ptheta)

outputnames = ['Ptheta5', 'Wtheta5']
output = [Ptheta, Wtheta]
utils.write_catalog('%s/chi2_trough_weights.fits' % path_troughcat,
                    np.arange(len(Wtheta)), outputnames, output)

# Calculating covariance of the chi2 weighted trough signal
path_lenssel_weighted = 'No_bins_gama_absmag/Pmasktheta5_0p8_1-Ptheta5_0_0p5_lw-Wtheta5/'
esdfiles_weighted = np.array([
    '/%s/%s/%s/%s' %
    (path_sheardata, path_lenssel_weighted, path_cosmo, path_filename)
])
data_x, data_y_weighted, error_h_weighted, error_l_weighted = utils.read_esdfiles(
    esdfiles_weighted)
covfiles_weighted = np.array([
    e.replace('bins_%s.txt' % blind, 'matrix_%s.txt' % blind)
    for e in esdfiles_weighted
])

data_weighted = data_y_weighted[0]
# Defining the names of the columns
outputnames = ['RA', 'DEC']
[outputnames.append('Ngaltheta%i' % (theta * 60)) for theta in thetalist]
[outputnames.append('Ngridtheta%i' % (theta * 60)) for theta in thetalist]
[outputnames.append('Pgridtheta%i' % (theta * 60)) for theta in thetalist]
[outputnames.append('rhotheta%i' % (theta * 60)) for theta in thetalist]
[outputnames.append('Ptheta%i' % (theta * 60)) for theta in thetalist]

# Defining the output
output = [gridRA, gridDEC]
[output.append(Ngaltheta[theta, :]) for theta in range(Ntheta)]
[output.append(Ngridtheta[theta, :]) for theta in range(Ntheta)]
[output.append(Pgridtheta[theta, :]) for theta in range(Ntheta)]
[output.append(rhotheta[theta, :]) for theta in range(Ntheta)]
[output.append(Ptheta[theta, :]) for theta in range(Ntheta)]

print('Writing output catalogue...')
filename = '/data2/brouwer/MergedCatalogues/trough_catalogues/mock_trough_catalogue.fits'
utils.write_catalog(filename, gridID, outputnames, output)

# Writing the mean galaxy density information to a text file
field_density = field_galaxies / field_area

field_header = '1: Number of galaxies, 2: Effective area (arcmin^2), 3: Galaxy density (arcmin^-2)'
density_info = np.array([field_galaxies, field_area, field_density])

filename = 'density_info.txt'

np.savetxt(filename, density_info, delimiter='    ', header=field_header)
print('Written:', filename)
예제 #3
0
        for theta in range(len(thetalist)):

            troughcatname = 'trough_catalog_%s.fits' % sel[theta]

            # Full directory & name of the trough catalogue
            troughcatfile = '%s/%s' % (path_troughcat, troughcatname)
            troughcat = pyfits.open(troughcatfile, memmap=True)[1].data

            print('Creating weight catalog for:', troughcatfile)

            #            Atheta = poly_func_amps(Ptheta)
            #            poly_func_amps = np.poly1d(poly_param_amps[theta])
            #            outputnames.append('Atheta%g'%thetalist[theta])
            #            output.append(np.abs(Atheta))

            # Write weight fits-file
            Ptheta = troughcat['Ptheta%g' % thetalist[theta]]
            poly_func_weights = np.poly1d(poly_param_weights[theta])
            Wtheta = poly_func_weights(Ptheta)

            outputnames.append('Ptheta%g' % thetalist[theta])
            outputnames.append('Wtheta%g' % thetalist[theta])

            output.append(np.abs(Ptheta))
            output.append(np.abs(Wtheta))

        weightcatname = '%s/amplitude_trough_weights_%s.fits' % (
            path_troughcat, sel[0])
        utils.write_catalog(weightcatname, np.arange(len(Ptheta)), outputnames,
                            output)
        outputnames = ['RA', 'DEC']
        output = [gridRA_tot, gridDEC_tot]

        [
            outputnames.append('Nmasktheta%g' % (theta * 60))
            for theta in thetalist
        ]
        [output.append(Nmasktheta_tot[theta, :]) for theta in range(Ntheta)]

        [
            outputnames.append('Pmasktheta%g' % (theta * 60))
            for theta in thetalist
        ]
        [output.append(Pmasktheta_tot[theta, :]) for theta in range(Ntheta)]

        utils.write_catalog(maskfilename, gridID_tot, outputnames, output)

        # Save the effective survey area into a text file for later use
        np.savetxt(masktextname,
                   field_area,
                   header='Total effective field area (in arcmin^2)')
        print('Written:', masktextname)

    else:
        # Import the masked percentage
        print('Importing mask from:', maskfilename)
        maskcat = pyfits.open(maskfilename, memmap=True)[1].data

        Nmasktheta_tot = np.array([
            (maskcat['Nmasktheta%g' % (theta * 60)])[0:Ngrid_tot]
            for theta in thetalist
예제 #5
0
            # Index of the grid point in the flag list
            field_index = sampindex_field[s] + g

            # If the point is not flagged (not flagged = 1), flag all overlapping grid points (flagged = 0).
            if selected[field_index] == 1:
                removeindex = gridoverlap[(sampxgrid == g)
                                          & (gridoverlap != field_index)]
                selected[removeindex] = 0.

            # If the point is already flagged, do nothing.
            else:
                pass

    # Remove overlapping mask points
    selmask = (selected == 1)
    print('Selected:', np.sum(selmask), '/', len(selmask))

    # Print output to file

    filename = '/data2/brouwer/MergedCatalogues/Masks/%s_mask_%s_%gdeg.fits' % (
        cat, fieldnames[f], gridspace_mask)
    outputnames = ['RA', 'DEC', 'mask']
    output = [
        RAlist_field[selmask], DEClist_field[selmask], masklist_field[selmask]
    ]

    print('Writing output catalogue...')
    utils.write_catalog(filename, np.arange(len(RAlist_field[selmask])),
                        outputnames, output)