Skip to content

Commit 6f17291

Browse files
Fix AnomAnal time series time zone
1 parent 09a54c2 commit 6f17291

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Source/AnomalyDetection.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,12 @@ def initUI(self):
219219
self.ThresholdCheckBox.setChecked(False)
220220
self.ThresholdCheckBoxUpdate()
221221

222-
# # Set up datetime axis objects
223-
# # https://stackoverflow.com/questions/49046931/how-can-i-use-dateaxisitem-of-pyqtgraph
224-
# class TimeAxisItem(pg.AxisItem):
225-
# def tickStrings(self, values, scale, spacing):
226-
# return [datetime.fromtimestamp(value, pytz.timezone("UTC")) for value in values]
227-
228-
# date_axis_Dark = TimeAxisItem(orientation='bottom')
229-
# date_axis_Light = TimeAxisItem(orientation='bottom')
230-
231222
# Set up realtime plot widgets
232223
self.plotWidgetDark = pg.PlotWidget(self)
233224
self.plotWidgetDark.addLegend()
234-
self.plotWidgetDark.setAxisItems({'bottom': pg.DateAxisItem()})
225+
self.plotWidgetDark.setAxisItems({'bottom': pg.DateAxisItem(utcOffset=0)})
235226
self.plotWidgetLight = pg.PlotWidget(self)
236-
self.plotWidgetLight.setAxisItems({'bottom': pg.DateAxisItem()})
227+
self.plotWidgetLight.setAxisItems({'bottom': pg.DateAxisItem(utcOffset=0)})
237228

238229
guideLabel = QtWidgets.QLabel(\
239230
'Left-click-hold to pan, right-click-hold to zoom, or right-click-release for more options.\
@@ -1124,7 +1115,7 @@ def realTimePlot(self, radiometry1D, dateTime, sensorType,lightDark):
11241115
radUnits = self.root.attributes['LI_UNITS']
11251116

11261117
text_ylabel=f'[DARKS] {sensorType}({self.waveBand:.0f}) [{radUnits}]'
1127-
text_xlabel='Timestamp'
1118+
text_xlabel='Time series'
11281119
figTitle = f'Band: {self.waveBand} Window: {window} Sigma: {sigma}'
11291120
# self.plotWidgetDark.setWindowTitle(figTitle)
11301121
print(f'{figTitle} Dark')
@@ -1133,8 +1124,7 @@ def realTimePlot(self, radiometry1D, dateTime, sensorType,lightDark):
11331124
self.plotWidgetDark.setLabel('bottom', text_xlabel,**styles)
11341125
# self.plotWidgetDark.setLabel('bottom', text_xlabel,**styles)
11351126
self.plotWidgetDark.showGrid(x=True, y=True)
1136-
# ''' legend not working '''
1137-
# self.plotWidgetDark.addLegend()
1127+
11381128
else:
11391129
ph = self.phLight
11401130
phAve = self.phTimeAveLight
@@ -1153,7 +1143,7 @@ def realTimePlot(self, radiometry1D, dateTime, sensorType,lightDark):
11531143
radUnits = self.root.attributes['LI_UNITS']
11541144

11551145
text_ylabel=f'[LIGHTS] {sensorType}({self.waveBand:.0f}) [{radUnits}]'
1156-
text_xlabel='Timestamp'
1146+
text_xlabel='Time series'
11571147
figTitle = f'Band: {self.waveBand} Window: {window} Sigma: {sigma}'
11581148
print(f'{figTitle} Dark')
11591149
# self.plotWidgetLight.setWindowTitle(figTitle, **styles)
@@ -1165,8 +1155,7 @@ def realTimePlot(self, radiometry1D, dateTime, sensorType,lightDark):
11651155
badIndex, badIndex2, badIndex3 = Utilities.deglitchBand(self.waveBand,radiometry1D, window, sigma, lightDark, minRad, maxRad,minMaxBand)
11661156
avg = Utilities.movingAverage(radiometry1D, window).tolist()
11671157

1168-
# ''' Use numeric series (x) for now in place of datetime '''
1169-
# x = np.arange(0,len(radiometry1D),1)
1158+
# Convert to timestamp
11701159
x = np.array([x.timestamp() for x in dateTime])
11711160

11721161
# First Pass

0 commit comments

Comments
 (0)