cleaned up for new data
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from pathlib import Path
|
||||
from spectral import diag_projection, peakedness
|
||||
from spectral import diag_projection, peak_size
|
||||
from plotstyle import plot_style
|
||||
from punitexamplecell import load_baseline, load_noise, load_spectra
|
||||
from punitexamplecell import plot_colorbar
|
||||
@@ -119,35 +119,35 @@ def plot_chi2(ax, s, contrast, freqs, chi2, fcutoff, vmax):
|
||||
|
||||
def plot_diagonals(ax, s, fbase, contrast1, freqs1, chi21, contrast2, freqs2, chi22, fcutoff):
|
||||
diags = []
|
||||
nlis = []
|
||||
nlips = []
|
||||
nlifs = []
|
||||
sis = []
|
||||
sips = []
|
||||
sifs = []
|
||||
for contrast, freqs, chi2 in [[contrast1, freqs1, chi21], [contrast2, freqs2, chi22]]:
|
||||
dfreqs, diag = diag_projection(freqs, chi2, 2*fcutoff)
|
||||
diags.append([dfreqs, diag])
|
||||
nli, nlif = peakedness(dfreqs, diag, fbase, median=False)
|
||||
nlip = diag[np.argmin(np.abs(dfreqs - nlif))]
|
||||
nlis.append(nli)
|
||||
nlips.append(nlip)
|
||||
nlifs.append(nlif)
|
||||
print(f' SI at {100*contrast:.1f}% contrast: {nli:.2f}')
|
||||
sinorm, sirel, sif = peak_size(dfreqs, diag, fbase, median=False)
|
||||
sip = diag[np.argmin(np.abs(dfreqs - sif))]
|
||||
sis.append(sinorm)
|
||||
sips.append(sip)
|
||||
sifs.append(sif)
|
||||
print(f' SI at {100*contrast:.1f}% contrast: {sinorm:.2f}')
|
||||
#ax.axvline(fbase, **s.lsGrid)
|
||||
ax.plot(diags[1][0], 1e-3*diags[1][1], **s.lsC2)
|
||||
ax.plot(diags[0][0], 1e-3*diags[0][1], **s.lsC1)
|
||||
ax.plot(nlifs[1], 1e-3*nlips[1], **s.psC2)
|
||||
ax.plot(nlifs[0], 1e-3*nlips[0], **s.psC1)
|
||||
ax.plot(sifs[1], 1e-3*sips[1], **s.psC2)
|
||||
ax.plot(sifs[0], 1e-3*sips[0], **s.psC1)
|
||||
ax.set_xlim(0, 2*fcutoff)
|
||||
ax.set_ylim(0, 1.7)
|
||||
ax.set_xticks_delta(100)
|
||||
ax.set_yticks_delta(1)
|
||||
ax.set_xlabel('$f_1 + f_2$', 'Hz')
|
||||
#ax.set_ylabel(r'$|\chi_2|$', 'kHz')
|
||||
ax.text(nlifs[1] - 25, 1e-3*nlips[1], f'{100*contrast2:.0f}\\%',
|
||||
ax.text(sifs[1] - 25, 1e-3*sips[1], f'{100*contrast2:.0f}\\%',
|
||||
ha='right')
|
||||
ax.text(nlifs[1] + 35, 1e-3*nlips[1], f'SI={nlis[1]:.1f}')
|
||||
ax.text(nlifs[0] - 25, 1e-3*nlips[0], f'{100*contrast1:.0f}\\%',
|
||||
ax.text(sifs[1] + 35, 1e-3*sips[1], f'SI={sis[1]:.1f}')
|
||||
ax.text(sifs[0] - 25, 1e-3*sips[0], f'{100*contrast1:.0f}\\%',
|
||||
ha='right')
|
||||
ax.text(nlifs[0] + 35, 1e-3*nlips[0], f'SI={nlis[0]:.1f}')
|
||||
ax.text(sifs[0] + 35, 1e-3*sips[0], f'SI={sis[0]:.1f}')
|
||||
#ax.text(fbase, 1.75, '$r$', ha='center')
|
||||
|
||||
|
||||
@@ -231,12 +231,12 @@ if __name__ == '__main__':
|
||||
eodf, rate, cv, isis, pdf, _, _ = load_baseline(data_path, cell)
|
||||
fcutoff, contrast, freqs, gain, chi2 = load_spectra(data_path, cell, run)
|
||||
dfreqs, diag = diag_projection(freqs, chi2, 2*fcutoff)
|
||||
nli, nlif = peakedness(dfreqs, diag, rate, median=False)
|
||||
print(f' {cell:<22s}: run={run:2d}, fbase={rate:3.0f}Hz, CV={cv:.2f}, SI={nli:3.1f}')
|
||||
sinorm, sirel, sif = peak_size(dfreqs, diag, rate, median=False)
|
||||
print(f' {cell:<22s}: run={run:2d}, fbase={rate:3.0f}Hz, CV={cv:.2f}, SI={sinorm:3.1f}')
|
||||
plot_isih2(axs[0, k], s, rate, cv, isis, pdf)
|
||||
pc = plot_chi2(axs[1, k], s, contrast, freqs, chi2, fcutoff, 1.2)
|
||||
#axs[k].set_title(f'$r={rate:.0f}$Hz, CV$_{{\\rm base}}$={cv:.2f}', fontsize='medium')
|
||||
axs[1, k].text(0.95, 0.9, f'SI($r$)={nli:.1f}', ha='right', zorder=50,
|
||||
axs[1, k].text(0.95, 0.9, f'SI($r$)={sinorm:.1f}', ha='right', zorder=50,
|
||||
color='white', fontsize='medium',
|
||||
transform=axs[1, k].transAxes)
|
||||
axs[0, 0].text(0, 1.6, 'Ampullary cells:', transform=axs[0, 0].transAxes,
|
||||
|
||||
Reference in New Issue
Block a user