Syndicat des Apiculteurs de la Région Est
Page d'accueil
Blog
Sorties, expos, manifestations...
Actualité syndicale
Réglementation
Presse
Nuisibles
Publications UNAF
Vie au rucher
Divers (photos, recettes, anecdotes...)
Api Infos
Accès Membre
Blog
Syndicat des Apiculteurs de la Région Est
Contact
Vidéos
Accueil
Analyses des données
Analyses des données
- numpy - pandas - openpyxl - matplotlib - panel==0.13.1a2
0
1.Upload un fichier xlsx téléchargé sur Optibee 2.Ploter!
Plot
import matplotlib import matplotlib.pyplot as plt import asyncio import panel as pn import datetime import pandas as pd import asyncio from panel.io.pyodide import show from pyodide import create_proxy import io ########## def Setup_Button_Listeners(): btnList = document.querySelectorAll(".button") for i in range(len(btnList)): e = document.getElementById(btnList[i].id) btn_event = create_proxy(Process_Button) e.addEventListener("click", btn_event) async def Process_Button(event): if document.getElementById("evtMsg").innerHTML == '100': # button plot_it fig = await process_file() pyscript.write('plot', fig) async def process_file(*args, **kwargs): if file_input.value is not None : file = pd.ExcelFile(file_input.value) data=pd.read_excel(file_input.value,sheet_name=file.sheet_names[1]) # sheet_name = 'C.N.' n, m = data.shape nb_j = 12 * n // (24 * 60) D = [data['Date'][0]] P=[data['Poids'][0]] T = [data['Température'][0]] err=[0] Tc=[data['Température couvain'][0]] for i in range(0, n - 1): D.append(data['Date'][i]) P.append(data['Poids'][i]) T.append(data['Température'][i]) err.append(0) D[i] = D[i].split(' ') D[i] = D[i][0].split('-') + D[i][1].split(':') D[i] = datetime.datetime(int(D[i][0]), int(D[i][1]), int(D[i][2]), int(D[i][3]), int(D[i][4]), int(D[i][5])) Tc.append(data['Température couvain'][i]) # if data['Température couvain'][i]!='NA': # Tc.append(data['Température couvain'][i]) print(D,P) def annomalie_poid(P): for i in range(len(P) - 1): if abs(P[i] - P[i + 1]) > 1: # P[i][1] = P[i + 1][0] - P[i][0] err[i] = 1 P[i] = P[i - 1] def nb_buttineuses(data, n): nb_j = 12 * n // (24 * 60) heure = list( map(int, data['Date'][0].split(' ')[0].split('-') + data['Date'][0].split(' ')[1].split(':'))) t0 = datetime.datetime(heure[0], heure[1], heure[2], 0, 0, 0) heure1 = list(map(int, data['Date'][n - 1].split(' ')[0].split('-') + data['Date'][n - 1].split(' ')[ 1].split(':'))) t1 = datetime.datetime(heure1[0], heure1[1], heure1[2], 0, 0, 0) nb_j = datetime.timedelta(days=(t1 - t0).days) nb_j = nb_j.days print("nb jour=", nb_j) Lj = [[] for i in range(nb_j + 1)] nj_act = 0 Lj[0].append([0, t0]) for i in range(1, n): # heure=data['Date'][i].split(' ') heure = list(map(int, data['Date'][i].split(' ')[0].split('-') + data['Date'][i].split(' ')[1].split( ':'))) time = datetime.datetime(heure[0], heure[1], heure[2], heure[3], heure[4], heure[5]) # tdelta=datetime.timedelta(days=time.day-t0.day) if Lj[nj_act] != [] and Lj[nj_act][0][1].day != time.day: nj_act += 1 Lj[nj_act].append([i, time]) # print(nj_act) else: Lj[nj_act].append([i, time]) D = [] dP = [0] moy = [] miel_j = [0] miel_tot = [0] # ventil = [] # tracey=[] # tracex = [] Lj.pop() while Lj[-1] == []: Lj.pop() for day in Lj: anomalie = False for id in day: if err[id[0]] != 0: anomalie = True if anomalie: dP.append(dP[-1]) D.append(day[0][1]) miel_j.append(miel_j[-1]) miel_tot.append(miel_tot[-1]) # ventil.append(ventil[-1]) else: min = 1000 h7 = 0 ibis = 0 for id in day: i, date = id if date.hour > 6 and date.hour < 9 and min > data['Poids'][day[ibis][0]]: min = data['Poids'][day[ibis][0]] else: min = max(0, min) if date.hour == 7: h7 = data['Poids'][day[ibis][0]] else: h7 = max(h7, 0) ibis += 1 # print(day[1],min) dP.append(max((h7 - min) / (80 * 10 ** -6) / 500,0)) miel_j.append((data['Poids'][day[-1][0]] - data['Poids'][day[0][0]])) # ventil.append((max_n[0] - data['Poids'][day[6 * 60 // 12][0]])*10) if miel_tot == []: miel_tot.append(miel_j[-1]) else: miel_tot.append(miel_tot[-1] + miel_j[-1]) D.append(day[0][1]) if len(dP) <= 2: moy.append(sum(x for x in dP) / (len(dP))) else: moy.append(sum((dP[-1], dP[-2], dP[-3])) / 3) dP.pop() miel_j.pop() miel_tot.pop() moy.pop(0) moy.append((dP[-1] + dP[-2]) / 2) return D, err, moy, miel_j, miel_tot annomalie_poid(P) d, err,moy, miel_j, miel_tot = nb_buttineuses(data, n) fig, axs = plt.subplots(4,1) axs[0].plot(D, P, linestyle='-', color='b', label='Poids') first=False for i in range(len(err)): if err[i]!=0 and not first: first=True axs[0].axvline(D[i], linestyle='--',color='k',label='annomalie de poids') elif err[i]!=0 and first: axs[0].axvline(D[i], linestyle='--', color='k') axs[0].set_title('Poids et erreur') axs[0].legend() axs[0].tick_params('x', labelrotation=20) axs[0].grid() axs[1].plot(d, moy, linestyle='-', color='g', label='nombre de buttineuses') axs[1].set_title('Activité de la ruche') axs[1].legend() axs[1].tick_params('x', labelrotation=20) axs[1].grid() axs[2].plot(d, miel_j, linestyle='-', color='r', label=' miel journalier (depuis j1)') axs[2].plot(d, miel_tot, linestyle='-', color='y', label='miel total') axs[2].set_title('Evolution du miel (en kg)') axs[2].legend() axs[2].tick_params('x', labelrotation=20) axs[2].grid() axs[3].plot(D, T, linestyle='-', color='b',label='Température') axs[3].plot(D, Tc, linestyle='-', color='y', label='Température du couvain') axs[3].legend() axs[3].set_title('Températures') axs[3].tick_params('x', labelrotation=20) axs[3].grid() # fig.tight_layout() fig.set_figwidth(15) fig.set_figheight(40) fig return fig else: print("mauvaise feuille") file_input = pn.widgets.FileInput(accept='.xlsx', width=180) row = pn.Row(file_input, height=75) await show(row, 'fileinput') Setup_Button_Listeners()
Vous devez être connecté pour poster un commentaire