Skip to content

Commit

Permalink
Fixed frontend for cycling and setpoint detectors
Browse files Browse the repository at this point in the history
  • Loading branch information
hlngo committed Jul 7, 2017
1 parent 907f66b commit 79cbd05
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
Expand Up @@ -4199,12 +4199,12 @@ angular.module('openeis-ui.directives.analysis-report', [])
setpoints.sort(function(a,b) {return a[args.Timestamp]-b[args.Timestamp]});
//Interpolate setpoint values for visualization purpose
setpoints_viz = real_data.map(function (d) {
for (i=0; i<numSetpoints; i++){
for (var i=0; i<numSetpoints; i++){
if (d[args.Timestamp] < setpoints[i][args.Timestamp])
break;
}
if (i>=numSetpoints) {
i = numSetpoints - 1;
if (i > 0) {
i = i - 1;
}
return {x: d[args.Timestamp], y: setpoints[i][points.ZoneTemperatureSetPoint]};
});
Expand Down Expand Up @@ -4823,7 +4823,7 @@ angular.module('openeis-ui.directives.analysis-report', [])
var timeUnit = getTimeUnit(data[0][fTsName], data[data.length - 1][fTsName], [data[0][fTsName], data[1][fTsName], data[2][fTsName]]);
var tArgs = {
Timestamp: fTsName,
Title: 'Temperature Set Point Detection',
Title: 'Schedule Detection',
Container: '#temps-chart-box',
TimeUnit: timeUnit
};
Expand Down
24 changes: 14 additions & 10 deletions openeis/applications/cycling_detector.py
Expand Up @@ -257,13 +257,14 @@ class Application(DrivenApplicationBaseClass):
zonetemperature_stpt_name = 'zone_temp_setpoint'
comprstatus_name = 'compressor_status'

def __init__(self, *args, minimum_data_count=5, analysis_run_interval=500, local_tz=1, **kwargs):
def __init__(self, *args, minimum_data_count=5, analysis_run_interval=500, local_tz=1, db=0.3, **kwargs):
super().__init__(*args, **kwargs)
try:
self.cur_tz = available_tz[local_tz]
except:
self.cur_tz = 'UTC'
self.cycling_detector = CyclingDetector(minimum_data_count, analysis_run_interval)

self.cycling_detector = CyclingDetector(minimum_data_count, analysis_run_interval, db)

@classmethod
def get_config_parameters(cls):
Expand All @@ -281,7 +282,11 @@ def get_config_parameters(cls):
ConfigDescriptor(int,
"Integer corresponding to local timezone: "
"[1: 'US/Pacific', 2: 'US/Mountain', 3: 'US/Central', 4: 'US/Eastern']",
value_default=1)
value_default=1),
'db':
ConfigDescriptor(float,
"Temperature Deadband",
value_default=0.3)
}

@classmethod
Expand Down Expand Up @@ -426,9 +431,10 @@ def data_builder(value_tuple, point_name):

class CyclingDetector(object):
"""OpenEIS Compressor Cycling diagnostic agent."""
def __init__(self, minimum_data_count=5, analysis_run_interval=500, **kwargs):
def __init__(self, minimum_data_count=5, analysis_run_interval=500, db=0.3, **kwargs):
self.minimum_data_count = minimum_data_count
self.check_time = analysis_run_interval
self.db = db

