Exemplo n.º 1
0
def replace_photo_uncert(catalog, columns):
    """

    """
    data = C.loaddata(catalog)  # Loading the whole catalog content.
    head = C.loadheader(catalog)  # Loading the original header.
    mm = A.get_magnitudes(catalog, columns)
    em = A.get_errmagnitudes(catalog, columns)
    filters = B.get_filter_list(columns)

    nl = len(mm[:,
                0])  # nl is the number of detections inside every single band.
    nf = len(mm[0, :])  # nf is the number of bands inside the catalog.
    errmag = U.zeros((nl, nf),
                     float)  # Where the new photo errors will be saved.

    for jj in range(nf):
        maglim = B.get_limitingmagnitude(mm[:, jj], em[:, jj], 1., 0.25)
        print 'Limiting Magnitude for filter %s: %.3f' % (filters[jj], maglim)
        for ii in range(nl):
            if mm[ii, jj] == -99.:
                errmag[ii, jj] = 0.00
            elif mm[ii, jj] == 99.:
                errmag[ii, jj] = maglim
            else:
                errmag[ii, jj] = em[ii, jj]

    # New values of mags error overwrites now the original data.
    vars, evars, posref, zpe, zpo = get_usefulcolumns(columns)
    data[:, evars] = errmag[:, U.arange(nf)]
    finalcatalog = catalog[:-3] + 'upp.cat'
    C.savedata(data, finalcatalog, dir="",
               header=head)  # Saving & creating a new catalog.
Exemplo n.º 2
0
def minimum_photouncert(catalog, columns):
    """

    """
    data = C.loaddata(catalog)  # Loading the whole catalog content.
    head = C.loadheader(catalog)  # Loading the original header.
    mm = A.get_magnitudes(catalog, columns)
    em = A.get_errmagnitudes(catalog, columns)
    nl = len(mm[:,
                0])  # nl is the number of detections inside every single band.
    nf = len(mm[0, :])  # nf is the number of bands inside the catalog.
    errmag = N.zeros((nl, nf),
                     float)  # Where the new photo errors will be saved.

    for jj in range(nf):
        for ii in range(nl):
            if em[ii, jj] < 0.01: errmag[ii, jj] = 0.03
            elif em[ii, jj] > 1.0: errmag[ii, jj] = 1.0
            else: errmag[ii, jj] = em[ii, jj]

    # New values of mags error overwrites now the original data.
    vars, evars, posref, zpe, zpo = A.get_usefulcolumns(columns)
    data[:, evars] = errmag[:, N.arange(nf)]
    finalcatalog = catalog[:-3] + 'ecor.cat'
    C.savedata(data, finalcatalog, dir="",
               header=head)  # Saving & creating a new catalog.
def replace_kerttu_errmags(catalog, columns, finalcatalog):
    """

import alhambra_kerttu_fixerrmags as AFM
catalog = '/Users/albertomolino/doctorado/articulos/ALHAMBRA/kerttu/test_photoz/kerttu.cat'
columns = '/Users/albertomolino/doctorado/articulos/ALHAMBRA/kerttu/test_photoz/kerttu.columns'
finalcatalog = '/Users/albertomolino/doctorado/articulos/ALHAMBRA/kerttu/test_photoz/kerttu3.cat'
AFM.replace_kerttu_errmag(catalog,columns,finalcatalog)
------

    """

    data = C.loaddata(catalog)  # Loading the whole catalog content.
    head = C.loadheader(catalog)  # Loading the original header.
    mm = A.get_magnitudes(catalog, columns)
    em = A.get_errmagnitudes(catalog, columns)
    filters = B.get_filter_list(columns)

    nl = len(mm[:,
                0])  # nl is the number of detections inside every single band.
    nf = len(mm[0, :])  # nf is the number of bands inside the catalog.
    errmag = U.zeros((nl, nf),
                     float)  # Where the new photo errors will be saved.

    for jj in range(nf):
        for ii in range(nl):
            if mm[ii, jj] == -99.: errmag[ii, jj] = 0.00
            else: errmag[ii, jj] = em[ii, jj]

    # New values of mags error overwrites now the original data.
    vars, evars, posref, zpe, zpo = A.get_usefulcolumns(columns)
    data[:, evars] = errmag[:, U.arange(nf)]
    C.savedata(data, finalcatalog, dir="",
               header=head)  # Saving & creating a new catalog.
