예제 #1
0
def f_plot(**kwargs):
    args = read_kwargs(**kwargs)
    C.debug_var(args.debug, kwargs = kwargs)
    H = args.H
    mask = args.x.mask | args.y.mask
    xm = np.ma.masked_array(args.x, mask = mask)
    ym = np.ma.masked_array(args.y, mask = mask)
    zm = np.ma.masked_array(args.z, mask = mask)
    f = plt.figure()
    f.set_size_inches(10, 8)
    ax = f.gca()
    plotScatterColorAxis(f, xm, ym, zm, args.xlabel, args.ylabel, args.zlabel, args.xlim, args.ylim, args.zlim, contour = args.contour, run_stats = args.run_stats, OLS = args.OLS)
    ax.xaxis.set_major_locator(MultipleLocator(args.x_major_locator))
    ax.xaxis.set_minor_locator(MultipleLocator(args.x_minor_locator))
    ax.yaxis.set_major_locator(MultipleLocator(args.y_major_locator))
    ax.yaxis.set_minor_locator(MultipleLocator(args.y_minor_locator))
    txt = r'DGR = $10^{%.2f}$' % (np.log10(args.DGR))
    plot_text_ax(ax, txt, 0.02, 0.98, 14, 'top', 'left')
    ax.grid(which = 'major')
    f.suptitle(r'%d galaxies - tSF:%.2fMyr  $x_Y$(min):%.0f%%  $\tau_V^\star$(min):%.2f  $\tau_V^{neb}$(min):%.2f  $\epsilon\tau_V^{neb}$(max):%.2f' % (H.N_gals, (args.tSF / 1e6), H.xOkMin * 100., H.tauVOkMin, H.tauVNebOkMin, H.tauVNebErrMax), fontsize=14)
    f.savefig(args.fname)
    plt.close(f)
예제 #2
0
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

if __name__ == '__main__':
    Zsun = 0.019

    t_init_gal = time.clock()
    
    args = parser_args()
    debug = args.debug
    iT = args.itSF

    H = C.H5SFRData(args.hdf5)
    paths = C.CALIFAPaths()

    C.debug_var(debug, args = args)

    if (len(np.where(H.califaIDs == args.califaID)[0]) == 0):
        exit('<<< plot: %s: no data in HDF5 file.' % args.califaID)
        
    K = C.read_one_cube(args.califaID, EL = True, GP = True)
    
    age = H.tSF__T[iT]
    ageMyr = age / 1e6
    
    # Setup elliptical-rings geometry
    pa, ba = K.getEllipseParams()
    K.setGeometry(pa, ba)
    
    tipos, tipo, tipo_m, tipo_p = C.get_morfologia(args.califaID)
    
예제 #3
0
        for line in l.linesbpt:
            ax.plot(l.x[line], l.y[line], label = line)
        ax.text(-0.7, -0.5, 'SF')
        ax.text(-0.3, 0.6, 'Seyfert')
        ax.text(0.15, -0.5, 'LINER')
        C.plot_zbins(
            debug = True,
            cb = False,
            write_N = True,
            zmask = None,
            f = f,
            ax = ax,
            x = logN2Ha__g, 
            y = logO3Hb__g, 
            z = H.zone_dist_HLR__g, 
            zlim = zlim,
            xlim = (-1.5, 0.5),
            ylim = (-1.5, 1.0),
            x_major_locator = 1.,
            x_minor_locator = 0.2,
            y_major_locator = 1.,
            y_minor_locator = 0.2,
            kwargs_scatter = dict(marker = 'o', s = 10, edgecolor = 'none', alpha = 0.45, label = ''),
            xlabel = r'$\log [NII]/H\alpha$',
            ylabel = r'$\log [OIII]/H\beta$',
            zlabel = r'R (HLR)',
        )

        ax = plt.subplot2grid(grid_shape, loc = (0, 1))
        ax.set_axis_on()
        for line in l.linesbpt:
            ax.plot(l.x[line], l.y[line], label = line)
예제 #4
0
                        help = 'Name of the output PDF file.',
                        metavar = 'FILENAME',
                        type = str,
                        default = default['output'])
    parser.add_argument('--bamin', '-B',
                        help = 'min b/a',
                        metavar = '',
                        type = float,
                        default = default['bamin'])

    return parser.parse_args()