self.available_data_points = []
self.inconsistent_data_flag = 0
Expand Down Expand Up @@ -646,8 +652,6 @@ def results_handler(self, maximums, minimums, filtered_timeseries, diagnostic_re
def create_setpoint_array(self, pcopy, vcopy):
"""Creates setpoint array when zone temperature set point is not measured."""

db = 0.3

peak_ts1 = zip([self.timestamp_array[ind] for ind in pcopy], [self.zone_temperature_array[ind] for ind in pcopy])
valley_ts1 = zip([self.timestamp_array[ind] for ind in vcopy], [self.zone_temperature_array[ind] for ind in vcopy])

Expand All @@ -659,14 +663,14 @@ def create_setpoint_array(self, pcopy, vcopy):

zip1 = zip(peak_ts1, valley_ts1)
zip2 = zip(peak_ts2, valley_ts2)
remove_temp1 = [(x[0], x[1]) for x, y in zip1 if x[1] >= y[1] + db]
remove_temp2 = [(y[0], y[1]) for x, y in zip2 if x[1] >= y[1] + db]
remove_temp1 = [(x[0], x[1]) for x, y in zip1 if x[1] >= y[1] + self.db]
remove_temp2 = [(y[0], y[1]) for x, y in zip2 if x[1] >= y[1] + self.db]

peak_ts_list = list(peak_ts3)
valleys_ts_list = list(valley_ts3)

peaks = [pcopy[x] for x in range(pcopy.size) if peak_ts_list[x][1] >= valleys_ts_list[x][1] + db]
valleys = [vcopy[x] for x in range(vcopy.size) if peak_ts_list[x][1] >= valleys_ts_list[x][1] + db]
peaks = [pcopy[x] for x in range(pcopy.size) if peak_ts_list[x][1] >= valleys_ts_list[x][1] + self.db]
valleys = [vcopy[x] for x in range(vcopy.size) if peak_ts_list[x][1] >= valleys_ts_list[x][1] + self.db]

zone_temperature_stpt = []

Expand Down
17 changes: 11 additions & 6 deletions openeis/applications/setpoint_detector.py
Expand Up @@ -88,7 +88,7 @@ class Application(DrivenApplicationBaseClass):
zone_temp_name = 'zone_temp'
zone_temp_setpoint_name = 'zone_temp_setpoint'

def __init__(self, *args, minimum_data_count=5, sensitivity=1, local_tz=1, **kwargs):
def __init__(self, *args, minimum_data_count=5, sensitivity=1, local_tz=1, db=0.3, **kwargs):
super().__init__(*args, **kwargs)
try:
self.cur_tz = available_tz[local_tz]
Expand All @@ -103,7 +103,7 @@ def __init__(self, *args, minimum_data_count=5, sensitivity=1, local_tz=1, **kwa
else:
area_distribution_threshold = 0.1

self.setpoint_detector = SetPointDetector(minimum_data_count, area_distribution_threshold)
self.setpoint_detector = SetPointDetector(minimum_data_count, area_distribution_threshold, db)

@classmethod
def get_config_parameters(cls):
Expand All @@ -126,7 +126,11 @@ def get_config_parameters(cls):
ConfigDescriptor(int,
"Integer corresponding to local timezone: "
"[1: 'US/Pacific', 2: 'US/Mountain', 3: 'US/Central', 4: 'US/Eastern']",
value_default=1)
value_default=1),
'db':
ConfigDescriptor(float,
"Temperature Deadband",
value_default=0.3)
}

@classmethod
Expand Down Expand Up @@ -398,9 +402,10 @@ def detect_peaks(data, mph=None, threshold=0, mpd=1, edge='rising',
return ind

class SetPointDetector(object):
def __init__(self, minimum_data_count=5, area_distribution_threshold=0.1, **kwargs):
def __init__(self, minimum_data_count=5, area_distribution_threshold=0.1, db=0.3, **kwargs):
self.minimum_data_count = minimum_data_count
self.area_distribution_threshold = area_distribution_threshold
self.db = db
self.initialize()

def initialize(self):
Expand Down Expand Up @@ -582,8 +587,8 @@ def create_setpoint_array(self, pcopy, vcopy):
peak_valley_ts1 = zip(peak_ts1, valley_ts1)
peak_valley_ts2 = zip(peak_ts2, valley_ts2)

remove_temp2 = [(y[0], y[1]) for x, y in peak_valley_ts2 if x[1] >= y[1] + 0.3]
remove_temp1 = [(x[0], x[1]) for x, y in peak_valley_ts1 if x[1] >= y[1] + 0.3]
remove_temp2 = [(y[0], y[1]) for x, y in peak_valley_ts2 if x[1] >= y[1] + self.db]
remove_temp1 = [(x[0], x[1]) for x, y in peak_valley_ts1 if x[1] >= y[1] + self.db]

peak_temp = [row[1] for row in remove_temp1]
valley_temp = [row[1] for row in remove_temp2]
Expand Down

0 comments on commit 79cbd05

Please sign in to comment.