line_tracking_of_fish_movement/plot_power_mean.py

59 lines
2.2 KiB
Python

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.gridspec as gridspec
from IPython import embed
import helper_functions as hf
from params import *
import os
import datetime
if __name__ == '__main__':
###################################################################################################################
# parameter and variables
# plot params
inch = 2.45
all_power_means = []
###################################################################################################################
# load all the data of one day
for filename_idx in [1, 4, 6]:
filename = sorted(os.listdir('../../../data/'))[filename_idx]
power_means = np.load('../data/' + filename + '/power_means.npy', allow_pickle=True)
all_power_means.extend(power_means)
###########################################################################################################
# plot power_mean histogram
fig0= plt.figure(figsize=[16 / inch, 12 / inch])
spec = gridspec.GridSpec(ncols=1, nrows=1, figure=fig0, hspace=0.5, wspace=0.5)
ax0 = fig0.add_subplot(spec[0, 0])
n, bin_edges = np.histogram(power_means, bins=20)
# n3 = n3 / np.sum(n3) / (bin_edges3[1] - bin_edges3[0])
ax0.bar(bin_edges[:-1] + (bin_edges[1] - bin_edges[0]) / 2, n, width=0.9 * (bin_edges[1] - bin_edges[0]))
ax0.set_xlabel('Power', fontsize=fs)
ax0.set_ylabel('n', fontsize=fs)
ax0.make_nice_ax()
###########################################################################################################
# plot power_mean histogram
fig1 = plt.figure(figsize=[16 / inch, 12 / inch])
spec = gridspec.GridSpec(ncols=1, nrows=1, figure=fig1, hspace=0.5, wspace=0.5)
ax1 = fig1.add_subplot(spec[0, 0])
n, bin_edges = np.histogram(all_power_means, bins=20)
# n3 = n3 / np.sum(n3) / (bin_edges3[1] - bin_edges3[0])
ax1.bar(bin_edges[:-1] + (bin_edges[1] - bin_edges[0]) / 2, n, width=0.9 * (bin_edges[1] - bin_edges[0]))
ax1.set_xlabel('Power', fontsize=fs)
ax1.set_ylabel('n', fontsize=fs)
ax1.make_nice_ax()
plt.show()