if __name__ == '__main__':
    args = parser_args()
    
    C.debug_var(args.debug, args = args)
    
    H = C.H5SFRData(args.hdf5)
    iT = args.itSF
    iU = -1

    fnamesuffix = '.pdf'
    minR = args.maskradius

    if minR is None:
        maskRadiusOk__g = np.ones_like(H.zone_dist_HLR__g, dtype = np.bool)
        maskRadiusOk__rg = np.ones((H.NRbins, H.N_gals_all), dtype = np.bool)
    else:
        maxR = H.Rbin__r[-1]
        maskRadiusOk__g = (H.zone_dist_HLR__g >= minR) & (H.zone_dist_HLR__g <= maxR) 
        maskRadiusOk__rg = (np.ones((H.NRbins, H.N_gals_all), dtype = np.bool).T * ((H.RbinCenter__r >= minR) & (H.RbinCenter__r <= maxR))).T
예제 #5
0
SFR_int = get_h5_data_masked(h5, 'SFR_int__Tg', **dict(dtype = np.float_))
SFR_Ha_int = get_h5_data_masked(h5, 'SFR_Ha_int__Tg', **dict(dtype = np.float_))
SFR_Ha_int_masked = get_h5_data_masked(h5, 'SFR_Ha_int_masked__Tg', **dict(dtype = np.float_))
O3N2_int_masked = get_h5_data_masked(h5, 'O3N2M13_int_masked__Tg', **dict(dtype = np.float_))
O3N2_int = np.array(h5['data/O3N2M13_int__g'].value, dtype = np.float_)
O3N2_int = np.ma.masked_array(O3N2_int, mask = np.isnan(O3N2_int))

sc_kwargs = dict(marker = 'o', s = 50, edgecolor = 'none', label = '')
kwargs_ols_plot = dict(c = 'r', ls = '--', lw = 2, label = 'OLS')
kwargs_ols = dict(c = 'k', pos_x = 0.98, pos_y = 0.01, fs = 12, rms = True, text = True, kwargs_plot = kwargs_ols_plot)

f = plt.figure()
grid_shape = (1, 2)
ax1 = plt.subplot2grid(grid_shape, loc = (0, 0))
ax2 = plt.subplot2grid(grid_shape, loc = (0, 1))
xm1, ym1 = C.ma_mask_xyz(x = O3N2_int, y = np.ma.log10(SFR_int[1]) - np.ma.log10(SFR_Ha_int[1]))
ax1.scatter(xm1, ym1, **sc_kwargs)
_ = plotOLSbisectorAxis(ax1, xm1.compressed(), ym1.compressed(), **kwargs_ols)
ax1.set_xlabel(r'12 + $\log$ O/H M13')
ax1.set_ylabel(r'$\Delta$SFR (syn - $H\alpha$)')
sc = ax2.scatter(np.ma.log10(SFR_int[1]), np.ma.log10(SFR_Ha_int[1]), c = O3N2_int, cmap = 'viridis', **sc_kwargs)
ax2.set_xlabel(r'$\log$ SFR(syn) [$M_\odot\ yr^{-1}$]')
ax2.set_ylabel(r'$\log$ SFR(H$\alpha$) [$M_\odot\ yr^{-1}$]')
f.colorbar(sc)
f.savefig('Zneb_SFR.pdf')
f.subplots_adjust(bottom = 0.15, hspace = 0.15, wspace = 0., right = 0.95, left = 0.10)

f = plt.figure()
grid_shape = (1, 2)
ax1 = plt.subplot2grid(grid_shape, loc = (0, 0))
ax2 = plt.subplot2grid(grid_shape, loc = (0, 1))
예제 #6
0
 tickpos = np.linspace(mtypes[0] + halfbinstep, mtypes[-1] - halfbinstep, Ntype)
         
 aSFRSD__Ttr = np.empty((N_T, Ntype, NRbins), dtype = np.float_)
 aSFRSD_Ha__Ttr = np.empty((N_T, Ntype, NRbins), dtype = np.float_)
 nbinelem_aSFRSD__Ttr = np.empty((N_T, Ntype, NRbins), dtype = np.int_)
 nbinelem_aSFRSD_Ha__Ttr = np.empty((N_T, Ntype, NRbins), dtype = np.int_)
 perc_aSFRSD__pTtr = np.ma.masked_all((3, N_T, Ntype, NRbins), dtype = np.float_)
 perc_aSFRSD_Ha__pTtr = np.ma.masked_all((3, N_T, Ntype, NRbins), dtype = np.float_)
 
 Ngals__t = np.empty((Ntype), dtype = np.int_)
 
 for it, t in enumerate(mtypes):
     mask_morf__g = (morf__g == t)
     Ngals__t[it] = np.sum(mask_morf__g)
     for iT in range(N_T):
         C.debug_var(debug, iT = iT, it = it, NGals = Ngals__t[it])
         # G means masked g
         aSFRSD__rG = aSFRSD__Trg[iT][:, mask_morf__g]
         aSFRSD_Ha__rG = aSFRSD_Ha__Trg[iT][:, mask_morf__g]
 
         for ir in np.where(RbinCenter__r <= 2 + rbinstep)[0]:
             for ig in xrange(Ngals__t[it]):
                 if aSFRSD__rG[ir].mask[ig]:
                     aSFRSD__rG[ir, ig] = 0
                 if aSFRSD_Ha__rG[ir].mask[ig]:    
                     aSFRSD_Ha__rG[ir, ig] = 0.
         C.debug_var(debug, aSFRSD__rG = aSFRSD__rG)
         
         aSFRSD__Ttr[iT][it] = aSFRSD__rG.mean(axis = 1)
         nbinelem_aSFRSD__Ttr[iT][it] = aSFRSD__rG.count(axis = 1)
         aSFRSD_Ha__Ttr[iT][it] = aSFRSD_Ha__rG.mean(axis = 1)
