def get_mean_z(ddz,vector,base):

    n_ele = len(base)-1
    values = N.zeros(n_ele)
    base2 = base[:-1]+((base[1]-base[0])/2.)
    for ii in range(n_ele):
        good = N.greater_equal(vector,base[ii])
        good *= N.less_equal(vector,base[ii+1])
        values[ii] = U.mean_robust(ddz[good])
    return values,base2
示例#2
0
def get_seeing_from_data_pro(fwhm, mr):
    """
    :param fwhm:
    :param mr:
    :return:
    """
    dm = 0.1
    base = N.arange(0., 7, dm)
    stars = N.greater_equal(mr, 14) * N.less_equal(mr, 18)
    b1, b2 = N.histogram(fwhm[stars], base)
    pos = N.argmax(b1)
    seeing = b2[pos] + (dm / 2.)
    redu = N.less_equal(
        fwhm,
        U.mean_robust(fwhm[stars]) + U.std_mad(fwhm[stars]) * 2.)
    redu *= N.greater_equal(
        fwhm,
        U.mean_robust(fwhm[stars]) - U.std_mad(fwhm[stars]) * 2.)
    redu *= N.greater_equal(mr, 14) * N.less_equal(mr, 18)

    return seeing, redu
示例#3
0
def runZPcal_catalogue(reference, frame, final):
    """
    ----
filter_ref_cat,alig_frame_cat,alig_cal_frame_cat
    """
    plots = 1
    data2 = C.loaddata(frame)  # Loading the whole catalog2 content.
    head2 = C.loadheader(frame)  # Loading the original header2.
    pos_mags = 12  # ([12,20,21,22])

    mag_r = U.get_data(reference, 12)
    mag_f = U.get_data(frame, 12)
    # good_sample = U.greater_equal(mag_r,16.) * U.less_equal(mag_r,21.5)
    good_sample = U.greater_equal(mag_r, 16.) * U.less_equal(mag_r, 19.)
    mag_r2, mag_f2 = U.multicompress(good_sample, (mag_r, mag_f))
    offset = U.mean_robust(mag_f2 - mag_r2)

    if plots:
        plt.figure(11, figsize=(12, 9), dpi=80, facecolor='w', edgecolor='k')
        plt.clf()
        plt.plot(mag_r, (mag_f - mag_r - offset), 'ko', ms=10, alpha=0.1)
        plt.xlim(16, 25)
        plt.ylim(-5, 5.)
        plt.xlabel('AB', size=25)
        plt.ylabel('Mf-Mr', size=25)
        plt.xticks(fontsize=25)
        plt.yticks(fontsize=25)
        plt.legend(['Offset: %.4f' % (offset)], loc='upper right', numpoints=1)
        plt.title(A.getfilename(frame), size=15)
        plt.grid()
        figurename = final[:-3] + 'png'
        print 'figurename: ', figurename
        plt.savefig(figurename, dpi=100)
        plt.close()

    # Here it saves the offset in an ASCII file
    fileout = open(final[:-3] + 'txt', 'w')
    linea = '%s %.5f \n' % (final, offset)
    fileout.write(linea)
    fileout.close()

    # The offset is only applied to m!=99. magnitudes.
    new_mags = U.where(abs(mag_f) < 99, mag_f - offset, mag_f)
    data2[:, pos_mags] = new_mags
    C.savedata(data2, final, dir="", header=head2)
    print ' '
