Skip to content

Commit

Permalink
onglet supplementaire traitement + sauvegarde parametres - fichier ec…
Browse files Browse the repository at this point in the history
…hange variables
  • Loading branch information
YLefrais committed Oct 12, 2020
1 parent 19eda82 commit e677df4
Show file tree
Hide file tree
Showing 18 changed files with 1,242 additions and 378 deletions.
24 changes: 24 additions & 0 deletions LIBStick.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[LIBStick_traitement]
rep_travail_L_trait = ./

[LIBStick_extraction]
flag_zone2_L_ext = 1
flag_2D_L_ext = 0
flag_3D_L_ext = 0
flag_image_brute_L_ext = False
borne_zone1_inf_L_ext = 528.0
borne_zone1_sup_L_ext = 543.0
borne_zone2_inf_L_ext = 525.0
borne_zone2_sup_L_ext = 562.0
rep_travail_L_ext = /home/yannick/Bureau/LIBS/Scripts_divers_pour_LIBS

[LIBStick_compare]
flag_denominateur_L_comp = 1
flag_2D_L_comp = 1
flag_3D_L_comp = 0
type_extension_L_comp = *.tsv
borne_zone1_inf_L_comp = 529.0
borne_zone1_sup_L_comp = 542.0
borne_zone2_inf_L_comp = 534.7
borne_zone2_sup_L_comp = 535.8
rep_travail_L_comp = /home/yannick/Bureau/LIBS/Scripts_divers_pour_LIBS
1,112 changes: 882 additions & 230 deletions LIBStick.py

Large diffs are not rendered by default.

60 changes: 26 additions & 34 deletions LIBStick_comp_spectres.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import numpy,os,pandas
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as plt3d
import LIBStick_echange_vars

#rep_travail="/home/yannick/Bureau/LIBS/Scripts_divers_pour_LIBS/Fluorose_LIBS/Spectres_moyen/528-543/"
#bornes_moyenne_spectres=numpy.linspace(528,543,150)
limites_zone1=[534.5 , 535.8]
limites_zone2=[528.0 , 543.0]
limites_spectre=[528.0, 543.0]
Expand All @@ -24,29 +21,29 @@ def repertoire_de_travail(rep_script,rep_travail_relatif):
rep_travail=rep_script+"/"+rep_travail_relatif
return rep_travail

def creation_liste_fichiers(rep_travail,type_extension_L_comp):
def creation_liste_fichiers(rep_travail,type_extension):
os.chdir(rep_travail)
liste=[]
if type_extension_L_comp.get() == "*.mean" :
if type_extension == "*.mean" :
for fichier in os.listdir():
if (os.path.isfile(fichier) and fichier[-4:] == "mean") :
liste.append(fichier)
if type_extension_L_comp.get() == "*.tsv" :
if type_extension == "*.tsv" :
for fichier in os.listdir():
if (os.path.isfile(fichier) and fichier[-3:] == "tsv") :
liste.append(fichier)
liste.sort()
return liste

def lit_spectre(fichier,tableau_abscisses,type_extension_L_comp):
if type_extension_L_comp.get() == "*.mean" :
def lit_spectre(fichier,tableau_abscisses,type_extension):
if type_extension == "*.mean" :
spectre=numpy.loadtxt(fichier,delimiter="\t",usecols=[0],dtype=float,encoding="Latin-1")
#tableau_abscisses=lit_tableau_abscisses()
spectre=numpy.vstack((tableau_abscisses,spectre))
# spectre=numpy.zeros((0,document.shape[0]))
# for ligne in document :
# spectre=numpy.row_stack((spectre,ligne))
if type_extension_L_comp.get() == "*.tsv" :
if type_extension == "*.tsv" :
spectre=numpy.loadtxt(fichier,delimiter="\t",usecols=[1],dtype=float,encoding="Latin-1")
spectre=numpy.vstack((tableau_abscisses,spectre))
return spectre
Expand All @@ -56,8 +53,8 @@ def lit_tableau_abscisses():
tableau_abscisses=numpy.loadtxt("tableau_abscisses.txt", delimiter="\t", usecols=[0])
return tableau_abscisses

