diff --git a/apteronotus_code/figure_apteronotus_gain_plot.py b/apteronotus_code/figure_apteronotus_gain_plot.py index acdb8a5..7dfe595 100644 --- a/apteronotus_code/figure_apteronotus_gain_plot.py +++ b/apteronotus_code/figure_apteronotus_gain_plot.py @@ -7,6 +7,8 @@ from matplotlib.mlab import specgram import os from jar_functions import gain_curve_fit +plt.rcParams.update({'font.size': 10}) + identifier = ['2018lepto1', #'2018lepto4', '2018lepto5', @@ -52,81 +54,73 @@ for ID in identifier: sort = sorted(zip(f_cs, identifier)) print(sort) +# order of plotting: 2018lepto1, 2018lepto5, 2018lepto76, 2018lepto98, 2019lepto24, 2020lepto06 # order of f_c: 2019lepto24, 2020lepto06, 2018lepto98, 2018lepto76, 2018lepto1, 2018lepto5 fig = plt.figure(figsize=(8.27,11.69)) ax0 = fig.add_subplot(321) +fig.text(0.05, 0.5, 'gain [Hz/(mV/cm)]', ha='center', va='center', rotation='vertical') +fig.text(0.5, 0.04, 'envelope frequency [Hz]', ha='center', va='center') + ax0.set_xlim(0.0007, 1.5) +ax0.set_ylim(0.001, 10) 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) +ax0.axes.xaxis.set_ticklabels([]) 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.set_ylim(0.001, 10) 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) +ax1.axes.yaxis.set_ticklabels([]) +ax1.axes.xaxis.set_ticklabels([]) 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_ylim(0.001, 10) +ax2.plot(amfs[3], gains[3],'o' , label = 'gain') +ax2.plot(amfs[3], predicts[3], label = 'fit') +ax2.axvline(x=f_cs[3], 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) +ax2.axes.xaxis.set_ticklabels([]) 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.set_ylim(0.001, 10) 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) +ax3.axes.yaxis.set_ticklabels([]) +ax3.axes.xaxis.set_ticklabels([]) ax4 = fig.add_subplot(325) ax4.set_xlim(0.0007, 1.5) -#ax4.get_shared_y_axes().join(ax0, ax4) +ax4.set_ylim(0.001, 10) 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.set_ylim(0.001, 10) 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) +ax5.axes.yaxis.set_ticklabels([]) #plt.legend(loc = 'lower left') plt.show() diff --git a/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py b/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py index a5e69e5..b04b2dc 100644 --- a/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py +++ b/apteronotus_code/figure_apteronotus_gaincurve_cutofff_tau.py @@ -35,8 +35,8 @@ for ID in identifier: fig = plt.figure() ax = fig.add_subplot() ax.plot(amf, gain,'o' , label = 'gain') - #ax.plot(amf, predict, label = 'fit') - #ax.axvline(x=f_cutoff, ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') + ax.plot(amf, predict, label = 'fit') + ax.axvline(x=f_cutoff, ymin=0, ymax=5, ls='-', alpha=0.5, label = 'cutoff frequency') ax.set_xscale('log') ax.set_yscale('log') ax.set_ylabel('gain [Hz/(mV/cm)]') diff --git a/apteronotus_code/figure_apteronotus_jar_plot.py b/apteronotus_code/figure_apteronotus_jar_plot.py index 1b0441f..4324f6e 100644 --- a/apteronotus_code/figure_apteronotus_jar_plot.py +++ b/apteronotus_code/figure_apteronotus_jar_plot.py @@ -13,22 +13,22 @@ 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}) +#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', +identifier = ['2018lepto1', + '2018lepto4', + '2018lepto5', + '2018lepto76', '2018lepto98', '2019lepto03', - #'2019lepto24', - #'2019lepto27', - #'2019lepto30', - #'2020lepto04', - #'2020lepto06', + '2019lepto24', + '2019lepto27', + '2019lepto30', + '2020lepto04', + '2020lepto06', '2020lepto16', '2020lepto19', '2020lepto20' diff --git a/apteronotus_code/figure_apteronotus_rms_gaincurve.py b/apteronotus_code/figure_apteronotus_rms_gaincurve.py index af0dafd..bfa4d67 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 = ['2020lepto16'] +identifier = ['2020lepto19'] for ident in identifier: predict = [] @@ -37,16 +37,16 @@ for ident in identifier: currf = None idxlist = [] - data = sorted(np.load('5Hz_%s files.npy' %ident), key = take_second) # list with filenames in it + 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) - jar = np.load('5Hz_%s.npy' %dd) # load data for every file name + jar = np.load('%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('5Hz_%s time.npy' %dd) # time file + time = np.load('%s time.npy' %dd) # time file dt = time[1] - time[0] n = int(1/float(d[1])/dt) @@ -127,7 +127,7 @@ for ident in identifier: fig = plt.figure(figsize = (8,14)) fig.suptitle('gaincurve and RMS %s' %ident) ax0 = fig.add_subplot(2, 1, 1) - ax0.plot(amfreq_arr, mgain_arr, 'o') + ax0.plot(amfreq_arr[idx_arr], mgain_arr[idx_arr], 'o') ax0.set_yscale('log') ax0.set_xscale('log') ax0.set_ylabel('gain [Hz/(mV/cm)]') diff --git a/apteronotus_code/sin_all_uniform.py b/apteronotus_code/sin_all.py similarity index 72% rename from apteronotus_code/sin_all_uniform.py rename to apteronotus_code/sin_all.py index 98cfca8..be66ef9 100644 --- a/apteronotus_code/sin_all_uniform.py +++ b/apteronotus_code/sin_all.py @@ -8,6 +8,8 @@ from jar_functions import avgNestedLists import matplotlib as mpl from matplotlib import cm +#plt.rcParams.update({'font.size': 18}) + identifier_uniform = ['2018lepto1', #'2018lepto4', '2018lepto5', @@ -32,14 +34,14 @@ identifier = ['2018lepto1', '2019lepto24', '2019lepto27', '2019lepto30', - #'2020lepto04', + '2020lepto04', '2020lepto06', '2020lepto16', - #'2020lepto19', + '2020lepto19', '2020lepto20' ] -amf = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1] +custom_amf = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1] #colors = ['dimgray', 'dimgrey', 'gray', 'grey', 'darkgray', 'darkgrey', 'silver', 'lightgray', 'lightgrey', 'gainsboro', 'whitesmoke'] colorss = ['g', 'b', 'r', 'y', 'c', 'm', 'k'] all = [] @@ -54,10 +56,16 @@ for ident in identifier_uniform: av = avgNestedLists(all) new_av = avgNestedLists(new_all) -fig = plt.figure() +fig = plt.figure(figsize=(8.27, 11.69/2)) ax = fig.add_subplot(111) -ax.plot(amf, av, 'o', color = 'darkorange', label = 'normal') -ax.plot(amf, new_av, 'o', label = 'uniform') +ax.plot(custom_amf, av, 'o', label = 'normal') +#ax.plot(amf, new_av, 'o', label = 'uniform') + +sinv, sinc = curve_fit(gain_curve_fit, custom_amf, av, [2, 3]) +predict = [] +for f in custom_amf: + G = np.max(av) / np.sqrt(1 + (2 * ((np.pi * f * sinv[0]) ** 2))) + predict.append(G) tau = [] f_c = [] @@ -76,8 +84,10 @@ for ID in identifier: f_c.append(f_cutoff) fit.append(gain_curve_fit(amf, *sinv)) fit_amf.append(amf) + ax.axvline(x=f_cutoff, ymin=0, ymax=5, color='C0', ls='-', alpha=0.5, label='cutoff frequency') -# uniformed: 2018lepto5, 2018lepto1, 2018lepto76, 2018lepto98, 2020lepto06, 2019lepto24, 2020lepto4 + +# uniformed: 2018lepto1, 2018lepto5, 2018lepto76, 2018lepto98, 2020lepto06, 2019lepto24, 2020lepto06 tau_uniform = [] f_c_uniform = [] @@ -98,6 +108,7 @@ for ID in identifier_uniform: fit_uniform.append(gain_curve_fit(amf, *sinv)) fit_amf_uniform.append(amf) + colors = plt.cm.flag(np.linspace(0,1,len(fit_uniform))) #for ff ,f in enumerate(fit_uniform): @@ -106,13 +117,15 @@ colors = plt.cm.flag(np.linspace(0,1,len(fit_uniform))) ax.set_xscale('log') ax.set_yscale('log') -ax.set_title('gain average all fish uniform') ax.set_ylabel('gain [Hz/(mV/cm)]') -ax.set_xlabel('envelope_frequency [Hz]') -ax.set_ylim(0.0008, ) -ax.plot(f_c, np.full(len(identifier), 0.0015), 'o', alpha = 0.5, c = 'darkorange', label = 'normal cutoff frequencies') -ax.plot(f_c_uniform, np.full(len(identifier_uniform), 0.002), 'o', alpha = 0.5, c = 'C0', label = 'uniform cutoff frequencies') -ax.legend(loc = 'center left') +ax.set_xlabel('envelope frequency [Hz]') +ax.set_xlim(0.0007, 1.5) +ax.set_ylim(0.001, 10) +ax.plot(custom_amf, predict) +#ax.plot(f_c, np.full(len(identifier), 0.0015), 'o', color = 'C0', alpha = 0.5, label = 'normal cutoff frequencies') +#ax.plot(f_c_uniform, np.full(len(identifier_uniform), 0.002), 'o', alpha = 0.5, c = 'C0', label = 'uniform cutoff frequencies') +#ax.legend(loc = 'center left') + plt.show() embed() diff --git a/apteronotus_code/sin_all_normal.py b/apteronotus_code/sin_all_model.py similarity index 85% rename from apteronotus_code/sin_all_normal.py rename to apteronotus_code/sin_all_model.py index 60f9038..e86bbe7 100644 --- a/apteronotus_code/sin_all_normal.py +++ b/apteronotus_code/sin_all_model.py @@ -7,20 +7,20 @@ from jar_functions import gain_curve_fit from jar_functions import avgNestedLists -identifier = [#'2018lepto1', - #'2018lepto4', - #'2018lepto5', - #'2018lepto76', +identifier = ['2018lepto1', + '2018lepto4', + '2018lepto5', + '2018lepto76', '2018lepto98', - #'2019lepto03', - #'2019lepto24', - #'2019lepto27', - #'2019lepto30', - #'2020lepto04', - #'2020lepto06', - #'2020lepto16', + '2019lepto03', + '2019lepto24', + '2019lepto27', + '2019lepto30', + '2020lepto04', + '2020lepto06', + '2020lepto16', '2020lepto19', - #'2020lepto20' + '2020lepto20' ] amf = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1] @@ -62,7 +62,7 @@ for ident in identifier: av = avgNestedLists(all) embed() -fig = plt.figure() +fig = plt.figure(figsize=(8.27,11.69/2)) ax = fig.add_subplot(111) ax.plot(amf, av, 'o', c = 'C0', label = 'gain') diff --git a/eigenmannia_code/eigenmannia_jar_subplot.py b/eigenmannia_code/eigenmannia_jar_subplot.py index 4e03d4c..4742f0e 100644 --- a/eigenmannia_code/eigenmannia_jar_subplot.py +++ b/eigenmannia_code/eigenmannia_jar_subplot.py @@ -12,7 +12,7 @@ from jar_functions import get_time_zeros from jar_functions import import_data_eigen from scipy.signal import savgol_filter -plt.rcParams.update({'font.size': 18}) +#plt.rcParams.update({'font.size': 18}) base_path = 'D:\\jar_project\\JAR\\eigenmannia\\deltaf' @@ -99,7 +99,7 @@ for ID in identifier: # plt.title('spectogram %s, deltaf: %sHz' %tuple(ID_delta_f)) # plt.xlim(times[0],times[-1]) -fig = plt.figure(figsize = (20,20)) +fig = plt.figure(figsize = (8.27, 11.69/2)) 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)