示例#4
0
def check_rms_SPLUS(segmentation,photometry,minrad,maxrad,totnum,plots,verbose):

    """
    It describes the photometric noise in images by launching apertures
    in blank areas and describing the area vs rms dependency.

    Philosophy:
    Several apertures (of random radius and positions) will be created (over blank areas) on 
    a 'segmentation' image to estimate the real photometric error of an input 'photometry' image. 
    --------
    segmentation: Segmentation-like image (SExtractor output) used to select 'blank' areas.
    photometry:   scientific image over which estimate the real photometric errors      
    minrad,maxrad = minimun & maximum radius of the used apertures (pixels).
    totnum = total number of apertures.
    area,rms = final outputs.
    ---------
    USAGE:

---------
import script_dcluster_tools as to
segmentation = 'f814.seg.fits'
photometry   = 'f814.fits'
apertures,finalbackg,finalmeans,fluxes = to.check_rms_JPLUS(segmentation,photometry,1,21,5.0e+04,'yes',False)
----

    """ 
    if not os.path.exists(segmentation):
       print
       print 'Image %s does not exist!' %(segmentation)
       sys.exist()

    if not os.path.exists(photometry):
       print
       print 'Image %s does not exist!' %(photometry)
       sys.exist()
    
    if verbose==True: verba=1
    else: verba=0	       

    # Reading data from images
    if photometry[:-2]=='fz':
       photima = fits.open(photometry)[1].data
    else:
       photima = fits.open(photometry)[0].data
    
    if segmentation[:-2]=='fz':
       segima  = fits.open(segmentation)[1].data  
    else:
       segima  = fits.open(segmentation)[0].data

    # Final root where to save the data
    final_path = os.path.os.path.dirname(photometry)
    base_name = os.path.os.path.basename(photometry)
    len_extension = len(base_name.split('.')[-1])+1
    file_root = final_path+'/Apertures/%s'%(base_name[:-len_extension])
       
    # Physical limits (pixel) for the segmentation image.
    xGC = N.shape(segima)[1]/2.
    yGC = N.shape(segima)[0]/2.
    # For CLASH, due to the rotating frames, a maximum radius is set.
    min_maxim_radius = min([xGC,yGC])
    radialmax = min_maxim_radius # Maximum radial distance to the center [pixels]
    
    # Here the random position (X,Y) are limited in range.
    minpix_X = 1500 
    maxpix_X = N.shape(segima)[1]-1500 
    minpix_Y = 1500 
    maxpix_Y = N.shape(segima)[0]-1500 
    binhisto = 100  
    # Final vector with positions.
    x_values = N.arange(minpix_X,maxpix_X,1)
    y_values = N.arange(minpix_Y,maxpix_Y,1)
    # Total dimension for the input variables.
    maxdim = int(20*(10.+(4*(((maxrad)*(maxrad+1))/2.))))
    # Defining other variables.
    XX = N.zeros((maxdim),float)
    YY = N.zeros((maxdim),float)
    XO = N.zeros((maxdim),float)
    YO = N.zeros((maxdim),float)
    RR = N.zeros(totnum)
    # Range of apertures to be launched.
    apertures = N.arange(minrad,maxrad,1)
    n_apertures = len(apertures)
    # Length definition for the final outputs.
    finalbackg = N.zeros(n_apertures,'float64')
    finalmeans = N.zeros(n_apertures,'float64') 
    gausshisto = N.zeros((binhisto,2*n_apertures),dtype='float64') 
    # Starting the analysis.
    mmm = 0
    for app in range(n_apertures):
        raper = apertures[app] 
        # minrad = maxrad = raper
        if verba:
           print 'Interation %i out of %i ' %(app+1,n_apertures)
           print '-------------------------'
            
        # New temporal variables (erased in every loop).
        fluxes = N.zeros(totnum,dtype='float64')
        sbackg = N.zeros(totnum,dtype='float64') 
        ff = -1
        
        # Now it runs until it gets "totnum" measurements.
        hh = -1
        contador = 0
        while contador < (totnum):
            kk = -1
            # Random x,y numbers to estimate the position
            # to place the aperture.
            xo = N.random.random_integers(minpix_X,maxpix_X)  
            yo = N.random.random_integers(minpix_Y,maxpix_Y)
            if verba: print 'xo,yo',xo,yo
            # Corresponding radial distance to the center.
            tempradii = N.sqrt((xo-xGC)*(xo-xGC)+(yo-yGC)*(yo-yGC))
            if tempradii < (radialmax+1):
               # Now it is computed the shape of the aperture. 
               Xr = N.zeros((raper*raper),float)
               Yr = N.zeros((raper*raper),float)
               for ii in range(raper):
                   xvalue = xo+ii
                   for jj in range(raper):
                       kk += 1
                       yvalue = yo+jj
                       Xr[kk] = xvalue
                       Yr[kk] = yvalue
                       
               # Here it checks the blanckness of the aperture.                                 
               tempflux = area2noise(segima,photima,Xr,Yr)
               if raper<2 :
                  if tempflux != -999. : 
                     fluxes[hh] = tempflux
                     if verba: print 'Adding flux: ',tempflux
                     hh += 1 
                     contador += 1
                         
               if raper>1:
                  if tempflux[0] != -999. :
                     fluxes[hh] = tempflux.sum() - (finalmeans[0] * raper**2) #why?
                     contador += 1
                     hh += 1 
                     if verba: print 'hh',hh
                   
        # Computing values from the sample.    
        sigfluxes = U.std_robust(fluxes) 
        good      = U.less_equal(abs(fluxes),5.*sigfluxes)
        fluxes    = U.compress(good,fluxes)
        
        # Storing the background dispersion & mean inside that aperture.   
        finalbackg[app] = U.std(fluxes)
        finalmeans[app] = U.mean(fluxes)
        
        if plots == 'yes': 
           plt.figure(1,figsize = (7,6),dpi=70, facecolor='w', edgecolor='k')
           plt.clf()
           # va1,va2 = N.histogram(fluxes,binhisto,normed=1)
           va1,va2,va3 = plt.hist(fluxes,binhisto,normed=1,facecolor='black',alpha=0.5,linewidth=1.5)
           baseh = va2[0:-1] + ((va2[1]-va2[0])/2.)
           nele  = len(fluxes)
           mu    = U.mean(fluxes)
           sig   = U.std(fluxes)
           # yh    = U.normpdf(va2,mu,sig)
           # plt.plot(va2,yh,'r-',linewidth=3,alpha=0.7)
           mu = U.mean_robust(fluxes) # repeated
           sig = U.std_robust(fluxes) # repeated
           # yh = U.normpdf(va2,mu,sig) # repeated
           # plt.plot(va2,yh,'r--',linewidth=3,alpha=0.7) # repeated          
           plt.legend([('MEAN: %.4f ''\n'' RMS:  %.4f '%(mu,sig)),
                       'Aperture: %i $pix$'%(raper*raper)],
                       numpoints=1,loc='upper right',fontsize=14)
           plt.xlim(mu-4*sig,mu+4*sig)
           plt.xlabel('Aperture Flux [ADU]',size=20)
           plt.ylabel('Number Counts',size=20)
           plt.xticks(fontsize=17),plt.yticks(fontsize=17)
           nameima = photometry.split('/')[-1:][0]
           plt.ylim()
           figure2name = file_root+'_hfaper_%i.png' %(raper)
           plt.savefig(figure2name,dpi=150)
           plt.close()
           
           # Here it saves the info from the histogram.
           ind1 = app*2
           ind2 = app*2+1
           if verba: print 'ind1,ind2',ind1,ind2
           gausshisto[:,ind1] = baseh # va2
           gausshisto[:,ind2] = va1   # yh
            
    # At this point all apertures have been computed.        
    # Now it will represent the sigma_vs_area dependency.
    sigmas = finalbackg #-abs(finalmeans)
    aa,bb = sigmafit(sigmas,sigmas[0],apertures)
      
    if plots == 'yes':
       plt.figure(2, figsize = (7,6),dpi=80, facecolor='w', edgecolor='k')
       plt.clf()
       plt.plot(apertures,sigmas[0]*apertures*(aa+bb*apertures),'k-',apertures,apertures*sigmas[0],'r-')
       plt.legend([('%.3f$\sqrt{N}$ (%.3f + %.3f$\sqrt{N}$)' %(sigmas[0],aa,bb)),
                   '%.3f$\sqrt{N}$ | Poisson Distribution '%(sigmas[0])],
                   numpoints=1,loc='upper left')
       plt.plot(apertures,sigmas,'ko')
       plt.xlim(0.,max(apertures)+1)
       plt.xlabel('$\sqrt{N}$',size=18)
       plt.ylabel('$\sigma$',size=20)
       plt.xticks(fontsize=15)
       plt.yticks(fontsize=15)
       nick2 = photometry.split('/')[-1:][0]

       figure1name = file_root+'_apersigma.png'
       plt.savefig(figure1name,dpi=150)
       plt.close()

    # Saving outputs in ASCII files.
    fileout = file_root+'.apertures.txt'
    header = '# AREA[pix] RMS(std[counts]) MEAN(mean_robust[counts])'
    U.put_data(fileout,(apertures,sigmas,finalmeans),header)
    #print 'Saving data... in %s' %(fileout)

    """
示例#5
0
    plt.clf()
    plt.subplot(211)
    a13_p, a23_p, a33_p = plt.hist(mr[c3], base, alpha=0.5, color='red')
    m_peak = base2[N.argmax(a13_p)]

    plt.figure(2)
    plt.clf()
    c0 = N.greater_equal(s2n, .01) * N.less(mr, 30)
    a13_c, a23_c, a33_c = plt.hist(mr[c0], base, cumulative='yes')
    aa_norm_c = (a13_c / fov) / max(a13_c / fov)
    plt.figure(1)
    plt.subplot(212)
    plt.plot(base2, aa_norm_c, 'o-', lw=12, alpha=0.5, color='orange')
    pos_50 = N.argmin(abs(aa_norm_c - 0.5))
    m_50 = base2[pos_50]
    pos_80 = N.argmin(abs(aa_norm_c - 0.8))
    m_80 = base2[pos_80]
    pos_95 = N.argmin(abs(aa_norm_c - 0.95))
    m_95 = base2[pos_95]

    m_c3, s2n_c3 = U.get_data(filename, (mag_3arc_pos[ii], s2n_3arc_pos[ii]))
    m_c3 += -0.2
    c3_min = N.greater_equal(s2n_c3, 2.95) * N.less_equal(s2n_c3, 3.05)
    c3_min *= N.less(m_c3, 30)
    m_3s_3arcs = U.mean_robust(m_c3)

    print '%s &  %.2f  &  %.2f  &  %.2f  & %.2f  & %.2f ' % (
        filters[ii], m_peak, m_50, m_80, m_95, m_3s_3arcs)

    pausa = raw_input('paused')
示例#6
0
    good_g_aper = N.greater(g_aper, 0) * N.less(g_aper, 30)
    good_r_aper = N.greater(r_aper, 0) * N.less(r_aper, 30)
    good_i_aper = N.greater(i_aper, 0) * N.less(i_aper, 30)
    good_z_aper = N.greater(z_aper, 0) * N.less(z_aper, 30)
    #
    good_u_sdss = N.greater(u_sdss, 0) * N.less(u_sdss, 30)
    good_g_sdss = N.greater(g_sdss, 0) * N.less(g_sdss, 30)
    good_r_sdss = N.greater(r_sdss, 0) * N.less(r_sdss, 30)
    good_i_sdss = N.greater(i_sdss, 0) * N.less(i_sdss, 30)
    good_z_sdss = N.greater(z_sdss, 0) * N.less(z_sdss, 30)

    ### Computing offsets
    ### U-band
    dm_u_auto = u_auto[good_u_sdss * good_u_auto] - u_sdss[good_u_sdss *
                                                           good_u_auto]
    offset_dm_u_auto = U.mean_robust(dm_u_auto)
    dm_u_petro = u_petro[good_u_sdss * good_u_petro] - u_sdss[good_u_sdss *
                                                              good_u_petro]
    offset_dm_u_petro = U.mean_robust(dm_u_petro)
    dm_u_aper = u_auto[good_u_sdss * good_u_aper] - u_sdss[good_u_sdss *
                                                           good_u_aper]
    offset_dm_u_aper = U.mean_robust(dm_u_aper)
    # Saving info.
    line = 'uJAVA  %.3f  %.3f ' % (offset_dm_u_auto, offset_dm_u_petro)
    line += ' %.3f \n' % (offset_dm_u_aper)
    filename.write(line)

    ### G-band
    dm_g_auto = g_auto[good_g_sdss * good_g_auto] - g_sdss[good_g_sdss *
                                                           good_g_auto]
    offset_dm_g_auto = U.mean_robust(dm_g_auto)
list_cali_columns = root2cats + 'calicolumns.list'
if not os.path.exists(list_cali_columns):
    cmd = 'ls %s*.auto_cali.columns > %scalicolumns.list' % (root2cats,
                                                             root2cats)
    os.system(cmd)

# Reading list
if os.path.exists(list_cali_columns):
    cols = U.get_str(list_cali_columns, 0)
    n_c = len(cols)
    zp_val = N.zeros((12, n_c), float)
    zp_final = N.zeros(12)
    for ss in range(n_c):
        vars, evars, posref, zpe, zpc = A.get_usefulcolumns(cols[ss])
        #print zpc[:]
        #pausa = raw_input('paused')
        for ii in range(12):
            zp_val[ii, ss] = zpc[ii]

    for hh in range(12):
        zp_final[hh] = U.mean_robust(zp_val[hh, :])

    # Saving results
    master_cali_columns = root2cats + 'master_calicolumns.txt'
    U.put_data(master_cali_columns, (N.arange(12) + 1, zp_final),
               '# Filter ZPc')

else:
    print 'File %s does not exist!' % (master_cali_columns)
            pepa = pepe[jj].split()
            #print pepa
            med_value[ii, jj] = float(pepa[1])
            std_value[ii, jj] = float(pepa[2])
            out_value[ii, jj] = float(pepa[3])
            num_sourc[ii, jj] = float(pepa[4])
        except:
            med_value[ii, jj] = 0.0
            std_value[ii, jj] = 0.0
            out_value[ii, jj] = 0.0
            num_sourc[ii, jj] = 0.0

print 'Model  med  std  out  num '
for jj in range(n_models):
    good = N.greater(std_value[:, jj], 0.0001)
    linea = '%i, %.3f, %.3f, ' % (jj + 1, U.mean_robust(
        med_value[good, jj]), U.mean_robust(std_value[good, jj]))
    linea += '%.3f  %i ' % (U.mean_robust(
        out_value[good, jj]), U.sum(num_sourc[good, jj]))
    print linea

base_sz = N.arange(0.0005, 0.095, 0.015)
base_sz_2 = N.arange(-0.095, 0.095, 0.015)
plt.clf()
for ss in range(n_models):
    plt.subplot(3, 4, ss + 1)
    good = N.greater(std_value[:, ss], 0.0001)
    a1, a2, a3 = plt.hist(std_value[good, ss], base_sz, alpha=0.5, normed=1)
    b1, b2, b3 = plt.hist(med_value[good, ss],
                          base_sz_2,
                          facecolor='red',
                          alpha=0.5,
示例#9
0
        good_sample, (delta_ra, delta_dec, r_sd))

    # Starting the figure
    res = 50
    plt.figure(1, figsize=(12, 10), dpi=70, facecolor='w', edgecolor='k')
    plt.clf()
    #plt.plot(U.mean_robust(delta_dec[::res])-0.15,U.mean_robust(delta_ra[::res]),'rs',ms=20)
    plt.scatter(delta_dec[::res] - 0.15,
                delta_ra[::res],
                s=100,
                c=r_sd[::res],
                marker=u'o',
                cmap=cm.PuOr,
                alpha=0.25,
                vmin=14.0,
                vmax=21.5)
    #plt.plot(U.mean_robust(delta_dec[::res])-0.15,U.mean_robust(delta_ra[::res]),'rs',ms=20)
    #plt.legend(['Mean'],loc='upper left',fontsize=30)
    cb = plt.colorbar(pad=0., format='%.1f')
    cb.set_label('R-band Magnitude', size=25, labelpad=10)
    plt.xlim(-1.99, 1.99)
    plt.ylim(-1.99, 1.99)
    plt.ylabel('$\delta$$(RA)$ [pix]', size=25, labelpad=5)
    plt.xlabel('$\delta$$(Dec)$ [pix]', size=25, labelpad=5)
    plt.xticks(fontsize=20)
    plt.yticks(fontsize=20)
    plt.grid()
    print '%.2f,%.2f' % (U.mean_robust(
        delta_dec[::res]), U.mean_robust(delta_ra[::res]))
    plt.savefig('/Users/albertomolino/Desktop/example1.png', dpi=100)
示例#10
0
def get_masterPDZ_pro(hdf5file, mmin, mmax, dm):
    """
    TAKEN DIRECTLY FROM CLASH_TOOLS.py

    This routine derives the master PDZ for
    a sample of magnitudes based on an empirical
    BPZ-HDF5 catalogue.
    ---
    This new version allows the user to change
    the magnitude range from outside.
    ===