예제 #7
0
    Rp, _ = st.pearsonr(xm.compressed(), ym.compressed())
    C.debug_var(debug, Rs = Rs)
    C.debug_var(debug, Rp = Rp)
    return Rs, Rp

if __name__ == '__main__':
    try:
        h5file = sys.argv[1]
    except IndexError:
        print 'usage: %s HDF5FILE' % (sys.argv[0])
        exit(1)
    
    H = C.H5SFRData(h5file)    
    
    tSF__T = H.tSF__T
    C.debug_var(debug, tSF__T = tSF__T)
    iT__t = np.arange(len(tSF__T))
    C.debug_var(debug, iTs = iT__t)
    RsSFR = np.empty(iT__t.shape, dtype = np.double)
    RpSFR = np.empty(iT__t.shape, dtype = np.double)
    RsSFRSD = np.empty(iT__t.shape, dtype = np.double)
    RpSFRSD = np.empty(iT__t.shape, dtype = np.double)
    RsaSFRSD = np.empty(iT__t.shape, dtype = np.double)
    RpaSFRSD = np.empty(iT__t.shape, dtype = np.double)
    RsaSFRSDn = np.empty(iT__t.shape, dtype = np.double)
    RpaSFRSDn = np.empty(iT__t.shape, dtype = np.double)
    RsiSFR = np.empty(iT__t.shape, dtype = np.double)
    RpiSFR = np.empty(iT__t.shape, dtype = np.double)
    RsiSFRSD = np.empty(iT__t.shape, dtype = np.double)
    RpiSFRSD = np.empty(iT__t.shape, dtype = np.double)
예제 #8
0
    
    fnamesuffix = '.pdf'
    
    if args.slice_gals is None:
        N_gals = H.N_gals
        gals_slice__g = np.ones_like(H.zone_dist_HLR__g, dtype = np.bool)
        gals_slice__rg = np.ones((NRbins, H.N_gals_all), dtype = np.bool)
        gals_slice__integr = np.ones(H.califaIDs_all.shape, dtype = np.bool)
        gals_txt = ''
    else:
        gals_slice__g, N_gals = H.get_mask_zones_list(args.slice_gals, return_ngals = True)
        gals_slice__rg, N_gals = H.get_mask_radius_list(args.slice_gals, return_ngals = True)
        gals_txt = (args.slice_gals).split('/')[-1]
        fnamesuffix = '_%s%s' % (gals_txt, fnamesuffix)
        #integrated
        l_gals, _ = C.sort_gals(args.slice_gals)
        l_gals = sorted(l_gals)
        gals_slice__integr = np.zeros(H.califaIDs_all.shape, dtype = np.bool)
        for g in l_gals:
            i = H.califaIDs_all.tolist().index(g)
            gals_slice__integr[i] = True

    mask__Tg = np.zeros((N_T, H.N_zones__g.sum()), dtype = bool)
    for iT in xrange(N_T):
        mask__Tg[iT] = mask_zones_iT(iT, H, args.bamin, gals_slice__g)
            
    for iGal, califaID in enumerate(H.califaIDs):
        K = C.read_one_cube(califaID, EL = True, GP = True, debug = args.debug, v_run = args.v_run)
        tipos, tipo, tipo_m, tipo_p = C.get_morfologia(califaID)
        my_type = C.my_morf(tipos)
        N_zone = K.N_zone
