80 lines
3.4 KiB
Python
80 lines
3.4 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.dates as mdates
|
|
import matplotlib.colors as mcolors
|
|
import matplotlib.gridspec as gridspec
|
|
from IPython import embed
|
|
from scipy import stats
|
|
import os
|
|
from IPython import embed
|
|
from params import *
|
|
import datetime
|
|
import itertools
|
|
import pandas as pd
|
|
|
|
if __name__ == '__main__':
|
|
###################################################################################################################
|
|
# parameter
|
|
save_path = '../../thesis/Figures/Results/'
|
|
inch=2.54
|
|
# color_emf = ['#a2a2a2', '#729ece', '#ed665d']
|
|
|
|
|
|
# lists
|
|
eigen = []
|
|
males = []
|
|
females = []
|
|
###################################################################################################################
|
|
# load data
|
|
###################################################################################################################
|
|
# load all the data of one day
|
|
for index, filename_idx in enumerate([0,1,2,3]):
|
|
filename = sorted(os.listdir('../data/'))[filename_idx]
|
|
all_q10 = np.load('../data/'+filename+'/fish_freq_q10.npy', allow_pickle=True)
|
|
power_means = np.load('../data/' + filename + '/power_means.npy', allow_pickle=True)
|
|
names = np.load('../data/' + filename + '/fish_species.npy', allow_pickle=True)
|
|
|
|
for fish_number in range(len(power_means)):
|
|
if power_means[fish_number] >= -90.0:
|
|
|
|
# if all_q10[fish_number,2] <560:
|
|
# eigen.append(all_q10[fish_number,2])
|
|
# elif all_q10[fish_number,2] >=760:
|
|
# males.append(all_q10[fish_number, 2])
|
|
# elif (all_q10[fish_number,2]>=560) and (all_q10[fish_number,2]<760):
|
|
# females.append(all_q10[fish_number, 2])
|
|
if names[fish_number] == 'Eigenmannia':
|
|
eigen.append(all_q10[fish_number,2])
|
|
elif names[fish_number] == 'Apteronotus' and all_q10[fish_number,2] >=760:
|
|
males.append(all_q10[fish_number, 2]) and all_q10[fish_number,2]>=400 and all_q10[fish_number,2]<760
|
|
elif names[fish_number] == 'Apteronotus':
|
|
females.append(all_q10[fish_number, 2])
|
|
|
|
|
|
# eigen.extend(all_q10[:,2][all_q10[:,2]<500])
|
|
# males.extend(all_q10[:,2][all_q10[:,2]>=760])
|
|
# females.extend(all_q10[:,2][(all_q10[:,2]>=500)&(all_q10[:,2]<760)])
|
|
|
|
# plot
|
|
fig, ax = plt.subplots(1, 1, figsize=(16 /inch, 8 /inch))
|
|
fig.subplots_adjust(left=0.1, bottom=0.15, right=0.95, top=0.95)
|
|
|
|
# ax.hist(eigen, bins=np.arange(400, 1000, 20), color=color_efm[0], label=labels[0])
|
|
# ax.hist(females, bins=np.arange(400, 1000, 20), color=color_efm[1], label=labels[1])
|
|
# ax.hist(males, bins=np.arange(400, 1000, 20), color=color_efm[2], label=labels[2])
|
|
ax.hist([eigen,females,males], bins=np.arange(400, 1000, 20), histtype='bar', stacked=True, label=labels[0:3], color=color_efm[0:3])
|
|
# ax.hist(females, bins=np.arange(400, 1000, 20), color=color_efm[1], label=labels[1])
|
|
# ax.hist(males, bins=np.arange(400, 1000, 20), color=color_efm[2], label=labels[2])
|
|
|
|
ax.make_nice_ax()
|
|
ax.set_xlabel('EODf [Hz]', fontsize=fs)
|
|
ax.set_ylabel('n', fontsize=fs)
|
|
ax.set_yticks([0,5,10,15,20,25])
|
|
ax.set_xlim([400,1000])
|
|
fig.legend(loc='upper right')
|
|
# fig.savefig(save_path+'EODf_hist.png')
|
|
fig.savefig(save_path+'EODf_hist.pdf')
|
|
plt.show()
|
|
|
|
embed()
|