def creer_tableau(liste,type_extension_L_comp):
if type_extension_L_comp.get() == "*.mean" :
def creer_tableau(liste,type_extension):
if type_extension == "*.mean" :
i=0
for nom_fichier in liste :
if i==0 :
Expand All @@ -69,11 +66,7 @@ def creer_tableau(liste,type_extension_L_comp):
fichier_entree=numpy.loadtxt(nom_fichier, delimiter="\t", usecols=[0])
tableau_comparatif=numpy.row_stack((tableau_comparatif,fichier_entree))
i=i+1
# if type_extension_L_comp.get() == "*.tsv" :
# tableau_comparatif=graphique_lit_tableau()
# print(tableau_comparatif)
# print(tableau_comparatif.shape)
if type_extension_L_comp.get() == "*.tsv" :
if type_extension == "*.tsv" :
i=0
for nom_fichier in liste :
if i==0 :
Expand Down Expand Up @@ -101,17 +94,16 @@ def creer_DataFrame(tableau_comparatif,liste, tableau_abscisses):
DataFrame_comparatif=pandas.DataFrame(data=tableau_comparatif, index=liste, columns=tableau_abscisses)
return DataFrame_comparatif

def creer_DataFrame_resultats(DataFrame_comparatif, limites_zone1,limites_zone2,flag_denominateur_L_comp):
if flag_denominateur_L_comp.get() == 1 :
def creer_DataFrame_resultats(DataFrame_comparatif, limites_zone1,limites_zone2,flag_denominateur):
print(DataFrame_comparatif)
if flag_denominateur == 1 :
DataFrame_tableau_calculs=pandas.DataFrame()
Sous_DataFrame = DataFrame_comparatif.loc[ : , limites_zone1[0]:limites_zone1[1]]
#print(Sous_DataFrame)
DataFrame_tableau_calculs["Somme zone 1"] = Sous_DataFrame.sum(axis=1)
Sous_DataFrame = DataFrame_comparatif.loc[ : , limites_zone2[0]:limites_zone2[1]]
#print(Sous_DataFrame)
DataFrame_tableau_calculs["Somme zone 2"] = Sous_DataFrame.sum(axis=1)
DataFrame_tableau_calculs["Rapport"]=DataFrame_tableau_calculs["Somme zone 1"] / DataFrame_tableau_calculs["Somme zone 2"]
if flag_denominateur_L_comp.get() == 0 :
if flag_denominateur == 0 :
DataFrame_tableau_calculs=pandas.DataFrame()
Sous_DataFrame = DataFrame_comparatif.loc[ : , limites_zone1[0]:limites_zone1[1]]
DataFrame_tableau_calculs["Somme zone 1"] = Sous_DataFrame.sum(axis=1)
Expand Down Expand Up @@ -187,37 +179,37 @@ def graphique_lit_tableau():
###############################################################################
# programme principal
###############################################################################
def main(rep_travail, tableau_bornes,type_extension_L_comp,flag_denominateur_L_comp):
def main(rep_travail, liste_fichiers, tableau_bornes,type_extension,flag_denominateur, flag_2D, flag_3D):
os.chdir(rep_travail)
liste=LIBStick_echange_vars.L_comp_liste_fichiers
tableau_comparatif=creer_tableau(liste,type_extension_L_comp)
tableau_comparatif=creer_tableau(liste_fichiers,type_extension)
#tableau_abscisses=lit_tableau_abscisses()
DataFrame_comparatif=creer_DataFrame(tableau_comparatif,liste,tableau_abscisses)
DataFrame_comparatif=creer_DataFrame(tableau_comparatif,liste_fichiers,tableau_abscisses)
print(DataFrame_comparatif)
limites_zone1[0]=tableau_bornes[0,0]
limites_zone1[1]=tableau_bornes[0,1]
limites_zone2[0]=tableau_bornes[1,0]
limites_zone2[1]=tableau_bornes[1,1]

