Hello I'm hoping for some help I'm quite new to python and I wanted some advice on ways I can set up a condition so that if -inf is encounter in my data then the programme will loop to the next iteration
import numpy as np
import math
import matplotlib.pylab as plt
import pandas as pd
from scipy.interpolate import interp1d
from scipy.signal import butter, filtfilt
from scipy import interpolate
Ic = 400
lower_Ig = 720 #the lower limit of the generator current Ig
Upper_Ig = 1040 #Upper limit
Ix=range(-60,61,1)
for j in range(40, 80, 10):
Var=(40000* j)/ 10000
#print Var
for c in range(lower_Ig, Upper_Ig+1, 40):
#print c
Names =['Vg','V3', 'V4']
Data = pd.read_csv('/Documents/JTL_'+str(Var)+'/Ig='+str(c)+'/Grey_Zone.csv', names=Names)
Vg = Data['Vg']
V3 = Data['V3']
V4 = Data ['V4']
Prf = V4 / Vg
#print Prf
C = 0.802
freq = 100
b, a = butter(2, (5/C)/(freq/2), btype = 'low')
yg = filtfilt(b, a, Vg) # filter with phase shift correction
y4 = filtfilt(b, a, V4) # filter with phase shift correction
SW = y4 / yg
if SW == np.nan: #I need a condition here that if -inf is encountered then the programme should loop to next c value in for loop
continue
f = interp1d( SW, Ix )
print f(0.25), f(0.5), f(0.75)
print f(0.75)-f(0.25)
I have attempted using different numpy functions but I always get the same error
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I dont think I can use any() or all() since that will just include all the data and I want to ignore -inf. Any help is greatly appreciated
Aucun commentaire:
Enregistrer un commentaire