updated captions to new figures
This commit is contained in:
107
noisesplit.py
107
noisesplit.py
@@ -65,56 +65,9 @@ def plot_overn(ax, s, files, nmax=1e6):
|
||||
ax.set_xlabel('segments')
|
||||
ax.set_ylabel(r'$|\chi_2|$', r'Hz/\%$^2$')
|
||||
|
||||
|
||||
def plot_chi2_contrast(ax1, ax2, s, files, nums, nsmall, nlarge, rate):
|
||||
for ax, n in zip([ax1, ax2], [nsmall, nlarge]):
|
||||
i = nums.index(n)
|
||||
data = np.load(files[i])
|
||||
nsegs = data['nsegs']
|
||||
fcutoff = data['fcutoff']
|
||||
alpha = data['contrast']
|
||||
freqs = data['freqs']
|
||||
pss = data['pss']
|
||||
prss = data['prss']
|
||||
if nsegs < 10000:
|
||||
ax.text(1, 1.1, f'$N={nsegs}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
else:
|
||||
ax.text(1, 1.1, f'$N=10^{{{np.log10(nsegs):.0f}}}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
chi2 = np.abs(prss)*0.5/(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
cax = plot_chi2(ax, s, freqs, chi2, fcutoff, rate)
|
||||
cax.set_ylabel('')
|
||||
print(f'Modeled cell {"-".join(files[i].name.split("-")[2:-2])} at {100*alpha:4.1f}% contrast: noise_frac={1:3.1f}, nsegs={n}')
|
||||
print()
|
||||
|
||||
|
||||
def plot_chi2_split(ax1, ax2, s, files, nums, nsmall, nlarge, rate):
|
||||
for ax, n in zip([ax1, ax2], [nsmall, nlarge]):
|
||||
i = nums.index(n)
|
||||
data = np.load(files[i])
|
||||
nsegs = data['nsegs']
|
||||
fcutoff = data['fcutoff']
|
||||
alpha = data['contrast']
|
||||
noise_frac = data['noise_frac']
|
||||
freqs = data['freqs']
|
||||
pss = data['pss']
|
||||
prss = data['prss']
|
||||
chi2 = np.abs(prss)*0.5/(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
if nsegs < 10000:
|
||||
ax.text(1, 1.1, f'$N={nsegs}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
else:
|
||||
ax.text(1, 1.1, f'$N=10^{{{np.log10(nsegs):.0f}}}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
cax = plot_chi2(ax, s, freqs, chi2, fcutoff, rate)
|
||||
cax.set_ylabel('')
|
||||
print(f'Modeled cell {"-".join(files[i].name.split("-")[2:-1])} at {100*alpha:4.1f}% contrast: noise_frac={noise_frac:3.1f}, nsegs={n}')
|
||||
print()
|
||||
return alpha, noise_frac
|
||||
|
||||
|
||||
def plot_chi2_data(ax, s, cell_name, run):
|
||||
vmax = 15
|
||||
data_file = data_path / f'{cell_name}-baseline.npz'
|
||||
data = np.load(data_file)
|
||||
eodf = float(data['eodf'])
|
||||
@@ -131,13 +84,65 @@ def plot_chi2_data(ax, s, cell_name, run):
|
||||
pss = data['pss']
|
||||
prss = data['prss']
|
||||
chi2 = np.abs(prss)*0.5/(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
print(f'Measured cell {"-".join(data_file.name.split("-")[:-2])} at {100*alpha:4.1f}% contrast: r={ratebase:3.0f}Hz, CV={cvbase:4.2f}, dt={1000*deltat:4.2f}ms, nfft={nfft}, win={1000*deltat*nfft:6.1f}ms, nsegs={nsegs}')
|
||||
print(f'Measured cell {"-".join(data_file.name.split("-")[:-3])} at {100*alpha:4.1f}% contrast:')
|
||||
print(f' r={ratebase:3.0f}Hz, CV={cvbase:4.2f}, dt={1000*deltat:4.2f}ms, nfft={nfft}, win={1000*deltat*nfft:6.1f}ms, nsegs={nsegs}')
|
||||
print()
|
||||
ax.text(1, 1.1, f'$N={nsegs}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
plot_chi2(ax, s, freqs, chi2, fcutoff, ratebase, 15)
|
||||
plot_chi2(ax, s, freqs, chi2, fcutoff, ratebase, vmax)
|
||||
return alpha, ratebase, eodf
|
||||
|
||||
|
||||
def plot_chi2_contrast(ax1, ax2, s, files, nums, nsmall, nlarge, rate):
|
||||
vmax = {0.05: {nsmall: 15, nlarge: 1.2},
|
||||
0.01: {nsmall: 400, nlarge: 4}}
|
||||
for ax, n in zip([ax1, ax2], [nsmall, nlarge]):
|
||||
i = nums.index(n)
|
||||
data = np.load(files[i])
|
||||
nsegs = data['nsegs']
|
||||
fcutoff = float(data['fcutoff'])
|
||||
alpha = float(data['contrast'])
|
||||
freqs = data['freqs']
|
||||
pss = data['pss']
|
||||
prss = data['prss']
|
||||
if nsegs < 10000:
|
||||
ax.text(1, 1.1, f'$N={nsegs}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
else:
|
||||
ax.text(1, 1.1, f'$N=10^{{{np.log10(nsegs):.0f}}}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
chi2 = np.abs(prss)*0.5/(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
cax = plot_chi2(ax, s, freqs, chi2, fcutoff, rate, vmax[alpha][n])
|
||||
cax.set_ylabel('')
|
||||
print(f'Modeled cell {"-".join(files[i].name.split("-")[:-4])} at {100*alpha:4.1f}% contrast: noise_frac={1:3.1f}, nsegs={n}')
|
||||
print()
|
||||
|
||||
|
||||
def plot_chi2_split(ax1, ax2, s, files, nums, nsmall, nlarge, rate):
|
||||
vmax = {nsmall: 4, nlarge: 1.2}
|
||||
for ax, n in zip([ax1, ax2], [nsmall, nlarge]):
|
||||
i = nums.index(n)
|
||||
data = np.load(files[i])
|
||||
nsegs = data['nsegs']
|
||||
fcutoff = float(data['fcutoff'])
|
||||
alpha = float(data['contrast'])
|
||||
noise_frac = data['noise_frac']
|
||||
freqs = data['freqs']
|
||||
pss = data['pss']
|
||||
prss = data['prss']
|
||||
chi2 = np.abs(prss)*0.5/(pss.reshape(1, -1)*pss.reshape(-1, 1))
|
||||
if nsegs < 10000:
|
||||
ax.text(1, 1.1, f'$N={nsegs}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
else:
|
||||
ax.text(1, 1.1, f'$N=10^{{{np.log10(nsegs):.0f}}}$',
|
||||
ha='right', transform=ax.transAxes)
|
||||
cax = plot_chi2(ax, s, freqs, chi2, fcutoff, rate, vmax[n])
|
||||
cax.set_ylabel('')
|
||||
print(f'Modeled cell {"-".join(files[i].name.split("-")[:-3])} at {100*alpha:4.1f}% contrast: noise_frac={noise_frac:3.1f}, nsegs={n}')
|
||||
print()
|
||||
return alpha, noise_frac
|
||||
|
||||
|
||||
def plot_ram(ax, contrast, eodf, wtime, wnoise):
|
||||
tmax = 50
|
||||
@@ -217,7 +222,7 @@ if __name__ == '__main__':
|
||||
|
||||
s = plot_style()
|
||||
fig, axs = plt.subplots(4, 4, cmsize=(s.plot_width, 0.85*s.plot_width),
|
||||
width_ratios=[1, 0, 1, 1, 0.15, 0.9])
|
||||
width_ratios=[1, 0, 1, 1, 0.2, 0.85])
|
||||
fig.subplots_adjust(leftm=8, rightm=1.5, topm=3.5, bottomm=4,
|
||||
wspace=0.25, hspace=0.6)
|
||||
axs[0, 2].set_visible(False)
|
||||
|
||||
Reference in New Issue
Block a user