# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

#Tonda's data

fileName="Experimental data/Graphite HOPG1 overnight_-2 to 2T 330GHz 1.7K 000 (1).dat"
Data = np.loadtxt(open(fileName,'r'), skiprows = 22)
B_exp=Data[:,0] #Values of B in mT, therefore 1E3, zero is shifted by 24,7mT
ds_exp=Data[:,2] #Derivative of conductivity
Xch_data = Ych_data = ds_exp


#The other data
"""
fileName="Experimental data/322_NG_04K_345GHz.dat"
Data = np.loadtxt(open(fileName,'r'), skiprows=29)
B_exp=(Data[:,0])
Xch_data=(Data[:,1])
Ych_data=(Data[:,2])
ds_exp = ((Xch_data**2) + (Ych_data**2))**0.5 #Xch and Ych data combined
"""

#My data
"""
Natural graphite_0 to 12.5T 330GHz 1.6K 000.dat
Natural graphite_13 to 0T 330GHz 1.6K 000 (1).dat
NAtural graphite_0 to 1T 360GHz 1.5K 000.dat
Graphite_0 to 3T 340GHz 1.7K 002.dat
"""
"""
fileName="Experimental data/NAtural graphite_0 to 1T 360GHz 1.5K 000.dat"
Data = np.loadtxt(open(fileName,'r'), skiprows=21)
B_exp=(Data[:,1]) #Values of B in mT, therefore 1E3
Xch_data=(Data[:,2])
Ych_data=(Data[:,3])
ds_exp = ((Xch_data**2) + (Ych_data**2))**0.5 #Xch and Ych data combined
"""

#f=210E9
#T=5.5 #temperature in K
Fr_val = 16.5 #Magnetic field range in the plot, must be high enough
Fr_det_min = 0.05 #detailed section of that field, min value
Fr_det_max = 0.9 #max value
B_exp_det = B_exp
ds_exp_det = ds_exp

B_exp = B_exp[np.logical_and(-Fr_val<B_exp,B_exp<Fr_val)]
B_exp_det = B_exp_det[np.logical_and(Fr_det_min<B_exp_det,B_exp_det<Fr_det_max)]
Xch_data = 1E6*Xch_data[np.logical_and(-Fr_val<B_exp,B_exp<Fr_val)]
Ych_data = 1E6*Ych_data[np.logical_and(-Fr_val<B_exp,B_exp<Fr_val)]
ds_exp = - 1E6*ds_exp[np.logical_and(-Fr_val<B_exp,B_exp<Fr_val)]
ds_exp_det = ds_exp[np.logical_and(Fr_det_min<B_exp,B_exp<Fr_det_max)]

"""
fig,ax=plt.subplots() #xch and ych data separately
ax.plot(B_exp, -1*Xch_data, 'r')
ax.plot(B_exp, -1*Ych_data, 'g')
plt.xlabel('$B_{exp} (T)$', fontsize=15)            
plt.ylabel('experimental $-d\sigma_{xx}/dB$', fontsize=15)  
plt.title("Xch + Ych data separately")
"""
fig,ax=plt.subplots() #xch and ych data combined
ax.plot(B_exp, ds_exp, 'b')
plt.xlabel('$B$ (T)', fontsize=15)         
plt.gcf().subplots_adjust(left=0.14)   
plt.ylabel('$d\sigma_{xx}/dB$ (arb.u.)', fontsize=15)  
plt.title("HOPG při $T$ = 2 K", fontsize=15)

fig,ax=plt.subplots() #detailed section of combined data
ax.plot(B_exp_det, -1*ds_exp_det, 'b')
plt.xlabel('$B_{exp} (T)$', fontsize=15)            
plt.ylabel('experimental $-d\sigma_{xx}/dB$', fontsize=15)  
plt.title("Detail")


plt.show()