예제 #9
0
                        help = 'Name of the output PDF file.',
                        metavar = 'FILENAME',
                        type = str,
                        default = default['output'])
    parser.add_argument('--bamin', '-B',
                        help = 'min b/a',
                        metavar = '',
                        type = float,
                        default = default['bamin'])

    return parser.parse_args()

if __name__ == '__main__':
    args = parser_args()
    
    C.debug_var(args.debug, args = args)
    
    H = C.H5SFRData(args.hdf5)
    iT = args.itSF
    iU = -1

    minR = 0
    fnamesuffix = '.pdf'
    
    if args.maskradius is None:
        maskRadiusOk__g = np.ones_like(H.zone_dist_HLR__g, dtype = np.bool)
        maskRadiusOk__rg = np.ones((H.NRbins, H.N_gals_all), dtype = np.bool)
    else:
        minR = args.maskradius
        maskRadiusOk__g = (H.zone_dist_HLR__g >= args.maskradius) & (H.zone_dist_HLR__g <= H.Rbin__r[-1]) 
        maskRadiusOk__rg = (np.ones((H.NRbins, H.N_gals_all), dtype = np.bool).T * (H.RbinCenter__r >= args.maskradius)).T
예제 #10
0
 m_gal_not_OK = np.bitwise_or(m_gal_not_OK, N2_obs.mask)
 m_gal_not_OK = np.bitwise_or(m_gal_not_OK, np.ma.less(SN_Ha_obs, 3))
 m_gal_not_OK = np.bitwise_or(m_gal_not_OK, np.ma.less(SN_Hb_obs, 3))
 m_gal_not_OK = np.bitwise_or(m_gal_not_OK, np.ma.less(SN_O3_obs, 3))
 m_gal_not_OK = np.bitwise_or(m_gal_not_OK, np.ma.less(SN_N2_obs, 3))
 
 tau_V_lines = AV_lines * 1. / (2.5 * np.log10(np.exp(1.)))
 
 logO3Hb, logN2Ha, logO3N2 = calc_O3N2(Hb_obs, O3_obs, 
                                       Ha_obs, N2_obs, 
                                       m_gal_not_OK, tau_V_lines, 
                                       correct = True)
 
 logOH_M13 = 8.533 - 0.214 * logO3N2
 
 xm, ym = CALIFAUtils.ma_mask_xyz(x = logOH_M13, y = Zneb_mpa)
 
 #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
 # f = plt.figure()
 # f.set_dpi(100)
 # f.set_size_inches(10, 8)    
 # ax = f.gca()
 # ax.scatter(logN2Ha, logO3Hb, marker = '.', s = 1, c = '0.7', edgecolor = 'none', alpha = 0.6, label = '')
 # #m_aux = l.maskAbovelinebpt('K01', logN2Ha, logO3Hb)
 # ax.scatter(logN2Ha[~(Zneb_mpa.mask | m_aux)], logO3Hb[~(Zneb_mpa.mask | m_aux)], marker = '.', s = 5, c = 'b', edgecolor = 'none', alpha = 0.6, label = '')
 # for line in l.linesbpt:
 #     ax.plot(l.x[line], l.y[line], label = line)
 # #axis = [-2.5, 1.0, -1.6, 1.6]
 # ax.set_xlim(-2.5, 1.0)
 # ax.set_ylim(-1.6, 1.6) 
 # ax.set_xlabel(r'$\log\ ([NII]\lambda 6584 / H\alpha)$')    
