Skip to content

Commit bf10ba4

Browse files
author
stephanie
committed
merging
2 parents 65166e9 + a245f91 commit bf10ba4

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

odmtools/controller/frmLinearDrift.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ def OnBtnOKButton(self, event):
1313
Perform Drift Correction based on given input. Catch errors if the user enters something invalid
1414
"""
1515
try:
16-
self._record_service.drift_correction(float(self.txtFinalGapValue.GetValue()))
16+
result = self._record_service.drift_correction(float(self.txtFinalGapValue.GetValue()))
17+
if not result:
18+
dial = wx.MessageDialog( None, "Linear drift can only be performed on one continuous data selection. \nPlease modify your selection and try again.", "Bad Input", wx.OK)
19+
dial.ShowModal()
1720
except Exception as e:
1821
dial = wx.MessageDialog(None, "Unable to convert value to float %s" % e, "Bad Input",
1922
wx.OK | wx.ICON_ERROR)

odmtools/controller/logicEditTools.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ def interpolate(self):
196196

197197
def drift_correction(self, gap_width):
198198
ret = self._edit_service.drift_correction(gap_width)
199-
self.refresh_edit()
200-
if self._record:
201-
self._script("edit_service.drift_correction(%s)\n" % (gap_width), 'black')
202-
Publisher.sendMessage("scroll")
199+
if ret:
200+
self.refresh_edit()
201+
if self._record:
202+
self._script("edit_service.drift_correction(%s)\n" % (gap_width), 'black')
203+
Publisher.sendMessage("scroll")
203204
return ret
204205

205206
def reset_filter(self):

odmtools/odmdata/memory_database.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def __init__(self, taskserver=None):
2121
self.df = None
2222
# Series_Service handles remote database
2323
self.series_service = None
24+
2425
# Memory_service handles in memory database
2526
self.mem_service = SeriesService("sqlite:///:memory:")
2627
# TODO clean up closing of program

odmtools/odmservices/edit_service.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,22 @@ def interpolate(self):
404404

405405
self.memDB.update(update_list)
406406

407-
408407
self._populate_series()
409408

410409
self.filtered_dataframe = self._series_points_df[self._series_points_df.index.isin(ids)]
411410

411+
412412
def drift_correction(self, gap_width):
413+
414+
413415
if self.isOneGroup():
414416
tmp_filter_list =self.get_filtered_points()
415417
startdate =tmp_filter_list.index[0]
416418
x_l = (tmp_filter_list.index[-1]-startdate).total_seconds()
417-
419+
#nodv= self.memDB.series_service.get_variable_by_id(self.memDB.df["VariableID"][0])
420+
nodv = self.memDB.series.variable.no_data_value
418421
# y_n = y_0 + G(x_i / x_l)
419-
f = lambda row : row["DataValue"]+(gap_width * ((row.name-startdate).total_seconds() / x_l))
422+
f = lambda row : row["DataValue"]+(gap_width * ((row.name-startdate).total_seconds() / x_l)) if row["DataValue"] != nodv else row["DataValue"]
420423
tmp_filter_list["DataValue"]=tmp_filter_list.apply(f, axis = 1)
421424

422425
update_list = [{"value": row["DataValue"], "id":index} for index, row in tmp_filter_list.iterrows()]

0 commit comments

Comments
 (0)