def fig_power(po, pos=(0,4, 4,8)): ax = py.subplot(gs[pos[2]:pos[3], pos[0]:pos[1]]) set_axis(ax, -0.1, 1.2, letter= letters[po]) if po>5: py.xlabel('Power ($mV^{2}$)', fontsize = fsize-4) for ll in range(2,4): py.fill_between(range(2),-2,2,facecolor='grey', alpha=0.3) mean_csd = np.mean(csd_col[ll], axis=0) std_csd = np.std(csd_col[ll], axis=0)/np.sqrt(len(nazwy)) py.plot(mean_csd, np.linspace(-30,30,64), label = labels[ll%2], linewidth = 2, color = colors[ll%2]) py.fill_betweenx(np.linspace(-30,30,64), mean_csd - std_csd, mean_csd + std_csd, color=colors[ll%2], alpha = 0.3) py.axvline(0, linewidth = 0.5, linestyle = '--', color = 'grey') nzw.append('average csd') if po<5: py.yticks([-3,0, 10], tiky) else: py.yticks([-6,0, 6], tiky) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.spines['left'].set_visible(False) if ele_typ==20: py.ylim(-15, 10) else: py.ylim(-4, 25)
def fig_mua(pos, num, gs, df, version='cor'): ax = py.subplot(gs[pos[2]:pos[3], pos[0]:pos[1]]) set_axis(ax, -0.05, 1.1, letter=num) # py.title('MUA average frequency/phase') nazwy = ['022', '027', '128', '114']#, '116' miti= -1 csd_col = np.zeros((2,len(nazwy),64)) for i,key in enumerate(nazwy): hist_layer = list(df[int(key)][4:36].values) mit_pos = sl.all_indices(hist_layer, 'mit') sp_mtrx = np.load(loaddir+'saved_csd/spike_cor'+ str(key)+'.npy') sp_freq = np.load(loaddir+'saved_csd/spike_freq'+ str(key)+'.npy') min_mit = mit_pos[miti] frqs = np.linspace(0, 558, 51) frq_max = frqs[list(np.argmax(sp_freq[0, :, :], axis=1))] if min_mit<mit_pos[miti]: min_mit = mit_pos[miti] csd_col[1, i, 31-min_mit:63-min_mit] = sp_mtrx[0] csd_col[0, i, 31-min_mit:63-min_mit] = frq_max i=0 if version == 'cor': mean_csd = np.mean(csd_col[1], axis=0) std_csd = np.std(csd_col[1], axis=0)/(len(nazwy))**(1/2) else: mean_csd = np.mean(csd_col[0], axis=0) std_csd = np.std(csd_col[0], axis=0)/(len(nazwy))**(1/2) py.plot(mean_csd+i, np.linspace(-31,32,64), color = 'black', marker = 'o') py.fill_betweenx(np.linspace(-31,32,64), mean_csd - std_csd, mean_csd + std_csd, color='black', alpha = 0.5) py.yticks([-12, -5, -1, 5], ['glom.', 'EPL', 'mitral', 'grn']) py.ylim(-15, 15) py.axvline(0, ls ='--', color = 'grey') py.axvline(-0.5, ls ='--', color = 'grey') py.axvline(0.5, ls ='--', color = 'grey') if version == 'cor': py.xlim(-1, 1) py.xlabel('MUA histogram-HFO correlation', fontsize = fsize-4) else: py.xlim(1,200) py.xlabel('MUA histogram frequency', fontsize=fsize-4) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False)
def figprof(pos, let, lowpass=0.1, highpass=8, title=''): nazwy = ['022', '027', '114', '116', '117', '127', '128', '129'] ax = py.subplot(gs[pos[2]:pos[3], pos[0]:pos[1]]) set_axis(ax, -0.05, 1.05, letter=let) miti = -1 csd_col = np.zeros((len(nazwy), 64)) for i, key in enumerate(nazwy): hist_layer = list(df[int(key)][4:36].values) mit_pos = sl.all_indices(hist_layer, 'mit') y = np.load(loaddir + 'CSD' + str(key) + '.npy') Fss = 1394 [b, a] = butter(3., [lowpass / (Fss / 2.0), highpass / (Fss / 2.0)], btype='bandpass') y = filtfilt(b, a, y) pol = int(len(y[0]) / 2) + 1 y = y[:, pol] y = y / np.max(abs(y + 1e-10)) * .3 csd_col[i, 31 - mit_pos[miti]:63 - mit_pos[miti]] = y y2 = csd_col[i] py.plot(y2 + i + 1, np.linspace(-30, 30, 64), color='grey') py.fill_betweenx(np.linspace(-30, 30, 64), i + 1 + y2, i + 1, where=y2 + i + 1 >= i + 1, color='red', alpha=0.5) py.fill_betweenx(np.linspace(-30, 30, 64), i + 1 + y2, i + 1, where=y2 + i + 1 <= i + 1, color='blue', alpha=0.5) py.yticks([-12, -5, -1, 5], ['glom.', 'EPL', 'mitral', 'grn']) py.ylim(-15, 15) py.plot([0, 10], [-1, -1], color='grey', alpha=0.3, lw=10) py.xlabel('Rats') py.xlim(0.5, 8.5) py.title(title, fontsize=20) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False)
def fig_phase(po, pos=(0,4, 4,8)): ax = py.subplot(gs[pos[2]:pos[3], pos[0]:pos[1]]) set_axis(ax, -0.1, 1.2, letter= letters[po]) for ll in range(2): py.fill_between(range(300),-2,2,facecolor='grey', alpha=0.3) mean_csd = np.mean(csd_col[ll], axis=0) std_csd = np.std(csd_col[ll], axis=0)/np.sqrt(len(nazwy)) py.plot(mean_csd, np.linspace(-30,30,64), label = labels[ll], linewidth = 2, color = colors[ll]) py.fill_betweenx(np.linspace(-30,30,64), mean_csd - std_csd, mean_csd + std_csd, color=colors[ll], alpha = 0.3) py.axvline(0, linewidth = 0.5, linestyle = '--', color = 'grey') if po<5: py.yticks([-3,0, 10], tiky) else: py.yticks([-6,0, 6], tiky) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.spines['left'].set_visible(False) if ele_typ==20: py.ylim(-15, 10) else: py.ylim(-4, 25) xL=['0',r'$\frac{\pi}{2}$',r'$\pi$', r'$\frac{3\pi}{2}$'] py.xlim(0,290) py.xticks([0, 90, 180, 270], xL) if po<5: ax.legend(loc='center', bbox_to_anchor=(-.1, 1.1), ncol=2, frameon = True, fontsize = 16) if po>5: py.xlabel('Relative phase', fontsize = fsize-4)
cnt = 1 for cl in range(nclusters): v_inds = clusters[cl][1] t_inds = clusters[cl][0] signals = [np.mean(np.mean(np.array(s)[:, :, v_inds], axis=0), axis=1).squeeze() for s in data] pl.subplot(nclusters, 2, cnt) # The time plot figure only makes sense if it's not DICS_epochs if mask_fname.find('DICSepochs') < 0: for c in range(len(colors)): pl.plot(times, signals[c], color=colors[c]) pl.xlabel('Time (s)') pl.ylabel('Activation') pl.legend(groups, loc='best') pl.plot([0, 0], pl.ylim(), ':k') pl.fill_betweenx(pl.ylim(), times[np.min(t_inds)], times[np.max(t_inds)], color='grey', alpha=0.3) cnt += 1 # now, work on the mean over time barplot or regression, depending on result pl.subplot(nclusters, 2, cnt) my_test = mask_fname.split('_')[0] if my_test.find('anova') >= 0 or my_test.find('nvVSper') >= 0 or \ my_test.find('nvVSrem') >= 0 or my_test.find('perVSrem') >= 0: signals = [np.mean(np.array(s)[:, :, v_inds], axis=2) for s in data] signals = [np.mean(s[:, t_inds], axis=1) for s in signals] ybars = [np.mean(s) for s in signals] y_sd = [np.std(s)/np.sqrt(len(s)) for s in signals] pl.bar(np.arange(len(ybars)), ybars, 0.35, color=colors, ecolor='k', yerr=y_sd, align='center') pl.xticks(range(len(groups)), groups) pl.xlim([-.2, 2.5])
def foo(): pylab.fill_betweenx(fill_mtotal, fill_min_mchirp, fill_max_mchirp, edgecolor='0.6', facecolor='0.6') #pylab.plot(big_data[0], big_data[1], ',k', markersize=0.01) pylab.plot(small_data[0], small_data[1], ',k')
def make_figure(data, wavelength, beam, bins=50): uvcts = np.concatenate([ data[spw]['uvdist'][~data[spw]['flag'].any(axis=(0, 1))] for spw in data ]).ravel() uvwts = np.concatenate([ data[spw]['weight'].mean(axis=0)[~data[spw]['flag'].any(axis=(0, 1))] for spw in data ]).ravel() beam_to_bl = (wavelength / beam).to(u.m, u.dimensionless_angles()) pl.figure(figsize=(8, 4)) ax1 = pl.subplot(1, 2, 1) _ = pl.hist(uvcts, bins=bins) _ = pl.xlabel('Baseline Length (m)') _ = pl.ylabel("Number of Visibilities") yl = pl.ylim() pl.fill_betweenx(yl, beam_to_bl[0].value, beam_to_bl[1].value, zorder=-5, color='orange', alpha=0.5) pl.fill_betweenx(yl, np.percentile(uvcts, 25), np.percentile(uvcts, 75), zorder=-5, color='red', alpha=0.25) pl.ylim(yl) ax1t = ax1.secondary_xaxis( 'top', functions=(lambda x: x / 1e3 / wavelength.to(u.m).value, lambda x: x / 1e3 / wavelength.to(u.m).value)) ax1t.set_xlabel("Baseline Length (k$\lambda$)") #ax1t.set_ticks(np.linspace(1000,100000,10)) ax2 = pl.subplot(1, 2, 2) _ = pl.hist(uvcts, weights=uvwts, bins=bins, density=True) _ = pl.xlabel('Baseline Length (m)') _ = pl.ylabel("Fractional Weight") def forward(x): return (wavelength.to(u.m) / (x * u.arcsec)).to( u.m, u.dimensionless_angles()).value def inverse(x): return (wavelength.to(u.m) / (x * u.m)).to( u.arcsec, u.dimensionless_angles()).value ax2t = ax2.secondary_xaxis('top', functions=(forward, inverse)) ax2t.set_xlabel("Angular size $\lambda/D$ (arcsec)") if ax2.get_xlim()[1] > 1000: ax2t.set_ticks([10, 1, 0.5, 0.4, 0.3, 0.2, 0.1]) elif ax2.get_xlim()[1] > 600: ax2t.set_ticks([10, 2, 1, 0.6, 0.5, 0.4, 0.3]) else: ax2t.set_ticks([10, 2, 1, 0.8, 0.7, 0.6, 0.2]) yl = pl.ylim() pl.fill_betweenx(yl, beam_to_bl[0].value, beam_to_bl[1].value, zorder=-5, color='orange', alpha=0.5) #pl.fill_betweenx(yl, np.percentile(uvcts, 25), np.percentile(uvcts, 75), zorder=-5, color='red', alpha=0.25) pl.ylim(yl) #pl.subplots_adjust(wspace=0.3) pl.tight_layout() print( f"25th pctile={forward(np.percentile(uvcts, 25))}, 75th pctile={forward(np.percentile(uvcts, 75))}" ) return (forward(np.percentile(uvcts, [1, 5, 10, 25, 50, 75, 90, 95, 99])), scipy.stats.percentileofscore(uvcts, beam_to_bl[0].value), scipy.stats.percentileofscore(uvcts, beam_to_bl[1].value))
def plots_hsc_paper(theta, xip, xip_s8p, xip_s8m): # plot xiplus, ximoins shear_color = 'k' atmo_color = 'b' non_linear_color = 'r' xip_dic = pickle.load(open('xip_30_sec.pkl', 'rb')) #print(xip_dic['xip_atm']) g = 0.2 * 1e3 theta_atm = xip_dic['r'] * 60. #xip_atmo = (1./8.) * (xip_dic['xip_atm']**2 / g**4) xip_atmo = (1. / 8.) * (xip_dic['xip_atm_squared'] / g**4) #plt.plot(theta_atm, xip_atmo * theta_atm * 1e4, ) #plt.show() #francis = (xip_dic['xip_atm'] / (200 * 200) )**2 /16 #print(francis - xip_atmo) #plt.plot(theta_atm, theta_atm * francis * 1e4) #plt.xscale('log') #plt.show() plt.figure(figsize=(12, 7)) plt.subplots_adjust(wspace=0.0, hspace=0., top=0.99, left=0.05, right=0.99) XLIM = [2, 300] SUBPLOTS_plus = [1, 2, 3, 4, 5, 6, 7, 9, 10, 13] KEY_plus = ['14', '13', '12', '11', '24', '23', '22', '34', '33', '44'] HMAX = 4.5 HMIN = -0.1 #YLIM = [[-0.49, 2.5], [-0.49, 2.5], [-0.49, 2.5], [-0.49, 2.5], # [-0.49, 2.8], [-0.49, 2.8], [-0.49, 2.8], # [-0.49, 4.9], [-0.49, 4.9], # [-0.49, 5.4]] YLIM = [[HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX], [HMIN, HMAX]] LEGEND = [ '1,4', '1,3', '1,2', '1,1', '2,4', '2,3', '2,2', '3,4', '3,3', '4,4' ] for i in range(len(SUBPLOTS_plus)): key = KEY_plus[i] plt.subplot(4, 4, SUBPLOTS_plus[i]) if i == 1: LABEL = 'Contribution from astrometric residuals (simulation LSST like)' else: LABEL = None plt.plot(theta_atm, xip_atmo * theta_atm * 1e4, atmo_color, lw=2, label=LABEL) plt.text(165, 3.8, LEGEND[i], color='black', bbox=dict(facecolor='none', edgecolor='black', boxstyle='round'), fontsize=10) if i == 1: LABEL = 'Cosmic shear signal with DES Y1 cosmology' else: LABEL = None plt.plot(theta * 60., theta * 60. * xip[key] * 1e4, shear_color, label=LABEL) if i == 1: LABEL = '$\pm$ 1$\sigma$ on $S_8$ from cosmic shear DES Y1 analysis' else: LABEL = None plt.fill_between(theta * 60, theta * 60. * xip_s8m[key] * 1e4, theta * 60. * xip_s8p[key] * 1e4, alpha=0.5, color=shear_color, label=LABEL) #shear_bias_xipm = 1e-5 #shear_bias_xipm_des = 1e-5 / 25. #plt.plot(theta*60., # theta * 60. * shear_bias_xipm * 1e4, atmo_color+'--') #plt.plot(theta*60., # theta * 60. * shear_bias_xipm_des * 1e4, atmo_color+'-.') # non linear scale dic = pickle.load(open('xip_xim_real.pkl', 'rb')) ang = dic['xip'][(dic['xip']['BIN1'] == int(key[0])) & (dic['xip']['BIN2'] == int(key[1]))]['ANG'] mask = dic['xip'][(dic['xip']['BIN1'] == int(key[0])) & (dic['xip']['BIN2'] == int(key[1]))]['USED'] nlscale = ang[~mask] if i == 1: LABEL = 'Scale removed from DES Y1 cosmic shear analysis' else: LABEL = None plt.fill_betweenx(YLIM[i], [0, 0], [nlscale[-1], nlscale[-1]], color=non_linear_color, alpha=0.2, label=LABEL) #atmo scale: #plt.fill_betweenx(YLIM[i], [nlscale[-1],nlscale[-1]], [50, 50], color=atmo_color, alpha=0.2) if HMIN <= 0: plt.plot(XLIM, np.zeros(2), 'k', alpha=0.5) plt.xlim(XLIM[0], XLIM[1]) plt.ylim(YLIM[i][0], YLIM[i][1]) plt.xscale('log') if SUBPLOTS_plus[i] not in [4, 7, 10, 13]: plt.xticks([], []) else: plt.xlabel('$\\theta$ (arcmin)', fontsize=12) if SUBPLOTS_plus[i] not in [1, 5, 9, 13]: plt.yticks([], []) else: plt.ylabel('$\\theta \\xi_{+}$ / $10^{-4}$', fontsize=12) #leg = plt.legend(handlelength=0, handletextpad=0, # loc=1, fancybox=True, fontsize=8) #for item in leg.legendHandles: # item.set_visible(False) if i == 1: plt.legend(bbox_to_anchor=(0.9, -2.3), loc=2, borderaxespad=0., fontsize=12)
plt.ylabel(r"$\sigma(H_0)$ [km/s/Mpc]", fontsize=15, labelpad=10) plt.gca().tick_params(axis='both', which='major', labelsize=16, size=7., width=1.5, pad=8., right=True, direction='in') plt.gca().tick_params(axis='both', which='minor', labelsize=18, size=4., width=1.5, pad=8., right=True, direction='in') plt.gca().yaxis.set_major_locator(ticker.MultipleLocator(1.0)) plt.gca().yaxis.set_minor_locator(ticker.MultipleLocator(0.2)) #plt.gca().xaxis.set_major_locator(ticker.MultipleLocator(2.0)) #plt.gca().xaxis.set_minor_locator(ticker.MultipleLocator(0.5)) plt.xticks(ticks=[]) #plt.xticks(ticks=np.arange(len(expts), dtype=int), labels=labels, rotation=45, size=10) plt.fill_betweenx([0., 3.], [-1.,-1.], [0.5, 0.5], color='gray', alpha=0.1, zorder=50, lw=0) plt.fill_betweenx([0., 3.], [3.5,3.5], [6.5, 6.5], color='gray', alpha=0.1, zorder=50, lw=0) plt.fill_betweenx([0., 3.], [9.5,9.5], [12.5, 12.5], color='gray', alpha=0.1, zorder=50, lw=0) # Labels plt.text(0.0, 1.9, r" CMB + LSS", color='k', fontsize=11, rotation=90, ha='center') plt.text(2.0, 1.9, r" + DESI", color='gray', fontsize=11, rotation=90, ha='center') plt.text(5.0, 1.9, r" + HIRAX high-z", color='#D92E1C', fontsize=11, rotation=90, ha='center') plt.text(8.0, 1.9, r" + HIRAX", color='#E6773D', fontsize=11, rotation=90, ha='center') plt.text(11., 1.9, r" + Stage 2", color='#3465a4', fontsize=11, rotation=90, ha='center') plt.text(14.5, 1.9, r" + CV-lim. low-z", color='#64a164', fontsize=11, rotation=90, ha='center') #plt.legend(loc='upper left') plt.tight_layout() try: plt.savefig(figname)
# Get values kpar_min = 2. * np.pi / (rnu * dnutot) kpar_max = 1. / cosmo['sigma_nl'] * np.ones(zz.shape) kperp_min_int = 2. * np.pi * Dmin / (r * l) kperp_max_int = 2. * np.pi * Dmax / (r * l) kperp_min_sd = 2. * np.pi / np.sqrt(r**2. * Sarea) kperp_max_sd = 2. * np.pi * Ddish / (r * l) # 16.*np.log(2.) / 1.22 kperp_max_sd2 = np.sqrt(16. * np.log(2.)) * Ddish / (r * l) # Set-up plots P.subplot(111) # Interferom. transverse P.plot(kperp_min_int, zz, lw=1.8, color='#1619A1') P.plot(kperp_max_int, zz, lw=1.8, color='#1619A1') P.fill_betweenx(zz, kperp_min_int, kperp_max_int, color='#B1C9FD', alpha=1.) P.annotate("Int.", xy=(0.9, 0.8), xytext=(0., 0.), fontsize='xx-large', textcoords='offset points', ha='center', va='center') # Single-dish transverse P.plot(kperp_min_sd, zz, lw=1.8, color='#CC0000') P.plot(kperp_max_sd, zz, lw=1.8, color='#CC0000', ls='dashed') #ax.plot(kperp_max_sd2, zz, lw=1.8, color='g') P.fill_betweenx(zz, kperp_min_sd, kperp_max_sd, color='#F09B9B', alpha=0.7)
cnt = 1 for cl in range(nclusters): v_inds = res['clusters'][cl][1] t_inds = res['clusters'][cl][0] signals = [np.mean(np.mean(np.array(s)[:, :, v_inds], axis=0), axis=1).squeeze() for s in data] pl.subplot(nclusters, 2, cnt) # The time plot figure only makes sense if it's not DICS_epochs if mask_fname.find('DICSepochs') < 0: for c in range(len(colors)): pl.plot(stc.times, signals[c], color=colors[c]) pl.xlabel('Time (s)') pl.ylabel('Activation') pl.legend(groups, loc='best') pl.plot([0, 0], pl.ylim(), ':k') pl.fill_betweenx(pl.ylim(), stc.times[np.min(t_inds)], stc.times[np.max(t_inds)], color='grey', alpha=0.3) cnt += 1 # now, work on the mean over time barplot or regression, depending on result pl.subplot(nclusters, 2, cnt) my_test = mask_fname.split('_')[0] if my_test.find('anova') >= 0 or my_test.find('VS') > 0: signals = [np.mean(np.array(s)[:, :, v_inds], axis=2) for s in data] signals = [np.mean(s[:, t_inds], axis=1) for s in signals] ybars = [np.mean(s) for s in signals] y_sd = [np.std(s)/np.sqrt(len(s)) for s in signals] pl.bar(np.arange(len(ybars)), ybars, 0.35, color=colors, ecolor='k', yerr=y_sd, align='center') pl.xticks(range(len(groups)), groups) pl.xlim([-.2, 2.5]) # running post-hoc tests
P.plot(kmax_int, z, 'r-', lw=1.2) P.plot(kmin_sd, z, 'b-', lw=1.2, label="SKAMID Dish") #P.plot(k_rsd, z, 'b-', lw=1.5) P.plot(kmax_sd, z, 'b-', lw=1.2) P.plot(kmax2, z, 'b--', lw=1.2, label="SKAMID Dish (RSD evol.)") kk = np.logspace(-4., 3., 1000) pk = cosmo['pk_nobao'](kk) * (1. + cosmo['fbao'](kk)) P.plot(kk, 0.3 * np.log10(pk / np.max(pk)) + 2.6, 'k-', lw=2., alpha=0.4) #P.plot(kk, 10.*cosmo['fbao'](kk) + 2., 'k-', lw=2., alpha=0.4) # RSD region P.fill_betweenx(z, 2e-2 * np.ones(z.shape), 4e-1 * np.ones(z.shape), color='k', alpha=0.07) P.fill_betweenx(z, kmin_int, kmax_int, color='r', alpha=0.1) P.fill_betweenx(z, kmin_sd, kmax_sd, color='b', alpha=0.1) P.legend(loc='upper right', prop={'size': 'large'}) P.xscale('log') P.xlim((1e-4, 1e3)) P.ylim((0., 3.)) P.xlabel("k [Mpc$^{-1}$]", fontdict={'fontsize': '18'}) P.ylabel("z", fontdict={'fontsize': '18'})
import numpy as np import bump_calculator import pylab as plt plt.ioff() data = np.loadtxt('SN2007af_r.dat') results = bump_calculator.get_bump_flux(data[:, 0], np.exp(-data[:, 1]), np.exp(-data[:, 1]) * data[:, 2]) x_pred = np.arange(-30, 100, 0.1) y_pred, y_pred_var = results.gp_model._raw_predict(x_pred[:, None]) y_pred = y_pred.squeeze() y_pred_var = y_pred_var.squeeze() plt.scatter(results.x, results.y_norm, s=10) plt.errorbar(results.x, results.y_norm, yerr=results.y_norm_err, fmt='+', color='b') plt.plot(x_pred, y_pred, color='k') plt.fill_between(x_pred, y_pred - np.sqrt(y_pred_var), y_pred + np.sqrt(y_pred_var), color='b', alpha=0.1) plt.axvline(results.bump_time, color='b') plt.fill_betweenx(np.arange(*plt.ylim()), results.bump_time - 3 * results.bump_time_err, results.bump_time + 3 * results.bump_time_err, alpha=0.1) plt.xlabel('$\mathrm{Time}~(days)$') plt.ylabel('$\mathrm{Flux}$') plt.show()
def plot_coef_corr_seismic(offsets, trace_synt_ar_int, seismicData, T, tmp_time_max, data_KK, int_time1, int_time2, data_short, sgyname): """ Draws coef. correlation betweem real and synthetic seismic data Parameters ---------- Input: offsets - array of offsets (m) trace_synt_ar_int - synthetic data interpolate on seismic grid seismicData - seismic data class T - time axs for seismic tmp_time_max - picking of max amplitude near explored horizon data_KK - array with correlation coefficients int_time1 - upper time near explored horizon int_time2 - lower time near explored horizon data_short - interval real data sgy_name - name of current segy Output: subplot figure with synthetic and real data, color shows the correlation coefficient between them """ #допилить граничные значения #T_plot = np.arange(int_time1, int_time2, seismicData.dt) fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(35, 12)) plt.sca(axs[0]) for ii in range(trace_synt_ar_int.shape[0]): plt.plot( trace_synt_ar_int[ii, :] / np.max(trace_synt_ar_int[ii, :]).T + ii + 1, T, 'k', alpha=1, zorder=1, lw=1) x = trace_synt_ar_int[ii, :] / np.max( trace_synt_ar_int[ii, :]).T + ii + 1 T_tmp_plot = np.arange(int_time1, int_time2, seismicData.dt / 4) y = T_tmp_plot x2 = np.interp(T_tmp_plot, T, x) plt.fill_betweenx(y, ii + 1, x2, where=(x2 > ii + 1), color='k') #plt.plot(ii+1,pick[ii],'c.',alpha=1,zorder=1,lw=1,markersize = 10) x1 = np.arange(1, ii + 1) plt.xticks( x1, (np.round(offsets / 1000, decimals=1)), fontsize=10, ) plt.gca().invert_yaxis() plt.xlabel('Offset,km') plt.ylabel('T, ms') plt.title('Synthetic') plt.plot(tmp_time_max, '.r', markersize=25) plt.imshow( np.zeros_like(data_KK[:, :len(offsets)]), alpha=1, extent=[1, len(offsets) + 1, int_time2, int_time1], aspect='auto', cmap='Pastel1_r', vmin=0, vmax=0, ) plt.sca(axs[1]) for ii in range(data_short.shape[0]): plt.plot(data_short[ii, :] / np.max(data_short[ii, :]).T + ii + 1, T, 'k', alpha=1, zorder=1, lw=1) x = data_short[ii, :] / np.max(data_short[ii, :]).T + ii + 1 T_tmp_plot = np.arange(int_time1, int_time2, seismicData.dt / 4) y = T_tmp_plot x2 = np.interp(T_tmp_plot, T, x) plt.fill_betweenx(y, ii + 1, x2, where=(x2 > ii + 1), color='k') #plt.plot(ii+1,pick[ii],'c.',alpha=1,zorder=1,lw=1,markersize = 10) x1 = np.arange(1, ii + 1) plt.xticks( x1, (np.round(offsets[:-2] / 1000, decimals=1)), fontsize=10, ) plt.gca().invert_yaxis() plt.xlabel('Offset,km') plt.ylabel('T, ms') plt.title(sgyname) im = plt.imshow( data_KK[:, :len(offsets) + 1], alpha=1, extent=[1, len(offsets) + 1, int_time2, int_time1], aspect='auto', cmap='rainbow', vmin=0, vmax=1, ) divider = make_axes_locatable(axs[1]) cax = divider.append_axes("right", size="5%", pad=0.05) cbar = plt.colorbar(im, cax=cax) cbar.set_label('Coef. correlation', rotation=270) return
import pylab as pl inds_t, inds_v = [(clusters[cluster_ind]) for ii, cluster_ind in enumerate(good_cluster_inds)][0] # first cluster times = np.arange(X[0].shape[1]) * tstep * 1e3 pl.clf() colors = ['y', 'b', 'g', 'purple'] for ii, (condition, color, eve_id) in enumerate( zip(X, colors, ['l_aud', 'r_aud', 'l_vis', 'r_vis'])): # extract time course at cluster vertices condition = condition[:, :, inds_v] # normally we would normalize values across subjects but # here we use data from the same subject so we're good to just # create average time series across subjects and vertices. mean_tc = condition.mean(axis=2).mean(axis=0) std_tc = condition.std(axis=2).std(axis=0) pl.plot(times, mean_tc.T, color=color, label=eve_id) pl.fill_between(times, mean_tc + std_tc, mean_tc - std_tc, color='gray', alpha=0.5, label='') pl.xlabel('Time (ms)') pl.ylabel('Activation (F-values)') pl.xlim(times[[0, -1]]) pl.fill_betweenx(np.arange(*pl.ylim()), times[inds_t[0]], times[inds_t[-1]], color='orange', alpha=0.3) pl.legend() pl.title('Interaction between stimulus-modality and location.') pl.show()
def plotit(): import astropy.stats import pylab as pl pl.rcParams['axes.prop_cycle'] = pl.cycler('color', [ '#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf' ]) pl.rcParams['figure.figsize'] = (12, 8) pl.rcParams['figure.dpi'] = 75 pl.rcParams['savefig.dpi'] = 150 pl.rcParams['axes.titlesize'] = 40 pl.rcParams['axes.labelsize'] = 24 pl.rcParams['xtick.labelsize'] = 20 pl.rcParams['ytick.labelsize'] = 20 pl.figure(1).clf() pl.figure(2).clf() pl.figure(3).clf() pl.figure(4).clf() pl.figure(5, figsize=(12, 8), dpi=75).clf() fig9 = pl.figure(9) fig9.clf() for ii, imname in enumerate(f for f in files if 'column' in f.lower()): print("Plotting {0}".format(imname)) data = files[imname]['file'].data mask = files[imname]['mask'] brickdata = brick_files[imname]['file'].data # https://github.com/astropy/astropy/pull/5232 for ignore_nan lo = astropy.stats.mad_std(data, ignore_nan=True) hi = np.nanmax(data) bins = np.logspace(np.log10(lo), np.log10(hi), 100) pl.figure(1) pl.subplot(2, 4, ii + 1) brickweights = np.ones(np.isfinite(brickdata).sum(), dtype='float') / np.isfinite( brickdata).sum() * np.isfinite(data).sum() bH, bL, bP = pl.hist( brickdata[np.isfinite(brickdata)], bins=bins, log=True, alpha=0.5, histtype='step', #weights=brickweights, bottom=1.1, color='b', zorder=-1) #weights = np.ones(np.isfinite(data).sum(), dtype='float')/np.isfinite(data).sum() H, L, P = pl.hist( data[np.isfinite(data) & mask], bins=bins, log=True, alpha=0.5, color='k', #normed=True, histtype='step') # Lada threshold, approximately (116 Msun/pc^2) pl.vlines(5e21, 1.1, H.max(), label='Lada+ 2010 Threshold') #pl.hist(tbl[imname], bins=bins, log=True, alpha=0.5) pl.xlim(np.min([bL.min(), L.min()]), L.max()) pl.semilogx() pl.yscale('log', nonposy='clip') ax2 = pl.gca().twinx() ax2.plot(np.sort(tbl[imname]), np.arange(len(tbl), dtype='float') / len(tbl), 'k-', linewidth=3, alpha=0.5, zorder=10) ax2.set_xlim(L.min(), L.max()) ax2.set_ylim(0, 1) pl.title(imname, fontsize=12) pl.figure(2) pl.subplot(2, 4, ii + 1) pl.imshow(data, cmap='gray_r') pl.contour(data, levels=np.percentile(tbl[imname], [5, 10, 25, 50, 75, 90, 95])) pl.contour(mask, levels=[0.5]) pl.title(imname) sorted_col = u.Quantity(np.sort(data[mask & (data > 0)]), u.cm**-2) cumul = np.cumsum(sorted_col)[::-1] pixarea_cm2 = (files[imname]['pixarea'] * distance**2) cum_mass = (cumul * pixarea_cm2 * 2.8 * u.Da).to( u.M_sun, u.dimensionless_angles()) pl.figure(3) pl.plot(sorted_col, cum_mass, label=names[imname]) pl.legend(loc='best') pl.xlim(1e21, 2e25) pl.gca().set_xscale('log') pl.gca().set_yscale('log') pl.figure(4) assert cum_mass.min() > 0.1 * u.M_sun pl.plot(sorted_col - 5e22 * u.cm**-2, cum_mass - (5e22 * u.cm**-2 * pixarea_cm2 * 2.8 * u.Da).to( u.M_sun, u.dimensionless_angles()), label=names[imname]) pl.legend(loc='best') pl.xlim(1e21, 2e25) pl.gca().set_xscale('log') pl.gca().set_yscale('log') pl.figure(1) pl.tight_layout() pl.savefig(paths.fpath("flux_histograms_with_core_location_CDF.pdf"), bbox_inches='tight') pl.figure(3) pl.vlines(5e21, 0.5, 1e6, color='k', linestyle='--', linewidth=1, label='Lada+ 2010 Threshold') pl.tight_layout() pl.legend(loc='best') pl.savefig(paths.fpath("mass_cdf_histograms.pdf"), bbox_inches='tight') pl.figure(4) pl.vlines(5e21, 0.5, 1e6, color='k', linestyle='--', linewidth=1, label='Lada+ 2010 Threshold') pl.legend(loc='best') pl.tight_layout() pl.savefig(paths.fpath("mass_cdf_histograms_bgsubd.pdf"), bbox_inches='tight') pl.figure(5).clf() for imname, color in [('HerschelColumn25', 'k'), ('HerschelColumn36', 'g'), ('SharcHTemColumn', 'b'), ('ScubaHTemColumn', 'r')]: pl.plot( np.sort(tbl[imname]), np.arange(len(tbl), dtype='float') / len(tbl), linestyle='-', linewidth=4, alpha=1, zorder=10, color=color, label=names[imname], ) pl.xscale('log') pl.xlim(1e21, 2e25) pl.ylim(0, 1) fb1 = pl.fill_betweenx( y=np.arange(len(tbl), dtype='float') / len(tbl), x1=np.sort(nan_to_val(tbl['Sharc20Column'], 1e26)), x2=np.sort(nan_to_val(tbl['Sharc50Column'], 1e26)), alpha=0.5, label='SHARC 20-50 K', edgecolor='b', facecolor='none', zorder=-10, hatch='//', linewidth=2, ) fb2 = pl.fill_betweenx( y=np.arange(len(tbl), dtype='float') / len(tbl), x1=np.sort(nan_to_val(tbl['Scuba20Column'], 1e26)), x2=np.sort(nan_to_val(tbl['Scuba50Column'], 1e26)), alpha=0.5, label='SCUBA 20-50 K', edgecolor='r', facecolor='none', zorder=-10, hatch='\\\\', linewidth=2, ) pl.figure(5) pl.vlines(5e21, 0, 1, color='k', linestyle='--', linewidth=1, label='Lada+ 2010 Threshold') pl.vlines(2e23, 0, 1, color='k', linestyle=':', label='Krumholz+ 2008 Threshold') pl.legend(loc='best', fontsize=20) pl.tight_layout() pl.xlabel("Column Density [$N(\mathrm{H}_2)$ cm$^{-2}$]", fontsize=24) pl.ylabel("Cumulative fraction\nof cores at column $<N$", fontsize=24) ax1 = pl.gca() pl.draw() ax2 = ax1.twiny() print("ax1 xlims: {0}".format(ax1.get_xlim())) pl.draw() ax2.set_xlim(np.array(ax1.get_xlim()) * (2.8 * u.Da).to(u.g).value) print("ax2 xlims: {0}".format(ax2.get_xlim())) ax2.set_xscale('log') ax2.set_xlabel("Column Density [g cm$^{-2}$]") pl.draw() pl.savefig(paths.fpath("core_background_column_cdf.pdf"), bbox_inches='tight') pl.figure(6).clf() ax1 = pl.gca() imname = 'ScubaHTemColumn' print("fig6: Plotting {0}".format(imname)) data = files[imname]['file'].data mask = files[imname]['mask'] brickdata = brick_files[imname]['file'].data lo = astropy.stats.mad_std(brickdata, ignore_nan=True) hi = np.nanmax(data) bins = np.logspace(np.log10(lo) - 0.5, np.log10(hi), 100) bH, bL, bP = ax1.hist(brickdata[np.isfinite(brickdata)], bins=bins, log=True, alpha=0.5, histtype='step', bottom=0.1, linewidth=2, color='b', zorder=-1) #weights = np.ones(np.isfinite(data).sum(), dtype='float')/np.isfinite(data).sum() H, L, P = ax1.hist( data[np.isfinite(data) & mask], bins=bins, log=True, alpha=0.5, color='k', linewidth=2, #normed=True, histtype='step') # Lada threshold, approximately (116 Msun/pc^2) ax1.vlines(5e21, 1.1, H.max(), label='Lada+ 2010 Threshold') ax1.vlines(2e23, 0.1, H.max() * 2, color='k', linestyle=':', label='Krumholz+ 2008 Threshold') #ax1.hist(tbl[imname], bins=bins, log=True, alpha=0.5) ax1.set_xlim(np.min([bL.min(), L.min()]), L.max()) ax1.set_ylim(0.5, np.max([bH.max(), H.max()]) * 1.1) ax1.semilogx() ax1.set_yscale('log', nonposy='clip') ax1.set_xlabel("Column Density [N(H$_2$) cm$^{-2}$]") ax1.set_ylabel("Number of pixels") ax3 = ax1.twiny() print("ax1 xlims: {0}".format(ax1.get_xlim())) pl.draw() ax3.set_xlim(np.array(ax1.get_xlim()) * (2.8 * u.Da).to(u.g).value) ax3lims = ax3.get_xlim() print("ax2 xlims: {0}".format(ax2.get_xlim())) ax3.set_xscale('log') ax3.set_xlabel("Column Density [g cm$^{-2}$]") pl.draw() pl.savefig(paths.fpath("compare_brick_sgrb2_colPDF_nofractions.pdf"), bbox_inches='tight') ax2 = ax1.twinx() ax2.plot(np.sort(tbl[imname]), np.arange(len(tbl), dtype='float') / len(tbl), 'k-', linewidth=3, alpha=0.5, zorder=10) ax2.set_xlim(L.min(), L.max()) ax2.set_ylim(0, 1) ax2.set_ylabel("Fraction of point sources below N(H$_2$)") ax3.set_xlim(ax3lims) ax2.set_xlim(L.min(), L.max()) pl.savefig(paths.fpath("compare_brick_sgrb2_colPDF.pdf"), bbox_inches='tight') ax9 = fig9.gca() ax9.loglog(np.sort(tbl[imname]), 1 - np.arange(len(tbl), dtype='float') / len(tbl), 'k-', linewidth=3, alpha=0.5, zorder=10, label='Stars') ax9.set_ylabel("Fraction of point sources above N(H$_2$)") ax9.set_xlabel("Column Density [N(H$_2$) cm$^{-2}$]") fig9.savefig(paths.fpath("cdf_of_point_sources.pdf"), bbox_inches='tight') ax9.set_ylabel("Fraction above N(H$_2$)") dmask = np.isfinite(data) & mask ax9.loglog(np.sort(data[dmask]), 1 - np.arange(dmask.sum(), dtype='float') / dmask.sum(), alpha=0.5, color='b', linewidth=2, label='Gas') fig9.legend(loc='best') fig9.savefig(paths.fpath("cdf_of_point_sources_and_column.pdf"), bbox_inches='tight') nn11_pc = (u.Quantity(tbl['nn11'], u.arcsec) * distance).to( u.pc, u.dimensionless_angles()) nn = 11 nn11_msunpersqpc_starcentered = ((nn - 1) * mass_represented_by_a_source / (np.pi * (nn11_pc)**2)).to(u.M_sun / u.pc**2) herschelsurfdens = (u.Quantity(tbl['HerschelColumn25']).to(u.cm**-2) * 2.8 * u.Da).to(u.M_sun / u.pc**2) tbl.add_column(table.Column(name='HerschelSurfDens', data=herschelsurfdens)) tbl.add_column( table.Column(name='nn11_starcentered_surfdens', data=nn11_msunpersqpc_starcentered)) assert herschelsurfdens.min() < 10**5 * u.M_sun / u.pc**2 assert herschelsurfdens.max() > 10**3 * u.M_sun / u.pc**2 fig7 = pl.figure(7, figsize=(10, 10)) fig7.clf() ax7 = fig7.gca() ax7.loglog(herschelsurfdens, nn11_msunpersqpc_starcentered, 'k.', alpha=0.7, markeredgecolor=(0, 0, 0, 0.5)) lims = ax7.axis() # 5/3 slope #ax7.loglog([1e3,1e6], [3e0, 3e5], 'k--') ax7.set_ylabel( "Source-centered NN11 Surface Density\n$\Sigma_*$ [M$_\odot$ pc$^{-2}$]" ) ax7.set_xlabel("Gas Surface Density $\Sigma_{gas}$ [M$_\odot$ pc$^{-2}$]") ax7.axis(lims) # Arrows showing the shift if you subtract off the "most aggressive plausible" # uniform foreground value bg_5e22 = (5e22 * u.cm**-2 * 2.8 * u.Da).to(u.M_sun / u.pc**2) ax7.arrow(3e3, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (3e3 - bg_5e22.value), color='k') ax7.arrow(1e4, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (1e4 - bg_5e22.value), color='k') ax7.arrow(3e4, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (3e4 - bg_5e22.value), color='k') ax7.axis([1e3, 1e5, 1e0, 1e5]) fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels_nolocal.png" ), bbox_inches='tight') fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels_nolocal.pdf" ), bbox_inches='tight') monr2_lowerline = np.array([0.1, 1e5])**2.67 / (100**2.67) * 2.5 monr2_fill = ax7.fill_between([0.1, 1e5], monr2_lowerline, monr2_lowerline * 10, alpha=0.5, color='green', label='Mon R2') oph_lowerline = np.array([0.1, 1e5])**1.87 / (100**1.87) * 1.5 oph_fill = ax7.fill_between([0.1, 1e5], oph_lowerline, oph_lowerline * 10, color='blue', alpha=0.5, label='Ophiuchus') local_plotobjs = [monr2_fill, oph_fill] T = ax7.text(2.3e3, 9e3, "Mon R2", color='k', rotation=50, fontsize=18, verticalalignment='bottom', horizontalalignment='center') local_plotobjs.append(T) T = ax7.text(2.5e3, 4.5e2, "Ophiuchus", color='k', rotation=38, fontsize=18, verticalalignment='bottom', horizontalalignment='center') local_plotobjs.append(T) #ax7.plot([0.1, 1e5], np.array([0.1, 1e5])**1.87/(1e4**1.87)*(1e4**(5/3.)/1e5), 'b:', linewidth=3, alpha=0.5) oph_scalefactor = 50. L = ax7.plot([0.1, 1e5], oph_lowerline / oph_scalefactor, 'b:', linewidth=3, alpha=0.5) local_plotobjs += L ax7.axis([1e3, 1e5, 1e0, 1e5]) fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels.png"), bbox_inches='tight') fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels.pdf"), bbox_inches='tight') sigma_gas = np.logspace(1, 6) * u.M_sun / u.pc**2 mdlplots = {} for time in (0.01, 0.1, 0.74) * u.Myr: mdlplots[(1, time)] = ax7.loglog( sigma_gas_of_t(sigma_gas, time, alpha=1, k=0.1 / u.Myr), gas_depletion_law(sigma_gas, time, alpha=1, k=0.1 / u.Myr), label=time, color='r', linewidth=3, alpha=0.5, zorder=-10, ) mdlplots[(2, time)] = ax7.loglog(sigma_gas_of_t(sigma_gas, time), gas_depletion_law(sigma_gas, time), label=time, color='orange', linewidth=3, zorder=-5, alpha=0.5) ax7.axis([1e3, 1e5, 1e0, 1e5]) #ax7.plot([0.1, 1e5], np.array([0.1, 1e5])*4e-2, 'r-', linewidth=3, alpha=0.5, zorder=-10) fig7.savefig( paths.fpath("stellar_vs_gas_column_density_starcentered_herschel.png"), bbox_inches='tight') fig7.savefig( paths.fpath("stellar_vs_gas_column_density_starcentered_herschel.pdf"), bbox_inches='tight') ax7.loglog(np.logspace(3, 5), lada2017relation.sigma_star_california( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, color='m', label='Lada2017_cali') ax7.loglog(np.logspace(3, 5), lada2017relation.sigma_star_orionA( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, linestyle='--', color='m', label='Lada2017_orionA') ax7.loglog(np.logspace(3, 5), lada2017relation.sigma_star_orionB( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, linestyle=':', color='m', label='Lada2017_orionB') fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_withLada2017.png" ), bbox_inches='tight') fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_withLada2017.pdf" ), bbox_inches='tight') for line in mdlplots.values(): try: for ll in line: ll.set_visible(False) except TypeError: line.set_visible(False) for obj in local_plotobjs: obj.set_visible(False) fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels_withLada2017.png" ), bbox_inches='tight') fig7.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_herschel_nomodels_withLada2017.pdf" ), bbox_inches='tight') scubasurfdens = (u.Quantity(tbl['ScubaHTemColumn'], u.cm**-2) * 2.8 * u.Da).to(u.M_sun / u.pc**2) fig8 = pl.figure(8) fig8.clf() ax8 = fig8.gca() ax8.loglog(scubasurfdens, nn11_msunpersqpc_starcentered, 'k.', alpha=0.7, markeredgecolor=(0, 0, 0, 0.5)) lims = ax8.axis() # 5/3 slope #ax8.loglog([1e3,1e6], [3e0, 3e5], 'k--') #ax8.plot([0.1, 1e5], np.array([0.1, 1e5])**1.87/(1e4**1.87)*(1e4**(5/3.)/1e5), 'b:', linewidth=3, alpha=0.5) ax8.plot([0.1, 1e5], oph_lowerline / oph_scalefactor, 'b:', linewidth=3, alpha=0.5) ax8.axis(lims) ax8.set_ylabel( "Source-centered NN11 Surface Density\n$\Sigma_*$ [M$_\odot$ pc$^{-2}$]" ) ax8.set_xlabel("SCUBA-derived Surface Density [M$_\odot$ pc$^{-2}$]") # arrows showing the shift if you subtract off the "most aggressive plausible" # uniform foreground value bg_5e22 = (5e22 * u.cm**-2 * 2.8 * u.Da).to(u.M_sun / u.pc**2) ax8.arrow(3e3, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (3e3 - bg_5e22.value), color='k') ax8.arrow(1e4, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (1e4 - bg_5e22.value), color='k') ax8.arrow(3e4, 1.1, -bg_5e22.value, 0, head_width=0.1, head_length=0.033 * (3e4 - bg_5e22.value), color='k') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels_nolocal.png" ), bbox_inches='tight') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels_nolocal.pdf" ), bbox_inches='tight') monr2_lowerline = np.array([0.1, 1e5])**2.67 / (100**2.67) * 2.5 monr2_fill = ax8.fill_between([0.1, 1e5], monr2_lowerline, monr2_lowerline * 10, alpha=0.5, color='green', label='Mon R2') oph_lowerline = np.array([0.1, 1e5])**1.87 / (100**1.87) * 1.5 oph_fill = ax8.fill_between([0.1, 1e5], oph_lowerline, oph_lowerline * 10, color='blue', alpha=0.5, label='Ophiuchus') local_plotobjs = [monr2_fill, oph_fill] monr2txt = ax8.text(2.3e3, 9e3, "Mon R2", color='k', rotation=50, fontsize=18, verticalalignment='bottom', horizontalalignment='center') ophtxt = ax8.text(2.5e3, 4.5e2, "Ophiuchus", color='k', rotation=38, fontsize=18, verticalalignment='bottom', horizontalalignment='center') local_plotobjs.append(monr2txt) local_plotobjs.append(ophtxt) ax8.axis([1e3, 1e5, 1e0, 1e5]) fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels.png"), bbox_inches='tight') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels.pdf"), bbox_inches='tight') mdlplots = {} for time in (0.01, 0.1, 0.74) * u.Myr: mdlplots[(1, time)] = ax8.loglog( sigma_gas_of_t(sigma_gas, time, alpha=1, k=0.1 / u.Myr), gas_depletion_law(sigma_gas, time, alpha=1, k=0.1 / u.Myr), label=time, color='r', linewidth=3, alpha=0.5, zorder=-10, ) mdlplots[(2, time)] = ax8.loglog(sigma_gas_of_t(sigma_gas, time), gas_depletion_law(sigma_gas, time), label=time, color='orange', linewidth=3, zorder=-5, alpha=0.5) #ax8.axis(lims) ax8.axis([1e3, 1e5, 1e0, 1e5]) fig8.savefig( paths.fpath("stellar_vs_gas_column_density_starcentered_scuba.png"), bbox_inches='tight') fig8.savefig( paths.fpath("stellar_vs_gas_column_density_starcentered_scuba.pdf"), bbox_inches='tight') ax8.loglog(np.logspace(3, 5), lada2017relation.sigma_star( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, color='m', label='Lada2017') ax8.loglog(np.logspace(3, 5), lada2017relation.sigma_star_orionA( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, linestyle='--', color='m', label='Lada2017_orionA') ax8.loglog(np.logspace(3, 5), lada2017relation.sigma_star_orionB( np.logspace(3, 5) * u.M_sun / u.pc**2), linewidth=3, linestyle=':', color='m', label='Lada2017_orionB') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_withLada2017.png"), bbox_inches='tight') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_withLada2017.pdf"), bbox_inches='tight') for line in mdlplots.values(): try: for ll in line: ll.set_visible(False) except TypeError: line.set_visible(False) for obj in local_plotobjs: obj.set_visible(False) fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels_withLada2017.png" ), bbox_inches='tight') fig8.savefig(paths.fpath( "stellar_vs_gas_column_density_starcentered_scuba_nomodels_withLada2017.pdf" ), bbox_inches='tight') # TODO: plot the same (?) histograms for The Brick # DONE! tbl.write(paths.tpath("continuum_photometry_plusbackground.ipac"), format='ascii.ipac', overwrite=True)
def results(fiuno,fidue,fauno,fadue,fivalues,dval,lee_lambda,txtout,graphout): """Draws output graphs and a text file report for the point(s) examined""" import pylab fout=open(txtout,'w') fout.write("~~~ Input Data Summary ~~~") fout.write('\n') fout.writelines("Grainsize examined:") fout.write('\n') fout.writelines('phi_1='+str(fiuno)) fout.write('\n') fout.writelines('phi_2='+str(fidue)) fout.write('\n') fout.writelines("Bedload composition:") fout.write('\n') fout.writelines('Fa_1='+str(fauno)) fout.write('\n') fout.writelines('Fa_2='+str(fadue)) fout.write('\n') fout.write('\n') fout.writelines("~~~ Prediction Results ~~~") fout.write('\n') neg=[] for i in dval: neg.append(float(i*(-1))) for i in fivalues: f=i.split('|')[4:][::2] fi=[] for j in f: fi.append(float(j)) pylab.plot(fi,neg,'o',color='b') pylab.fill_betweenx(neg,fi,facecolor='orange') pylab.axis([0.0,1.0,min(neg),max(neg)]) pylab.xlabel('F1, F2 [%]') pylab.ylabel('Relative depth from the bed surface [mm]') pylab.savefig(str(graphout)+'_point'+str(i[0])+'.png') pylab.close() east=float(i.split('|')[2]) north=float(i.split('|')[3]) cat=int(i.split('|')[1]) deltalee=float(lee_lambda[cat-1].split('|')[7]) etat=float(lee_lambda[cat-1].split('|')[8]) etab=float(lee_lambda[cat-1].split('|')[9]) fout.write('\n') fout.writelines("Output for point #"+str(i.split('|')[0])+":") fout.write('\n') fout.writelines("E [mm or m]="+str(east)) fout.write('\n') fout.writelines("N [mm or m]="+str(north)) fout.write('\n') fout.writelines("Total heigth of the bedform [mm or m]="+str(deltalee)) fout.write('\n') fout.writelines("Crest heigth of the bedform over the mean heigth of the reach [mm or m]="+str(etat)) fout.write('\n') fout.writelines("Through heigth of the bedform over the mean heigth of the reach [mm or m]="+str(etab)) fout.write('\n') fout.writelines("Prediction of vertical sorting of sediment over the bed surface for chosen grainsizes (phi_1,phi_2="+str(fiuno)+","+str(fidue)+"):") fout.write('\n') fout.writelines("(depth [m or mm], F1 [%], F2 [%])") fout.write('\n') f11=i.split('|')[4:][::2] f22=i.split('|')[5:][::2] m=0 for i in neg: fout.writelines("("+str(i)+", "+str(float(f11[m]))+", "+str(float(f22[m]))+")") fout.write('\n') m=m+1 fout.close()
pl.clf() colors = ['y', 'b', 'g', 'purple'] for ii, (condition, color, eve_id) in enumerate( zip(X, colors, ['l_aud', 'r_aud', 'l_vis', 'r_vis'])): # extract time course at cluster vertices condition = condition[:, :, inds_v] # normally we would normalize values across subjects but # here we use data from the same subject so we're good to just # create average time series across subjects and vertices. mean_tc = condition.mean(axis=2).mean(axis=0) std_tc = condition.std(axis=2).std(axis=0) pl.plot(times, mean_tc.T, color=color, label=eve_id) pl.fill_between(times, mean_tc + std_tc, mean_tc - std_tc, color='gray', alpha=0.5, label='') pl.xlabel('Time (ms)') pl.ylabel('Activation (F-values)') pl.xlim(times[[0, -1]]) pl.fill_betweenx(np.arange(*pl.ylim()), times[inds_t[0]], times[inds_t[-1]], color='orange', alpha=0.3) pl.legend() pl.title('Interaction between stimulus-modality and location.') pl.show()