예제 #11
0
 f, axArr = plt.subplots(1, 2)
 f.set_dpi(100)
 f.set_size_inches(14, 8)
 ax = f.gca()
 i = 0
 filename = '%s_%s_%s_%.2fMyr.png' % (xk, yk, zk, tSF / 1e6)
 suptitle = r'NGals:%d  tSF:%.2f Myr  $x_Y$(min):%.0f%%  $\tau_V^\star$(min):%.2f  $\tau_V^{neb}$(min):%.2f  $\epsilon\tau_V^{neb}$(max):%.2f' % (H.N_gals, (tSF / 1e6), H.xOkMin * 100., H.tauVOkMin, H.tauVNebOkMin, H.tauVNebErrMax)
 cbarr = [ False, False ]
 for Rn in [ 0.5, 1.0 ]:
     print '######' , i 
     x = np.ma.copy(xv['v'])
     y = np.ma.copy(yv['v'])
     if mask_radius is True:
         x[~(H.RbinCenter__r > Rn)] = np.ma.masked
         y[~(H.RbinCenter__r > Rn)] = np.ma.masked
     xm, ym, zm = CALIFAUtils.ma_mask_xyz(x = x.flatten(), y = y.flatten(), z = H.reply_arr_by_radius(H.morfType_GAL__g).flatten())
     zticks_mask = [
         np.ma.bitwise_or(np.ma.equal(zm, 9.), np.ma.equal(zm, 9.5)), 
         np.ma.equal(zm, 10), 
         np.ma.equal(zm, 10.5), 
         np.ma.bitwise_or(np.ma.equal(zm, 11.), np.ma.equal(zm, 11.5)),
     ]
     #zticks_mask = [(zm == 9), (zm == 9.5), (zm == 10), (zm == 10.5), (zm == 11.), (zm == 11.5)]
     zticks = [9., 9.5, 10, 10.5, 11., 11.5]
     zticklabels = ['Sa', 'Sab', 'Sb', 'Sbc', 'Sc', 'Scd']
     zbins_colors = ['r', 'g', 'y', 'b']
     #zbins_labels = ['Sa + Sab: %d' % len(xm[zticks_mask[0]]), 'Sb: %d' % len(xm[zticks_mask[1]]), 'Sbc: %d' % len(xm[zticks_mask[2]]), 'Sc + Scd: %d' % len(xm[zticks_mask[3]])]
     zbins_labels = ['Sa + Sab', 'Sb', 'Sbc', 'Sc + Scd']
     #zbins_labels = ['Sa', 'Sab', 'Sb', 'Sbc', 'Sc', 'Scd']
     kw = plot_zbins(
         return_kwargs = True,
예제 #12
0
         v = np.ma.log10((H.Mcor_GAL__g[..., np.newaxis] * np.ones((20))).T),
         label = r'$\log\ M_\star^{GAL}$ [$M_\odot$]', 
 )
 
 for xk, xv in xaxis.iteritems():
     for yk, yv in yaxis.iteritems():
         if xk != yk:
             tSF = H.tSF__T[iT]
             f = plt.figure()
             f.set_dpi(100)
             f.set_size_inches(14, 8)
             ax = f.gca()
             i = 0
             filename = '%s_%s_%s_%.2fMyr.png' % (xk, yk, zk, tSF / 1e6)
             suptitle = r'NGals:%d  tSF:%.2f Myr  $x_Y$(min):%.0f%%  $\tau_V^\star$(min):%.2f  $\tau_V^{neb}$(min):%.2f  $\epsilon\tau_V^{neb}$(max):%.2f' % (H.N_gals, (tSF / 1e6), H.xOkMin * 100., H.tauVOkMin, H.tauVNebOkMin, H.tauVNebErrMax)
             xm, ym, zm = CALIFAUtils.ma_mask_xyz(x = xv['v'], y = yv['v'], z = np.ma.log10((H.Mcor_GAL__g[..., np.newaxis] * np.ones((20))).T))
             zticks_mask = [
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 8.8), np.ma.less(zm, 9.6)),
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 9.6), np.ma.less(zm, 10.1)),
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 10.1), np.ma.less(zm, 10.6)),
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 10.6), np.ma.less(zm, 10.9)),
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 10.9), np.ma.less(zm, 11.2)),
                 np.ma.bitwise_and(np.ma.greater_equal(zm, 11.2), np.ma.less(zm, 11.6)),
             ]                    
             zbins_labels = ['9.6--8.8', '10.1--9.6', '10.6--10.1', '10.9--10.6', '11.2--10.9', '11.6--11.2']
             kw = plot_zbins(
                 return_kwargs = True,
                 f = f,
                 ax = ax,
                 debug = debug,
                 x = xv['v'],
예제 #13
0
 f.set_size_inches(15,8) 
 kw = C.plot_zbins(
     return_kwargs = True,
     f = f,
     ax = axArr[0],
     debug = True,
     x = np.ma.log10(x1),
     y = np.ma.log10(y1),
     xlabel = x1label,
     ylabel = y1label,
     #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
     # z = H.zone_dist_HLR__g,
     # zmask = None,
     # zlim = [RNuc, 3],
     # zlabel = r'R (HLR)',
     # cb = None,
     #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
     xlim = [-5, 1],
     ylim = [-5, 1],
     x_major_locator = 1.,
     x_minor_locator = 0.2,
     y_major_locator = 1.,
     y_minor_locator = 0.2,
     ols = True,
     spearmanr = True,
     kwargs_figure = dict(figsize = (10, 8), dpi = 100),
     kwargs_scatter = dict(marker = 'o', s = 10, edgecolor = 'none', alpha = 0.3, label = ''),
     kwargs_ols = dict(c = 'k', pos_x = 0.98, pos_y = 0.01, fs = 12, rms = True, text = True),
     kwargs_ols_plot = dict(c = 'r', ls = '-', lw = 2, label = 'OLS'),
 )
 kw['ax'].plot(kw['ax'].get_xlim(), kw['ax'].get_xlim(), ls = '--', label = '', c = 'k')    
                        help = 'initial RDisc value in HLR',
                        metavar = 'NUM',
                        type = float,
                        default = default['maskradius'])
    parser.add_argument('--output', '-o',
                        help = 'Name of the output PDF file.',
                        metavar = 'FILENAME',
                        type = str,
                        default = default['output'])

    return parser.parse_args()

