-
Notifications
You must be signed in to change notification settings - Fork 0
/
_VariationDeriveEntropie_Angle
77 lines (69 loc) · 3.43 KB
/
_VariationDeriveEntropie_Angle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
"""
Auteur: Olivier Bernard
Creer 6 Juin 2019 a 13:48
Entrer: Clavier
Sortie: Moniteur
Code permettant le lecture de document ds vs l'angle et d'en calculer les dérivé puis de tracer le dds vs l'angle
"""
import numpy as np
from matplotlib import pyplot as plt
import os.path
import seaborn as sns
def trace_ddeltaSvsAng(angle_min, doc, cryst, champ , ech, fpath, date,crystt):
# fpath = 'C:/Users/Laurier/Desktop/EMCR/02- Data/03-Data_'
#fpath = 'C:/Users/Laurier/Desktop/EMCR/02- Data'
def deriv(x1, x2, y1, y2):
dx = x2 - x1
dy = y2 - y1
return dy/dx
nom_doc = doc + str(angle_min) + '_ds_champ_' + str(champ)+'.txt'
file = open(os.path.join(fpath+str(cryst)+ '/' + str(ech) + '/' + str(date), nom_doc), 'r')
var =np.loadtxt(os.path.join(fpath+str(cryst)+ '/' + str(ech) + '/' + str(date),nom_doc) ,delimiter=',', skiprows= 1)
file.close()
NUM_COLORS = len(var[:,1])
LINE_STYLES = ['solid', 'dashed', 'dashdot', 'dotted']
NUM_STYLES = len(LINE_STYLES)
clrs = sns.color_palette('husl', n_colors=NUM_COLORS)
jj=0
for tempi in var[:,1].tolist():
fd=open(os.path.join(fpath+str(cryst)+ '/' + str(ech) + '/' + str(date)+'/04-dds', '_'+doc +'(ddSvsA)'+ str(tempi) +'K'+ str(champ)+ 'T'+'.txt'), "w")
fd.write(str(r' d Delta S ') + ','+ str('angle') + ',' + 'Temperature (K)' +','+ 'Champ (H)'+ "\n")
nom_d = doc +'(dSvsA)'+ str(tempi) +'K'+ str(champ)+ 'T'+'.txt'
file2 = open(os.path.join(fpath+str(cryst)+ '/' + str(ech) + '/' + str(date), nom_d) , 'r')
var2 =np.loadtxt(os.path.join(fpath+str(cryst)+ '/' + str(ech) + '/' + str(date),nom_d) ,delimiter = ',',skiprows= 1)
file2.close()
i=0
xx = []
yy = []
omg2 = (var2[:,1].tolist())
omg= len(omg2)
for ang in var2[:omg-1,1].tolist() :
angle_s = var2[:,1].tolist()
delta_s = var2[:,0].tolist()
lo = deriv(ang, angle_s[i+1], delta_s[i], delta_s[i+1])
moy_angle = (ang + angle_s[i+1])/2
yy.append(lo)
xx.append(moy_angle)
fd.write(str(lo) + ',' + str(moy_angle) +','+ str(tempi)+','+ str(champ) + "\n")
i+=1
file.close()
font = 21
font2 = 15.5
#plt.figure()
#plt.axvline(x=80, linewidth= 0.5, color='grey')
#plt.axvline(x=100, linewidth= 0.5, color='grey')
plt.axvline(x=90, linewidth= 0.5, color='grey')
#plt.axvline(x=50, linewidth= 0.5, color='grey')
#plt.axvline(x=130, linewidth= 0.5, color='grey')
plt.axhline(y=0, linewidth= 0.5, color='grey')
plt.legend( loc='best', ncol=3, frameon = True,fontsize = font2-2)
plt.tick_params(axis='both', which='major', labelsize=font)
graph = plt.plot(xx[:], yy[:], label = str(tempi)+'K')
graph[0].set_color(clrs[jj])
graph[0].set_linestyle(LINE_STYLES[jj%NUM_STYLES])
plt.xlim(0, 180)
plt.xlabel(r'Angle ($\theta^{\circ}$)',fontsize=font) # axe x angle
plt.ylabel(r'$-\frac{\partial \Delta S_{M}}{\partial \theta}$',fontsize=font) #axe y delta s
#plt.title(r'Variation de $-\partial \Delta S/\partial \theta$ en fonction de $\theta$ du '+str(crystt)+' échantillon ' +ech+' sous un champ magnétique de '+str(champ)+'T pour une température variant de 2.5K à '+ str(tempi) +'K',fontsize = font,wrap=True)
jj+=1