import clash_tools as CT
hdf5file = root+'alhambra.spz.hdf5'
mpdz,z,sigz,meanz = CT.get_masterPDZ(hdf5file)

    """
    # Reading data
    p1 = h5py.File(hdf5file, mode='r')
    pdz1 = p1.get('FullProbability')
    zz1 = p1.get('redshift')[:]
    tt1 = p1.get('type')[:]
    mo1 = p1.get('m_0')[:]

    # Defining resolution and other variables.
    basem = N.arange(mmin, mmax + dm, dm)
    nm = len(basem)
    res = 2
    zz1r = zz1[::res]
    dz2 = (zz1r.max() - zz1r.min())
    basez = N.linspace(-dz2, dz2, len(zz1r) * 2)
    basez2 = basez + ((basez[1] - basez[0]) / 2.)
    masterpdz = N.zeros((nm, len(basez)), float)
    sigma_pdz = N.zeros(nm)
    meanz = N.zeros(nm)

    # Global P(z)
    weirdpeaks = []
    print 'Number of magnitude-bins: ', nm
    for jj in range(nm):
        # Selecting galaxies within that magnitude bin.
        if jj == 0:
            good = N.less_equal(mo1, basem[jj])
            pdz1r = pdz1[good, :, :]
        elif jj == nm - 1:
            good = N.greater_equal(mo1, basem[jj - 1])
            good *= N.less_equal(mo1, basem[jj])
            pdz1r = pdz1[good, :, :]
        else:
            good = N.greater_equal(mo1, basem[jj - 1])
            good *= N.less_equal(mo1, basem[jj])
            pdz1r = pdz1[good, :, :]

        ng1 = N.shape(pdz1r)[0]
        peaks = []
        print '%i galaxies in magnitude-bin %i ' % (ng1, jj + 1)
        mo1r = mo1[good]
        for ii in range(ng1):
            # print 'galaxy number %i out of %i '%(ii+1,ng1)
            pdz_ind = N.sum(pdz1r[ii, :, :], axis=1)
            pdz_ind_r = pdz_ind[::res]
            peak = pdz_ind_r.max()
            pos = N.where(pdz_ind_r == peak)[0][0]
            zpeak = zz1r[pos]
            # new_zmin = len(zz1r)-zpeak
            new_zmin = len(zz1r) - pos - 1  # len(zz1r[0:pos])
            min_val = min(pdz_ind_r)
            max_val = max(pdz_ind_r)
            if abs(min_val - max_val) < 1.0e-8: pdz_ind_r[:] = zz1r * 0
            if zpeak < 0.0005: pdz_ind_r[:] = zz1r * 0
            # try:
            if zpeak > 0.0005:
                masterpdz[jj, new_zmin:new_zmin + len(zz1r)] += pdz_ind_r[:]
            # except: weirdpeaks.append(zpeak)
            if zpeak > 0.0005:
                peaks.append(zpeak)

            # plt.figure(200)
            # plt.clf()
            # plt.plot(zz1r,pdz_ind_r,'k-')
            # plt.xlim(0.,0.2)
            # plt.grid()
            # print 'AB,dz/1+z,dz: %.2f,%.3f,%.2f:'%(mo1r[ii],(zpeak-0.044)/1.044,zpeak-0.044)
            # pausa = raw_input('paused')

        masterpdz[jj, :] /= float(masterpdz[jj, :].sum())
        cumasterpdz = U.add.accumulate(masterpdz[jj, :])
        cumasterpdz /= cumasterpdz.max()
        zmin_err_e = U.match_resol(cumasterpdz, basez2, 0.17)
        zmax_err_e = U.match_resol(cumasterpdz, basez2, 0.83)
        sigma_pdz[jj] = (zmax_err_e - zmin_err_e)
        peak_position = N.where(
            masterpdz[jj, :] == masterpdz[jj, :].max())[0][0]
        # print 'peak_position',peak_position
        # print 'zpeak=',zz1r[peak_position]
        meanz[jj] = U.mean_robust(N.array(peaks))
        # U.std_mad(N.array(peaks))

    return masterpdz, basez2, sigma_pdz, meanz
示例#11
0
for sss in range(n_cats):
    field = os.path.basename(cats[sss])[9:-15]
    master_cat = root_to_cats + 'STRIPE82-%s_Photometry.cat' % (field)  ##
    print 'reading catalog %i out of %i ' % (sss + 1, n_cats)
    x, y, fwhm, mr = U.get_data(master_cat, (3, 4, 8, 84))
    fwhm_master, stars = sct.get_seeing_from_data_pro(fwhm, mr)
    # Reading FWHM from Individual R images.
    ind_catalog = root_to_ind + 'sex_STRIPE82-%s_R_swp.cat' % (field)  ##
    fwhm_indiv = U.get_data(ind_catalog, 6)
    x_stars, y_stars, fw_stars = U.multicompress(stars, (x, y, fwhm_indiv))
    center_pos_x = N.less(abs(x_stars - N.mean(x_stars)), 1000.)
    center_pos_y = N.less(abs(y_stars - N.mean(y_stars)), 1000.)
    fw_stars_center = fw_stars[center_pos_x * center_pos_y]
    for ii in range(len(x_stars)):
        linea = '%i  %i ' % (x_stars[ii], y_stars[ii])
        mean_value_center = U.mean_robust(fw_stars_center)
        #valor = (fw_stars[ii]*fw_stars[ii])-(mean_value_center*mean_value_center)
        valor = (fw_stars[ii] - mean_value_center)
        linea += '%.2f \n' % (valor)
        file_out.write(linea)
file_out.close()

if os.path.exists(file_out_name):
    xx, yy, ff = U.get_data(file_out_name, (0, 1, 2))

# Starting the figure
res = 1
plt.figure(1, figsize=(12, 10), dpi=70, facecolor='w', edgecolor='k')
plt.clf()
plt.scatter(xx[::100] + 30000.,
            yy[::100] + 30000.,
示例#12
0
    z_y1_model, mag_y1_model = U.get_data(ab_filter_y1_model, (0, 1))
    ab_filter_y1[:, ii] = B.flux2mag(mag_y1_model)

    ab_filter_y2_model = ab_path + sed_models[ii][:-3] + filter_y2 + '.AB'
    z_y2_model, mag_y2_model = U.get_data(ab_filter_y2_model, (0, 1))
    ab_filter_y2[:, ii] = B.flux2mag(mag_y2_model)

for zz in range(res_z - 1):
    # Select galaxies with that redshift.
    if zz < 1:
        good_z = N.less_equal(zs, z_range[zz + 1])
    else:
        good_z = N.greater_equal(zs, z_range[zz])
        good_z *= N.less_equal(zs, z_range[zz + 1])

    mean_z = U.mean_robust(zs[good_z])
    pos_z = N.argmin(abs(mean_z - z_ab))

    #Template Colour definition
    color_templ_xaxis = (ab_filter_x1[pos_z, :] - ab_filter_x2[pos_z, :])
    color_templ_yaxis = (ab_filter_y1[pos_z, :] - ab_filter_y2[pos_z, :])

    # Plots
    plt.figure(1, figsize=(12, 10), dpi=75, facecolor='w', edgecolor='k')
    plt.clf()
    plt.plot(color_x[good_z], color_y[good_z], 'bo', alpha=0.2, ms=10)
    if mean_z < 0.2:
        plt.xlim(0., 2.5)
        plt.ylim(0., 2.5)
    else:
        plt.xlim(0.5, 3.5)
示例#13
0
#splus_colors = list(cm.jet(N.linspace(0, 1, 12)))
#splus_colors = list(cm.rainbow(N.linspace(0, 1, 5)))
y_min = -1.49
y_max = 1.49
y_min = -0.99
y_max = 0.99
x_min = 14
x_max = 21

## U
#plt.figure(1,figsize = (14,6),dpi=70, facecolor='w', edgecolor='k')
plt.figure(1, figsize=(14, 4), dpi=70, facecolor='w', edgecolor='k')
plt.clf()
uno = plt.axes([.075, .12, .725, .87])
plt.plot(u_sd[::res],
         delta_u[::res] - (U.mean_robust(delta_u)),
         'o',
         ms=5,
         alpha=0.1,
         color='grey')
plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
plt.grid()
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
plt.ylabel('$m^{sp}_{u}$ - $m^{sd}_{u}$', size=25, labelpad=-1)
#plt.xlabel('$m^{sd}_{u}$',size=25,labelpad=1)
plt.xlabel('$m^{u,sp}$', size=23, labelpad=-10)

dos = plt.axes([.8, .12, .15, .87])
a1, a2, a3 = plt.hist(delta_u[::res] - (U.mean_robust(delta_u)),
示例#14
0
#seeing_values = N.zeros((n_cats,12),float)

## Reading data from catalogues
for sss in range(n_cats):
    field = os.path.basename(cats[sss])[9:-15]
    master_cat = root_to_cats + 'STRIPE82-%s_Photometry.cat' % (field)  ##
    print 'reading catalog %i out of %i ' % (sss + 1, n_cats)
    fwhm, mr = U.get_data(master_cat, (8, 84))
    fwhm_master, stars = sct.get_seeing_from_data_pro(fwhm, mr)
    for hhh in range(12):
        ind_catalog = root_to_ind + 'sex_STRIPE82-%s_%s_swp.cat' % (
            field, filters[hhh])  ##
        fwhm_ind = U.get_data(ind_catalog, 6)
        fwhm_redu = fwhm_ind[stars]
        good_stars = N.greater_equal(fwhm_redu, 1.)
        fwhm_values[sss, hhh] = U.mean_robust(fwhm_redu[good_stars]) * 0.55
        # aa & bb have to be picked from other catalogues.
        #aa,bb = U.get_data(ind_catalog,(11,12))
        #pausa = raw_input('paused in filter: %s'%(filters[hhh]))
        #boa_values[sss,hhh] = U.mean_robust((bb/aa)[stars])

        # Reading s/n from master for each filter
        mp, s2n = U.get_data(master_cat, (mag_pos[hhh], s2n_pos[hhh]))
        mp += 0.083
        c0 = N.greater_equal(s2n, 3.) * N.less(mp, 30)
        w1, w2 = N.histogram(mp[c0], base_mlim)
        mlim_values[sss, hhh] = base_mlim2[N.argmax(w1)]

    # Reading ZP values
    zp_file = root_to_zps + 'STRIPE82-%s_ZP.cat' % (field)
    zps_values[sss, :] = U.get_data(zp_file, 1)[:]