if __name__ == '__main__':
    args = parser_args()
    
    C.debug_var(args.debug, args = args)
    
    H = C.H5SFRData(args.hdf5)
    iT = args.itSF
    iU = -1

    minR = 0
    
    if args.maskradius is None:
        maskRadiusOk__g = np.ones_like(H.zone_dist_HLR__g, dtype = np.bool)
        maskRadiusOk__rg = np.ones((H.NRbins, H.N_gals_all), dtype = np.bool)
    else:
        minR = args.maskradius
        maskRadiusOk__g = (H.zone_dist_HLR__g >= args.maskradius) & (H.zone_dist_HLR__g <= H.Rbin__r[-1]) 
        maskRadiusOk__rg = (np.ones((H.NRbins, H.N_gals_all), dtype = np.bool).T * (H.RbinCenter__r >= args.maskradius)).T
        
예제 #15
0
파일: SFR.py 프로젝트: elacerda/emlines
        print '<<< %s galaxy: miss gasprop file' % califaID
        return 2, False
    # Problem in FITS file
    return 0, True       

#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

if __name__ == '__main__':
    # Saving the initial time
    t_init_prog = time.clock()

    # Parse arguments 
    args = parser_args(sys.argv[0])
    C.debug_var(True, args = args.__dict__)    
    
    Zsun = 0.019

    # Creating radial bins.
    Rbin__r = np.arange(args.rbinini, args.rbinfin + args.rbinstep, args.rbinstep)
    RbinCenter__r = (Rbin__r[:-1] + Rbin__r[1:]) / 2.0
    NRbins = len(RbinCenter__r)
    RColor = [ 'r', 'y', 'b', 'k' ]
    RRange = [  .5, 1., 1.5, 2.  ]
    Rbin_oneHLR = [1. - args.rbinstep, 1. + args.rbinstep]
    
    # Reading galaxies file,
    gals, _ = C.sort_gals(gals = args.gals_filename, order = 1)
    N_gals = len(gals)
    maxGals = None
예제 #16
0
        'logWHaWHbR' : dict(lim = [-0., 0.8]),
        'tauVdiffR' : dict(lim = [-0.75, 1.5]),
        'tauVRatioR' : dict(lim = [0., 6.]),
        'baR' : dict(lim = [0, 1.]),
    }
    
    xkeys = [ 'RadDist', 'morfTypeR', 'atfluxR', 'alogZmassR', 'logO3N2S06R', 'logMcorSDR', 'xYR', 'logWHaWHbR', 'tauVdiffR', 'tauVRatioR', 'baR' ]

    for iT in iT_values:
        tSF = H.tSF__T[iT]
        
        xk, xv = H.get_plot_dict(iT = iT, iU = -1, key = 'logtauVR')
        yk, yv = H.get_plot_dict(iT = iT, iU = -1, key = 'alogSFRSDR')
        xname = H.get_plot_dict(iT = iT, iU = -1)[xk[:-1]]['legendname']
        yname = H.get_plot_dict(iT = iT, iU = -1)[yk[1:-1]]['legendname']
        xm, ym = C.ma_mask_xyz(xv['v'], yv['v'])
        a, b, sig_a, sig_b = OLS_bisector(xm, ym)
        R = ym - (a * xm + b)
        Yrms = R.std()
        Yrms_str = r' : $y_{rms}$:%.2f' % Yrms
        if b > 0:
           txt_y = r'$y_{OLS}$ = %.2f %s + %.2f %s' % (yname, a, xname, b, Yrms_str)
        else:
           txt_y = r'$y_{OLS}\ \equiv$ %s = %.2f %s - %.2f %s' % (yname, a, xname, b * -1., Yrms_str)
        C.debug_var(debug, txt_y = txt_y)
        for xk in xkeys:
            fnamepref = 'SKdevOLS_%s' % xk
            if xk != 'RadDist':
                _, xv = H.get_plot_dict(iT = iT, iU = -1, key = xk)
                xv.update(updates.get(xk, {}))
            else:
