%pylab notebook
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib inline
from importlib import reload
import pandas as pd
from scipy.optimize import curve_fit
import scipy.ndimage as flt
from scipy.stats import linregress
from matplotlib import mlab as mlab
import xarray as xr
import json
import scipy
from astropy.table import Table, Column, MaskedColumn
from astropy.io import ascii
from scipy.signal import butter, filtfilt, lfilter
from urllib.request import urlopen
def linear_fit(x, a, b):
return a*x+b
def my_butter_filter(cutoff, fs, order = 32):
nyq = 0.5 * fs
normal_cutoff = cutoff / nyq
b, a = butter(order, normal_cutoff, btype='low', analog=False)
return b, a
def my_lowpass_filter(data, cutoff, fs, order = 32):
#scipy filtfilt
b, a = my_butter_filter(cutoff, fs, order = order)
return filtfilt(b, a, data)
#FS = 1 / dsp.get_sampling_step(current),... tj. 1/T
def lowpasss(t, s, cutoff, vb=False, order = 3):
f_sample = (1./(t[1]-t[0]))
sigma = f_sample/(2.*np.pi*cutoff)
return flt.gaussian_filter1d(s, sigma)
def my_bandstop_filter(data, lowcut, highcut, fs, order = 32):
nyq = 0.5 * fs
low = lowcut / nyq
high = highcut /nyq
b, a = butter(order, [low, high], btype = 'bandstop')
return filtfilt(b, a, data)
def bin_average(current, voltage, binsize, vb=False):
min_voltage = np.nanmin(voltage)
max_voltage = np.nanmax(voltage)
if binsize == 0.: return {'I': current, 'V': voltage} #binsize zero will returned the input values
voltage_bins = np.arange(min_voltage + 0.5*binsize, max_voltage - 0.5*binsize, binsize)
current_bins_mean = np.empty_like(voltage_bins)
voltage_bins_mean = np.empty_like(voltage_bins)
current_bins_std = np.empty_like(voltage_bins)
voltage_bins_std = np.empty_like(voltage_bins)
for i, voltage_bin in enumerate(voltage_bins):
bin_condition = (voltage_bin + 0.5 * binsize > voltage) & (voltage > voltage_bin - 0.5 * binsize)
current_bins_mean[i] = np.mean(current[bin_condition])
voltage_bins_mean[i] = np.mean(voltage[bin_condition])
current_bins_std[i] = np.std(current[bin_condition])
voltage_bins_std[i] = np.std(voltage[bin_condition])
current_bins_std[current_bins_std == 0.] = np.nanmean(current_bins_std) #zero error can happen but is unphysical.
voltage_bins_std[voltage_bins_std == 0.] = np.nanmean(voltage_bins_std)
return {'I': current_bins_mean, 'V': voltage_bins_mean, 'I_err': current_bins_std, 'V_err': voltage_bins_std}
class Interpolator(object):
def __init__(self, x, y, kind = 'linear'):
"""
Construct 1 dimensional interpolator for function of kind f(x)=y
:param x: x coordinates, array
:param y: y coordinates, array
:param kind: method of interpolation, default linear
"""
self.interpolator = scipy.interpolate.interp1d(x, y, kind = kind)
def interpolate(self, x):
"""
Interpolates new values of y for values of x for f(x)=y
:param x: x coordinates, array
:retun: intepolated values of y, array
"""
return self.interpolator(x)
def mean_of_interpolate(self, x):
"""
Interpolates new values of y for values of x for f(x)=y and calculates their mean.
:param x: x coordinates, array
:return: mean value of interpolates values of y
"""
interval = self.interpolate(x)
return np.mean( interval )
class Intervals(object):
def __init__(self, interval, x, y, kind = 'linear'):
"""
Costructs interval with 1 dimensional interpolator for function of kind f(x)=y, where interval is x.
:param interval: interval of all possible values, array
:param x: x coordinates, array
:param y: y coordinates, array
:param kind: method of interpolation, default linear
"""
self._interpolator = Interpolator(x, y, kind = kind)
self._interval = interval
def interval(self, begin, end):
"""
Returns interval of values between begin and end.
:param begin: Smallest possible value of interval.
:param end: Largest possible value of interval.
"""
return self._interval[
np.where(
np.logical_and(
begin <= self._interval, self._interval <= end
)
)
]
def interpolate_for_interval(self, begin, end):
"""
Interpolates new values of y for values of x for f(x)=y
for interval between begin and end.
:param begin: Smallest possible value of interval.
:param end: Largest possible value of interval.
:retun: intepolated values of y within interval, array
"""
return self._interpolator.interpolate(self.interval(begin, end))
def interpolate_mean_for_interval(self, begin, end):
"""
Interpolates new values of y for values of x for f(x)=y and calculates their mean
for interval between begin and end.
:param begin: Smallest possible value of interval.
:param end: Largest possible value of interval.
:return: mean value of interpolates values of y within interval
"""
return self._interpolator.mean_of_interpolate(self.interval(begin, end))
def nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
##############FOURIER TRANSFORMATION SHOT CHECK################
#1. normal method
def freq_gen(t, Fs): #FS default value change to freq of data aquisition
n = len(t)
half = int(n/2)
k = np.arange(n)
T = n/Fs
f = k/T
f_half = f[0:half]
return f_half
#2. averaged method
from scipy.signal import welch
def my_welch(signals, nperseg, fs):
#FS sampling frq, nperseg is window lenght
#(The bigger the box the lower frequency/wavelenght we can see)
frequencies, spectras = welch(signals, fs = fs, nperseg = nperseg, scaling = 'spectrum')
return frequencies, spectras
def running_mean(l, N):
#he running mean is a case of the mathematical operation of convolution.
#For the running mean, you slide a window along the input and compute the mean of the window's contents.
# Also works for the(strictly invalid) cases when N is even.
if (N//2)*2 == N:
N = N - 1
front = np.zeros(N//2)
back = np.zeros(N//2)
for i in range(1, (N//2)*2, 2):
front[i//2] = np.convolve(l[:i], np.ones((i,))/i, mode = 'valid')
for i in range(1, (N//2)*2, 2):
back[i//2] = np.convolve(l[-i:], np.ones((i,))/i, mode = 'valid')
return np.concatenate([front, np.convolve(l, np.ones((N,))/N, mode = 'valid'), back[::-1]])
def ivchar_fit(v, Ti, R, Vf, Isat):
return np.exp(alpha)* Isat * (1 + R*(v-Vf)) - Isat * np.exp((Vf - v) / Ti)
#makes a 3-param fit with fixed Vp (eats potential gives 3p fit)###########
def Afterburner(Vf):
def ivchar_fit(v, Ti, R, Isat):
return np.exp(alpha)* Isat * (1 + R*(v-Vf)) - Isat * np.exp((Vf - v) / Ti)
return ivchar_fit
# for applications (eats Voltage and params gives I)
def ivchar_fit_Weighted(v, Ti, R, Isat):
return np.exp(alpha)* Isat * (1 + R*( v-rrpopt2[2])) - Isat * np.exp((rrpopt2[2]-v ) / Ti)
def ivchar_fit_Unweighted(v, Ti, R, Isat):
return np.exp(alpha)* Isat * (1 + R*(v-rrpopt[2] )) - Isat * np.exp(( rrpopt[2]-v) / Ti)
####condition = (150+rrpopt2[2]) < 3*crrpopt2[0] ####
def Afterburner_1(Vf):
def ivchar_fit_2p(v, Ti, Isat):
return np.exp(alpha)* Isat * (1) - Isat * np.exp(( Vf-v) / Ti)
return ivchar_fit_2p
def Afterburner_2(Vf):
def ivchar_fit_3p(v, Ti, R, Isat):
return np.exp(alpha)* Isat * (1 + R*(v-Vf )) - Isat * np.exp((Vf-v) / Ti)
return ivchar_fit_3p
def Rzero(condition):
if condition:
# print(alpha)
return Afterburner_1
else:
# print('4-param')
# print(alpha)
return Afterburner_2
def q_curve_fit(boundss, *args, **kwargs):
_len = len(boundss[0])
if _len == 3:
res_11, res_22 = curve_fit(*args, **kwargs)
return np.asarray([res_11[0], res_11[1], res_11[2]]) , np.asarray([np.sqrt(res_22[0][0]), np.sqrt(res_22[1][1]) ,np.sqrt(res_22[2][2])])
elif _len == 2:
res_1, res_2 = curve_fit(*args, **kwargs)
#return np.asarray([res_1[0], 0, res_1[1]]), res_2
return np.asarray([res_1[0], 0, res_1[1]]) , np.asarray([np.sqrt(res_2[0][0]), 0 ,np.sqrt(res_2[1][1] )])
def signal_cleaner(problem):
for i in range(len(problem)):
if np.isnan(problem[i]) == True:
problem[i]=0.0
print(i)
elif problem[i] == -inf:
problem[i] = 0.0
print('inf = ' +str(i))
elif problem[i] == inf:
problem[i] = 0.0
print('inf = ' +str(i))
return problem
Populating the interactive namespace from numpy and matplotlib
shot_number = 0
radial_probe_position = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/'+str(shot_number)+'/Diagnostics/PetiProbe/Parameters/r_lp_tip'),names = ['R'])['R'][0]
sweep_frequency = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/'+str(shot_number)+'/Diagnostics/PetiProbe/Parameters/f_fg')
,names = ['f_fg'])['f_fg'][0]/1e3 # [kHz]
print('sweep_frequency =' +str(sweep_frequency))
resistor = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/'+str(shot_number)+'/Diagnostics/PetiProbe/Parameters/r_i'),names = ['r_i'])['r_i'][0] # [Ohm]
print('resistor =' +str(resistor))
data_file = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/'+str(shot_number)+'/Diagnostics/PetiProbe/DAS_raw_data_dir/TektrMSO64_ALL.csv'), skiprows=10)
#BPP
current_BPP = signal_cleaner(data_file['CH2'])
bpp_time = 1e3*(data_file['TIME'])
current = current_BPP/resistor*1e3 ##odpor bol 47 *1000 to [mA]
voltage_BPP = (data_file['CH1'])
voltage_time = 1e3*data_file['TIME']
voltage = -1*signal_cleaner(voltage_BPP)
time_ax = 1e3*data_file['TIME']
##BPP float
# voltage_BPP_float = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/' + shot_number_float +'/Diagnostics/PetiProbe/DAS_raw_data_dir/ch5.csv'),names = ['t','V'])
# BPP_time_float = 1e3*voltage_BPP_float.t
# Vp_BPP_float = 1*voltage_BPP_float.V
# OffsetBPP_float = np.mean(Vp_BPP_float[10:nearest(time_ax, tt)])
# Vp_BPP = Vp_BPP_float - OffsetBPP_float
# print('ofset_BPP_float: '+str(OffsetBPP_float))
f_sample = (1./(bpp_time[1]-bpp_time[0]))
print('DAS freqency = '+ str(f_sample) + ' MHz') ### = 1MHz
FS = f_sample
# zakladni parametry plazmatu
Bt = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/' + str(shot_number) +'/Diagnostics/BasicDiagnostics/U_IntBtCoil.csv'),names = ['t','B'])
Bt.t = 1000*Bt.t
Ip = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/' + str(shot_number) +'/Diagnostics/BasicDiagnostics/U_IntRogCoil.csv'),names = ['t','I'])
Ip.t = 1000*Ip.t
Ip.I = (Ip.I)
Uloop = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/' + str(shot_number) +'/Diagnostics/BasicDiagnostics/U_Loop.csv'),names = ['t','V'])
Uloop.t = 1000*Uloop.t
sweep_frequency =50.0 resistor =47 DAS freqency = 12500.000000004846 MHz
fig,ax = plt.subplots(3)
fromm = Bt.t[nearest(Bt.B, 0.30)] ### usefull signal start est.
untill = Bt.t[nearest(Bt.B, 0.40)]
ax[0].plot(Uloop.t,Uloop.V)
ax[0].set_xticks([])
ax[0].set_ylabel('Uloop [V]')
ax[0].axvline(x = fromm)
ax[0].axvline(x = untill)
ax[1].plot(Ip.t,Ip.I,color = 'red')
ax[1].set_xticks([])
ax[1].set_ylabel('Ip [kA]')
ax[1].axvline(x = fromm)
ax[1].axvline(x = untill)
st = nearest(Bt.t , fromm)
ed = nearest(Bt.t , untill)
ax[2].plot(Bt.t,Bt.B, color = 'green', label = '$B_t$ interval aver. ~ '+str('{0:4.2f}'.format((Bt.B[st] + Bt.B[ed])/2))+' T')
ax[2].legend()
ax[2].set_xlabel('t [ms]')
ax[2].set_ylabel('B[T]')
ax[2].axvline(x = fromm)
ax[2].axvline(x = untill)
ax[2].grid()
B_tor_avg = (Bt.B[st] + Bt.B[ed])/2
#alpha_calc_avg = -2.735 * B_tor_avg + 2.041 ### calib_koef from lin fit of results alpha_bpp on B [P.Macha]
alpha = 0.25
print('alpha used = ' + str(alpha))
if Bt.B[st]< 0.22:
print('WARNING !!! ' +'B min calculated = ' +str(Bt.B[st]) +' WARNING !!!' )
else:
print('B min calculated = ' + str(Bt.B[st]))
st = nearest(time_ax , fromm)
ed = nearest(time_ax , untill)
B_interpol = scipy.interpolate.interp1d(Bt.t, Bt.B)
B_interpolated = B_interpol(time_ax[st:ed])
ax[2].plot(time_ax[st:ed] , B_interpolated)
plt.savefig('Results/plasma_params'+str(shot_number)+'.png')
alpha used = 0.25 B min calculated = 0.300017118
fig,ax = plt.subplots(2 , figsize = (8,8) ,sharex= False)
ax[0].plot(bpp_time, current , color= 'steelblue', label = 'BPP Current')
# ax[0].plot(bpp_time[:-1], reconstructed_shifted, 'b', label='reconstructed')
ax[0].set_ylabel('I [mA]')
#ax[0].set_ylim(-0.02,0.02)
ax[0].legend(loc= 'lower right' ,fontsize = 12)
ax[1].plot(bpp_time, voltage, color= 'lightcoral', label = 'BPP sweept voltage')
ax[1].set_xlabel('t [ms]')
ax[1].set_ylabel('U [V]')
# ax[0].set_xlim(0.75,0.77)
# ax[1].set_xlim(0.75,0.77)
# ax[1].set_ylim(-100,100)
ax[1].legend(loc= 'lower right' ,fontsize = 12)
# ax[0].axhline(x = 0)
# ax[1].axhline(x = 0)
#ax[1].plot(bpp_time, lp_I , color= 'Darkkhaki', label = 'lp Current original')
# ax[2].plot(time_ax, Vfl_LP , color= 'green', label = 'Lp_floating')
# ax[2].set_ylabel('U [V]')
# #ax[2].set_ylim(-6,6)
# ax[2].legend(loc= 'lower right' ,fontsize = 12)
plt.savefig('Results/raw_probes'+str(shot_number)+'.png')
# ------------------------------------------------------------------------------------------------------------
# ---------------------------------- Change this -------------------------------------------------------------
shift0 = 0 #shift the array to find the relative phase
shift1 = 0
tcap = 1 # end of the unperturbed voltage signal
lowpass= sweep_frequency*10 # up to 10x frequency estimate
fig, ax =plt.subplots(3,1,figsize=(8, 8))
plt.grid()
artificial = np.diff(my_lowpass_filter(voltage[nearest(bpp_time, 0.1):nearest(bpp_time, tcap)], lowpass, FS, order = 2))
real = my_lowpass_filter(current[nearest(bpp_time, 0.1):nearest(bpp_time, tcap)][:-1], lowpass, FS, order = 2)
ax[0].plot(np.roll(a=artificial, shift=shift0), real, linestyle='None', Marker='*', color='g', label='reference')
ax[0].plot(np.roll(a=artificial, shift=shift1), real, linestyle='None', Marker='*', color='b', label='shifted')
popt, pcov = curve_fit(linear_fit, artificial, real)
ax[0].plot(artificial, linear_fit(artificial, popt[0], popt[1]), linewidth=5, color='orange', label = 'linear fit')
#plt.ylim(0., 0.008)
ax[0].set_xlabel(r'Smooth $\frac{{dV}}{{dt}}$', fontsize=12)
ax[0].set_ylabel('Real current', fontsize=12)
ax[0].legend(fontsize=12)
x = np.diff(my_lowpass_filter(voltage, lowpass, FS, order = 5))
###############SHIFTING ##############################################
reconstr_shift_right = list(linear_fit(x, popt[0], popt[1]))
reconstr_shift_right.insert(0, 0.0)
reconstr_shift_right.insert(0, 0.0)
reconstructed_shifted = reconstr_shift_right[:-2]
# reconstr_shift_left = list(linear_fit(x, popt[0], popt[1]))
# reconstr_shift_left.append(0.0)
# reconstr_shift_left.append(0.0)
# reconstr_shift_left.append(0.0)
# reconstructed_shifted = reconstr_shift_left[3:]
reconstructed_noShift = linear_fit(x, popt[0], popt[1])
###############SHIFTING ##############################################
current_corrected_1 = current[:-1]-reconstructed_shifted
ax[1].grid()
ax[1].plot(bpp_time, current, 'k', label='Current raw')
ax[1].plot(bpp_time[:-1], current_corrected_1, 'red', label='Current corrected 1')
ax[1].plot(bpp_time[:-1], reconstructed_shifted, 'b', label='reconstructed 1')
###############SHIFTING RESULT COMPARATION##############################################
# ax[1].plot(bpp_time[:-1], current[:-1]-reconstructed_noShift, 'red', label='Current corrected')
# ax[1].plot(bpp_time[:-1], current[:-1]-reconstructed_shifted, 'green', label='Current corrected SHIFTED')
########################################################################################
ax[1].legend()
ax[1].set_xlabel('time [ms]', fontsize=12)
ax[1].set_ylabel('Current [mA]', fontsize=12)
ax[2].grid()
ax[2].plot(bpp_time, current, 'k',linewidth = 2, label='Current raw')
ax[2].plot(bpp_time[:-1], current_corrected_1, 'red', label='Current corrected 1')
ax[2].plot(bpp_time[:-1], reconstructed_shifted, 'b', label='reconstructed 1')
ax[2].set_xlim(0.1 , 0.3)
ax[2].set_ylim(-0.0015*1e3, 0.0015*1e3)
ax[2].legend()
ax[2].set_xlabel('time [ms]', fontsize=12)
ax[2].set_ylabel('Current [mA]', fontsize=12)
plt.tight_layout()
plt.savefig('Results/cleaning1A_'+str(shot_number)+'.png')
# ------------------------------------------------------------------------------------------------------------
# SECONDARY REMOVAL OF LEFTOVER STRAY CURRENT
# ------------------------------------------------------------------------------------------------------------
N_points = ((1/sweep_frequency)/4) // (1/(FS)) #### input in kHz!!!. This stray current is shifted by pi/2 , calculating the num. of points which represent pi/2 shift
print('second shift is '+ str(N_points))
shift0 = 0 #shift the array to find the relative phase
shift1 = 0
fig, ax =plt.subplots(3,1,figsize=(8, 8))
plt.grid()
artificial = (my_lowpass_filter(voltage[nearest(bpp_time, 0.1):nearest(bpp_time, tcap)], lowpass, FS, order = 5))
real = my_lowpass_filter(current_corrected_1[nearest(bpp_time, 0.1):nearest(bpp_time, tcap)], lowpass, FS, order = 5)
artificial1 = artificial[(np.where(artificial>0 ))]
artificial2= artificial1[(np.where(artificial1<100 ))]
real1 = real[(np.where(artificial>0 ))]
real2= real1[(np.where(artificial1<100 ))]
ax[0].plot(np.roll(a=artificial, shift=shift0), real, linestyle='None', Marker='*', color='g', label='reference')
ax[0].plot(np.roll(a=artificial, shift=shift1), real, linestyle='None', Marker='*', color='b', label='shifted')
popt, pcov = curve_fit(linear_fit, np.roll(a=artificial2, shift=shift1), real2)
ax[0].plot(artificial2, linear_fit(artificial2, popt[0], popt[1]), linewidth=5, color='orange', label = 'linear fit')
ax[0].set_xlabel(r'Smooth Voltage [V]', fontsize=12)
ax[0].set_ylabel('Real current', fontsize=12)
ax[0].legend(fontsize=12)
x = np.diff(my_lowpass_filter(voltage, lowpass, FS, order = 5))
volt_derived = my_lowpass_filter(voltage, lowpass, FS, order = 5)
reconstructed_shifted_2 = np.roll(a=volt_derived, shift=shift1)* popt[0] + popt[1]
###############SHIFTING ##############################################
current_corrected_2 = current_corrected_1 -reconstructed_shifted_2[:-1]
ax[1].grid()
ax[1].plot(bpp_time[:-1], current_corrected_1, 'k', label='Current corrected 1')
ax[1].plot(bpp_time[:-1], current_corrected_2, 'red', label='Current corrected 2')
ax[1].plot(bpp_time[:-1], reconstructed_shifted_2[:-1], 'b', label='reconstructed 2 ')
###############SHIFTING RESULT COMPARATION##############################################
# ax[1].plot(bpp_time[:-1], current[:-1]-reconstructed_noShift, 'red', label='Current corrected')
# ax[1].plot(bpp_time[:-1], current[:-1]-reconstructed_shifted, 'green', label='Current corrected SHIFTED')
########################################################################################
ax[1].legend()
ax[1].set_xlabel('time [ms]', fontsize=12)
ax[1].set_ylabel('Current [mA]', fontsize=12)
ax[1].set_ylim(-20, 0.01*1e3)
ax[2].plot(bpp_time[:-1], current_corrected_1, 'k', label='Current corrected 1')
ax[2].plot(bpp_time[:-1], current_corrected_2, 'red', label='Current corrected 2')
ax[2].plot(bpp_time[:-1], reconstructed_shifted_2[:-1], 'b', label='reconstructed 2 ')
ax[2].grid()
ax[2].set_xlim(0.1 , 0.3)
ax[2].set_ylim(-1.5, 1.5)
ax[2].legend()
ax[2].set_xlabel('time [ms]', fontsize=12)
ax[2].set_ylabel('Current [mA]', fontsize=12)
plt.tight_layout()
plt.savefig('Results/cleaning1B_'+str(shot_number)+'.png')
<ipython-input-1-debd3c57a73c>:18: MatplotlibDeprecationWarning: Case-insensitive properties were deprecated in 3.3 and support will be removed two minor releases later ax[0].plot(np.roll(a=artificial, shift=shift0), real, linestyle='None', Marker='*', color='g', label='reference') <ipython-input-1-debd3c57a73c>:19: MatplotlibDeprecationWarning: Case-insensitive properties were deprecated in 3.3 and support will be removed two minor releases later ax[0].plot(np.roll(a=artificial, shift=shift1), real, linestyle='None', Marker='*', color='b', label='shifted')
second shift is 62.0
<ipython-input-1-debd3c57a73c>:93: MatplotlibDeprecationWarning: Case-insensitive properties were deprecated in 3.3 and support will be removed two minor releases later ax[0].plot(np.roll(a=artificial, shift=shift0), real, linestyle='None', Marker='*', color='g', label='reference') <ipython-input-1-debd3c57a73c>:94: MatplotlibDeprecationWarning: Case-insensitive properties were deprecated in 3.3 and support will be removed two minor releases later ax[0].plot(np.roll(a=artificial, shift=shift1), real, linestyle='None', Marker='*', color='b', label='shifted')
lowpass= sweep_frequency*7.4
smooth_voltage = my_lowpass_filter(voltage, lowpass, FS, order = 10)
V = smooth_voltage[:-1]
Id = current_corrected_2
trt = bpp_time[:-1]
t = np.array(trt)
fourier_from = nearest(trt,fromm)
fourier_until = nearest(trt,untill )
I = my_lowpass_filter(Id, lowpass, FS, order = 10 ) # order32 like default for compass(only current), For 1kHz -> 200 50kHz->500
#PLOTING:
fig, ax = plt.subplots(3,1, sharex= False, figsize =(10,10))
ax[0].plot(bpp_time, current, label=r'raw', color='orange', alpha=.5)
ax[0].plot(t, current_corrected_2, label='I after stray current removal', color='gray', alpha=.7)
# ax[0].plot(t, Id, label='I before lowpass', color='black', alpha=.7)
ax[0].plot(t, I, label='I - offset, after lowpass', color='blue')
ax[0].plot(t[fourier_from:fourier_until], Id[fourier_from:fourier_until], label=r'Fourier analysed', color='red', alpha=1)
ax[0].legend(fontsize = 12)
ax[0].set_xlabel('t [ms]', fontsize=14)
ax[0].set_ylabel('I [mA]', fontsize=14)
ax[0].axhline(y=0)
ax[1].plot(bpp_time, current, label=r'raw', color='orange', alpha=.5)
ax[1].plot(t, current_corrected_2, label='I after stray current removal', color='gray', alpha=.7)
ax[1].plot(t, I, label='I - offset, after lowpass', color='blue')
ax[1].plot(t[fourier_from:fourier_until], Id[fourier_from:fourier_until], label=r'Fourier analysed', color='red', alpha=1)
ax[1].legend(fontsize = 12)
ax[1].set_xlabel('t [ms]', fontsize=14)
ax[1].set_ylabel('I [mA]', fontsize=14)
ax[1].set_xlim(0.1 , 4)
ax[1].set_ylim(-0.002*1e3, 0.002*1e3)
# ax[0].set_ylim(-0.04*1e3, 0.01*1e3)
fffff, sssss = my_welch(Id[fourier_from:fourier_until], nperseg=3500, fs = FS)
fff, sss = my_welch(I[fourier_from:fourier_until], nperseg=3500, fs = FS)
ax[2].loglog(fffff, sssss, color= 'gray', alpha = 0.5, label= 'before lowpass')
ax[2].loglog(fff, sss, label= 'after lowpass' )
# ax[1].set_ylim(10**(-13), 10**(-6))
ax[2].set_ylim(10**(-12), 10**(1))
# ax[1].set_xlim(0, 5*10**(6))
ax[2].axvline(lowpass, lineStyle= 'dashed' , color = "gray", label = 'cut-off freq = ' +str(lowpass)+' kHz')
ax[2].set_xlabel('frequency [kHz]', fontsize=14)
ax[2].set_ylabel('amplitude', fontsize=14)
plt.legend(fontsize=12)
plt.tight_layout()
plt.savefig('Results/cleaning2_'+str(shot_number)+'.png')
amplitude_of_cap_curr_upbound = np.std(I[nearest(bpp_time, 1.5):nearest(bpp_time, 2.5)])*3
amplitude_of_cap_curr_lobound = np.std(I[nearest(bpp_time, 1.5):nearest(bpp_time, 2.5)])*3
amplitude_of_cap_curr=np.std(I[nearest(bpp_time, 1.5):nearest(bpp_time, 2.5)])
print('Capacitive current max amplitude after all cleaning is '+str(amplitude_of_cap_curr_upbound))
<ipython-input-1-f897446c4c3a>:42: MatplotlibDeprecationWarning: Case-insensitive properties were deprecated in 3.3 and support will be removed two minor releases later ax[2].axvline(lowpass, lineStyle= 'dashed' , color = "gray", label = 'cut-off freq = ' +str(lowpass)+' kHz')
Capacitive current max amplitude after all cleaning is 0.041466013176959075
VAchar_voltage_smoothed=running_mean(V,5)
VAchar_current_smoothed=running_mean(I,5)
data=VAchar_voltage_smoothed
extrems_tmp = (np.diff(np.sign(np.diff(data))).nonzero()[0] + 1) # local min+max
minima = ((np.diff(np.sign(np.diff(data))) > 0).nonzero()[0] + 1) # local min
maxima = ((np.diff(np.sign(np.diff(data))) < 0).nonzero()[0] + 1) # local max
# Sometimes double extrems appear, removal:
#print extrems
extrems=[]
for i in range(len(extrems_tmp)-1):
if abs(extrems_tmp[i]-extrems_tmp[i+1])>10:
extrems.append(extrems_tmp[i])
# graphical output...
from pylab import *
plt.figure(figsize=(10,6), dpi= 80, facecolor='w', edgecolor='k')
plt.plot(t,data , label = 'smoothed voltage')
plt.plot(t,V, '-+', label = 'voltage')
plt.plot(t[maxima], data[maxima], "o", label="max",markersize=12)
plt.plot(t[minima], data[minima], "o", label="min",markersize=12)
plt.ylabel('Voltage [V]', fontsize = 12)
plt.xlabel('Time [ms]',fontsize = 12)
#plt.title('Maxima and minima identification')
plt.legend(fontsize = 10)
plt.axvline(x=fromm)
plt.axvline(x=untill)
# plt.ylim( -10.,110)
interval_pivots =np.concatenate([minima, maxima])
interval_pivots.sort()
interval_pivots = t[interval_pivots]
#plt.xlim(interval_pivots[192],interval_pivots[196])
sweep_amplitude = np.mean(data[maxima])-5
print('sweep_amplitude = '+str(sweep_amplitude))
sweep_amplitude = 130.74705466100085
iv_start = 1158
# iv_start = Index_filter[2]
index_to_time = interval_pivots[iv_start]
# print('For current B_tor = '+str('{0:4.2f}'.format(B_interpolated[nearest(time_ax[st:ed] , index_to_time)]))+ ' T ' + ' ln(alpha_BPP) is '+str('{0:4.2f}'.format(alpha)))
time_bin = 15
Ti_lobound= 0
Ti_upboud = 50
Vp_lobound = -20 ### The Vp can also be neg on golem
Vp_upbound = 40
R_lobound = 0
R_upbound = 1
Isat_lobound = -10## mA
Isat_upbound = 0
MAX_voltage = sweep_amplitude
potential_shift = 0.1 ### shifting the obtained Vp before cutting to the left by a factor: potetial_shift*rrpopt[2]
lobound = [Ti_lobound, R_lobound, Vp_lobound, Isat_lobound] # fit lower bound for Ti, R, Vf, Isat
upbound = [Ti_upboud, R_upbound, Vp_upbound, Isat_upbound] # fit upper bound for Ti, R, Vf, Isat
binsize = 5
# ------------------------------------------------------------------------------------------------------------
iv_stop = iv_start + 1 # +1 perioda # LOL
cut_err = (interval_pivots[iv_start-time_bin//2] < t) & (t < interval_pivots[iv_start+time_bin//2])
cut_dat = (interval_pivots[iv_start] < t) & (t < interval_pivots[iv_stop])
I_for_float_potential_index = nearest(I[cut_dat],0.0)
V_for_float_potential = V[cut_dat][I_for_float_potential_index]
cut_V = (-20 < V) & (V < MAX_voltage)
cut_I = True
cut_I = (I < 0.0)
I_short = I[cut_dat & cut_I & cut_V]
V_short = V[cut_dat & cut_I & cut_V]
I_long = I[cut_err & cut_I & cut_V]
V_long = V[cut_err & cut_I & cut_V]
if -np.nanmin(I_short) < abs(amplitude_of_cap_curr_lobound)*5:
print('WARNING: EFFECTIVE CURRENT LESS THAN 5 TIMES THE CAPACITIVE')
binned_data = bin_average(I_long, V_long, binsize) # Compute the standard deviations for each bin
verrs = binned_data['V_err'] # voltage stds
ierrs = binned_data['I_err'] # current stds
vbins = binned_data['V'] # un-center the bins
ibins = binned_data['I']
current_err = np.ones_like(I_short) # create an array of ones with the same size as I
voltage_err = np.ones_like(V_short) # which is also the size of V, so both are the same size
for i, vbin in enumerate(vbins): # iterate on the bins
current_err[V_short >= vbin] = ierrs[i]
voltage_err[V_short >= vbin] = verrs[i]
# This is the unweighted fit
popt, pcov = curve_fit(ivchar_fit, V_short, I_short, bounds=(lobound, upbound))
# This is the weighted fit
popt2, pcov2 = curve_fit(ivchar_fit, V_short, I_short, bounds=(lobound, upbound), sigma=current_err, absolute_sigma=False)
################# repeat the fit for better Vfl evaluation ##########################################################
# This is the unweighted fit
rpopt, rpcov = curve_fit(ivchar_fit, V_short, I_short, bounds=([Ti_lobound, R_lobound, popt[2]-10, Isat_lobound], [Ti_upboud, R_upbound, popt[2]+10, Isat_upbound]))
# This is the weighted fit
rpopt2, rpcov2 = curve_fit(ivchar_fit, V_short, I_short, bounds=([Ti_lobound, R_lobound, popt2[2]-10, Isat_lobound], [Ti_upboud, R_upbound, popt2[2]+10, Isat_upbound]), sigma=current_err, absolute_sigma=False)
################# 2x repeat the fit for better Vfl evaluation ######################################################
# This is the unweighted fit
rrpopt, rrpcov = curve_fit(ivchar_fit, V_short, I_short, bounds=([Ti_lobound, R_lobound, rpopt[2]-5, Isat_lobound], [Ti_upboud, R_upbound, rpopt[2]+5, Isat_upbound]))
# This is the weighted fit
rrpopt2, rrpcov2 = curve_fit(ivchar_fit, V_short, I_short, bounds=([Ti_lobound, R_lobound, rpopt2[2]-5, Isat_lobound], [Ti_upboud, R_upbound, rpopt2[2]+5, Isat_upbound]), sigma=current_err, absolute_sigma=False)
rcut_V = ((rrpopt[2] - potential_shift*rrpopt[2]) < V) & (V < MAX_voltage)
rI_short = I[cut_dat & cut_I & rcut_V]
rV_short = V[cut_dat & cut_I & rcut_V]
rI_long = I[cut_err & cut_I & rcut_V]
rV_long = V[cut_err & cut_I & rcut_V]
binned_data = bin_average(rI_long, rV_long, binsize) # Compute the standard deviations for each bin
rverrs = binned_data['V_err'] # voltage stds
rierrs = binned_data['I_err'] # current stds
rvbins = binned_data['V']
ribins = binned_data['I']
r_current_err = np.ones_like(rI_short) # create an array of ones with the same size as I
r_voltage_err = np.ones_like(rV_short) # which is also the size of V, so both are the same size
for i, vbin in enumerate(rvbins): # iterate on the bins
r_current_err[rV_short >= vbin] = rierrs[i]
r_voltage_err[rV_short >= vbin] = rverrs[i]
# This is the unweighted fit
crrpopt, crrpcov = curve_fit(Afterburner(rrpopt[2]), rV_short, rI_short, bounds=([Ti_lobound, R_lobound, Isat_lobound], [Ti_upboud, R_upbound, Isat_upbound]))
#This is the weighted fit
crrpopt2, crrpcov2 = curve_fit(Afterburner(rrpopt2[2]), rV_short, rI_short, bounds=([Ti_lobound, R_lobound, Isat_lobound], [Ti_upboud, R_upbound, Isat_upbound]), sigma=r_current_err, absolute_sigma=False)
conditions = [(MAX_voltage-rrpopt[2]) < 3*crrpopt[0] , np.sqrt(crrpcov[0][0])/crrpopt[0] < 0.6]
print(conditions)
condition = all(conditions)
if condition :
boundss = ([Ti_lobound, Isat_lobound], [Ti_upboud, Isat_upbound])
else:
boundss = ([Ti_lobound, R_lobound, Isat_lobound], [Ti_upboud, R_upbound, Isat_upbound])
#()() means call chaining... FUN()(xyz) means calling the second function returned by the first one
Ccrrpopt, Ccrrpcov = q_curve_fit(boundss, Rzero(condition)(rrpopt[2]), rV_short, rI_short, bounds=boundss)
Ccrrpopt2, Ccrrpcov2 = q_curve_fit(boundss, Rzero(condition)(rrpopt2[2]), rV_short, rI_short, bounds=boundss, sigma= r_current_err, absolute_sigma=False)
fig, ax = plt.subplots(figsize = (8,6))
ax.plot([],[],ls ='None', label ='#' +str(shot_number)+', time: '+str('{0:4.3f}'.format(index_to_time))+' s; '+ ' B_tor = '+'{0:4.2f}'.format(B_interpolated[nearest(time_ax[st:ed] , index_to_time)])+ ' T; ' +' alpha_BPP = '+str('{0:4.2f}'.format(alpha)))
ax.plot(V_short, -I_short, color='k', Marker = 'o',alpha = 0.3, linestyle='None')
ax.plot(rV_short, -rI_short, color='k', label='data', Marker = 'o', linestyle='None')
# ax.plot(vbins , -ibins , '*',color ='gray', label = 'bins through ' +str(time_bin)+' IVs')
#ax.errorbar(vbins , -ibins ,ierrs)
xx = np.linspace(rrpopt[2]- 0.1*rrpopt[2], np.nanmax(V_short), num=100) ## cutted IV
#ax.errorbar(V_short, -I_short, yerr=current_err, color='grey', label='sigma', Marker = '', linestyle='None')
##### FIRST Fits ###########
x = np.linspace(np.nanmin(V_short) , np.nanmax(rV_short), num=100) ## noncutted IV
ax.plot(x, -ivchar_fit(x, *rrpopt), color='gray', linewidth=4, alpha=.53 ,label='UNweighted_FF Ti = {0:4.2f} ± {1:4.2f} eV, Vfl = {2:4.2f} V, Isat = {3:4.2f} A'.format(rrpopt[0], np.sqrt(rrpcov[0][0]),rrpopt[2], -rrpopt[3]))
# ax.plot(x, -ivchar_fit(x, *rrpopt2), color='green', linewidth=4, alpha=.3, label='Weighted_FF Ti = {0:4.2f} ± {1:4.2f} eV, Vfl = {2:4.2f} V, Isat = {3:4.2f} A'.format(rrpopt2[0], np.sqrt(rrpcov2[0][0]),rrpopt2[2], -rrpopt2[3]))
###################### Results of normal fits ########
# ax.plot(xx, -ivchar_fit_Weighted(xx, *Ccrrpopt2), color='red', linewidth=4, alpha=.5,
# label='Weighted Ti Rzero= {0:4.2f} ± {1:4.2f} eV, Vfl = {2:4.2f} ± {3:4.2f} V, Isat = {4:4.2f} A'.format(Ccrrpopt2[0], Ccrrpcov2[0], rrpopt2[2], np.sqrt(rrpcov2[2][2]) ,-Ccrrpopt2[2]))
ax.plot(xx, -ivchar_fit_Unweighted(xx, *Ccrrpopt), color='blue', linewidth=4, alpha=.5,
label='fit: Ti= {0:4.1f} ± {1:4.1f} eV, V_pl = {2:4.1f} ± {3:4.1f} V, Isat = {4:4.3f} A'.format(Ccrrpopt[0], Ccrrpcov[0], rrpopt[2],np.sqrt(rrpcov[2][2]) , -Ccrrpopt[2]))
# ax.set_xlim(0,)
# ax.set_ylim(0,)
ax.axvline(x=0, color = 'black')
ax.axvline(x=V_for_float_potential, color = 'gray', ls = '--', label = 'BPP floating potential')
ax.axhline(y=0, color = 'black')
ax.axhline(y=-amplitude_of_cap_curr_lobound, label='stray current max. amplitude')
ax.axhline(y=-amplitude_of_cap_curr_upbound)
ax.set_xlabel('Voltage [V]', fontsize=12)
ax.set_ylabel('Current [mA]', fontsize=12)
ax.legend(loc='lower right', fontsize=10)
ax.legend(loc='upper left', fontsize=10)
plt.savefig('Results/Example_'+str(index_to_time)+'_shot'+str(shot_number)+'.png')
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-1-d607b0275828> in <module> 39 I_long = I[cut_err & cut_I & cut_V] 40 V_long = V[cut_err & cut_I & cut_V] ---> 41 if -np.nanmin(I_short) < abs(amplitude_of_cap_curr_lobound)*5: 42 print('WARNING: EFFECTIVE CURRENT LESS THAN 5 TIMES THE CAPACITIVE') 43 <__array_function__ internals> in nanmin(*args, **kwargs) /opt/anaconda3/lib/python3.8/site-packages/numpy/lib/nanfunctions.py in nanmin(a, axis, out, keepdims) 317 # Fast, but not safe for subclasses of ndarray, or object arrays, 318 # which do not implement isnan (gh-9009), or fmin correctly (gh-8975) --> 319 res = np.fmin.reduce(a, axis=axis, out=out, **kwargs) 320 if np.isnan(res).any(): 321 warnings.warn("All-NaN slice encountered", RuntimeWarning, ValueError: zero-size array to reduction operation fmin which has no identity
time_bin = 15
Ti_lobound= 0
Ti_upboud = 50
Vp_lobound = -20 ### The Vp can also be neg on golem
Vp_upbound = 40
R_lobound = 0
R_upbound = 1
Isat_lobound = -10## mA
Isat_upbound = 0
MAX_voltage = sweep_amplitude
potential_shift = 0.1 ### shifting the obtained Vp before cutting to the left by a factor: potetial_shift*rrpopt[2]
min_float_potential = -50
max_float_potential = 40
time_start = fromm
time_end = untill
iv_start = nearest(interval_pivots,time_start)
iv_terminate = nearest(interval_pivots,time_end)
# iv_start = 666
# iv_terminate = 667
j = iv_start
cutoff_resolution = 5
resolution = 1 # radial temperature resolution. It is a multiplication constant! #############################1
###############################################################################################################
Ti = []
Vfl = []
R = []
I_sat = []
Ti_err = []
R_err = []
Vfl_err = []
I_sat_err= []
index = []
recognition = []
iv_time = []
V_BPP_floating_pot = []
B_IV = []
alpha_for_Te = []
for j in range(iv_start,iv_terminate, 1):
iv_start = j
lobound = [Ti_lobound, R_lobound, Vp_lobound, Isat_lobound] # fit lower bound for Ti, R, Vf, Isat
upbound = [Ti_upboud, R_upbound, Vp_upbound, Isat_upbound] # fit upper bound for Ti, R, Vf, Isat
# ------------------------------------------------------------------------------------------------------------
iv_stop = iv_start + resolution #+ 1 perioda # LOL
cut_dat = (interval_pivots[iv_start] < t) & (t < interval_pivots[iv_stop])
####### estimation of BPP floating potential##############
cut_V_for_float = (min_float_potential < V) & (V < max_float_potential)
I_for_float_potential_index = nearest(I[cut_dat & cut_V_for_float],0.0)
V_for_float_potential = V[cut_dat & cut_V_for_float][I_for_float_potential_index]
V_BPP_floating_pot.append(V_for_float_potential)
#############################################################
index_to_time = interval_pivots[iv_start]
alpha_for_Te.append(1.89 * B_interpolated[nearest(time_ax[st:ed] , index_to_time)] + 1.85)
B_IV.append(B_interpolated[nearest(time_ax[st:ed] , index_to_time)])
# cut_V = (V_for_float_potential < V) & (V < MAX_voltage)
# cut_V = (-30 < V) & (V < MAX_voltage)
cut_V = (-20 < V) & (V < MAX_voltage)
cut_I = (I < 0.0)
I_short = I[cut_dat & cut_I & cut_V]
V_short = V[cut_dat & cut_I & cut_V]
V_check = V[cut_dat & cut_V ]
if ( len(V_check) < 1 ):
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
recognition.append('unfitable V_check')
iv_time.append(index_to_time)
# alpha_bpp.append(alpha)
continue
if (np.max(V_check) < MAX_voltage-10):
print('THIS IS NOT SUPPOSED TO HAPPEN CHECK VOLTAGE SWEEP AND ALLOWED RANGE')
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
recognition.append('unfitable V_check 2 ')
iv_time.append(index_to_time)
continue
try:
rrpopt, rrpcov = curve_fit(ivchar_fit, V_short, I_short, bounds=(lobound, upbound))
except (RuntimeError,ValueError): # for the graph is dark and full of errors
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
recognition.append('unfitable FF')
iv_time.append(index_to_time)
# alpha_bpp.append(alpha)
continue
rcut_V = ((rrpopt[2] - potential_shift*rrpopt[2]) < V) & (V < MAX_voltage)
rI_short = I[cut_dat & cut_I & rcut_V]
rV_short = V[cut_dat & cut_I & rcut_V]
try:
cpopt, cpcov = curve_fit(Afterburner(rrpopt[2]), rV_short, rI_short, bounds=([Ti_lobound, R_lobound, Isat_lobound], [Ti_upboud, R_upbound, Isat_upbound]))
except (RuntimeError,ValueError): # for the graph is dark and full of errors
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
iv_time.append(index_to_time)
# alpha_bpp.append(alpha)
recognition.append('unfitable cpopt')
continue #### must be continue otherwise two values can be written instead of one
try:
condition = [(MAX_voltage-rrpopt[2]) < 2*cpopt[0] ,
abs(np.sqrt(cpcov[0][0])/cpopt[0]) < 0.6]
condition = all(condition)
if condition :
boundss = ([Ti_lobound, Isat_lobound], [Ti_upboud, Isat_upbound])
else:
boundss = ([Ti_lobound, R_lobound, Isat_lobound], [Ti_upboud, R_upbound, Isat_upbound])
Ccrrpopt, Ccrrpcov = q_curve_fit(boundss, Rzero(condition)(rrpopt[2]), rV_short, rI_short, bounds=boundss)
except (RuntimeError,ValueError): # for the graph is dark and full of errors
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
recognition.append('unfitable errcode 1')
iv_time.append(index_to_time)
pass
rel_err = 0.6
cond1 = [abs(rrpopt[2]) < 5, np.sqrt(rrpcov[2][2]) < 3] #### From ISTTOK we have fluct.level of Te is 0.25. Thus 0.25*Te = 3 (\Te cca 13/);
if all(cond1):
# print(1)
typical_filtering_cond = [np.divide(Ccrrpcov[0],Ccrrpopt[0]) < rel_err ,
(MAX_voltage-rrpopt[2])/Ccrrpopt[0] >1,
Ccrrpopt[0] > 0.1]
else:
# print(2)
typical_filtering_cond = [np.divide(Ccrrpcov[0],Ccrrpopt[0]) < rel_err ,
abs(np.divide(np.sqrt(rrpcov[2][2]),rrpopt[2])) < rel_err,
(MAX_voltage-rrpopt[2])/Ccrrpopt[0] >1,
Ccrrpopt[0] > 0.1]
if all(typical_filtering_cond):
Ti.append(Ccrrpopt[0])
Ti_err.append(Ccrrpcov[0])
R.append(Ccrrpopt[1])
Vfl.append(rrpopt[2])
I_sat.append(Ccrrpopt[2])
R_err.append(Ccrrpcov[1])
Vfl_err.append(np.sqrt(rrpcov[2][2]))
I_sat_err.append(Ccrrpcov[2])
index.append(iv_start)
recognition.append('standard fit')
iv_time.append(index_to_time)
else:
Ti.append(-1000)
Ti_err.append(-1000)
Vfl.append(-1000)
R.append(-1000)
I_sat.append(-1000)
R_err.append(-1000)
Vfl_err.append(-1000)
I_sat_err.append(-1000)
index.append(iv_start)
recognition.append('unfitable')
iv_time.append(index_to_time)
# alpha_bpp.append(alpha)
rel_err= 0.6
Ti_filt = []
Ti_err_filt = []
Vp_probe_filt = []
Vp_err_filt = []
time_filter = []
Isat_filter = []
Index_filter = []
V_BPP_floating_pot_filter = []
statement = []
B_IV_filt =[]
# alpha_bpp_filt =[]
i = 0
for i in range(0,len(Ti)):
rules = [np.divide(Ti_err[i],Ti[i]) < rel_err ,
#abs(np.divide(Vfl_err[i],Vfl[i])) < rel_err, ### we do not need this. Vp err handeled already
Ti[i]<(MAX_voltage - np.array(Vfl[i]))/1,
Ti[i]<Ti_upboud-1,
Ti_err[i]>0.0,
]
if all(rules):
Ti_filt.append(Ti[i])
Ti_err_filt.append(Ti_err[i])
Vp_probe_filt.append(Vfl[i])
Vp_err_filt.append(Vfl_err[i])
time_filter.append(iv_time[i])
Isat_filter.append(I_sat[i])
Index_filter.append(index[i])
statement.append(recognition[i])
# alpha_bpp_filt.append(alpha_bpp[i])
V_BPP_floating_pot_filter.append(V_BPP_floating_pot[i])
B_IV_filt.append(B_IV[i])
print('nuber of succesful fits = '+ str(len(Ti_filt))+' / ' +str(len(Ti)))
nuber of succesful fits = 0 / 300
match_standard =[]
match_cutoff =[]
for i in range(len(statement)):
if 'standard fit' in statement[i]:
match_standard.append(i)
if 'cutoff_fit; precision: '+str(cutoff_resolution) in statement[i]:
match_cutoff.append(i)
plt.figure(figsize = (10,6))
plt.title('Histeresis checker')
for i in range(len(Index_filter)):
if Index_filter[i] % 2 == 0:
plt.plot(Index_filter[i], Vp_probe_filt[i], color='red', marker ='o', label = 'párne')
else:
plt.plot(Index_filter[i], Vp_probe_filt[i], color='orange', marker ='o',label='nepárne')
# plt.plot(Index_filter, V_BPP_floating_pot_filter, 'D-', label = 'BPP floating potential')
plt.plot(Index_filter, Vp_probe_filt, color = 'gray',ls = '--')
plt.xlabel('fit indentification number')
plt.ylabel('Plasma potential')
plt.savefig('Results/Plasma_potential.png')
fig,ax = plt.subplots(4, figsize = (8,10))
ax[0].plot(Uloop.t,Uloop.V,linewidth = 3 ,)
ax[0].set_ylabel('Uloop [V]')
ax[0].set_xlim(fromm,untill)
ax[0].grid()
ax[1].plot(Ip.t,Ip.I,linewidth = 3 ,color = 'red')
ax[1].set_ylabel('Ip [kA]')
ax[1].set_xlim(fromm,untill)
ax[1].grid()
ax[2].plot(Bt.t,Bt.B,linewidth = 3 , color = 'green')
ax[2].set_ylabel('B [T]')
ax[2].set_xlim(fromm,untill)
ax[2].grid()
ax[3].plot(time_filter, Ti_filt, '*',markersize = 10 , color = 'red' , label ='ion temperature ' + str(shot_number))
ax[3].errorbar(time_filter, Ti_filt, yerr=Ti_err_filt, xerr=None, fmt='None', ecolor='gray', elinewidth=None, capsize=None, barsabove=True, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, )
ax[3].set_ylim(0,80)
ax[3].set_xlim(fromm,untill)
ax[3].legend(loc= 'upper right', fontsize = 10)
ax[3].set_xlabel('time [ms]', fontsize = 12)
ax[3].set_ylabel('$T_i$ [eV]', fontsize = 12)
#ax[3].set_yticks([0,5,10,15,20,30,40,50])
ax[3].grid()
fig.savefig('Results/ALL_params_' + str(radial_probe_position ) +'mm_'+str(shot_number)+'.png' )
fig, ax = subplots(figsize= (8,6))
# ax.plot(times, Tes, 'o',markersize = 1.5,label = 'electron temperature #'+ str(shot_number_float))
# ax.plot(times, Te_smooth,color = 'darkorange', label = 'electron temperature smoothed #'+ str(shot_number_float))
ax.plot(time_filter, Ti_filt, 'o',markersize = 8 , color = 'red' , label ='ion temperature #' + str(shot_number))
plt.errorbar(time_filter, Ti_filt, yerr=Ti_err_filt, xerr=None, fmt='None', ecolor='red', elinewidth=0.5, capsize=3, barsabove=True, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, )
#ax.set_xlim(-0.005,0.02)
y_ticks = np.arange(0, 110, 10)
ax.set_yticks(y_ticks)
ax.set_ylim(0,80)
ax.legend(fontsize = 10, loc = 'upper right')
ax.set_xlabel('time [ms]', fontsize = 12)
ax.set_ylabel('Ion and electron temperature [eV]', fontsize = 12)
ax.grid()
plt.savefig('icon-fig.png' )
fig.savefig('Results/Ti_' + str(radial_probe_position ) +'mm_'+str(shot_number)+'.png' )
shot_number_float = shot_number
lp = pd.read_csv(urlopen('http://golem.fjfi.cvut.cz/shots/' + str(shot_number) +'/Diagnostics/PetiProbe/U_LP_fl.csv'),names = ['t','V'])
Vfl_LP = signal_cleaner(lp.V)
Vfl_LP_t = signal_cleaner(lp.t)*1e3
lo = nearest(Vfl_LP_t, fromm)-100
hi = nearest(Vfl_LP_t, untill)+100
Vfl_LP_smooth = my_lowpass_filter(Vfl_LP[lo:hi], 1 ,fs = 1/(lp.t[1]*1e3-lp.t[0]*1e3), order = 2)
# Vfl_LP_smooth = Vfl_LP[lo:hi]
xxxx = scipy.interpolate.interp1d(Vfl_LP_t[lo:hi],Vfl_LP_smooth)
V_LP_floating_pot = xxxx(iv_time)
V_BPP_floating_pot_smooth = running_mean(V_BPP_floating_pot, 100 )
# Tes =(V_BPP_floating_pot_smooth-V_LP_floating_pot)/2.5
Tes = []
Te_raw =[]
for i in range(len(V_BPP_floating_pot_smooth)):
Tes.append((V_BPP_floating_pot_smooth[i]-V_LP_floating_pot[i])/alpha_for_Te[i])
Te_raw.append((V_BPP_floating_pot[i]-V_LP_floating_pot[i])/alpha_for_Te[i])
Te_smooth = lowpasss(iv_time, Tes, 100)
V_p =[]
V_p_raw =[]
for i in range(len(Te_smooth)):
V_p.append(V_BPP_floating_pot_smooth[i] + alpha* Te_smooth[i])
V_p_raw.append(V_BPP_floating_pot[i] + alpha* Te_raw[i])
cut_lob = 0.
cut_hib = 0.
times = iv_time[nearest(iv_time, fromm+cut_lob) :nearest(iv_time, untill-cut_hib)]
Te_smooth = Te_smooth[nearest(iv_time, fromm+cut_lob) :nearest(iv_time, untill-cut_hib)]
V_p = V_p[nearest(iv_time, fromm+cut_lob) :nearest(iv_time, untill-cut_hib)]
Tes = Tes[nearest(iv_time, fromm+cut_lob) :nearest(iv_time, untill-cut_hib)]
inf = 10361 inf = 10363 inf = 10364 inf = 10365 inf = 10366 inf = 10368 inf = 10369 inf = 10371 inf = 10372 inf = 10373 inf = 10375 10376 inf = 10377 inf = 10378 inf = 10379 inf = 10380 inf = 10381 inf = 10383 inf = 10384 inf = 10385 inf = 10386 inf = 10387 inf = 10388 inf = 10389 10390 inf = 10391 inf = 10392 inf = 10393 inf = 10394 10395 inf = 10396 inf = 10397 inf = 10398 inf = 10400 inf = 10404 inf = 10405 inf = 10406 inf = 10407 inf = 10412 inf = 10413 inf = 10415 inf = 10416 inf = 10417 inf = 10418 inf = 10420 inf = 10423 inf = 10426 10427 inf = 10429 inf = 10430 inf = 10431 inf = 10432 inf = 10433 inf = 10434 inf = 10435 inf = 10436 inf = 10437 inf = 10438 inf = 10439 inf = 10440 inf = 10441 inf = 10442 inf = 10443 inf = 10445 inf = 10446 inf = 10447 inf = 10448 inf = 10449 inf = 10450 inf = 10451 inf = 10455 inf = 10457 inf = 10460 inf = 10462 inf = 10463 inf = 10466 inf = 10467 inf = 10471 10473 inf = 10477 inf = 10480 inf = 10481 inf = 10482 inf = 10484 inf = 10485 inf = 10486 inf = 10487 inf = 10488 inf = 10489 inf = 10490 inf = 10491 10493 inf = 10496 inf = 10497 inf = 10498 inf = 10499 inf = 10500 inf = 10502 inf = 10505 10506 inf = 10508 inf = 10509 inf = 10510 inf = 10515 inf = 10516 10518 inf = 10519 inf = 10520 inf = 10521 10522 inf = 10523 inf = 10525 inf = 10527 inf = 10528 inf = 10529 inf = 10530 inf = 10531 inf = 10534 inf = 10535 inf = 10536 inf = 10537 inf = 10539 inf = 10540 inf = 10541 inf = 10542 inf = 10543 inf = 10544 inf = 10545 inf = 10546 inf = 10551 inf = 10552 inf = 10553 inf = 10554 inf = 10555 inf = 10556 inf = 10557 inf = 10559 inf = 10560 inf = 10562 inf = 10564 inf = 10565 inf = 10566 inf = 10567 inf = 10568 inf = 10570 inf = 10572 inf = 10573 10575 inf = 10577 inf = 10579 inf = 10580 inf = 10581 inf = 10583 inf = 10584 inf = 10585 inf = 10586 inf = 10587 inf = 10589 inf = 10591 10592 inf = 10596 inf = 10597 inf = 10598 inf = 10599 inf = 10600 inf = 10601 inf = 10602 inf = 10603 inf = 10604 inf = 10606 inf = 10607 inf = 10608 inf = 10611 inf = 10612 inf = 10613 inf = 10614 inf = 10615 inf = 10616 inf = 10619 inf = 10621 inf = 10622 inf = 10623 inf = 10624 inf = 10625 inf = 10626 inf = 10627 inf = 10628 inf = 10629 inf = 10630 inf = 10632 inf = 10633 inf = 10634 inf = 10635 10637 inf = 10638 inf = 10639 inf = 10640 inf = 10641 inf = 10642 inf = 10644 inf = 10645 inf = 10650 inf = 10652 inf = 10653 inf = 10654 inf = 10655 inf = 10656 inf = 10658 inf = 10660 inf = 10662 inf = 10663 inf = 10664 inf = 10665 inf = 10667 inf = 10668 inf = 10670 inf = 10672 inf = 10675 inf = 10676 inf = 10677 inf = 10679 inf = 10680 inf = 10682 inf = 10683 inf = 10684 inf = 10685 inf = 10686 inf = 10688 inf = 10689 inf = 10690 inf = 10692 inf = 10694 inf = 10695 inf = 10698 inf = 10700 inf = 10701 inf = 10702 inf = 10704 inf = 10705 inf = 10709 inf = 10711 inf = 10712 inf = 10713 inf = 10714 inf = 10716 inf = 10717 10719 inf = 10721 inf = 10725 inf = 10726 inf = 10727 inf = 10728 inf = 10730 10731 inf = 10734 inf = 10735 inf = 10736 inf = 10737 inf = 10738 inf = 10740 inf = 10741 inf = 10742 inf = 10743 inf = 10747 inf = 10748 inf = 10750 inf = 10751 inf = 16655 inf = 16656 inf = 16659 inf = 16663 inf = 16664 inf = 16665 inf = 16666 inf = 16667 inf = 16668 inf = 16669 inf = 16670 inf = 16671 inf = 16673 inf = 16675 inf = 16677 inf = 16679 inf = 16682 inf = 16683 inf = 16684 inf = 16685 inf = 16686 inf = 16687 inf = 16688 inf = 16689 inf = 16690 inf = 16691 16708 inf = 16709 inf = 16710 inf = 16711 inf = 16712 inf = 16713 inf = 16715 inf = 16718 inf = 16719 inf = 16720 inf = 16721 inf = 16722 inf = 16723 inf = 16724 inf = 16725 inf = 16727 inf = 16730 inf = 16732 inf = 16737 inf = 16738 inf = 16739 inf = 16740 inf = 16741 inf = 16743 inf = 16744 inf = 16747 inf = 16749 inf = 16750 inf = 16751 inf = 16753 inf = 16754 inf = 16755 inf = 16758 inf = 16759 inf = 16760 16762 inf = 16763 inf = 16764 inf = 16769 inf = 16771 inf = 16772 inf = 16773 inf = 16775 inf = 16776 inf = 16778 inf = 16781 inf = 16784 inf = 16785 inf = 16787 inf = 16788 inf = 16791 16795 inf = 16797 inf = 16799 inf = 16802 inf = 16803 inf = 16804 16806 inf = 16807 inf = 16808 inf = 16809 inf = 16810 inf = 16811 inf = 16814 inf = 16815 inf = 16816 inf = 16817 inf = 16818 inf = 16820 inf = 16821 16822 16825 inf = 16826 inf = 16827 inf = 16828 inf = 16829 inf = 16833 inf = 16834 inf = 16836 inf = 16837 inf = 16838 inf = 16840 inf = 16842 inf = 16843 inf = 16844 inf = 16847 inf = 16849 inf = 16851 inf = 16853 inf = 16854 inf = 16858 inf = 16859 inf = 16860 inf = 16863 inf = 16865 inf = 16866 inf = 16867 inf = 16868 inf = 16869 inf = 16870 inf = 16872 16873 inf = 16874 inf = 16875 inf = 16876 inf = 16877 inf = 16878 inf = 16879 inf = 16882 inf = 16883 inf = 16885 inf = 16887 inf = 16889 inf = 16890 inf = 16891 inf = 16892 inf = 16894 inf = 16896 inf = 16901 inf = 16902 inf = 16903 inf = 16904 inf = 16905 inf = 16907 inf = 16910 inf = 16912 inf = 16915 inf = 16917 inf = 16918 inf = 16919 inf = 16920 inf = 16921 inf = 16922 inf = 16923 inf = 16926 inf = 16928 inf = 16930 inf = 16931 inf = 16932 inf = 16934 inf = 16935 inf = 16936 inf = 16937 inf = 16940 inf = 16942 inf = 16944 inf = 16945 inf = 16948 inf = 16949 inf = 16950 inf = 16952 inf = 16953 16955 inf = 16956 inf = 16957 inf = 16958 inf = 16960 inf = 16961 inf = 16963 inf = 16966 inf = 16968 inf = 16970 inf = 16971 inf = 16974 inf = 16975 inf = 16976 inf = 16977 inf = 16978 inf = 16979 inf = 16980 inf = 16982 inf = 16984 inf = 16986 inf = 16987 inf = 16988 inf = 16989 inf = 16990 inf = 16991 inf = 16992 inf = 16993 16994 16995 inf = 16996 inf = 16997 inf = 16998 inf = 16999 inf = 17000 inf = 17001 inf = 17002 inf = 17004 inf = 17006 inf = 17007 inf = 17008 inf = 17009 inf = 17011 inf = 17013 inf = 17014 inf = 17016 inf = 17018 inf = 17022 inf = 17024 inf = 17025 17026 inf = 17028 17029 inf = 17030 inf = 17032 inf = 17033 inf = 17035 inf = 17037 inf = 17038 inf = 17039 17040 inf = 17042 inf = 17043 inf = 17045 inf = 17046 inf = 17047 inf = 17048 inf = 17049 17051 inf = 17053 inf = 17054 inf = 17055 inf = 17056 inf = 17060 inf = 17062 inf = 17063 inf = 17064 inf = 17067 inf = 17068 inf = 17069 inf = 17070 inf = 17072 inf = 17074 inf = 17075 inf = 17077 inf = 17078 inf = 17082 inf = 17083 inf = 17084 inf = 17086 inf = 17087 inf = 17089 inf = 17090 inf = 17092 17093 inf = 17094 inf = 17096 inf = 17098 inf = 17099 inf = 17100 inf = 17101 inf = 17103 inf = 17104 inf = 17106 inf = 17107 inf = 17108 inf = 17109 17112 inf = 17113 inf = 17114 inf = 17115 inf = 17117 inf = 17118 inf = 17119 inf = 17120 inf = 17121 inf = 17123 inf = 17124 inf = 17125 inf = 17126 inf = 17127 inf = 17128 inf = 17131 inf = 17132 inf = 17134 inf = 17135 inf = 17136 inf = 17137 inf = 17138 inf = 17139 inf = 17140 inf = 17141 inf = 17142 inf = 17143 inf = 17144 inf = 17146 inf = 17147 inf = 17150 inf = 17152 inf = 17153 inf = 17154 inf = 17155 inf = 17156 inf = 17157 inf = 17158 inf = 17161 inf = 17162 inf = 17163 inf = 17165 inf = 17166 inf = 17167 inf = 17169 inf = 17170 inf = 17171 inf = 17172 inf = 17174 inf = 17175 inf = 17177 inf = 17178 17181 inf = 17183 inf = 17185 inf = 17186 inf = 17187 inf = 17188 inf = 17189 inf = 17190 inf = 17191 inf = 17198 inf = 17201 inf = 17204 inf = 17205 inf = 17207 inf = 17208 inf = 17209 inf = 17210 inf = 17211 inf = 17214 inf = 17216 inf = 17217 inf = 17218 inf = 17219 inf = 17221 inf = 17222 inf = 17225 inf = 17226 inf = 17229 inf = 17231 inf = 17232 inf = 17234 inf = 17236 inf = 17237 inf = 17238 inf = 17240 inf = 17243 inf = 17246 inf = 17249 inf = 17252 inf = 17254 inf = 17256 inf = 17257 inf = 17258 inf = 17259 inf = 17261 inf = 17262 17263 inf = 17265 inf = 17266 inf = 17267 inf = 17269 17271 inf = 17272 inf = 17273 inf = 17275 inf = 17276 inf = 17277 inf = 17278 inf = 17279 inf = 17281 inf = 17282 inf = 17288 inf = 17291 inf = 17292 inf = 17294 inf = 17295 inf = 17297 inf = 17298 inf = 17299 inf = 17300 inf = 17301 inf = 17303 inf = 17305 inf = 17307 inf = 17308 inf = 17309 inf = 17310 inf = 17311 inf = 17312 inf = 17313 inf = 17315 inf = 17319 inf = 17320 inf = 17323 inf = 17324 inf = 17325 inf = 17326 inf = 17327 inf = 17328 inf = 17329 inf = 17331 inf = 17332 inf = 17333 inf = 17337 inf = 17338 inf = 17342 inf = 17343 inf = 17344 inf = 17345 inf = 17347 inf = 17348 inf = 17349 inf = 17350 inf = 17351 inf = 17353 inf = 17354 inf = 17356 inf = 17359 inf = 17361 inf = 17362 inf = 17363 inf = 17364 inf = 17365 inf = 17366 inf = 17367 inf = 17368 inf = 17369 inf = 17371 inf = 17372 inf = 17373 inf = 17374 inf = 17375 inf = 17376 inf = 17377 inf = 17378 inf = 17379 inf = 17381 inf = 17382 inf = 17384 inf = 17385 inf = 17386 inf = 17387 inf = 17388 inf = 17390 inf = 17391 inf = 17395 inf = 17396 inf = 17397 inf = 17399 inf = 17401 17402 inf = 17403 inf = 17404 inf = 17406 inf = 17407 inf = 17408 inf = 17409 inf = 17410 inf = 17411 inf = 17412 inf = 17414 inf = 17415 inf = 17416 inf = 17420 inf = 17422 inf = 17424 inf = 17425 inf = 17427 inf = 17428 inf = 17429 17433 inf = 17434 inf = 17435 inf = 17437 inf = 17440 inf = 17441 inf = 17442 inf = 17447 inf = 17448 17449 17451 inf = 17452 inf = 17453 inf = 17454 inf = 17455 inf = 17456 inf = 17459 inf = 17460 inf = 17462 inf = 17464 inf = 17465 inf = 17466 inf = 17467 inf = 17470 inf = 17471 inf = 17472 17475 inf = 17477 inf = 17478 inf = 17479 inf = 17483 inf = 17484 inf = 17485 inf = 17486 inf = 17487 inf = 17488 inf = 17489 17491 inf = 17493 inf = 17495 inf = 17497 inf = 17498 inf = 17501 inf = 17502 inf = 17503 inf = 17504 inf = 17505 inf = 17507 inf = 17509 inf = 17512 inf = 17513 inf = 17515 inf = 17519 inf = 17520 inf = 17521 inf = 17523 inf = 17525 inf = 17526 inf = 17528 inf = 17529 inf = 17530 inf = 17531 17534 inf = 17535 inf = 17537 inf = 17538 inf = 17539 inf = 17540 inf = 17542 inf = 17544 17545 inf = 17546 inf = 17547 inf = 17548 inf = 17550 inf = 17551 inf = 17552 inf = 17553 inf = 17555 inf = 17556 17558 inf = 17559 inf = 17560 17562 inf = 17563 inf = 17565 inf = 17566 inf = 17568 inf = 17569 inf = 17570 inf = 17571 inf = 17572 inf = 17574 inf = 17575 inf = 17576 inf = 17577 inf = 17578 inf = 17579 inf = 17581 inf = 17582 inf = 17585 inf = 17587 inf = 17588 inf = 17589 inf = 17591 inf = 17592 inf = 17593 inf = 17595 inf = 17596 inf = 17597 inf = 17599 inf = 17602 inf = 17603 inf = 17604 inf = 17605 inf = 17606 inf = 17609 inf = 17610 inf = 17611 inf = 17612 inf = 17613 inf = 17615 inf = 17617 inf = 17619 inf = 17620 inf = 17621 inf = 17622 inf = 17625 inf = 17626 17627 inf = 17630 inf = 17631 inf = 17632 inf = 17633 inf = 17635 inf = 17636 inf = 17637 inf = 17638 17639 inf = 17640 inf = 17641 inf = 17642 inf = 17645 17646 inf = 17647 inf = 17649 inf = 17653 inf = 17655 inf = 17656 inf = 17658 inf = 17659 inf = 17660 inf = 17664 inf = 17665 inf = 17667 inf = 17668 inf = 17669 inf = 17670 inf = 17672 inf = 17674 inf = 17675 inf = 17676 inf = 17679 inf = 17680 inf = 17681 inf = 17685 inf = 17687 inf = 17688 inf = 17690 inf = 17691 inf = 17692 inf = 17694 inf = 17695 inf = 17696 inf = 17698 inf = 17702 inf = 17704 inf = 17709 inf = 17710 inf = 17712 inf = 17715 inf = 17717 inf = 17718 inf = 17720 inf = 17721 inf = 17722 inf = 17724 inf = 17725 inf = 17726 inf = 17727 inf = 17729 inf = 17730 inf = 17732 inf = 17734 inf = 17738 inf = 17740 inf = 17742 inf = 17743 inf = 17745 inf = 17747 inf = 17748 inf = 17750 inf = 17753 inf = 17754 inf = 17755 inf = 17756 inf = 17757 inf = 17761 inf = 17762 17763 inf = 17764 inf = 17766 inf = 17768 inf = 17769 inf = 17773 inf = 17774 inf = 17775 inf = 17778 inf = 17780 inf = 17782 inf = 17783 inf = 17785 inf = 17787 inf = 17789 inf = 17790 inf = 17793 inf = 17796 inf = 17797 inf = 17798 inf = 17799 inf = 17802 inf = 17803 inf = 17804 inf = 17805 inf = 17807 inf = 17808 inf = 17809 inf = 17811 inf = 17814 inf = 17815 inf = 17818 inf = 17820 inf = 17821 inf = 17822 inf = 17823 inf = 17824 inf = 17826 inf = 17828 inf = 17830 inf = 17831 inf = 17832 inf = 17835 inf = 17836 inf = 17838 inf = 17839 inf = 17841 inf = 17842 inf = 17843 inf = 17844 inf = 17845 inf = 17846 inf = 17847 inf = 17848 inf = 17850 inf = 17851 inf = 17852 inf = 17854 inf = 17855 inf = 17856 inf = 17859 inf = 17861 inf = 17862 inf = 17864 inf = 17865 inf = 17866 inf = 17868 inf = 17870 inf = 17874 17875 inf = 17877 inf = 17878 inf = 17880 inf = 17881 inf = 17884 inf = 17885 inf = 17886 inf = 17889 inf = 17890 17891 inf = 17892 inf = 17894 inf = 17895 inf = 17898 inf = 17902 inf = 17903 inf = 17904 inf = 17905 inf = 17906 inf = 17907 inf = 17908 inf = 17910 inf = 17911 inf = 17913 inf = 17914 inf = 17915 inf = 17917 17918 inf = 17919 inf = 17920 inf = 17921 inf = 17922 inf = 17923 inf = 17924 inf = 17926 inf = 17927 inf = 17928 inf = 17929 inf = 17930 inf = 17931 17935 inf = 17940 inf = 17943 inf = 17945 inf = 17946 inf = 17947 inf = 17948 inf = 17950 inf = 17952 inf = 17953 inf = 17955 inf = 17956 inf = 17957 inf = 17958 inf = 17959 inf = 17960 inf = 17963 inf = 17964 inf = 17965 inf = 17966 inf = 17968 inf = 17969 inf = 17971 inf = 17972 inf = 17973 inf = 17975 inf = 17977 inf = 17978 inf = 17979 inf = 17980 inf = 17982 inf = 17984 inf = 17985 inf = 17986 inf = 17987 inf = 17988 inf = 17989 inf = 17990 inf = 17991 inf = 17993 inf = 17994 inf = 17996 inf = 17997 inf = 17998 inf = 17999 inf = 18000 inf = 18002 inf = 18003 inf = 18004 inf = 18005 inf = 18006 inf = 18007 inf = 18010 inf = 18011 inf = 18012 inf = 18014 inf = 18015 inf = 18017 inf = 18019 inf = 18023 inf = 18024 inf = 18025 inf = 18029 inf = 18030 inf = 18031 inf = 18032 inf = 18033 18034 inf = 18035 inf = 18036 inf = 18040 inf = 18041 inf = 18042 inf = 18044 inf = 18045 inf = 18046 inf = 18048 inf = 18050 inf = 18051 inf = 18052 inf = 18053 inf = 18054 inf = 18055 inf = 18056 inf = 18057 inf = 18058 inf = 18061 inf = 18062 inf = 18063 inf = 18065 inf = 18066 inf = 18068 inf = 18069 inf = 18070 inf = 18072 inf = 18074 inf = 18075 inf = 18077 inf = 18078 inf = 18082 inf = 18083 inf = 18084 inf = 18085 inf = 18086 inf = 18088 inf = 18089 inf = 18091 inf = 18092 inf = 18093 inf = 18095 inf = 18096 inf = 18097 inf = 18098 inf = 18099 inf = 18101 inf = 18102 inf = 18103 inf = 18105 inf = 18106 18108 inf = 18111 inf = 18113 inf = 18114 inf = 18115 inf = 18117 inf = 18120 inf = 18121 inf = 18123 inf = 18125 inf = 18126 inf = 18127 inf = 18129 inf = 18130 inf = 18133 inf = 18135 inf = 18136 inf = 18137 inf = 18138 inf = 18140 inf = 18141 18144 inf = 18145 inf = 18146 inf = 18147 inf = 18149 inf = 18150 inf = 18151 inf = 18152 inf = 18153 inf = 18157 inf = 18158 inf = 18159 inf = 18160 inf = 18161 inf = 18162 inf = 18164 inf = 18167 inf = 18170 inf = 18171 inf = 18175 inf = 18177 inf = 18178 inf = 18180 18181 inf = 18183 inf = 18184 inf = 18185 inf = 18188 inf = 18189 inf = 18190 inf = 18191 inf = 18193 18194 inf = 18196 inf = 18197 inf = 18198 inf = 18200 inf = 18201 inf = 18202 inf = 18205 inf = 18206 inf = 18207 inf = 18209 inf = 18210 inf = 18212 inf = 18214 inf = 18218 inf = 18221 inf = 18223 inf = 18224 inf = 18225 inf = 18226 inf = 18227 inf = 18229 inf = 18230 inf = 18231 inf = 18232 inf = 18237 inf = 18238 inf = 18239 inf = 18240 inf = 18241 inf = 18242 inf = 18243 inf = 18244 inf = 18246 inf = 18247 inf = 18248 inf = 18251 inf = 18252 18254 inf = 18255 inf = 18256 inf = 18258 inf = 18259 inf = 18260 inf = 18263 inf = 18265 inf = 18266 inf = 18267 inf = 18268 inf = 18270 inf = 18272 inf = 18273 inf = 18274 inf = 18277 inf = 18278 inf = 18279 inf = 18281 inf = 18285 inf = 18286 inf = 18287 inf = 18288 inf = 18290 inf = 18291 inf = 18293 inf = 18295 18297 inf = 18298 inf = 18299 inf = 18300 inf = 18301 inf = 18302 inf = 18303 inf = 18304 inf = 18305 inf = 18306 inf = 18307 inf = 18308 inf = 18310 inf = 18311 inf = 18312 inf = 18315 inf = 18317 inf = 18318 inf = 18319 inf = 18322 inf = 18323 inf = 18325 inf = 18326 inf = 18327 inf = 18329 inf = 18330 inf = 18333 inf = 18334 inf = 18335 inf = 18339 inf = 18342 inf = 18343 inf = 18346 inf = 18348 inf = 18350 inf = 18351 inf = 18353 inf = 18354 inf = 18355 inf = 18356 inf = 18362 inf = 18364 inf = 18367 inf = 18374 inf = 18377 inf = 18378 inf = 18380 inf = 18381 inf = 18382 inf = 18386 inf = 18389 inf = 18391 18392 inf = 18393 inf = 18394 inf = 18395 inf = 18396 18398 inf = 18400 inf = 18402 inf = 18403 inf = 18404 inf = 18405 inf = 18407 inf = 18408 18411 inf = 18414 inf = 18415 inf = 18416 inf = 18417 inf = 18418 inf = 18420 inf = 18421 18423 inf = 18424 inf = 18425 inf = 18426 inf = 18428 inf = 18430 inf = 18431 inf = 18432 inf = 18435 inf = 18439 inf = 18442 inf = 18444 inf = 18445 inf = 18447 inf = 18448 inf = 18450 inf = 18451 inf = 18457 inf = 18458 inf = 18459 inf = 18463 inf = 18464 inf = 18465 inf = 18466 inf = 18467 inf = 18468 inf = 18469 18470 inf = 18472 18474 inf = 18475 inf = 18476 inf = 18477 inf = 18479 inf = 18481 inf = 18482 inf = 18483 inf = 18485 inf = 18488 inf = 18489 inf = 18490 inf = 18491 inf = 18492 inf = 18497 inf = 18498 18499 inf = 18500 inf = 18501 inf = 18502 inf = 18503 inf = 18504 inf = 18505 inf = 18507 18509 inf = 18510 inf = 18512 inf = 18514 inf = 18516 inf = 18518 inf = 18519 inf = 18520 18522 inf = 18524 inf = 18525 inf = 18527 inf = 18528 inf = 18529 inf = 18530 inf = 18532 inf = 18533 inf = 18536 inf = 18537 inf = 18540 inf = 18541 inf = 18542 inf = 18543 inf = 18544 inf = 18546 inf = 18547 inf = 18550 inf = 18551 inf = 18554 inf = 18557 inf = 18558 inf = 18561 inf = 18562 inf = 18564 inf = 18565 inf = 18568 inf = 18569 inf = 18570 inf = 18571 inf = 18572 inf = 18573 inf = 18576 inf = 18577 inf = 18578 inf = 18580 inf = 18581 inf = 18583 inf = 18584 inf = 18586 inf = 18588 inf = 18589 inf = 18590 inf = 18592 inf = 18593 inf = 18595 inf = 18596 inf = 18597 inf = 18598 inf = 18601 18602 inf = 18605 inf = 18607 inf = 18608 inf = 18609 inf = 18610 inf = 18611 inf = 18612 inf = 18614 inf = 18615 inf = 18616 inf = 18618 inf = 18619 inf = 18621 18623 inf = 18625 inf = 18626 inf = 18627 inf = 18630 inf = 18631 inf = 18632 18634 inf = 18635 inf = 18637 inf = 18639 inf = 18641 inf = 18642 inf = 18643 inf = 18644 inf = 18645 inf = 18648 18649 inf = 18650 inf = 18652 inf = 18653 18654 inf = 18655 inf = 18656 inf = 18658 inf = 18659 inf = 18661 inf = 18664 inf = 18665 inf = 18666 inf = 18669 inf = 18670 inf = 18674 inf = 18675 inf = 18676 inf = 18677 inf = 18678 inf = 18679 inf = 18680 inf = 18681 inf = 18682 inf = 18683 inf = 18684 inf = 18685 inf = 18686 inf = 18687 inf = 18688 inf = 18689 inf = 18690 inf = 18691 inf = 18693 inf = 18694 inf = 18695 inf = 18696 inf = 18697 inf = 18698 inf = 18699 inf = 18701 inf = 18702 inf = 18703 inf = 18704 inf = 18706 inf = 18708 inf = 18709 inf = 18710 inf = 18711 inf = 18713 inf = 18715 inf = 18717 inf = 18718 inf = 18720 inf = 18721 inf = 18723 inf = 18726 inf = 18728 inf = 18729 inf = 18730 inf = 18732 inf = 18733 inf = 18734 inf = 18736 inf = 18738 inf = 18741 inf = 18742 inf = 18743 18744 inf = 18747 inf = 18748 18750 inf = 18751 inf = 18753 18755 inf = 18757 18758 inf = 18759 inf = 18760 inf = 18762 inf = 18766 inf = 18767 inf = 18768 inf = 18769 inf = 18771 inf = 18773 inf = 18774 inf = 18776 inf = 18778 inf = 18779 inf = 18781 inf = 18782 inf = 18783 inf = 18787 inf = 18788 inf = 18790 inf = 18791 inf = 18792 inf = 18794 inf = 18795 inf = 18796 inf = 18797 inf = 18798 inf = 18799 inf = 18802 inf = 18804 inf = 18805 inf = 18807 inf = 18808 inf = 18809 inf = 18810 inf = 18812 inf = 18813 inf = 18815 inf = 18818 inf = 18819 inf = 18820 inf = 18821 inf = 18822 inf = 18823 inf = 18824 inf = 18826 inf = 18828 inf = 18829 inf = 18831 inf = 18832 inf = 18834 inf = 18835 inf = 18836 inf = 18837 inf = 18838 inf = 18840 inf = 18841 inf = 18842 inf = 18843 inf = 18844 inf = 18845 inf = 18847 inf = 18848 inf = 18850 inf = 18851 inf = 18855 18859 inf = 18860 inf = 18861 inf = 18862 18869 inf = 18870 inf = 18871 inf = 18873 18874 inf = 18875 inf = 18879 inf = 18881 inf = 18883 inf = 18884 inf = 18885 inf = 18886 inf = 18887 inf = 18888 inf = 18889 inf = 18891 inf = 18892 inf = 18894 inf = 18898 inf = 18901 inf = 18903 inf = 18904 inf = 18905 inf = 18906 18907 inf = 18908 18909 inf = 18910 inf = 18911 inf = 18913 inf = 18914 inf = 18915 inf = 18917 inf = 18918 inf = 18920 inf = 18922 inf = 18923 inf = 18924 inf = 18925 inf = 18926 inf = 18927 inf = 18929 inf = 18930 inf = 18931 inf = 18932 inf = 18934 18938 inf = 18940 inf = 18941 inf = 18942 inf = 18943 inf = 18944 inf = 18945 inf = 18948 inf = 18950 inf = 18951 inf = 18952 inf = 18953 inf = 18954 inf = 18956 inf = 18957 inf = 18958 inf = 18961 inf = 18962 inf = 18963 inf = 18964 inf = 18965 inf = 18968 inf = 18969 inf = 18970 inf = 18973 inf = 18974 inf = 18976 inf = 18977 inf = 18978 inf = 18980 inf = 18981 inf = 18982 inf = 18983 inf = 18984 inf = 18985 inf = 18987 inf = 18988 inf = 18989 18994 inf = 18995 inf = 18996 inf = 18997 inf = 18998 inf = 18999 inf = 19001 inf = 19002 inf = 19003 inf = 19005 inf = 19007 inf = 19008 inf = 19009 inf = 19011 inf = 19014 inf = 19015 inf = 19017 inf = 19021 inf = 19023 inf = 19024 inf = 19028 19029 inf = 19030 inf = 19032 inf = 19033 inf = 19035 inf = 19037 inf = 19039 19040 inf = 19041 inf = 19043 inf = 19045 inf = 19046 inf = 19047 inf = 19048 inf = 19050 inf = 19051 inf = 19052 inf = 19055 inf = 19057 inf = 19058 inf = 19059 inf = 19060 inf = 19061 inf = 19062 inf = 19063 inf = 19064 inf = 19066 inf = 19067 inf = 19070 inf = 19071 inf = 19072 inf = 19073 inf = 19075 inf = 19076 inf = 19078 inf = 19080 inf = 19083 inf = 19085 inf = 19086 inf = 19089 inf = 19090 inf = 19091 inf = 19093 inf = 19094 inf = 19097 inf = 19098 inf = 19099 inf = 19100 inf = 19102 inf = 19105 inf = 19106 inf = 19107 inf = 19108 inf = 19110 inf = 19111 inf = 19113 inf = 19114 inf = 19115 inf = 19118 inf = 19119 inf = 19120 inf = 19121 inf = 19122 inf = 19123 inf = 19124 inf = 19125 inf = 19126 inf = 19127 inf = 19129 inf = 19130 inf = 19132 inf = 19134 inf = 19135 inf = 19137 inf = 19139 inf = 19141 inf = 19142 19143 inf = 19145 inf = 19146 inf = 19147 inf = 19149 inf = 19150 inf = 19151 inf = 19152 inf = 19153 inf = 19154 inf = 19155 inf = 19156 inf = 19158 19161 inf = 19162 inf = 19165 inf = 19167 inf = 19168 inf = 19169 inf = 19171 inf = 19173 inf = 19174 inf = 19175 inf = 19176 inf = 19177 inf = 19180 inf = 19181 inf = 19182 inf = 19185 inf = 19187 inf = 19188 inf = 19190 inf = 19191 inf = 19192 inf = 19195 inf = 19197 inf = 19199 inf = 19200 inf = 19201 inf = 19202 inf = 19203 inf = 19204 inf = 19205 inf = 19206 inf = 19208 inf = 19211 inf = 19213 inf = 19214 inf = 19218 inf = 19219 inf = 19221 19222 inf = 19224 inf = 19229 inf = 19231 inf = 19232 inf = 19233 inf = 19234 inf = 19235 inf = 19236 inf = 19237 inf = 19238 inf = 19241 inf = 19242 19243 inf = 19244 inf = 19246 inf = 19248 inf = 19249 inf = 19251 inf = 19253 inf = 19254 inf = 19257 inf = 19259 inf = 19261 inf = 19263 inf = 19264 inf = 19266 inf = 19267 inf = 19269 inf = 19270 inf = 19271 inf = 19272 inf = 19273 inf = 19274 inf = 19275 inf = 19277 inf = 19278 inf = 19279 inf = 19280 inf = 19281 inf = 19282 inf = 19283 inf = 19284 inf = 19285 inf = 19286 inf = 19289 inf = 19290 inf = 19291 inf = 19292 inf = 19295 inf = 19297 inf = 19299 19301 inf = 19302 inf = 19304 inf = 19305 inf = 19307 inf = 19308 inf = 19309 inf = 19310 inf = 19313 inf = 19316 inf = 19317 inf = 19319 inf = 19322 inf = 19323 inf = 19325 inf = 19326 inf = 19327 inf = 19329 inf = 19330 inf = 19331 inf = 19334 inf = 19335 inf = 19340 inf = 19341 inf = 19342 inf = 19343 inf = 19344 inf = 19345 inf = 19346 inf = 19347 inf = 19351 inf = 19353 inf = 19357 inf = 19360 inf = 19361 inf = 19362 inf = 19363 inf = 19364 inf = 19366 inf = 19368 inf = 19369 inf = 19372 inf = 19374 inf = 19376 inf = 19377 inf = 19379 inf = 19380 inf = 19381 inf = 19383 inf = 19386 inf = 19387 19388 inf = 19390 inf = 19391 inf = 19392 inf = 19393 inf = 19396 inf = 19399 inf = 19402 inf = 19403 inf = 19404 inf = 19406 inf = 19407 inf = 19408 inf = 19410 inf = 19412 inf = 19413 inf = 19418 inf = 19419 inf = 19420 inf = 19422 inf = 19424 inf = 19425 inf = 19426 inf = 19427 inf = 19428 inf = 19429 inf = 19430 inf = 19432 inf = 19433 inf = 19434 inf = 19435 inf = 19436 inf = 19437 inf = 19438 inf = 19440 inf = 19442 inf = 19443 inf = 19444 inf = 19445 inf = 19446 inf = 19449 inf = 19451 inf = 19452 inf = 19454 inf = 19457 inf = 19458 inf = 19459 inf = 19460 inf = 19461 inf = 19462 inf = 19463 inf = 19465 inf = 19467 inf = 19468 inf = 19470 inf = 19471 inf = 19472 inf = 19473 inf = 19475 inf = 19477 inf = 19478 19479 inf = 19481 19486 inf = 19488 inf = 19489 inf = 19491 inf = 19494 19496 inf = 19498 inf = 19500 inf = 19501 inf = 19502 inf = 19504 19505 inf = 19507 inf = 19508 inf = 19509 inf = 19510 inf = 19511 inf = 19513 inf = 19516 inf = 19518 inf = 19521 inf = 19523 inf = 19524 inf = 19525 inf = 19526 inf = 19528 inf = 19529 inf = 19532 inf = 19534 inf = 19535 inf = 19536 inf = 19540 inf = 19542 inf = 19543 inf = 19544 inf = 19545 inf = 19547 inf = 19548 inf = 19549 inf = 19550 inf = 19552 inf = 19554 inf = 19555 inf = 19556 inf = 19558 inf = 19559 inf = 19560 inf = 19563 inf = 19565 inf = 19566 inf = 19568 inf = 19569 19570 inf = 19571 inf = 19572 inf = 19574 19575 inf = 19578 inf = 19579 inf = 19581 inf = 19583 inf = 19585 inf = 19588 inf = 19590 inf = 19592 inf = 19595 inf = 19596 inf = 19597 inf = 19598 inf = 19602 inf = 19604 inf = 19605 inf = 19606 inf = 19607 inf = 19608 inf = 19610 inf = 19611 inf = 19612 inf = 19613 inf = 19616 inf = 19618 inf = 19619 inf = 19620 inf = 19621 inf = 19622 inf = 19623 inf = 19624 inf = 19626 inf = 19627 inf = 19628 19630 inf = 19631 inf = 19632 inf = 19634 inf = 19635 inf = 19639 inf = 19640 inf = 19641 inf = 19642 inf = 19643 inf = 19644 inf = 19646 inf = 19647 inf = 19649 19650 inf = 19651 inf = 19654 inf = 19656 inf = 19658 inf = 19661 inf = 19662 inf = 19663 inf = 19664 inf = 19665 inf = 19666 inf = 19667 inf = 19668 inf = 19670 inf = 19672 inf = 19678 inf = 19681 inf = 19683 inf = 19684 inf = 19686 19687 inf = 19688 inf = 19689 inf = 19691 inf = 19692 inf = 19693 inf = 19694 inf = 19695 inf = 19697 inf = 19698 inf = 19701 inf = 19702 inf = 19703 inf = 19704 inf = 19705 inf = 19706 inf = 19707 inf = 19711 inf = 19713 inf = 19715 inf = 19716 inf = 19718 inf = 19719 inf = 19722 inf = 19723 inf = 19725 inf = 19727 inf = 19728 inf = 19731 inf = 19732 inf = 19734 inf = 19736 inf = 19737 inf = 19739 inf = 19741 inf = 19742 inf = 19743 inf = 19744 inf = 19745 inf = 19746 inf = 19750 inf = 19756 inf = 19760 inf = 19761 inf = 19762 inf = 19764 inf = 19765 inf = 19767 inf = 19769 19770 inf = 19772 inf = 19775 inf = 19776 inf = 19777 inf = 19778 19779 inf = 19780 inf = 19781 inf = 19782 inf = 19785 inf = 19786 inf = 19788 inf = 19789 inf = 19790 inf = 19792 inf = 19794 inf = 19796 inf = 19797 inf = 19800 inf = 19801 inf = 19802 inf = 19803 inf = 19804 inf = 19806 inf = 19807 inf = 19808 inf = 19810 inf = 19812 inf = 19816 inf = 19818 inf = 19820 inf = 19821 inf = 19822 inf = 19825 19826 inf = 19827 inf = 19828 inf = 19829 inf = 19830 inf = 19831 inf = 19832 inf = 19833 inf = 19834 inf = 19835 inf = 19837 inf = 19839 inf = 19840 inf = 19842 inf = 19843 inf = 19844 inf = 19846 inf = 19847 inf = 19848 inf = 19850 inf = 19861 inf = 19862 19864 inf = 19868 inf = 19869 19870 inf = 19872 inf = 19873 inf = 19874 inf = 19876 inf = 19877 inf = 19879 inf = 19880 inf = 19881 inf = 19882 inf = 19883 inf = 19884 inf = 19885 inf = 19886 inf = 19887 inf = 19888 inf = 19889 inf = 19890 inf = 19892 inf = 19893 inf = 19894 inf = 19920 inf = 19922 inf = 19924 inf = 19925 inf = 19926 inf = 19927 inf = 19928 inf = 19929 19930 inf = 19932 inf = 19933 inf = 19935 inf = 19976 inf = 19980 inf = 19981
plt.figure(figsize = (8,6))
# plt.plot(iv_time,V_BPP_floating_pot, 'blue', marker ='o',alpha = .4, label = 'Vfl BPP raw')
# plt.plot(iv_time,V_BPP_floating_pot_smooth, 'blue', marker ='o', label = 'Vfl BPP ')
plt.plot(iv_time,V_p_raw, marker ='o',markersize = 4, color='green',alpha = .3, label = '$\Phi$ from BPP & LP')
plt.plot(time_filter,Vp_probe_filt, 'red', marker ='o', markersize = 7, ls ='--',alpha = .5, label = '$\Phi$ 4-p fit ')
plt.plot(times,V_p, linewidth = 3, color='lime', label = '$\Phi$ smooth from BPP & LP')
plt.plot(time_filter,running_mean(Vp_probe_filt,50), color = 'red',linewidth = 3,label = '$\Phi$ smooth from fits ')
plt.ylim(-60,60)
plt.xlabel('time [ms]', fontsize = 12)
plt.ylabel('Potential [V]', fontsize = 12)
plt.legend()
plt.savefig('Results/Potential_check' + str(radial_probe_position ) +'mm_'+str(shot_number)+'.png' )
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-1-8d177e5f52a9> in <module> 6 7 plt.plot(times,V_p, linewidth = 3, color='lime', label = '$\Phi$ smooth from BPP & LP') ----> 8 plt.plot(time_filter,running_mean(Vp_probe_filt,50), color = 'red',linewidth = 3,label = '$\Phi$ smooth from fits ') 9 plt.ylim(-60,60) 10 plt.xlabel('time [ms]', fontsize = 12) <ipython-input-1-5dbf927b7065> in running_mean(l, N) 197 back = np.zeros(N//2) 198 for i in range(1, (N//2)*2, 2): --> 199 front[i//2] = np.convolve(l[:i], np.ones((i,))/i, mode = 'valid') 200 for i in range(1, (N//2)*2, 2): 201 back[i//2] = np.convolve(l[-i:], np.ones((i,))/i, mode = 'valid') <__array_function__ internals> in convolve(*args, **kwargs) /opt/anaconda3/lib/python3.8/site-packages/numpy/core/numeric.py in convolve(a, v, mode) 813 raise ValueError('a cannot be empty') 814 if len(v) == 0: --> 815 raise ValueError('v cannot be empty') 816 mode = _mode_from_name(mode) 817 return multiarray.correlate(a, v[::-1], mode) ValueError: v cannot be empty
BPP should not fluctuate more than lp. probably the noise from coax --> histeresis
plt.figure()
plt.plot(Vfl_LP_t[lo:hi], Vfl_LP[lo:hi], linewidth = 3, color = 'blue',alpha = .4, label = '$V_{fl}^{LP}$ [V]')
plt.plot(iv_time,V_BPP_floating_pot,'-o', linewidth = 1.5, color = 'red',alpha = .4, label = '$\Phi_{fl}^{BPP}$ [V]')
plt.plot(iv_time,V_LP_floating_pot, linewidth = 3, color = 'blue', label = 'smooth $V_{fl}^{LP}$ [V]')
plt.plot(iv_time,V_BPP_floating_pot_smooth,'-', linewidth = 3, color = 'orange', label = 'smooth $\Phi_{fl}^{BPP}$ [V]')
plt.xlabel('time [ms]', fontsize = 12)
plt.ylabel('Potential [V]', fontsize = 12)
plt.legend()
plt.savefig('Results/Vfl' + str(radial_probe_position ) +'mm_'+str(shot_number)+'.png' )
plt.figure()
plt.plot(times ,Tes, '-',label = 'Electron temperature [eV]' )
plt.plot(times,Te_smooth, linewidth = 3, color = 'orange', label = 'Electron temperature smooth [eV]')
plt.ylim(0,40)
plt.legend()
<matplotlib.legend.Legend at 0x7f258c1a4400>
fig, ax = subplots(figsize= (8,6))
ax.plot([],[],ls='None', label = 'OH-regime; $R = $'+str(radial_probe_position) + ' mm')
# ax.plot(times, Tes, 'o',markersize = 1.5,label = 'electron temperature #'+ str(shot_number_float))
ax.plot(times, Te_smooth,color = 'blue', linewidth =3, label = '$T_e$ smoothed #'+ str(shot_number_float))
ax.plot(time_filter, Ti_filt, 'o',markersize = 5 , color = 'red' , label ='$T_i$ 4-p fit #' + str(shot_number))
plt.errorbar(time_filter, Ti_filt, yerr=Ti_err_filt, xerr=None, fmt='None', ecolor='red', elinewidth=0.5, capsize=3, barsabove=True, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, )
#ax.set_xlim(-0.005,0.02)
ax.set_ylim(0,70)
ax.legend(fontsize = 10, loc = 'upper right')
ax.set_xlabel('time [ms]', fontsize = 12)
ax.set_ylabel('Ion and electron temperature [eV]', fontsize = 12)
plt.savefig('icon-fig.png' )
plt.savefig('Results/Ti_' + str(radial_probe_position ) +'mm_'+str(shot_number)+'.png' )
rel_p_for = np.ones(len(iv_time))
rel_p_forTi = rel_p_for-1 + radial_probe_position
My_Temperatures_full = Table([iv_time, Ti,Ti_err, Vfl,Vfl_err, R,R_err, I_sat,I_sat_err,rel_p_forTi, B_IV], names=[' t[ms] ', 'Ti[eV]', 'Ti_err[eV]', 'Vp_cut[V]','Vp_err[V]','R','R_err','I_sat','I_sat_err','p_position[m]','B_IV'])
ascii.write(My_Temperatures_full, 'Results/Ti_BPP_profile_Fast_full_'+str(shot_number)+'.txt')
#$$$$$$$$$ ULOZENIE FILTERED DAT $$$$$$$###############
p_fil = np.ones(len(time_filter))
p_filt = p_fil-1 + radial_probe_position
from astropy.table import QTable, Table, Column
My_Temperatures = Table([time_filter, Ti_filt,Ti_err_filt, Vp_probe_filt,Vp_err_filt, Isat_filter ,p_filt, B_IV_filt], names=[' t[ms] ', 'Ti[eV]', 'Ti_err[eV]', 'Vp_cut[V]','Vp_err[V]','Isat','Ti_norm_positions', 'B_IV_filt'])
ascii.write(My_Temperatures, 'Results/Ti_BPP_profile_filtered'+str(shot_number)+'.txt')
#$$$$$$$$$ ULOZENIE Te DAT $$$$$$$###############
Te_p_fil = np.ones(len(times))
Te_p_filt = Te_p_fil-1 + radial_probe_position
from astropy.table import QTable, Table, Column
Te_table = Table([times, Tes,Te_smooth,V_p, Te_p_filt , B_IV[:-1],V_LP_floating_pot[:-1] , V_BPP_floating_pot[:-1]], names=['t[ms] ', 'Te[eV]', 'Te_smooth','Plasma_potential', 'pos', 'B_IV', 'V_LP_floating_pot' , 'V_BPP_floating_pot'])
ascii.write(Te_table, 'Results/Te_'+str(shot_number)+'.txt')