So my code is basically scanning a notepad .txt document and showing the output of all P.U. voltage values below 0.8 and returns a message of "faliure" if one is found. The problem is, there is at least one value in each file at exactly 0.0. This is a nuisance value that I would like to exclude. The output file is saying the file fails if it finds this value because it is below the 0.8 threshold, but this is a null value.
timeForVoltageRecovery = 11.0
acceptableVoltagePU = 0.8
for channel in data:
if float(channel['time']) > timeForVoltageRecovery:
isVoltageGood = True
keys = channel.keys()
keys.sort()
volts = {}
for key in keys:
words = key.split(" ")
if words[0] == "VOLT":
volts[float(channel[key])] = key.strip()
voltsKeys = volts.keys()
voltsKeys.sort()
for k in range(10):
if float(channel[volts[voltsKeys[k]]]) < acceptableVoltagePU:
isVoltageGood = False
if isVoltageGood:
outfile.write("\nAt time %s, this scenario passed voltage recovery criteria of 0.8 PU!\n" % (channel['time']))
else:
outfile.write("\n\t***** BAD: At Time %s, this scenario failed voltage recovery criteria of .8 PU :{ *****\n\n" % (channel['time']))
outfile.write("the lowest 10 voltages in order are:\n")
for k in range(10):
outfile.write( "\t" + volts[voltsKeys[k]] + " -> " + channel[volts[voltsKeys[k]]] + "\n" )
outfile.write("\n")
break
Does anyone know how I can still scan values below 0.8, but exclude 0.0 in my scan?
thank you.
I tried to make a lower voltage threshold value of 0.01. From here you could do an "if" statement where the acceptablevoltagePU has to be between 0.8 and 0.01. Something like this could definitely get the job done. I am not exactly sure how to code this.
I am on phone so code editor doesn't work. But what you can do if
0.0is always afalseflag just use thisif float(channel[volts[voltsKeys[k]]]) < acceptableVoltagePU and float(channel[volts[voltsKeys[k]]]) != 0.0in your if statement.