DataFrame_resultats=creer_DataFrame_resultats(DataFrame_comparatif,limites_zone1,limites_zone2,flag_denominateur_L_comp)
if flag_denominateur_L_comp.get() == 1 :
#DataFrame_resultats=creer_DataFrame_resultats(DataFrame_comparatif,limites_zone1,limites_zone2,flag_denominateur_L_comp)
DataFrame_resultats=creer_DataFrame_resultats(DataFrame_comparatif,limites_zone1,limites_zone2,flag_denominateur)
if flag_denominateur == 1 :
DataFrame_comparatif=pandas.concat([DataFrame_comparatif, DataFrame_resultats["Rapport"]], axis=1)
DataFrame_comparatif=DataFrame_comparatif.sort_values(by=["Rapport"])
LIBStick_echange_vars.L_comp_DataFrame_resultats = DataFrame_resultats = DataFrame_resultats.sort_values(by=["Rapport"])
DataFrame_resultats = DataFrame_resultats.sort_values(by=["Rapport"])
enregistre_DataFrame_resultats(DataFrame_resultats)

if flag_denominateur_L_comp.get() == 0 :
#DataFrame_resultats=creer_DataFrame_resultats(DataFrame_comparatif,limites_zone1,limites_zone2,flag_denominateur_L_comp)
if flag_denominateur == 0 :
DataFrame_comparatif=pandas.concat([DataFrame_comparatif, DataFrame_resultats["Somme zone 1"]], axis=1)
DataFrame_comparatif=DataFrame_comparatif.sort_values(by=["Somme zone 1"])
LIBStick_echange_vars.L_comp_DataFrame_resultats = DataFrame_resultats = DataFrame_resultats.sort_values(by=["Somme zone 1"])
DataFrame_resultats = DataFrame_resultats.sort_values(by=["Somme zone 1"])
enregistre_DataFrame_resultats(DataFrame_resultats)

tableau_comparatif=Convertir_Dataframe_tableau(DataFrame_comparatif)
tableau8bits=tableau_256gris(tableau_comparatif)
if LIBStick_echange_vars.L_comp_flag_2D :
if flag_2D :
graphique_creation(tableau8bits, "Echantillons classés", limites_spectre)
if LIBStick_echange_vars.L_comp_flag_3D :
if flag_3D :
graphique_3D_creation(tableau8bits, "Echantillons classés", limites_spectre)
graphique_sauvegarde(tableau8bits)

return DataFrame_resultats