예제 #17
0
     continue
 xv.update(dict(limprc = [0, 100]))
 yv.update(dict(limprc = [0, 100]))
 xv.update(updates[xk])
 yv.update(updates[yk])
 C.plot_zbins(
     debug = debug,
     x = xv['v'],
     y = yv['v'],
     xlim = xv['lim'],
     ylim = yv['lim'],
     xlabel = xv['label'],
     ylabel = yv['label'],
     running_stats = True,
     rs_percentiles = True,
     rs_errorbar = False,
     rs_gaussian_smooth = True,
     rs_gs_fwhm = 4.,
     kwargs_figure = dict(figsize = (10, 8), dpi = 100),
     kwargs_scatter = dict(marker = 'o', s = 10, edgecolor = 'none', alpha = 0.5, label = ''),
     kwargs_plot_rs = dict(c = 'k', lw = 2, label = 'Median (run. stats)'),
     kwargs_suptitle = dict(fontsize = 12),
     kwargs_legend = dict(fontsize = 12, loc = 'best'),
     suptitle = r'NGals:%d  tSF:%.2f Myr  $x_Y$(min):%.0f%%  $\tau_V^\star$(min):%.2f  $\tau_V^{neb}$(min):%.2f  $\epsilon\tau_V^{neb}$(max):%.2f' % (H.N_gals, (tSF / 1e6), H.xOkMin * 100., H.tauVOkMin, H.tauVNebOkMin, H.tauVNebErrMax),
     filename = filename,
 )
  
 mask = []
 ba = H.reply_arr_by_radius(H.ba_GAL__g)
 balimsup = [0.39, 0.63, 1.]
 titles = [ 
    # Sebas
    SFR_int__Tg = np.ma.masked_all((N_T, N_gals), dtype=np.float_)
    SFR_Ha_int__Tg = np.ma.masked_all((N_T, N_gals), dtype=np.float_)
    SFR_Ha_int_masked__Tg = np.ma.masked_all((N_T, N_gals), dtype=np.float_)
    O3N2M13_int__g = np.ma.masked_all((N_gals), dtype=np.float_)
    O3N2M13_int_masked__Tg = np.ma.masked_all((N_T, N_gals), dtype=np.float_)

    morf__g = np.ma.masked_all((N_gals), dtype=np.int_)
    N_zones__g = np.ma.masked_all((N_gals), dtype=np.int_)
    N_zones_notmasked__Tg = np.ma.masked_all((N_T, N_gals), dtype=np.int_)

    # automatically read PyCASSO and EmLines data cubes.
    EL = True
    baseCode = "Bgsd6e"
    for iGal, K in C.loop_cubes(
        gals.tolist(), imax=maxGals, EL=EL, GP=args.gasprop, v_run=args.v_run, baseCode=baseCode
    ):
        # for iGal in xrange(len(gals)):
        t_init_gal = time.clock()
        califaID = gals[iGal]

        sit, verify = verify_files(K, califaID, EL=EL, GP=args.gasprop)

        if verify is not True:
            print "<<< ", califaID, sit
            if sit == 1:
                K.close()
            elif sit == 2:
                K.EL.close()
                K.close()
            continue
        for i in range(Nres_bins):
            f3.write(fmt % (res_bin_cen[i], histR[i], histS[i], histU[i]))
        f3.close()

        # npz file with the full Dictionary
        fname4 = 'SpecResidStats4DR2_AllDict.' + suf
        np.savez_compressed(fname4, D)

sys.exit('bai')

frac = 0.999
l_int = np.arange(3650, 7200, 2)
Nl_int = len(l_int)
import CALIFAUtils
gals, _ = CALIFAUtils.sort_gals('/Users/lacerda/CALIFA/listv20_q050.d15a.txt')
#gals, _ = CALIFAUtils.sort_gals('/Users/lacerda/CALIFA/listq50test.txt')

RF_SumR__l = np.ma.zeros((1601))
RF_SumR2__l = np.ma.zeros((1601))
RF_NOk__l = np.ma.zeros((1601))

for iGal, K in CALIFAUtils.loop_cubes(gals.tolist(), v_run=-1):
    isFlagOk__lz = np.where(K.f_flag == 0, 1, 0)
    isErrOk__lz = np.where(K.f_err > 0, 1, 0)
    isWeiOk__lz = np.where(K.f_wei > 0, 1, 0)
    isOk__lz = isFlagOk__lz * isWeiOk__lz * isErrOk__lz
    rad__z = np.sqrt((K.zonePos['x'] - K.x0)**2. +
                     (K.zonePos['y'] - K.y0)**2.) / K.HLR_pix
    isInRad__z = np.where(rad__z >= 1., 1, 0) * np.where(rad__z < 999.0, 1, 0)
    isOkAndInRad__lz = isOk__lz * isInRad__z
예제 #20
0
            #rs_gaussian_smooth = True,
            #rs_percentiles = True,
            #rs_gs_fwhm = 0.4,
            #kwargs_plot_rs = dict(c = c_rs, lw = 2, label = 'Median (run. stats)'),
            #rs_errorbar = False,
            #x_major_locator = xv['majloc'],
            #x_minor_locator = xv['minloc'],
            #y_major_locator = yv['majloc'],
            #y_minor_locator = yv['minloc'],
        )
 
    suptitle = r'NGals:%d  tSF:%.2f Myr  $x_Y$(min):%.0f%%  $\tau_V^\star$(min):%.2f  $\tau_V^{neb}$(min):%.2f  $\epsilon\tau_V^{neb}$(max):%.2f' % (H.N_gals, (tSF / 1e6), H.xOkMin * 100., H.tauVOkMin, H.tauVNebOkMin, H.tauVNebErrMax)                            
    f.suptitle(suptitle, fontsize = 12)
    filename = '%s_%.2fMyr.png' % ('logSFRSD_tauV', tSF / 1e6)
    #filename = '%s_%.2fMyr.png' % ('logSFRSDR_tauVR', tSF / 1e6)
    CALIFAUtils.debug_var(True, filename = filename)
    f.savefig(filename)
    plt.close(f)
 
    #################################################################################
     
    #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
    # xkeys = [ 'logtauVR', 'logtauVNebR' ]
    # ykeys = [ 'alogSFRSDR', 'alogSFRSDHaR' ]
    #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
    xkeys = [ 'logtauV', 'logtauVNeb' ]
    ykeys = [ 'logSFRSD', 'logSFRSDHa' ]
    for fnamepref, xv, yv in H.plot_xyz_keys_iter(iT = iT, iU = -1, xkeys = xkeys, ykeys = ykeys):
        xk = fnamepref.split('_')[0]
        yk = fnamepref.split('_')[1]
        plot_zbins(
예제 #21
0
def corr_xy_SFR(H, v, tSF__T, iT, mask_radius = False):
    C.debug_var(debug, corr = v)
    C.debug_var(debug, iT = iT)
    C.debug_var(debug, tSF = tSF__T[iT])
    if v == 'aSFRSD':
        dim = 'rg'
    else:
        dim = 'g'
    x = H.get_data_h5('%s__T%s' % (v, dim))[iT]
    y = H.get_data_h5('%s_Ha__%s' % (v, dim))
    xm, ym = C.ma_mask_xyz(x, y)
    if mask_radius is True:
        m = (H.zone_dist_HLR__g > 0.5) 
        xm[~m] = np.ma.masked
        ym[~m] = np.ma.masked 
    Rs, _ = st.spearmanr(xm.compressed(), ym.compressed())
    Rp, _ = st.pearsonr(xm.compressed(), ym.compressed())
    C.debug_var(debug, Rs = Rs)
    C.debug_var(debug, Rp = Rp)
    return Rs, Rp
예제 #22
0
    #example(listfile, sortby, order = 1)
    f = open('/Users/lacerda/CALIFA/list_SFR/rem_ba_morph/list_1234.txt', 'r')
    l = f.readlines()
    f.close()
    listgals_toberemoved = [l[i].strip() for i in np.arange(len(l))]

    f = open('/Users/lacerda/CALIFA/list_SFR/rem_ba_morph/list_0_si_si.txt',
             'r')
    l = f.readlines()
    f.close()
    listgals_zero = [l[i].strip() for i in np.arange(len(l))]

    kwargs = dict(EL=True, nuc_R=0.15)
    gals, data__g = C.sort_gals(
        gals='/Users/lacerda/CALIFA/listOf298GalPrefixes.txt',
        func=sort_f,
        order=1,
        **kwargs)

    for i, g in enumerate(gals):
        j = -1

        try:
            j = listgals_zero.index(g)
            mark = '0'
        except:
            mark = None

        #EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
        # if mark == None:
        #     try: