From 1797c75a6f80a2493f5cd007079855415692aad9 Mon Sep 17 00:00:00 2001 From: xaver Date: Thu, 22 Oct 2020 17:34:47 +0200 Subject: [PATCH] 22.10 --- apteronotus_code/FFR_model_specgram.py | 205 ++++++++++++++++++ apteronotus_code/base_eodf.py | 36 +-- .../figure_apteronotus_gain_plot.py | 136 ++++++++++++ ...igure_apteronotus_gaincurve_cutofff_tau.py | 2 +- .../figure_apteronotus_jar_plot.py | 131 +++++++++++ .../figure_apteronotus_rms_gaincurve.py | 10 +- apteronotus_code/stimulus_model.py | 41 ++-- eigenmannia_code/eigenmannia_jar_subplot.py | 26 ++- 8 files changed, 533 insertions(+), 54 deletions(-) create mode 100644 apteronotus_code/FFR_model_specgram.py create mode 100644 apteronotus_code/figure_apteronotus_gain_plot.py create mode 100644 apteronotus_code/figure_apteronotus_jar_plot.py diff --git a/apteronotus_code/FFR_model_specgram.py b/apteronotus_code/FFR_model_specgram.py new file mode 100644 index 0000000..dd6fd1f --- /dev/null +++ b/apteronotus_code/FFR_model_specgram.py @@ -0,0 +1,205 @@ +import matplotlib.pyplot as plt +import numpy as np +import pylab +from IPython import embed +from scipy.optimize import curve_fit +from matplotlib.mlab import specgram +import os +from jar_functions import import_data +from jar_functions import import_amfreq +from jar_functions import sin_response + +plt.rcParams.update({'font.size': 20}) + +base_path = 'D:\\jar_project\\JAR\\sin' + +identifier = ['2018lepto98'] +''' +specs = [] +jars = [] +sub_times = [] +sub_lim0 = [] +sub_lim1 = [] +time = [] + +for ID in identifier: + for dataset in os.listdir(os.path.join(base_path, ID)): + if dataset == 'prerecordings': + continue + datapath = os.path.join(base_path, ID, dataset, '%s.nix' % dataset) + print(datapath) + + amfreq = import_amfreq(datapath) + if amfreq == '0.005' or amfreq == '0.02' or amfreq == '0.05': + print(amfreq) + + data, pre_data, dt = import_data(datapath) + + #hstack concatenate: 'glue' pre_data and data + if len(data) == 2: + trace0 = np.hstack((pre_data[0], data[0])) + trace1 = np.hstack((pre_data[1], data[1])) + else: + trace0 = np.hstack((pre_data, data)) + + # data + nfft = 2**17 + spec, freqs, times = specgram(trace0, Fs=1 / dt, detrend='mean', NFFT=nfft, noverlap=nfft * 0.95) + dbspec = 10.0 * np.log10(spec) # in dB + power = dbspec[:, 25] + + fish_p = power[(freqs > 200) & (freqs < 1000)] + fish_f = freqs[(freqs > 200) & (freqs < 1000)] + + index = np.argmax(fish_p) + eodf = fish_f[index] + eodf4 = eodf * 4 + + lim0 = eodf4 - 10 + lim1 = eodf4 + 25 + + df = freqs[1] - freqs[0] + ix0 = int(np.floor(lim0/df)) # back to index + ix1 = int(np.ceil(lim1/df)) # back to index + spec4= dbspec[ix0:ix1, :] + freq4 = freqs[ix0:ix1] + jar4 = freq4[np.argmax(spec4, axis=0)] # all freqs at max specs over axis 0 + + cut_time_jar = times[:len(jar4)] + specs.append(spec4) + jars.append(jar4) + sub_times.append(cut_time_jar) + sub_lim0.append(lim0) + sub_lim1.append(lim1) + time.append(times) + +np.save('spec0.npy', specs[0]) +np.save('spec1.npy', specs[1]) +np.save('spec2.npy', specs[2]) +np.save('jar0.npy', jars[0]) +np.save('jar1.npy', jars[1]) +np.save('jar2.npy', jars[2]) +np.save('sub_times0.npy', sub_times[0]) +np.save('sub_times1.npy', sub_times[1]) +np.save('sub_times2.npy', sub_times[2]) +np.save('sub_lim0_0.npy', sub_lim0[0]) +np.save('sub_lim0_1.npy', sub_lim0[1]) +np.save('sub_lim0_2.npy', sub_lim0[2]) +np.save('sub_lim1_0.npy', sub_lim1[0]) +np.save('sub_lim1_1.npy', sub_lim1[1]) +np.save('sub_lim1_2.npy', sub_lim1[2]) +np.save('time0.npy', time[0]) +np.save('time1.npy', time[1]) +np.save('time2.npy', time[2]) +''' +spec0 = np.load('spec0.npy') +spec1 = np.load('spec1.npy') +spec2 = np.load('spec2.npy') +jar0 = np.load('jar0.npy') +jar1 = np.load('jar1.npy') +jar2 = np.load('jar2.npy') +sub_times0 = np.load('sub_times0.npy') +sub_times1 = np.load('sub_times1.npy') +sub_times2 = np.load('sub_times2.npy') +sub_lim0_0 = np.load('sub_lim0_0.npy') +sub_lim0_1 = np.load('sub_lim0_1.npy') +sub_lim0_2 = np.load('sub_lim0_2.npy') +sub_lim1_0 = np.load('sub_lim1_0.npy') +sub_lim1_1 = np.load('sub_lim1_1.npy') +sub_lim1_2 = np.load('sub_lim1_2.npy') +time0 = np.load('time0.npy') +time1 = np.load('time1.npy') +time2 = np.load('time2.npy') + +fig = plt.figure(figsize = (20,20)) +ax0 = fig.add_subplot(232) +ax0.tick_params(width = 2, length = 5) +ax0.imshow(spec0, cmap='jet', origin='lower', extent=(time0[0], time0[-1], sub_lim0_0, sub_lim1_0), aspect='auto', vmin=-80, vmax=-10) +#ax0.plot(sub_times0, jar0, 'k', label = 'peak detection trace', lw = 2) +ax0.set_xlim(time0[0],time0[-1]) +ax0.axes.xaxis.set_ticklabels([]) +ax0.axes.yaxis.set_ticklabels([]) + +ax1 = fig.add_subplot(231) +ax1.tick_params(width = 2, length = 5) +ax1.imshow(spec1, cmap='jet', origin='lower', extent=(time1[0], time1[-1], sub_lim0_1, sub_lim1_1), aspect='auto', vmin=-80, vmax=-10) +#ax1.plot(sub_times1, jar1, 'k', label = 'peak detection trace', lw = 2) +ax1.set_xlim(time1[0],time1[-1]) +ax1.set_ylabel('frequency [Hz]') +ax1.axes.xaxis.set_ticklabels([]) + +plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax1.transAxes) + +ax2 = fig.add_subplot(233) +ax2.tick_params(width = 2, length = 5) +ax2.imshow(spec2, cmap='jet', origin='lower', extent=(time2[0], time2[-1], sub_lim0_2, sub_lim1_2), aspect='auto', vmin=-80, vmax=-10) +#ax2.plot(sub_times2, jar2, 'k', label = 'peak detection trace', lw = 2) +ax2.set_xlim(time2[0],time2[-1]) +ax2.axes.xaxis.set_ticklabels([]) +ax2.axes.yaxis.set_ticklabels([]) + +# AM model: 0.05 Hz + +lower0 = 50 +upper0 = 250 +sample0 = 2000 +x0 = np.linspace(lower0, upper0, sample0) +y0_0 = (sin_response(np.linspace(lower0, upper0, sample0), 0.05, np.pi/2, -0.35) - 0.5) +y0_1 = (sin_response(np.linspace(lower0, upper0, sample0), 0.05, np.pi/2, 0.35) + 0.5) + +ax3 = fig.add_subplot(234) +ax3.tick_params(width = 2, length = 5) +plt.hlines(y = 0, xmin = 0, xmax = 50, color = 'red') +plt.vlines(x = 50, ymin = -0.15, ymax = 0.15, color = 'red') +ax3.plot(x0, y0_0, c = 'red') +ax3.plot(x0, y0_1, c = 'red') +ax3.fill_between(x0, y0_0, y0_1) + +ax3.set_ylabel('amplitude [mV/cm]') +ax3.set_xlabel('time [s]') +ax3.set_xlim(0,250) + +plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax3.transAxes) + +# AM model: 0.02 Hz +lower1 = 50 +upper1 = 250 +sample1 = 2000 +x1 = np.linspace(lower1, upper1, sample1) +y1_0 = (sin_response(np.linspace(lower1, upper1, sample1), 0.02, -np.pi/2 , -0.35) - 0.5) +y1_1 = (sin_response(np.linspace(lower1, upper1, sample1), 0.02, -np.pi/2, 0.35) + 0.5) + +ax4 = fig.add_subplot(235) +ax4.tick_params(width = 2, length = 5) +plt.hlines(y = 0, xmin = 0, xmax = 50, color = 'red') +plt.vlines(x = 50, ymin = -0.15, ymax = 0.15, color = 'red') +ax4.plot(x1, y1_0, c = 'red') +ax4.plot(x1, y1_1, c = 'red') +ax4.fill_between(x1, y1_0, y1_1) + +ax4.set_xlabel('time [s]') +ax4.set_xlim(0,250) +ax4.axes.yaxis.set_ticklabels([]) + +# AM model: 0.005 Hz +lower2 = 50 +upper2 = 450 +sample2 = 2000 +x2 = np.linspace(lower2, upper2, sample2) +y2_0 = (sin_response(np.linspace(lower2, upper2, sample2), 0.005, -np.pi , -0.35) - 0.5) +y2_1 = (sin_response(np.linspace(lower2, upper2, sample2), 0.005, -np.pi, 0.35) + 0.5) + +ax5 = fig.add_subplot(236) +ax5.tick_params(width = 2, length = 5) +plt.hlines(y = 0, xmin = 0, xmax = 50, color = 'red') +plt.vlines(x = 50, ymin = -0.15, ymax = 0.15, color = 'red') +ax5.plot(x2, y2_0, c = 'red') +ax5.plot(x2, y2_1, c = 'red') +ax5.fill_between(x2, y2_0, y2_1) + +ax5.set_xlabel('time [s]') +ax5.set_xlim(0,450) +ax5.axes.yaxis.set_ticklabels([]) + +plt.show() +embed() diff --git a/apteronotus_code/base_eodf.py b/apteronotus_code/base_eodf.py index 41c448b..5387e0a 100644 --- a/apteronotus_code/base_eodf.py +++ b/apteronotus_code/base_eodf.py @@ -9,22 +9,24 @@ from jar_functions import mean_traces from jar_functions import mean_noise_cut_eigen from jar_functions import adjust_eodf -base_path = 'D:\\jar_project\\JAR\\sin' +base_path = 'D:\\jar_project\\JAR\\eigenmannia\\sin' -identifier = ['2018lepto1', - '2018lepto4', - '2018lepto5', - '2018lepto76', - '2018lepto98', - '2019lepto03', - '2019lepto24', - '2019lepto27', - '2019lepto30', - '2020lepto04', - '2020lepto06', - '2020lepto16', - '2020lepto19', - '2020lepto20' +identifier = ['2015eigen8', + '2015eigen16','2015eigen17', '2015eigen19', '2015eigen15' + # '2018lepto1', + # '2018lepto4', + # '2018lepto5', + # '2018lepto76', + # '2018lepto98', + # '2019lepto03', + # '2019lepto24', + # '2019lepto27', + # '2019lepto30', + # '2020lepto04', + # '2020lepto06', + # '2020lepto16', + # '2020lepto19', + # '2020lepto20' ] eod = [] for ID in identifier: @@ -73,4 +75,8 @@ Q10_eod = [] for et in eod_temp: Q10 = adjust_eodf(et[0], et[1]) Q10_eod.append(Q10) + +print('MAXI KING', np.max(Q10_eod)) +print('MINI KING', np.min(Q10_eod)) + embed() diff --git a/apteronotus_code/figure_apteronotus_gain_plot.py b/apteronotus_code/figure_apteronotus_gain_plot.py new file mode 100644 index 0000000..acdb8a5 --- /dev/null +++ b/apteronotus_code/figure_apteronotus_gain_plot.py @@ -0,0 +1,136 @@ +import matplotlib.pyplot as plt +import numpy as np +import pylab +from IPython import embed +from scipy.optimize import curve_fit +from matplotlib.mlab import specgram +import os +from jar_functions import gain_curve_fit + +identifier = ['2018lepto1', + #'2018lepto4', + '2018lepto5', + '2018lepto76', + '2018lepto98', + #'2019lepto03', + '2019lepto24', + #'2019lepto27', + #'2019lepto30', + #'2020lepto04', + '2020lepto06', + #'2020lepto16', + #'2020lepto19', + #'2020lepto20' + ] + +amfs = [] +gains = [] +taus = [] +f_cs = [] +predicts = [] +for ID in identifier: + predict = [] + + print(ID) + amf = np.load('amf_%s.npy' %ID) + amfs.append(amf) + gain = np.load('gain_%s.npy' %ID) + gains.append(gain) + + sinv, sinc = curve_fit(gain_curve_fit, amf, gain, [2, 3]) + #print('tau:', sinv[0]) + taus.append(sinv[0]) + f_cutoff = abs(1 / (2*np.pi*sinv[0])) + print('f_cutoff:', f_cutoff) + f_cs.append(f_cutoff) + + # predict of gain + for f in amf: + G = np.max(gain) / np.sqrt(1 + (2 * ((np.pi * f * sinv[0]) ** 2))) + predict.append(G) + predicts.append(predict) + +sort = sorted(zip(f_cs, identifier)) +print(sort) +# order of f_c: 2019lepto24, 2020lepto06, 2018lepto98, 2018lepto76, 2018lepto1, 2018lepto5 + +fig = plt.figure(figsize=(8.27,11.69)) +ax0 = fig.add_subplot(321) +ax0.set_xlim(0.0007, 1.5) +ax0.plot(amfs[4], gains[4],'o' , label = 'gain') +ax0.plot(amfs[4], predicts[4], label = 'fit') +ax0.axvline(x=f_cs[4], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax0.set_xscale('log') +ax0.set_yscale('log') +ax0.set_ylabel('gain [Hz/(mV/cm)]') +#ax0.set_xlabel('envelope_frequency [Hz]') +#ax0.set_title('gaincurve %s' %ID) + +ax1 = fig.add_subplot(322) +ax1.set_xlim(0.0007, 1.5) +ax1.get_shared_y_axes().join(ax0, ax1) +ax1.axes.yaxis.set_ticklabels([]) +ax1.plot(amfs[5], gains[5],'o' , label = 'gain') +ax1.plot(amfs[5], predicts[5], label = 'fit') +ax1.axvline(x=f_cs[5], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax1.set_xscale('log') +ax1.set_yscale('log') +#ax1.set_ylabel('gain [Hz/(mV/cm)]') +#ax1.set_xlabel('envelope_frequency [Hz]') +#ax1.set_title('gaincurve %s' %ID) + +ax2 = fig.add_subplot(323) +ax2.set_xlim(0.0007, 1.5) +ax2.plot(amfs[4], gains[4],'o' , label = 'gain') +ax2.plot(amfs[4], predicts[4], label = 'fit') +ax2.axvline(x=f_cs[4], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax2.set_xscale('log') +ax2.set_yscale('log') +ax2.set_ylabel('gain [Hz/(mV/cm)]') +#ax2.set_xlabel('envelope_frequency [Hz]') +#ax2.set_title('gaincurve %s' %ID) + +ax3 = fig.add_subplot(324) +ax3.set_xlim(0.0007, 1.5) +ax3.get_shared_y_axes().join(ax2, ax3) +ax3.axes.yaxis.set_ticklabels([]) +ax3.plot(amfs[2], gains[2],'o' , label = 'gain') +ax3.plot(amfs[2], predicts[2], label = 'fit') +ax3.axvline(x=f_cs[2], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax3.set_xscale('log') +ax3.set_yscale('log') +#ax3.set_ylabel('gain [Hz/(mV/cm)]') +#ax3.set_xlabel('envelope_frequency [Hz]') +#ax3.set_title('gaincurve %s' %ID) + +ax4 = fig.add_subplot(325) +ax4.set_xlim(0.0007, 1.5) +#ax4.get_shared_y_axes().join(ax0, ax4) +ax4.plot(amfs[0], gains[0],'o' , label = 'gain') +ax4.plot(amfs[0], predicts[0], label = 'fit') +ax4.axvline(x=f_cs[0], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax4.set_xscale('log') +ax4.set_yscale('log') +ax4.set_ylabel('gain [Hz/(mV/cm)]') +#ax4.set_xlabel('envelope_frequency [Hz]') +#ax4.set_title('gaincurve %s' %ID) + +ax5 = fig.add_subplot(326) +ax5.set_xlim(0.0007, 1.5) +ax5.axes.yaxis.set_ticklabels([]) +ax5.get_shared_y_axes().join(ax4, ax5) +ax5.plot(amfs[1], gains[1],'o' , label = 'gain') +ax5.plot(amfs[1], predicts[1], label = 'fit') +ax5.axvline(x=f_cs[1], ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') +ax5.set_xscale('log') +ax5.set_yscale('log') +#ax5.set_ylabel('gain [Hz/(mV/cm)]') +#ax5.set_xlabel('envelope_frequency [Hz]') +#ax5.set_title('gaincurve %s' %ID) + +#plt.legend(loc = 'lower left') +plt.show() + + +#np.save('f_c', f_c) +#np.save('tau', tau) \ No newline at end of file diff --git a/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py b/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py index 3196422..a5e69e5 100644 --- a/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py +++ b/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py @@ -7,7 +7,7 @@ from matplotlib.mlab import specgram import os from jar_functions import gain_curve_fit -identifier = ['2020lepto19'] +identifier = ['2018lepto98'] tau = [] f_c = [] diff --git a/apteronotus_code/figure_apteronotus_jar_plot.py b/apteronotus_code/figure_apteronotus_jar_plot.py new file mode 100644 index 0000000..1b0441f --- /dev/null +++ b/apteronotus_code/figure_apteronotus_jar_plot.py @@ -0,0 +1,131 @@ +import matplotlib.pyplot as plt +import numpy as np +import pylab +from IPython import embed +from scipy.optimize import curve_fit +from scipy.optimize import curve_fit +from matplotlib.mlab import specgram +import os + +from jar_functions import import_data +from jar_functions import import_amfreq +from jar_functions import sin_response +from jar_functions import mean_noise_cut +from jar_functions import gain_curve_fit + +plt.rcParams.update({'font.size': 10}) + +def take_second(elem): # function for taking the names out of files + return elem[1] + +identifier = [#'2018lepto1', + #'2018lepto4', + #'2018lepto5', + #'2018lepto76', + '2018lepto98', + '2019lepto03', + #'2019lepto24', + #'2019lepto27', + #'2019lepto30', + #'2020lepto04', + #'2020lepto06', + '2020lepto16', + '2020lepto19', + '2020lepto20' + ] +for ident in identifier: + + times = [] + jars = [] + jms = [] + amfreq = [] + + times1 = [] + jars1 = [] + jms1 = [] + amfreq1 = [] + + amf = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1] + + data = sorted(np.load('%s files.npy' %ident), key = take_second) # list with filenames in it + + for i, d in enumerate(data): + dd = list(d) + if dd[1] == '1' or dd[1] == '0.2' or dd[1] == '0.05' or dd[1] == '0.01' or dd[1] == '0.005' or dd[1] == '0.001': + jar = np.load('%s.npy' %dd) # load data for every file name + jm = jar - np.mean(jar) # low-pass filtering by subtracting mean + + time = np.load('%s time.npy' %dd) # time file + dt = time[1] - time[0] + + n = int(1/float(d[1])/dt) + cutf = mean_noise_cut(jm, n = n) + cutt = time + if dd[1] == '0.001': + amfreq1.append(dd[1]) + jars1.append(jm - cutf) + jms1.append(jm) + times1.append(time) + if dd[1] not in amfreq: + print(dd) + amfreq.append(dd[1]) + jars.append(jm - cutf) + jms.append(jm) + times.append(time) + else: + print('1:', dd) + amfreq1.append(dd[1]) + jars1.append(jm - cutf) + jms1.append(jm) + times1.append(time) + if len(jars) != 6: + continue + + fig = plt.figure(figsize=(8.27,11.69)) + fig.suptitle('%s' %ident) + fig.text(0.06, 0.5, 'frequency [Hz]', ha='center', va='center', rotation='vertical') + fig.text(0.5, 0.04, 'time [s]', ha='center', va='center') + + ax0 = fig.add_subplot(611) + ax0.plot(times[0], jms[0]) + #ax0.plot(times[0], jars[0]) + ax0.set_ylim(-12, 12) + #plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax0.transAxes) + + ax1 = fig.add_subplot(612) + ax1.plot(times[1], jms[1]) + #ax1.plot(times[1], jars[1]) + ax1.set_ylim(-12, 12) + #plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax1.transAxes) + + ax2 = fig.add_subplot(613) + ax2.plot(times[2], jms[2]) + #ax2.plot(times[2], jars[2]) + ax2.set_ylim(-12, 12) + #plt.text(-0.1, 1.05, "C)", fontweight=550, transform=ax2.transAxes) + + ax3 = fig.add_subplot(614) + ax3.plot(times[3], jms[3]) + #ax3.plot(times[3], jars[3]) + ax3.set_ylim(-12, 12) + #plt.text(-0.1, 1.05, "D)", fontweight=550, transform=ax3.transAxes) + + ax4 = fig.add_subplot(615) + ax4.plot(times[4], jms[4]) + #ax4.plot(times[4], jars[4]) + ax4.set_ylim(-12, 12) + # plt.text(-0.1, 1.05, "E)", fontweight=550, transform=ax4.transAxes) + + ax5 = fig.add_subplot(616) + ax5.plot(times[5], jms[5]) + #ax5.plot(times[5], jars[5]) + ax5.set_ylim(-12, 12) + #plt.text(-0.1, 1.05, "F)", fontweight=550, transform=ax5.transAxes) + + plt.subplots_adjust(left=0.125, + bottom=0.1, + right=0.9, + top=0.9, + wspace=0.2, + hspace=0.35) + plt.show() \ No newline at end of file diff --git a/apteronotus_code/figure_apteronotus_rms_gaincurve.py b/apteronotus_code/figure_apteronotus_rms_gaincurve.py index 3e80128..af0dafd 100644 --- a/apteronotus_code/figure_apteronotus_rms_gaincurve.py +++ b/apteronotus_code/figure_apteronotus_rms_gaincurve.py @@ -19,7 +19,7 @@ plt.rcParams.update({'font.size': 12}) def take_second(elem): # function for taking the names out of files return elem[1] -identifier = ['2018lepto4'] +identifier = ['2020lepto16'] for ident in identifier: predict = [] @@ -37,16 +37,16 @@ for ident in identifier: currf = None idxlist = [] - data = sorted(np.load('%s files.npy' %ident), key = take_second) # list with filenames in it + data = sorted(np.load('5Hz_%s files.npy' %ident), key = take_second) # list with filenames in it for i, d in enumerate(data): dd = list(d) - jar = np.load('%s.npy' %dd) # load data for every file name + jar = np.load('5Hz_%s.npy' %dd) # load data for every file name jm = jar - np.mean(jar) # low-pass filtering by subtracting mean print(dd) - time = np.load('%s time.npy' %dd) # time file + time = np.load('5Hz_%s time.npy' %dd) # time file dt = time[1] - time[0] n = int(1/float(d[1])/dt) @@ -125,7 +125,7 @@ for ident in identifier: idx_arr = (rootmeansquare_arr < threshold_arr) | (rootmeansquare_arr < np.mean(rootmeansquare_arr)) fig = plt.figure(figsize = (8,14)) - fig.suptitle('gaincurve and RMS 2018lepto4') + fig.suptitle('gaincurve and RMS %s' %ident) ax0 = fig.add_subplot(2, 1, 1) ax0.plot(amfreq_arr, mgain_arr, 'o') ax0.set_yscale('log') diff --git a/apteronotus_code/stimulus_model.py b/apteronotus_code/stimulus_model.py index fb1be86..3be8c01 100644 --- a/apteronotus_code/stimulus_model.py +++ b/apteronotus_code/stimulus_model.py @@ -3,7 +3,7 @@ import numpy as np import matplotlib.pyplot as plt from jar_functions import sin_response -plt.rcParams.update({'font.size': 12}) +plt.rcParams.update({'font.size': 27}) # AM model lower = 0 @@ -13,33 +13,32 @@ x = np.linspace(lower, upper, sample) y1 = (sin_response(np.linspace(lower, upper, sample), 0.02, -np.pi/2, -0.75) - 1) y2 = (sin_response(np.linspace(lower, upper, sample), 0.02, -np.pi/2, 0.75) + 1) -fig = plt.figure(figsize = (12,6)) -ax = fig.add_subplot(121) -ax.plot(x, y1, c = 'red') -ax.plot(x, y2, c = 'red') -ax.fill_between(x, y1, y2) - -ax.set_xlabel('time[s]') -ax.set_ylabel('amplitude') -ax.set_xlim(0,200) -ax.axes.yaxis.set_ticks([]) -plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax.transAxes) +fig = plt.figure(figsize = (6,6)) +# ax = fig.add_subplot(121) +# ax.plot(x, y1, c = 'red') +# ax.plot(x, y2, c = 'red') +# ax.fill_between(x, y1, y2) +# +# ax.set_xlabel('time[s]') +# ax.set_ylabel('amplitude') +# ax.set_xlim(0,200) +# ax.axes.yaxis.set_ticks([]) +# plt.text(-0.1, 1.05, "A)", fontweight=550, transform=ax.transAxes) # carrier lower = 0 -upper = 10 -sample = 1000 +upper = 100 +sample = 10000 x = np.linspace(lower, upper, sample) y1 = (sin_response(np.linspace(lower, upper, sample), 800, np.pi, -0.75) - 1) -ax1 = fig.add_subplot(122) -ax1.plot(x, y1) -ax1.axhline(y = -0.25, c = 'red', lw = 2) -ax1.axhline(y = -1.75, c = 'red', lw = 2) +ax1 = fig.add_subplot(111) +ax1.plot(x, y1, lw = 4) +ax1.axhline(y = -0.25, c = 'red', lw = 4) +ax1.axhline(y = -1.75, c = 'red', lw = 4) ax1.set_xlabel('time[ms]') -ax1.set_xlim(0,10) +ax1.set_xlim(0,100) ax1.axes.get_yaxis().set_visible(False) -plt.text(-0.1, 1.05, "B)", fontweight=550, transform=ax1.transAxes) - +plt.xticks((0,50,100), [0,5,10]) plt.show() \ No newline at end of file diff --git a/eigenmannia_code/eigenmannia_jar_subplot.py b/eigenmannia_code/eigenmannia_jar_subplot.py index e9249ae..4e03d4c 100644 --- a/eigenmannia_code/eigenmannia_jar_subplot.py +++ b/eigenmannia_code/eigenmannia_jar_subplot.py @@ -58,8 +58,8 @@ for ID in identifier: eodf = fish_f[index] eodf4 = eodf * 4 - lim0 = eodf4 - 40 - lim1 = eodf4 + 40 + lim0 = eodf4 - 42 + lim1 = eodf4 + 42 df = freqs[1] - freqs[0] ix0 = int(np.floor(lim0 / df)) # back to index @@ -102,36 +102,38 @@ for ID in identifier: fig = plt.figure(figsize = (20,20)) ax0 = fig.add_subplot(221) ax0.imshow(specs[0], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[0], sub_lim1[0]), aspect='auto', vmin=-80, vmax=-10) -ax0.plot(sub_times[0], jars[0], 'k', label = 'peak detection trace', lw = 2) +#ax0.plot(sub_times[0], jars[0], 'k', label = 'peak detection trace', lw = 2) ax0.set_xlim(times[0],times[-1]) ax0.set_ylabel('frequency [Hz]') ax0.axes.xaxis.set_ticklabels([]) ax0.set_title('∆F -2 Hz') ax1 = fig.add_subplot(222) -ax1.imshow(specs[1], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[1], sub_lim1[1]), aspect='auto', vmin=-80, vmax=-10) -ax1.plot(sub_times[1], jars[1], 'k', label = 'peak detection trace', lw = 2) +ax1.imshow(specs[2], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[2], sub_lim1[2]), aspect='auto', vmin=-80, vmax=-10) +#ax1.plot(sub_times[2], jars[2], 'k', label = 'peak detection trace', lw = 2) ax1.set_xlim(times[0],times[-1]) ax1.axes.xaxis.set_ticklabels([]) -ax1.axes.yaxis.set_ticklabels([]) -ax1.set_title('∆F -10 Hz') +#ax1.axes.yaxis.set_ticklabels([]) +ax1.set_title('∆F 2 Hz') +ax1.get_shared_y_axes().join(ax0, ax1) ax2 = fig.add_subplot(223) -ax2.imshow(specs[2], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[2], sub_lim1[2]), aspect='auto', vmin=-80, vmax=-10) -ax2.plot(sub_times[2], jars[2], 'k', label = 'peak detection trace', lw = 2) +ax2.imshow(specs[1], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[1], sub_lim1[1]), aspect='auto', vmin=-80, vmax=-10) +#ax2.plot(sub_times[1], jars[1], 'k', label = 'peak detection trace', lw = 2) ax2.set_xlim(times[0],times[-1]) ax2.set_ylabel('frequency [Hz]') ax2.set_xlabel('time [s]') -ax2.set_title('∆F 2 Hz') +ax2.set_title('∆F -10 Hz') ax3 = fig.add_subplot(224) ax3.imshow(specs[3], cmap='jet', origin='lower', extent=(times[0], times[-1], sub_lim0[3], sub_lim1[3]), aspect='auto', vmin=-80, vmax=-10) -ax3.plot(sub_times[3], jars[3], 'k', label = 'peak detection trace', lw = 2) +#ax3.plot(sub_times[3], jars[3], 'k', label = 'peak detection trace', lw = 2) ax3.set_xlim(times[0],times[-1]) ax3.set_xlabel('time [s]') -ax3.axes.yaxis.set_ticklabels([]) +#ax3.axes.yaxis.set_ticklabels([]) ax3.set_title('∆F 10 Hz') +plt.subplots(sharex = True, sharey = True) plt.show() embed()