27 changes: 8 additions & 19 deletions LIBStick_creation_spectre_moyen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,44 @@
"""

import numpy,os
import LIBStick_echange_vars

###############################################################################
# 1- fonctions
###############################################################################
def extraction_spectres(tableau_norm):
#tableau_extrait=LIBStick_creation_tableau_norm.tableau_norm.copy()
def extraction_spectres(tableau_norm, nombre_fichiers, bornes_moyenne_spectres):
tableau_extrait=tableau_norm.copy()
# print ("format tableau initial : ")
# print(tableau_extrait.shape)
indice_premier=(LIBStick_echange_vars.L_ext_bornes_moyenne_spectres[0]-1)
indice_dernier=(LIBStick_echange_vars.L_ext_bornes_moyenne_spectres[1]-1)
indice_premier=(bornes_moyenne_spectres[0]-1)
indice_dernier=(bornes_moyenne_spectres[1]-1)
cols_supprime_debut=list()
cols_supprime_fin=list()
if indice_premier > 0 :
for i in range(0,indice_premier) :
cols_supprime_debut.append(i)
if indice_dernier < LIBStick_echange_vars.L_ext_nombre_fichiers :
for i in range(indice_dernier+1, LIBStick_echange_vars.L_ext_nombre_fichiers):
if indice_dernier < nombre_fichiers :
for i in range(indice_dernier+1, nombre_fichiers):
cols_supprime_fin.append(i)
cols_supprime=cols_supprime_debut+cols_supprime_fin
# print ("colonnes à supprimer : ")
# print(cols_supprime)

tableau_extrait=numpy.delete(tableau_extrait, cols_supprime, axis=1)
# print ("format tableau extrait : ")
# print(tableau_extrait.shape)
return tableau_extrait

def creation_spectre_moyen(tableau_extrait):
spectre_moyen=tableau_extrait.sum(axis=1)
spectre_moyen=spectre_moyen/tableau_extrait.shape[1]
# print("format spectre moyen : ")
# print(spectre_moyen.shape)
return spectre_moyen

def enregistre_fichier(spectre_moyen, nom_echantillon, bornes):
nom_fichier=nom_echantillon+"_spectre_moyen_"+ str(bornes[0])+"_"+str(bornes[1])+".mean"
nom_fichier=str(numpy.char.replace(nom_fichier, " ", "_"))
numpy.savetxt(nom_fichier,spectre_moyen,delimiter="\t", newline="\n")
# print (nom_fichier)

###############################################################################
# programme principal
###############################################################################
def main (rep_travail,nom_echantillon, bornes) :
# print("===========================================")
def main (rep_travail,nom_echantillon, bornes, nombre_fichiers, bornes_moyenne_spectres) :
os.chdir(rep_travail)
tableau_norm=numpy.loadtxt("tableau_normalisé.txt",delimiter="\t",dtype=float,encoding="Latin-1")
tableau_extrait=extraction_spectres(tableau_norm)
tableau_extrait=extraction_spectres(tableau_norm, nombre_fichiers, bornes_moyenne_spectres)
spectre_moyen=creation_spectre_moyen(tableau_extrait)
enregistre_fichier(spectre_moyen, nom_echantillon, bornes)
return spectre_moyen
12 changes: 3 additions & 9 deletions LIBStick_creation_tableau_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
import sys,os,numpy
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as plt3d
import LIBStick_echange_vars

#import matplotlib.ticker as tck
#import matplotlib.image as mpimg
#import LIBStick_interface

sys.path.insert(0,os.path.join(os.path.expanduser("~"),"Desktop"))
sys.path.insert(0,"./dossier_mes_modules/")
Expand Down Expand Up @@ -69,7 +64,6 @@ def creer_tableau_abscisses(liste):
fichier0=numpy.loadtxt(liste[0], delimiter="\t", usecols=[0])
tableau_abscisses=numpy.zeros((fichier0.shape[0],0))
tableau_abscisses=numpy.column_stack((tableau_abscisses,fichier0))
# print(tableau_abscisses)
return tableau_abscisses

###############################################################################
Expand Down Expand Up @@ -164,7 +158,7 @@ def graphique_sauvegarde(tableau8bits) :
###############################################################################
# programme principal
###############################################################################
def main (rep_travail,nom_echantillon,bornes) :
def main (rep_travail,nom_echantillon,bornes, flag_2D, flag_3D) :
global tableau_norm
liste_fichiers=creation_liste_fichiers(rep_travail)

Expand All @@ -181,9 +175,9 @@ def main (rep_travail,nom_echantillon,bornes) :
tableau8bits_norm=tableau_transpose_256gris(tableau_norm)
graphique_sauvegarde(tableau8bits_norm)

if LIBStick_echange_vars.L_ext_flag_2D :
if flag_2D == 1 :
graphique_creation(tableau8bits_norm,nom_echantillon,bornes)
if LIBStick_echange_vars.L_ext_flag_3D == 1 :
if flag_3D == 1 :
graphique_3D_creation(tableau8bits_norm,nom_echantillon,bornes)


4 changes: 2 additions & 2 deletions LIBStick_datas/ions/N.csv
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@
84 989.109 220 56 22.0
85 996.186 160 67 16.0
86 996.934 220 57 22.0
87 1,002.33 285 41 28.5
88 1,003.55 220 58 22.0
87 1002.33 285 41 28.5
88 1003.55 220 58 22.0
Binary file added LIBStick_datas/logo_libstick/ logo_0.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/ logo_0.75x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/ logo_1.5x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/ logo_2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/ logo_3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/ logo_4x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LIBStick_datas/logo_libstick/logo_1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 0 additions & 54 deletions LIBStick_echange_vars.py

This file was deleted.

2 changes: 1 addition & 1 deletion LIBStick_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def affiche_tableau_periodique(DataFrame_tableau_periodique):
ligne=ligne_tableau[5]
colonne=ligne_tableau[6]
couleur=ligne_tableau[8]
boutton = case_classification(frame1, nom, symbole, Z, ligne, colonne, couleur)
bouton = case_classification(frame1, nom, symbole, Z, ligne, colonne, couleur)


fenetre=tkinter.Tk()
Expand Down
Loading

0 comments on commit e677df4

Please sign in to comment.