def save_total_power(data,times,SCADA_faults,filename):
total_power = np.array([])
new_times = np.array([])
percent_active = np.array([])
for time in np.unique(times):
state_fault = SCADA_faults[times == time]
fault_mask = [state_fault == 2,state_fault == 1]
fault_mask = reduce(np.logical_or,fault_mask)
total_power = np.append(total_power,np.sum(data[times == time]))
new_times = np.append(new_times,time)
percent_active = np.append(percent_active,float(np.sum(fault_mask))/float(len(fault_mask)))
total_dictionary = {}
total_dictionary['total_power'] = total_power
total_dictionary['time'] = new_times
total_dictionary['percent_active'] = percent_active
file_path = os.path.normpath('%s/FormattedData/%s' % (os.getcwd(),filename))
np.savez(file_path,**total_dictionary)
评论列表
文章目录