Exemplo n.º 4
0
def check_variable_candidate(alhambraid):
    """
    It replaces failed magnitudes in the ALHAMBRA catalogues (artificial absorptions,
    non-observed sources assigned as non-detected with upper limits) by m=-99,em=99
    It might decrease the amount of low Odds at bright magnitudes.
----
import alhambra_photools as A
A.replacing_fakeabsorptions(2,1,2)

A.check_sample(image,catalog,posID,posX,posY,posMAG)
A.alhambra_id_finder(ra1,dec1)
    idd = int(id[pos])

A.alhambra_colorstamp_byID(id)

f,p,c,ids = A.alhambra_id_finder(37.4992,1.2482)
        
    """

    field = int(str(alhambraid)[3])
    pointing = int(str(alhambraid)[4])
    ccd = int(str(alhambraid)[5])

    numero = str(alhambraid)[-5:]
    print numero
    for ii in range(2):
        if numero[0] == '0': numero = numero[1:]
    print numero

    root2cats = '/Volumes/amb22/catalogos/reduction_v4f/f0%i/' % (field)
    catalog = root2cats + 'originals/f0%ip0%i_colorproext_%i_ISO.cat' % (
        field, pointing, ccd)

    cols1 = root2cats + 'f0%ip0%i_%i_tot_ISO_eB10.columns' % (field, pointing,
                                                              ccd)
    cols2 = root2cats + 'f0%ip0%i_colorproext_%i_ISO_phz_eB10.columns' % (
        field, pointing, ccd)
    if os.path.exists(cols1): columns = cols1
    else: columns = cols2

    filters = B.get_filter_list(columns)
    print filters

    data = C.loaddata(catalog)  # Loading the whole catalog content.
    head = C.loadheader(catalog)  # Loading the original header.
    m = A.get_magnitudes(catalog, columns)
    # em   = get_errmagnitudes(catalog,columns)

    root2 = '/Volumes/amb22/catalogos/reduction_v4e/'
    fluxc1 = root2 + 'f0%i/f0%ip0%i_colorproext_%i_ISO_phz_eB11.flux_comparison' % (
        field, field, pointing, ccd)
    fluxc2 = root2 + 'f0%i/f0%ip0%i_colorproext_%i_ISO.flux_comparison' % (
        field, field, pointing, ccd)
    if os.path.exists(fluxc1): fluxc = fluxc1
    else: fluxc = fluxc2
    ido, ftt, foo, efoo, zb, tb, mm = P.get_usefulfluxcomparison(
        columns, fluxc)

    pos = A.get_position(ido, int(numero))
    print ido[pos], mm[pos]

    plt.figure(1, figsize=(10, 7), dpi=80, facecolor='w', edgecolor='k')
    plt.clf()
    # P.plot1sedfitting(foo[:,jj],efoo[:,jj],ftt[:,jj],zb[jj],tb[jj],root_bpz_sed+'eB11.list',filters)
    plt.plot(U.arange(20) + 1, foo[0:20, pos], 'k-', alpha=0.4, lw=6)
    plt.plot(U.arange(20) + 1, foo[0:20, pos], 'ko', alpha=0.4, ms=12)
    plt.errorbar(U.arange(20) + 1,
                 foo[0:20, pos], (efoo[0:20, pos] / 1.),
                 fmt="ko",
                 alpha=0.4,
                 ms=10)
    minf = (foo[0:20, pos].min()) * 1.1
    maxf = (foo[0:20, pos].max()) * 1.1
    maxef = (efoo[0:20, pos].max()) * 1.1
    # plt.ylim(minf-maxef,maxf+maxef)
    plt.xlim(0, 21)
    plt.xlabel('Filter', size=25)
    plt.ylabel('Flux', size=25)
    plt.legend(['Magnitude: %.2f' % (m[pos][-1])],
               loc='upper right',
               numpoints=1,
               fontsize=20)
    plt.title(alhambraid, size=25)
    plt.grid()
    plt.show()
    namefig = '/Users/albertomolino/doctorado/photo/variability/analysis/vocheck.ID%s.png' % (
        alhambraid)
    plt.savefig(namefig, dpi=125)

    outcat = '/Users/albertomolino/doctorado/photo/variability/analysis/vocheck.ID%s.cat' % (
        alhambraid)
    A.select_rows_bylist_pro(catalog, ido[pos], outcat)
    print ' '
Exemplo n.º 5
0
import alhambra_photools as A
import matplotlib.pyplot as plt
"""
mainroot = '/Users/albertomolino/Postdoc/T80S_Pipeline/Commisioning/S82/Sept2017/'
root2cats = mainroot + 'data_quality/'
master_catalogue = root2cats + 'splus_master.cat'
master_columns   = root2cats + 'splus_auto.columns'
output_filename  = root2cats + 'magvsnoise.txt'
"""

master_catalogue = '/Users/albertomolino/jplus_data_download/SV02_March07/SV02_March07.clean.cat'
master_columns = '/Users/albertomolino/jplus_data_download/SV02_March07/jplus11.columns'
output_filename = '/Users/albertomolino/Postdoc/T80S_Pipeline/Commisioning/S82/Sept2017/data_quality/jplus_depth.txt'

# Reading data from master catalogue
mags = A.get_magnitudes(master_catalogue, master_columns)
emags = A.get_errmagnitudes(master_catalogue, master_columns)

#defining variables
basem = N.arange(14, 22.5, 0.5)
values = N.zeros((len(basem), 13), float)
values[:, 0] = basem[:]

#starting the party
for ii in range(11):
    mm = mags[:, ii]
    em = emags[:, ii]
    good = N.greater_equal(mm, 14) * N.less_equal(mm, 22)
    mr = mm[good]
    emr = em[good]
    values[:, ii + 1] = U.bin_stats(mr, emr, basem, 'mean_robust')