From 507d852057668b509e241ab65a1f95727fa8147c Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Wed, 28 Sep 2016 17:39:31 -0600 Subject: [PATCH 01/13] begin adding code for filling gaps --- ODMTools.py | 2 +- odmtools/controller/logicEditTools.py | 8 ++- odmtools/gui/mnuRibbon.py | 13 +++-- odmtools/odmdata/memory_database.py | 2 +- odmtools/odmservices/edit_service.py | 71 +++++++++++++++++++++------ 5 files changed, 74 insertions(+), 22 deletions(-) diff --git a/ODMTools.py b/ODMTools.py index ecbea16..6e57526 100755 --- a/ODMTools.py +++ b/ODMTools.py @@ -20,7 +20,7 @@ import pyodbc import pymysql -import psycopg2 +# import psycopg2 tool = LoggerTool() logger = tool.setupLogger('main', 'odmtools.log', 'a', logging.INFO) diff --git a/odmtools/controller/logicEditTools.py b/odmtools/controller/logicEditTools.py index 25b7ae2..c33dcdb 100644 --- a/odmtools/controller/logicEditTools.py +++ b/odmtools/controller/logicEditTools.py @@ -50,6 +50,13 @@ def filter_date(self, endDate, startDate): else: return "Cannot filter: %s" % (self._edit_error) + def fill_gap(self, value, time_period): + self._edit_service.fill_gap(value, time_period) + self.refresh_selection() + if self._record: + self._script("edit_service.fill_gap(%s, '%s')\n" % (value, time_period), 'black') + Publisher.sendMessage("scroll") + def data_gaps(self, value, time_period): self._edit_service.data_gaps(value, time_period) self.refresh_selection() @@ -57,7 +64,6 @@ def data_gaps(self, value, time_period): self._script("edit_service.data_gaps(%s, '%s')\n" % (value, time_period), 'black') Publisher.sendMessage("scroll") - def value_change_threshold(self, value, operator): self._edit_service.change_value_threshold(value, operator) self.refresh_selection() diff --git a/odmtools/gui/mnuRibbon.py b/odmtools/gui/mnuRibbon.py index 360f6cc..741caf8 100755 --- a/odmtools/gui/mnuRibbon.py +++ b/odmtools/gui/mnuRibbon.py @@ -36,9 +36,9 @@ wxID_RIBBONEDITSCRIPTSAVE, wxID_RIBBONVIEWPLOT, wxID_RIBBONVIEWTABLE, wxID_RIBBONVIEWSERIES, wxID_RIBBONVIEWCONSOLE, wxID_RIBBONVIEWSCRIPT, wxID_RIBBONPLOTBLANKBTN, wxID_FileMenu, wxID_STARTDPDATE, wxID_ENDDPDATE, wxID_FRAME1SPINCTRL1, wxID_RIBBONEDITFILTER, wxID_RIBBONEDITRECORD, wxID_RIBBONEDITLINFILTER, wxID_RIBBONPLOTDATEAPPLY, - wxID_RIBBONEDITRESETFILTER, wxID_RIBBONRECORDNEW, wxID_RIBBONRECORDOPEN, wxID_RIBBONRECORDSAVE] = [wx.NewId() for + wxID_RIBBONEDITRESETFILTER, wxID_RIBBONRECORDNEW, wxID_RIBBONRECORDOPEN, wxID_RIBBONRECORDSAVE, wxID_GAPFILL] = [wx.NewId() for _init_ctrls in - range(46)] + range(47)] ## ################################# ## Build Menu and Toolbar @@ -155,6 +155,7 @@ def _init_ctrls(self, prnt): self.edit_bar.AddSimpleButton(wxID_RIBBONEDITFLAG, "Flag", flag.GetBitmap(), "") self.edit_bar.AddSimpleButton(wxID_RIBBONEDITADDPOINT, "Add Point", add.GetBitmap(), "") self.edit_bar.AddSimpleButton(wxID_RIBBONEDITDELPOINT, "Delete Point", delete.GetBitmap(), "") + self.edit_bar.AddSimpleButton(wxID_GAPFILL, "Fill Gap", add.GetBitmap(), "") #self.edit_bar.AddSimpleButton(wxID_RIBBONEDITRECORD, "Record", bitmap=record.GetBitmap(), help_string="",kind=0x4) self.edit_bar.EnableButton(wxID_RIBBONEDITFILTER, False) @@ -250,6 +251,7 @@ def bindEvents(self): self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onEditFlag, id=wxID_RIBBONEDITFLAG) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onEditAddPoint, id=wxID_RIBBONEDITADDPOINT) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onEditDelPoint, id=wxID_RIBBONEDITDELPOINT) + self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onGapFill, id = wxID_GAPFILL) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onRecordNew, id=wxID_RIBBONRECORDNEW) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onRecordOpen, id=wxID_RIBBONRECORDOPEN) @@ -466,7 +468,12 @@ def onEditAddPoint(self, event): addPoint.ShowModal() event.Skip() - + # ################################### + # Gap fill + # ################################### + def onGapFill(self, event): + self.parent.getRecordService().fill_gap(30, 'minute') + event.Skip() # ################################### # Delete Point # ################################### diff --git a/odmtools/odmdata/memory_database.py b/odmtools/odmdata/memory_database.py index 2ae1763..9b2ab59 100644 --- a/odmtools/odmdata/memory_database.py +++ b/odmtools/odmdata/memory_database.py @@ -201,7 +201,7 @@ def initEditValues(self, seriesID): """ if not self.editLoaded: logger.debug("Load series from db") - + self.series = self.series_service.get_series_by_id(seriesID) self.df = self.series_service.get_values_by_series(seriesID) self.editLoaded = True diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index d3448fd..ea1354b 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -86,6 +86,7 @@ def _test_filter_previous(self): return df + def datetime2dataframe(self, datetime_list): """ Converts datetime_list to a pandas Dataframe @@ -141,19 +142,47 @@ def filter_date(self, before, after): if before and after: self.filtered_dataframe = df[(df.index < before) & (df.index > after)] + def fill_gap(self, gap, period): + + df = self.memDB.getDataValuesDF() + gaps= self.find_gaps(df, gap, period) + points = [] + series= self.memDB.series + timegap = np.timedelta64(gap, self.time_units[period]) + + for g in gaps.iterrows(): + row= g[0] + e = row["datetime"] + s= row["prevdate"] + print (s) + print (e) + + # for each gap time period in the larger gap ( until datetime = prev value) + while s != e: + s= s + timegap + points.append(('-9999', None, s, series.begin_date_time_utc, s, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id)) + #add a row points.append() [('-9999', None, datetime.datetime(2007, 9, 28, 0, 10), '-7', datetime.datetime(2007, 9, 28, 7, 10), None, None, u'nc', None, None, 1, 4, 2, 1, 0) + #('-9999', None, DATE, series.begin_date_time_utc, UTCDATE, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id + + + self.add_points(points) + + time_units = { + 'second': 's', + 'minute': 'm', + 'hour': 'h', + 'day': 'D', + 'week': 'W', + 'month': 'M', + 'year': 'Y' + } + # Data Gaps - def data_gaps(self, value, time_period): - df = self._test_filter_previous() - time_units = { - 'second': 's', - 'minute': 'm', - 'hour': 'h', - 'day': 'D', - 'week': 'W', - 'month': 'M', - 'year': 'Y' - } + + def find_gaps(self, df, value, time_period): + + # make a copy of the dataframe in order to modify it to be in the form we need to determine data gaps copy_df = df @@ -165,19 +194,29 @@ def data_gaps(self, value, time_period): value = int(value) # create a bool column indicating which rows meet condition - filtered_results = copy_df['datetime'].diff() >= np.timedelta64(value, time_units[time_period]) + filtered_results = copy_df['datetime'].diff() > np.timedelta64(value, self.time_units[time_period]) # filter on rows that passed previous condition - copy_df = copy_df[filtered_results] + return copy_df[filtered_results] + + + + def data_gaps(self, value, time_period): + df = self._test_filter_previous() + copy_df = self.find_gaps(df, value, time_period) + print (copy_df) # merge values and remove duplicates. this hack allows for both values to be marked when selecting data gaps newdf = pd.concat([copy_df['datetime'], copy_df['dateprev']], join='inner') - self.filtered_dataframe = df[df.index.isin(newdf.drop_duplicates().dropna())] # clean up del copy_df - del filtered_results - del newdf + + + self.filtered_dataframe= df[df.index.isin(newdf.drop_duplicates().dropna())] + + + def change_value_threshold(self, value, operator): From 30adaca4f4ace2c57fd8d393ebe42b57e5025359 Mon Sep 17 00:00:00 2001 From: stephanie Date: Sun, 2 Oct 2016 20:21:43 -0600 Subject: [PATCH 02/13] update gapfill --- odmtools/odmservices/edit_service.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index ea1354b..3cc47cf 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -149,22 +149,25 @@ def fill_gap(self, gap, period): points = [] series= self.memDB.series timegap = np.timedelta64(gap, self.time_units[period]) - + #if gaps is not of type dataframe- put it in a dataframe + #if not isinstance(gaps, pd.DataFrame for g in gaps.iterrows(): - row= g[0] - e = row["datetime"] - s= row["prevdate"] - print (s) - print (e) + row = g[1] + e = row.datetime + s = row.dateprev + #prime the loop + s = s + timegap # for each gap time period in the larger gap ( until datetime = prev value) - while s != e: - s= s + timegap - points.append(('-9999', None, s, series.begin_date_time_utc, s, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id)) - #add a row points.append() [('-9999', None, datetime.datetime(2007, 9, 28, 0, 10), '-7', datetime.datetime(2007, 9, 28, 7, 10), None, None, u'nc', None, None, 1, 4, 2, 1, 0) - #('-9999', None, DATE, series.begin_date_time_utc, UTCDATE, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id - - + while s < e: + utc_offset = (series.begin_date_time-series.begin_date_time_utc).total_seconds()/3600 + points.append((-9999, None, s, utc_offset, s, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id)) + #('-9999', None, DATE, series.begin_date_time_utc, UTCDATE, None, None, u'nc', None, None, + # series.site_id, series.variable_id, series.method_id, series.source_id, + # series.quality_control_level_id + + s = s + timegap + print points self.add_points(points) time_units = { From c57986dd03b910a91cb0972a3b0451c7bdf7f05b Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Mon, 3 Oct 2016 10:38:14 -0600 Subject: [PATCH 03/13] fix deprecated sort --- odmtools/controller/olvDataTable.py | 2 +- odmtools/gui/plotProbability.py | 6 ++++-- odmtools/odmservices/edit_service.py | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/odmtools/controller/olvDataTable.py b/odmtools/controller/olvDataTable.py index 58110d1..975f26c 100644 --- a/odmtools/controller/olvDataTable.py +++ b/odmtools/controller/olvDataTable.py @@ -31,7 +31,7 @@ def init(self, memDB): self.SetColumns(columns) self.dataframe = self.memDB.getDataValuesDF() sort_by_index = list(self.dataframe.columns).index("LocalDateTime") - self.dataframe.sort(self.dataframe.columns[sort_by_index], inplace=True) + self.dataframe.sort_values(self.dataframe.columns[sort_by_index], inplace=True) self.dataObjects = self.dataframe.values.tolist() self.SetObjectGetter(self.ObjectGetter) diff --git a/odmtools/gui/plotProbability.py b/odmtools/gui/plotProbability.py index 6e23761..1d2ded8 100644 --- a/odmtools/gui/plotProbability.py +++ b/odmtools/gui/plotProbability.py @@ -136,8 +136,10 @@ def updatePlot(self): #self.prob.append( #prop = oneSeries.Probability.plot(column="DataValue", ax=self.plots) #todo FutureWarning: order is deprecated, use sort_values(...) - xValues = oneSeries.Probability.xAxis.order().values - yValues = oneSeries.Probability.yAxis.order().values + #xValues = oneSeries.Probability.xAxis.order().values + xValues = oneSeries.Probability.xAxis.sort_values()#.order().values + # yValues = oneSeries.Probability.yAxis.order().values + yValues = oneSeries.Probability.yAxis.sort_values()#order().values ax = self.plots.plot(xValues, yValues, 'bs', color=oneSeries.color, label=oneSeries.plotTitle) diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index ea1354b..84eb4a5 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -150,17 +150,19 @@ def fill_gap(self, gap, period): series= self.memDB.series timegap = np.timedelta64(gap, self.time_units[period]) - for g in gaps.iterrows(): - row= g[0] - e = row["datetime"] - s= row["prevdate"] - print (s) - print (e) + for g in gaps.iterrows(): + print ("i am g[0]", g[0]) + e = g[1]#row["datetime"] + s= g[-1]#row["prevdate"] + print ( " i am the start", s) + print (" I am the end", e) + s = s+timegap # for each gap time period in the larger gap ( until datetime = prev value) - while s != e: - s= s + timegap - points.append(('-9999', None, s, series.begin_date_time_utc, s, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id)) + # while s != e: + # points.append(('-9999', None, s, series.begin_date_time_utc, s, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id)) + # s= s + timegap + #add a row points.append() [('-9999', None, datetime.datetime(2007, 9, 28, 0, 10), '-7', datetime.datetime(2007, 9, 28, 7, 10), None, None, u'nc', None, None, 1, 4, 2, 1, 0) #('-9999', None, DATE, series.begin_date_time_utc, UTCDATE, None, None, u'nc', None, None, series.site_id, series.variable_id, series.method_id, series.source_id, series.quality_control_level_id From bf69a0f45667fadb5ec73627067cecca2684e746 Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Mon, 3 Oct 2016 15:41:20 -0600 Subject: [PATCH 04/13] update visual --- odmtools/controller/logicEditTools.py | 6 +++++- odmtools/odmservices/edit_service.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/odmtools/controller/logicEditTools.py b/odmtools/controller/logicEditTools.py index c33dcdb..6ef5e64 100644 --- a/odmtools/controller/logicEditTools.py +++ b/odmtools/controller/logicEditTools.py @@ -52,10 +52,14 @@ def filter_date(self, endDate, startDate): def fill_gap(self, value, time_period): self._edit_service.fill_gap(value, time_period) - self.refresh_selection() + self.refresh_edit() if self._record: self._script("edit_service.fill_gap(%s, '%s')\n" % (value, time_period), 'black') Publisher.sendMessage("scroll") + print ("gaps filled") + + + def data_gaps(self, value, time_period): self._edit_service.data_gaps(value, time_period) diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index 2df6b9b..2debc3c 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -168,7 +168,7 @@ def fill_gap(self, gap, period): # series.quality_control_level_id s = s + timegap - print points + #print points self.add_points(points) time_units = { @@ -353,7 +353,6 @@ def change_value(self, value, operator): def add_points(self, points): # todo: add the ability to send in multiple datetimes to a single 'point' - self.memDB.addPoints(points) self._populate_series() From 46ec81bc136b4e94956c5ea4aa1ae9bf78863b9a Mon Sep 17 00:00:00 2001 From: stephanie Date: Mon, 3 Oct 2016 15:55:22 -0600 Subject: [PATCH 05/13] update plot draw --- odmtools/controller/logicEditTools.py | 2 +- odmtools/odmservices/edit_service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/odmtools/controller/logicEditTools.py b/odmtools/controller/logicEditTools.py index c33dcdb..4f03f50 100644 --- a/odmtools/controller/logicEditTools.py +++ b/odmtools/controller/logicEditTools.py @@ -52,7 +52,7 @@ def filter_date(self, endDate, startDate): def fill_gap(self, value, time_period): self._edit_service.fill_gap(value, time_period) - self.refresh_selection() + self.refresh_edit() if self._record: self._script("edit_service.fill_gap(%s, '%s')\n" % (value, time_period), 'black') Publisher.sendMessage("scroll") diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index 2df6b9b..f0655e2 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -168,7 +168,7 @@ def fill_gap(self, gap, period): # series.quality_control_level_id s = s + timegap - print points + #print points self.add_points(points) time_units = { From d24a0ffba64b6d557599a844f3a5c6595a956c5a Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Mon, 3 Oct 2016 17:16:47 -0600 Subject: [PATCH 06/13] add form --- odmtools/controller/logicEditTools.py | 10 +++++----- odmtools/gui/mnuRibbon.py | 14 +++++++++++++- odmtools/odmservices/edit_service.py | 21 ++++++++++++++++++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/odmtools/controller/logicEditTools.py b/odmtools/controller/logicEditTools.py index 6ef5e64..a3080e4 100644 --- a/odmtools/controller/logicEditTools.py +++ b/odmtools/controller/logicEditTools.py @@ -50,16 +50,16 @@ def filter_date(self, endDate, startDate): else: return "Cannot filter: %s" % (self._edit_error) - def fill_gap(self, value, time_period): - self._edit_service.fill_gap(value, time_period) + def fill_gap(self, gap, fill): + self._edit_service.fill_gap(gap , fill) self.refresh_edit() if self._record: - self._script("edit_service.fill_gap(%s, '%s')\n" % (value, time_period), 'black') + self._script("edit_service.fill_gap(gap = %s, fill= %s)\n" % (gap, fill), 'black') Publisher.sendMessage("scroll") - print ("gaps filled") - + + def data_gaps(self, value, time_period): self._edit_service.data_gaps(value, time_period) diff --git a/odmtools/gui/mnuRibbon.py b/odmtools/gui/mnuRibbon.py index 741caf8..91efa14 100755 --- a/odmtools/gui/mnuRibbon.py +++ b/odmtools/gui/mnuRibbon.py @@ -14,6 +14,7 @@ from frmFlagValues import frmFlagValues from odmtools.controller.frmLinearDrift import frmLinearDrift from odmtools.controller.frmAbout import frmAbout +from odmtools.controller.frmGapFill import frmGapFill import wizSave from odmtools.common.icons import * import pandas as pd @@ -472,7 +473,18 @@ def onEditAddPoint(self, event): # Gap fill # ################################### def onGapFill(self, event): - self.parent.getRecordService().fill_gap(30, 'minute') + + gap_fill = frmGapFill(self.parent, self.parent.getRecordService()) + + if gap_fill.Show() == wx.OK: + gap_fill.Destroy() + + + + + + + event.Skip() # ################################### # Delete Point diff --git a/odmtools/odmservices/edit_service.py b/odmtools/odmservices/edit_service.py index 2debc3c..ddfc019 100644 --- a/odmtools/odmservices/edit_service.py +++ b/odmtools/odmservices/edit_service.py @@ -17,6 +17,21 @@ # logger = tool.setupLogger(__name__, __name__ + '.log', 'w', logging.DEBUG) logger =logging.getLogger('main') +class time(object): + time_units = { + 'second': 's', + 'minute': 'm', + 'hour': 'h', + 'day': 'D', + 'week': 'W', + 'month': 'M', + 'year': 'Y' + } + + def __init__(self, value, time_period): + self.value = value + self.time_period = time_period + class EditService(): # Mutual exclusion: cursor, or connection_string def __init__(self, series_id, connection=None, connection_string="", debug=False): @@ -142,13 +157,13 @@ def filter_date(self, before, after): if before and after: self.filtered_dataframe = df[(df.index < before) & (df.index > after)] - def fill_gap(self, gap, period): + def fill_gap(self, gap, fill): df = self.memDB.getDataValuesDF() - gaps= self.find_gaps(df, gap, period) + gaps= self.find_gaps(df, gap[0], gap[1]) points = [] series= self.memDB.series - timegap = np.timedelta64(gap, self.time_units[period]) + timegap = np.timedelta64(fill[0], self.time_units[fill[1]]) #if gaps is not of type dataframe- put it in a dataframe #if not isinstance(gaps, pd.DataFrame From d6460e29d3bee9bae3e67755d3b3e9b9e7aded01 Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Tue, 11 Oct 2016 14:58:15 -0600 Subject: [PATCH 07/13] revert to deprecated sort, not compatible with current required version of pandas --- odmtools/controller/olvDataTable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odmtools/controller/olvDataTable.py b/odmtools/controller/olvDataTable.py index b9c7d70..92afb6e 100644 --- a/odmtools/controller/olvDataTable.py +++ b/odmtools/controller/olvDataTable.py @@ -31,7 +31,7 @@ def init(self, memDB): self.SetColumns(columns) self.dataframe = self.memDB.getDataValuesDF() sort_by_index = list(self.dataframe.columns).index("LocalDateTime") - self.dataframe.sort_values(self.dataframe.columns[sort_by_index], inplace=True) + self.dataframe.sort(self.dataframe.columns[sort_by_index], inplace=True) self.dataObjects = self.dataframe.values.tolist() self.SetObjectGetter(self.ObjectGetter) @@ -71,10 +71,10 @@ def sortColumn(self, selected_column): self.sortedColumnIndex = selected_column ascending = self.sortAscending if ascending: - self.dataframe.sort_values(by=self.dataframe.columns[selected_column], inplace=True) + self.dataframe.sort(by=self.dataframe.columns[selected_column], inplace=True) self.sortAscending = False elif not ascending: - self.dataframe.sort_values(by=self.dataframe.columns[selected_column], ascending=False, inplace=True) + self.dataframe.sort(by=self.dataframe.columns[selected_column], ascending=False, inplace=True) self.sortAscending = True self._UpdateColumnSortIndicators(selected_column, oldSortColumnIndex) From c68571462f66f21bb083423f0298824eb0723781 Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Tue, 11 Oct 2016 16:00:44 -0600 Subject: [PATCH 08/13] missed some deprecated sorts #290 --- odmtools/gui/plotProbability.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odmtools/gui/plotProbability.py b/odmtools/gui/plotProbability.py index 1d2ded8..7cf1551 100644 --- a/odmtools/gui/plotProbability.py +++ b/odmtools/gui/plotProbability.py @@ -137,9 +137,9 @@ def updatePlot(self): #prop = oneSeries.Probability.plot(column="DataValue", ax=self.plots) #todo FutureWarning: order is deprecated, use sort_values(...) #xValues = oneSeries.Probability.xAxis.order().values - xValues = oneSeries.Probability.xAxis.sort_values()#.order().values + xValues = oneSeries.Probability.xAxis.order().values # yValues = oneSeries.Probability.yAxis.order().values - yValues = oneSeries.Probability.yAxis.sort_values()#order().values + yValues = oneSeries.Probability.yAxis.order().values ax = self.plots.plot(xValues, yValues, 'bs', color=oneSeries.color, label=oneSeries.plotTitle) From b2e866e524f84be539ebe652b3b873f93c0e29b7 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 11 Oct 2016 17:14:06 -0600 Subject: [PATCH 09/13] update gap fill values #201 --- odmtools/controller/frmGapFill.py | 4 ++-- odmtools/controller/olvDataTable.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/odmtools/controller/frmGapFill.py b/odmtools/controller/frmGapFill.py index 44e52b8..91f7688 100644 --- a/odmtools/controller/frmGapFill.py +++ b/odmtools/controller/frmGapFill.py @@ -14,8 +14,8 @@ def onOKBtn(self, event): #TODO add validation gapvalue= self.txtGap.Value gaptime = self.cbGap.Value - fillvalue = self.txtGap.Value - filltime= self.cbGap.Value + fillvalue = self.txtFill.Value + filltime= self.cbFill.Value self.record_service.fill_gap(gap=[gapvalue, gaptime], fill=[fillvalue, filltime]) self.Close() diff --git a/odmtools/controller/olvDataTable.py b/odmtools/controller/olvDataTable.py index 92afb6e..58110d1 100644 --- a/odmtools/controller/olvDataTable.py +++ b/odmtools/controller/olvDataTable.py @@ -71,10 +71,10 @@ def sortColumn(self, selected_column): self.sortedColumnIndex = selected_column ascending = self.sortAscending if ascending: - self.dataframe.sort(by=self.dataframe.columns[selected_column], inplace=True) + self.dataframe.sort(self.dataframe.columns[selected_column], inplace=True) self.sortAscending = False elif not ascending: - self.dataframe.sort(by=self.dataframe.columns[selected_column], ascending=False, inplace=True) + self.dataframe.sort(self.dataframe.columns[selected_column], ascending=False, inplace=True) self.sortAscending = True self._UpdateColumnSortIndicators(selected_column, oldSortColumnIndex) From 2c7fc919f539b00809057a71b42a61e320761a67 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 11 Oct 2016 17:19:21 -0600 Subject: [PATCH 10/13] fix typo #201 --- odmtools/view/clsGapFill.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/odmtools/view/clsGapFill.py b/odmtools/view/clsGapFill.py index a44bdaa..13cb424 100644 --- a/odmtools/view/clsGapFill.py +++ b/odmtools/view/clsGapFill.py @@ -29,8 +29,8 @@ def __init__( self, parent ): self.lblGap.Wrap( -1 ) bsGap.Add( self.lblGap, 0, wx.ALL, 5 ) - self.txtGap1 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - bsGap.Add( self.txtGap1, 0, wx.ALL, 5 ) + self.txtGap = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + bsGap.Add( self.txtGap, 0, wx.ALL, 5 ) cbGapChoices = [ u"second", u"minute", u"hour", u"days", u"week", u"month", u"day", u"year", wx.EmptyString, wx.EmptyString, wx.EmptyString ] self.cbGap = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbGapChoices, 0 ) @@ -46,8 +46,8 @@ def __init__( self, parent ): self.lblFill.Wrap( -1 ) bsFill.Add( self.lblFill, 0, wx.ALL, 5 ) - self.txtGap = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - bsFill.Add( self.txtGap, 0, wx.ALL, 5 ) + self.txtFill = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + bsFill.Add( self.txtFill, 0, wx.ALL, 5 ) cbFillChoices = [ u"second", u"minute", u"hour", u"day", u"week", u"month", u"year" ] self.cbFill = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbFillChoices, 0 ) From 9af53acdf706b28d3866bf63f3f7d768564371de Mon Sep 17 00:00:00 2001 From: Stephanie Reeder Date: Tue, 11 Oct 2016 17:53:33 -0600 Subject: [PATCH 11/13] update from #201 --- doc/wxFormBuilder/frmFillGaps.fbp | 404 +++++++++--------------------- odmtools/view/clsGapFill.py | 153 ++++++----- 2 files changed, 195 insertions(+), 362 deletions(-) diff --git a/doc/wxFormBuilder/frmFillGaps.fbp b/doc/wxFormBuilder/frmFillGaps.fbp index 2674fa8..ddb8126 100644 --- a/doc/wxFormBuilder/frmFillGaps.fbp +++ b/doc/wxFormBuilder/frmFillGaps.fbp @@ -34,17 +34,17 @@ 1 1 - impl_virtual + decl 0 wxID_ANY - 315,174 - 315,174 + 315,217 + 315,217 dlgFill - 315,174 + 315,217 wxDEFAULT_DIALOG_STYLE @@ -93,15 +93,105 @@ bsForm wxVERTICAL none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + This function fills any gaps less than the gap duration with a no-data value at the fill frequency + + 0 + + + 0 + + 1 + lblInstructions + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + 300 + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND 1 - + + 3 + wxBOTH + + + 0 - bsGap - wxHORIZONTAL + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED none + 0 + 0 5 wxALL @@ -134,7 +224,7 @@ 0 0 wxID_ANY - Gap + Gap Duration: 0 @@ -225,7 +315,7 @@ 0 1 - txtGap1 + txtGap 1 @@ -294,7 +384,7 @@ 1 0 - "second" "minute" "hour" "days" "week" "month" "day" "year" "" "" "" + "second" "minute" "hour" "days" "week" "month" "day" "year" 1 1 @@ -367,17 +457,6 @@ - - - - 5 - wxEXPAND - 1 - - - bsFill - wxHORIZONTAL - none 5 wxALL @@ -410,7 +489,7 @@ 0 0 wxID_ANY - Fill + Fill Frequency: 0 @@ -501,7 +580,7 @@ 0 1 - txtGap + txtFill 1 @@ -649,267 +728,26 @@ 5 wxEXPAND 1 - + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 - bsButtons - wxHORIZONTAL - none - - 5 - wxEXPAND | wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panel1 - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - OK - - 0 - - - 0 - - 1 - btnOK - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onOKBtn - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Cancel - - 0 - - - 0 - - 1 - btnCancel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCancelBtn - - - - - - - - - - - - - - - - - - - - - - - - - + m_sdbSizer1 + protected + + OnCancelBtn + + + + onOKBtn + + diff --git a/odmtools/view/clsGapFill.py b/odmtools/view/clsGapFill.py index 13cb424..14a32a3 100644 --- a/odmtools/view/clsGapFill.py +++ b/odmtools/view/clsGapFill.py @@ -10,87 +10,82 @@ import wx import wx.xrc + ########################################################################### ## Class dlgFill ########################################################################### -class dlgFill ( wx.Dialog ): - - def __init__( self, parent ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 315,174 ), style = wx.DEFAULT_DIALOG_STYLE ) - - self.SetSizeHintsSz( wx.Size( 315,174 ), wx.Size( 315,174 ) ) - - bsForm = wx.BoxSizer( wx.VERTICAL ) - - bsGap = wx.BoxSizer( wx.HORIZONTAL ) - - self.lblGap = wx.StaticText( self, wx.ID_ANY, u"Gap", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.lblGap.Wrap( -1 ) - bsGap.Add( self.lblGap, 0, wx.ALL, 5 ) - - self.txtGap = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - bsGap.Add( self.txtGap, 0, wx.ALL, 5 ) - - cbGapChoices = [ u"second", u"minute", u"hour", u"days", u"week", u"month", u"day", u"year", wx.EmptyString, wx.EmptyString, wx.EmptyString ] - self.cbGap = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbGapChoices, 0 ) - self.cbGap.SetSelection( 1 ) - bsGap.Add( self.cbGap, 1, wx.ALL, 5 ) - - - bsForm.Add( bsGap, 1, wx.EXPAND, 5 ) - - bsFill = wx.BoxSizer( wx.HORIZONTAL ) - - self.lblFill = wx.StaticText( self, wx.ID_ANY, u"Fill", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.lblFill.Wrap( -1 ) - bsFill.Add( self.lblFill, 0, wx.ALL, 5 ) - - self.txtFill = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - bsFill.Add( self.txtFill, 0, wx.ALL, 5 ) - - cbFillChoices = [ u"second", u"minute", u"hour", u"day", u"week", u"month", u"year" ] - self.cbFill = wx.ComboBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbFillChoices, 0 ) - self.cbFill.SetSelection( 1 ) - bsFill.Add( self.cbFill, 1, wx.ALL, 5 ) - - - bsForm.Add( bsFill, 1, wx.EXPAND, 5 ) - - bsButtons = wx.BoxSizer( wx.HORIZONTAL ) - - self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) - bsButtons.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 ) - - self.btnOK = wx.Button( self, wx.ID_ANY, u"OK", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.btnOK.SetDefault() - bsButtons.Add( self.btnOK, 0, wx.ALL, 5 ) - - self.btnCancel = wx.Button( self, wx.ID_ANY, u"Cancel", wx.DefaultPosition, wx.DefaultSize, 0 ) - bsButtons.Add( self.btnCancel, 0, wx.ALL, 5 ) - - - bsForm.Add( bsButtons, 1, wx.EXPAND, 5 ) - - - self.SetSizer( bsForm ) - self.Layout() - - self.Centre( wx.BOTH ) - - # Connect Events - self.btnOK.Bind( wx.EVT_BUTTON, self.onOKBtn ) - self.btnCancel.Bind( wx.EVT_BUTTON, self.OnCancelBtn ) - - def __del__( self ): - pass - - - # Virtual event handlers, overide them in your derived class - def onOKBtn( self, event ): - event.Skip() - - def OnCancelBtn( self, event ): - event.Skip() - +class dlgFill(wx.Dialog): + def __init__(self, parent): + wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, + size=wx.Size(315, 217), style=wx.DEFAULT_DIALOG_STYLE) + + self.SetSizeHintsSz(wx.Size(315, 217), wx.Size(315, 217)) + + bsForm = wx.BoxSizer(wx.VERTICAL) + + self.lblInstructions = wx.StaticText(self, wx.ID_ANY, + u"This function fills any gaps less than the gap duration with a no-data value at the fill frequency", + wx.DefaultPosition, wx.DefaultSize, 0) + self.lblInstructions.Wrap(300) + bsForm.Add(self.lblInstructions, 0, wx.ALL, 5) + + fgSizer1 = wx.FlexGridSizer(0, 3, 0, 0) + fgSizer1.SetFlexibleDirection(wx.BOTH) + fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) + + self.lblGap = wx.StaticText(self, wx.ID_ANY, u"Gap Duration:", wx.DefaultPosition, wx.DefaultSize, 0) + self.lblGap.Wrap(-1) + fgSizer1.Add(self.lblGap, 0, wx.ALL, 5) + + self.txtGap = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer1.Add(self.txtGap, 0, wx.ALL, 5) + + cbGapChoices = [u"second", u"minute", u"hour", u"days", u"week", u"month", u"day", u"year"] + self.cbGap = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbGapChoices, 0) + self.cbGap.SetSelection(1) + fgSizer1.Add(self.cbGap, 1, wx.ALL, 5) + + self.lblFill = wx.StaticText(self, wx.ID_ANY, u"Fill Frequency:", wx.DefaultPosition, wx.DefaultSize, 0) + self.lblFill.Wrap(-1) + fgSizer1.Add(self.lblFill, 0, wx.ALL, 5) + + self.txtFill = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer1.Add(self.txtFill, 0, wx.ALL, 5) + + cbFillChoices = [u"second", u"minute", u"hour", u"day", u"week", u"month", u"year"] + self.cbFill = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, cbFillChoices, 0) + self.cbFill.SetSelection(1) + fgSizer1.Add(self.cbFill, 1, wx.ALL, 5) + + bsForm.Add(fgSizer1, 1, wx.EXPAND, 5) + + m_sdbSizer1 = wx.StdDialogButtonSizer() + self.m_sdbSizer1OK = wx.Button(self, wx.ID_OK) + m_sdbSizer1.AddButton(self.m_sdbSizer1OK) + self.m_sdbSizer1Cancel = wx.Button(self, wx.ID_CANCEL) + m_sdbSizer1.AddButton(self.m_sdbSizer1Cancel) + m_sdbSizer1.Realize(); + + bsForm.Add(m_sdbSizer1, 1, wx.EXPAND, 5) + + self.SetSizer(bsForm) + self.Layout() + + self.Centre(wx.BOTH) + + # Connect Events + self.m_sdbSizer1Cancel.Bind(wx.EVT_BUTTON, self.OnCancelBtn) + self.m_sdbSizer1OK.Bind(wx.EVT_BUTTON, self.onOKBtn) + + def __del__(self): + pass + + # Virtual event handlers, overide them in your derived class + def OnCancelBtn(self, event): + event.Skip() + + def onOKBtn(self, event): + event.Skip() + From 69b74c02d279f23dd4e8c111956e2e367f218940 Mon Sep 17 00:00:00 2001 From: stephanie Date: Tue, 11 Oct 2016 18:01:49 -0600 Subject: [PATCH 12/13] close form #201 --- odmtools/controller/frmGapFill.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odmtools/controller/frmGapFill.py b/odmtools/controller/frmGapFill.py index 91f7688..ce34a3b 100644 --- a/odmtools/controller/frmGapFill.py +++ b/odmtools/controller/frmGapFill.py @@ -23,3 +23,4 @@ def onOKBtn(self, event): def OnCancelBtn(self, event): self.Close() + self.Destroy() From b858ddaa78878adb0a2ae2132d7a815606a49b23 Mon Sep 17 00:00:00 2001 From: stephanie Date: Mon, 17 Oct 2016 15:13:12 -0600 Subject: [PATCH 13/13] update form text #290 --- odmtools/view/clsGapFill.py | 2 +- odmtools/view/clsSeriesSelector.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/odmtools/view/clsGapFill.py b/odmtools/view/clsGapFill.py index 14a32a3..95c1208 100644 --- a/odmtools/view/clsGapFill.py +++ b/odmtools/view/clsGapFill.py @@ -25,7 +25,7 @@ def __init__(self, parent): bsForm = wx.BoxSizer(wx.VERTICAL) self.lblInstructions = wx.StaticText(self, wx.ID_ANY, - u"This function fills any gaps less than the gap duration with a no-data value at the fill frequency", + u"This function fills any gaps greater than the gap duration with a no-data value at the fill frequency.", wx.DefaultPosition, wx.DefaultSize, 0) self.lblInstructions.Wrap(300) bsForm.Add(self.lblInstructions, 0, wx.ALL, 5) diff --git a/odmtools/view/clsSeriesSelector.py b/odmtools/view/clsSeriesSelector.py index fa4a00f..42ed9b1 100755 --- a/odmtools/view/clsSeriesSelector.py +++ b/odmtools/view/clsSeriesSelector.py @@ -155,7 +155,7 @@ def _init_ctrls(self): self.cbVariables = wx.ComboBox(choices=[], id=wxID_PNLSERIESSELECTORCBVARIABLES, name=u'cbVariables', parent=self.pnlVar, pos=wx.Point(100, 0), size=wx.Size(700, 25), style=wx.CB_READONLY, - value='comboBox4') + value='') self.cbVariables.SetLabel(u'') self.cbVariables.Enable(False)