To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit cf1482e9 authored by holukas's avatar holukas
Browse files

updated ustar detection

parent 9af1d38d
This diff is collapsed.
...@@ -328,7 +328,6 @@ class Ui_MainWindow(object): ...@@ -328,7 +328,6 @@ class Ui_MainWindow(object):
return frm_FocusArea return frm_FocusArea
def add_modbox_Plots(self): def add_modbox_Plots(self):
# CATEGORY 0: PLOTS (ModBox)
self.modbox_plots = modbox_pl.AddControls(grd_Categories=self.grd_categories, self.modbox_plots = modbox_pl.AddControls(grd_Categories=self.grd_categories,
stk_Options=self.stk_category_options, stk_Options=self.stk_category_options,
stk_Refinements=self.stk_option_refinements, stk_Refinements=self.stk_option_refinements,
...@@ -468,87 +467,28 @@ class Ui_MainWindow(object): ...@@ -468,87 +467,28 @@ class Ui_MainWindow(object):
self.lne_gf_ref_LinInterp_limit.setText('1') self.lne_gf_ref_LinInterp_limit.setText('1')
def add_modbox_Analyses(self): def add_modbox_Analyses(self):
self.btn_an_cat_Analyses_showStack, \ self.modbox_analyses = modbox_an.AddControls(grd_Categories=self.grd_categories,
self.btn_an_opt_ClassFinder, \ stk_Options=self.stk_category_options,
self.an_ref_ClassFinder_stackTab, \ stk_Refinements=self.stk_option_refinements,
self.drp_an_ref_ClassFinder_classVar, \ ctx=self.ctx)
self.btn_an_ref_ClassFinder_showPlot, \
self.lne_an_ref_ClassFinder_lowerClassLimit, \
self.lne_an_ref_ClassFinder_upperClassLimit, \
self.btn_an_opt_RunningLinRegr, \
self.an_ref_RunningLinRegr_stackTab, \
self.drp_an_ref_RunningLinRegr_indVar, \
self.lne_an_ref_RunningLinRegr_windowSize, \
self.lne_an_ref_RunningLinRegr_windowMinVals, \
self.lne_an_ref_RunningLinRegr_windowStepSize, \
self.btn_an_ref_RunningLinRegr_showPlot, \
self.an_ref_uStarDetection_stackTab, \
self.btn_an_opt_uStarDetection, \
self.btn_an_ref_uStarDetection_showInNewTab, \
self.an_ref_GapFinder_stackTab, \
self.btn_an_opt_GapFinder, \
self.btn_an_ref_GapFinder_showPlot, \
self.an_ref_BeforeAfterEvent_stackTab, \
self.btn_an_opt_BeforeAfterEvent, \
self.drp_an_ref_BeforeAfterEvent_var, \
self.lne_an_ref_BeforeAfterEvent_windowSize, \
self.lne_an_ref_BeforeAfterEvent_windowMinVals, \
self.btn_an_ref_BeforeAfterEvent_showPlot, \
self.an_ref_Aggregator_stackTab, \
self.btn_an_opt_Aggregator, \
self.btn_an_ref_Aggregator_showInNewTab, \
self.an_ref_NetGHGBalance_stackTab, \
self.btn_an_opt_NetGHGBalance, \
self.btn_an_ref_NetGHGBalance_showInNewTab = \
modbox_an.AddControls(grd_Categories=self.grd_categories,
stk_Options=self.stk_category_options,
stk_Refinements=self.stk_option_refinements,
ctx=self.ctx).get_handles()
# Default values # Default values
self.lne_an_ref_ClassFinder_lowerClassLimit.setText('0') self.modbox_analyses.ClassFinder.ref_lne_lower_class_lim.setText('0')
self.lne_an_ref_ClassFinder_upperClassLimit.setText('20') self.modbox_analyses.ClassFinder.ref_lne_upper_class_lim.setText('20')
self.lne_an_ref_RunningLinRegr_windowSize.setText('480') ## 10 days @30min files self.modbox_analyses.RunningLinReg.ref_lne_win_size.setText('480') ## 10 days @30min files
self.lne_an_ref_RunningLinRegr_windowMinVals.setText('321') ## more than 2/3 available self.modbox_analyses.RunningLinReg.ref_lne_win_min_vals.setText('321') ## more than 2/3 available
self.lne_an_ref_RunningLinRegr_windowStepSize.setText('480') self.modbox_analyses.RunningLinReg.ref_lne_win_step_size.setText('480')
self.lne_an_ref_BeforeAfterEvent_windowSize.setText('7') self.modbox_analyses.BeforeAfterEvent.ref_lne_win_size.setText('7')
self.lne_an_ref_BeforeAfterEvent_windowMinVals.setText('72') self.modbox_analyses.BeforeAfterEvent.ref_lne_win_min_vals.setText('72')
def add_modbox_Modifications(self): def add_modbox_Modifications(self):
self.btn_mf_cat_Conversions_showStack, \ self.modbox_modifications = modbox_mf.AddControls(grd_Categories=self.grd_categories,
self.mf_ref_ResampleToFreq_stackTab, \ stk_Options=self.stk_category_options,
self.btn_mf_opt_ResampleToFreq, \ stk_Refinements=self.stk_option_refinements,
self.lne_mf_ref_ResampleToFreq_freqDuration, \ ctx=self.ctx)
self.drp_mf_ref_ResampleToFreq_freq, \
self.drp_mf_ref_ResampleToFreq_agg, \
self.lne_mf_ref_ResampleToFreq_minVals, \
self.btn_mf_ref_ResampleToFreq_showPlot, \
self.mf_ref_CreateNewVarGain_stackTab, \
self.btn_mf_opt_CreateNewVarGain, \
self.lne_mf_ref_CreateNewVarGain_gain, \
self.lne_mf_ref_CreateNewVarGain_units, \
self.btn_mf_ref_CreateNewVarGain_showPlot, \
self.mf_ref_RemoveVar_stackTab, \
self.btn_mf_opt_RemoveVar, \
self.btn_mf_ref_RemoveVar_removeVar, \
self.mf_ref_CreateEvent_stackTab, \
self.btn_mf_opt_CreateEvent, \
self.lne_mf_ref_CreateEvent_name, \
self.dte_mf_ref_CreateEvent_start, \
self.dte_mf_ref_CreateEvent_end, \
self.btn_mf_ref_CreateEvent_addAsVar, \
self.mf_ref_LimitTimeRange_stackTab, \
self.btn_mf_opt_LimitTimeRange, \
self.dte_mf_ref_LimitTimeRange_start, \
self.dte_mf_ref_LimitTimeRange_end, \
self.btn_mf_ref_LimitTimeRange_apply = \
modbox_mf.AddControls(grd_Categories=self.grd_categories,
stk_Options=self.stk_category_options,
stk_Refinements=self.stk_option_refinements,
ctx=self.ctx).get_handles()
# Default values # Default values
self.lne_mf_ref_ResampleToFreq_freqDuration.setText('1') self.modbox_modifications.ResampleToFreq.ref_lne_freq_duration.setText('1')
self.lne_mf_ref_ResampleToFreq_minVals.setText('1') self.modbox_modifications.ResampleToFreq.ref_lne_min_vals.setText('1')
self.lne_mf_ref_CreateNewVarGain_gain.setText('1') self.modbox_modifications.CreateNewVarWithGain.ref_lne_gain.setText('1')
def add_modbox_Corrections(self): def add_modbox_Corrections(self):
self.btn_cr_cat_Corrections_showStack, \ self.btn_cr_cat_Corrections_showStack, \
......
...@@ -443,6 +443,14 @@ def parse_csv_file(filepath, settings_dict, args): ...@@ -443,6 +443,14 @@ def parse_csv_file(filepath, settings_dict, args):
na_values=settings_dict['na_values'], encoding='utf-8', delimiter=settings_dict['delimiter'], na_values=settings_dict['na_values'], encoding='utf-8', delimiter=settings_dict['delimiter'],
mangle_dupe_cols=True) mangle_dupe_cols=True)
# # In case of unknown and irregular number of columns, this could be used at some point:
# # https://stackoverflow.com/questions/51028331/pandas-read-csv-add-header-names-in-case-of-changing-number-of-columns
# import csv
# with open(filepath, newline='') as in_fp:
# reader = csv.reader(in_fp)
# header = next(reader)
# num_cols = max(len(row) for row in reader)
merged_args = {**shared_args, **args} merged_args = {**shared_args, **args}
data_df = pd.read_csv(filepath, **merged_args) data_df = pd.read_csv(filepath, **merged_args)
......
...@@ -19,6 +19,8 @@ GAPFILLED_GENERAL_SCALARS = ['*-f*'] ...@@ -19,6 +19,8 @@ GAPFILLED_GENERAL_SCALARS = ['*-f*']
MONIN_OBUKHOV_STABILITY = ['(z-d)/L'] MONIN_OBUKHOV_STABILITY = ['(z-d)/L']
NIGHTTIME_DETECTION = ['*SW_IN*', '*daytime*']
# ============================================================================================== # ==============================================================================================
# QC FLAGS ///////////////////////////////////////////////////////////////////////////////////// # QC FLAGS /////////////////////////////////////////////////////////////////////////////////////
# ============================================================================================== # ==============================================================================================
...@@ -38,7 +40,7 @@ SIGNAL_STRENGTH_IRGA = ['signal_strength*', 'window_dirtiness*', 'status_byte*'] ...@@ -38,7 +40,7 @@ SIGNAL_STRENGTH_IRGA = ['signal_strength*', 'window_dirtiness*', 'status_byte*']
SPECTRAL_CORRECTION_FACTOR =['_scf'] SPECTRAL_CORRECTION_FACTOR =['_scf']
STORAGE = ['_strg'] STORAGE = ['_strg']
USTAR = ['u*'] USTAR_EDDYPRO = ['u*']
VPD = ['*VPD*'] VPD = ['*VPD*']
......
...@@ -39,6 +39,7 @@ from modboxes.GapFilling import MDS as gf_MDS ...@@ -39,6 +39,7 @@ from modboxes.GapFilling import MDS as gf_MDS
from modboxes.GapFilling import RunningSimple as gf_RunningMedianSimple from modboxes.GapFilling import RunningSimple as gf_RunningMedianSimple
from modboxes.HiResTests import HiResTests_gui as hrt_HiResTests_gui from modboxes.HiResTests import HiResTests_gui as hrt_HiResTests_gui
from modboxes.HiResTests import StationarityM98 as hrt_StationarityM98 from modboxes.HiResTests import StationarityM98 as hrt_StationarityM98
from modboxes.Modifications import AddStringPrefixSuffix as mf_AddSuffix
from modboxes.Modifications import CreateEvent as mf_CreateEvent from modboxes.Modifications import CreateEvent as mf_CreateEvent
from modboxes.Modifications import CreateNewVarWithGain as mf_CreateNewVarGain from modboxes.Modifications import CreateNewVarWithGain as mf_CreateNewVarGain
from modboxes.Modifications import LimitTimeRange as mf_LimitTimeRange from modboxes.Modifications import LimitTimeRange as mf_LimitTimeRange
...@@ -133,11 +134,11 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -133,11 +134,11 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
od_OutlierDetection_gui.connect(self=self, opt_tab_idx=2) # OUTLIER DETECTION (ref stackTab 12-15) od_OutlierDetection_gui.connect(self=self, opt_tab_idx=2) # OUTLIER DETECTION (ref stackTab 12-15)
gf_GapFilling_gui.connect(self=self, opt_tab_idx=3) # GAP-FILLING (ref stackTab 16-19) gf_GapFilling_gui.connect(self=self, opt_tab_idx=3) # GAP-FILLING (ref stackTab 16-19)
an_Analyses_gui.connect(self=self, opt_tab_idx=4) # ANALYSES (ref stackTab 20-26) an_Analyses_gui.connect(self=self, opt_tab_idx=4) # ANALYSES (ref stackTab 20-26)
mf_Modifications_gui.connect(self=self, opt_tab_idx=5) # MODIFICATIONS (ref stackTab 27-31) mf_Modifications_gui.connect(self=self, opt_tab_idx=5) # MODIFICATIONS (ref stackTab 27-32)
cr_Corrections_gui.connect(self=self, opt_tab_idx=6) # CORRECTIONS (ref stackTab 32) cr_Corrections_gui.connect(self=self, opt_tab_idx=6) # CORRECTIONS (ref stackTab 33)
hrt_HiResTests_gui.connect(self=self, opt_tab_idx=7) # HI-RES TESTS (ref stackTab 33) hrt_HiResTests_gui.connect(self=self, opt_tab_idx=7) # HI-RES TESTS (ref stackTab 34)
pn_Pipelines_gui.connect(self=self, opt_tab_idx=8) # PIPELINES (ref stackTab 34) pn_Pipelines_gui.connect(self=self, opt_tab_idx=8) # PIPELINES (ref stackTab 35)
ex_Export_gui.connect(self=self, opt_tab_idx=9) # EXPORT (ref stackTab 35-36) ex_Export_gui.connect(self=self, opt_tab_idx=9) # EXPORT (ref stackTab 35-37)
# -------------------------------- # --------------------------------
# CONNECTIONS CONTROLS ----------- # CONNECTIONS CONTROLS -----------
...@@ -158,7 +159,7 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -158,7 +159,7 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
if self.load_initial_data: if self.load_initial_data:
self.select_source(action='load_initial_data') self.select_source(action='load_initial_data')
# self.plot_focus(fig=-9999, plot_type='OVERVIEW') # self.plot_focus(fig=-9999, plot_type='OVERVIEW')
self.make_tab(make_tab='MDS') # self.make_tab(make_tab='MDS')
# self.make_tab(make_tab='USTAR_DETECTION') # e.g., shortcut to ustar detection # self.make_tab(make_tab='USTAR_DETECTION') # e.g., shortcut to ustar detection
# self.make_tab(make_tab='AGGREGATOR') # self.make_tab(make_tab='AGGREGATOR')
# self.make_tab(make_tab='SCATTER') # self.make_tab(make_tab='SCATTER')
...@@ -444,9 +445,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -444,9 +445,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.lst_Variables.clear() self.lst_Variables.clear()
# Reset modBox drop-down menus # Reset modBox drop-down menus
self.drp_an_ref_ClassFinder_classVar.clear() self.modbox_analyses.ClassFinder.ref_drp_class_var.clear()
self.drp_an_ref_RunningLinRegr_indVar.clear() self.modbox_analyses.RunningLinReg.ref_drp_ind_var.clear()
self.drp_an_ref_BeforeAfterEvent_var.clear() self.modbox_analyses.BeforeAfterEvent.ref_drp_var.clear()
self.drp_qc_ref_DefaulFlagEddyPro.clear() # EddyPro default QC flag drop-down self.drp_qc_ref_DefaulFlagEddyPro.clear() # EddyPro default QC flag drop-down
self.drp_qc_ref_SignalStrengthIRGA.clear() self.drp_qc_ref_SignalStrengthIRGA.clear()
self.drp_qc_ref_SpectralCorrectionFactor.clear() self.drp_qc_ref_SpectralCorrectionFactor.clear()
...@@ -500,9 +501,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -500,9 +501,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
# REFINEMENT MENUS THAT NEED ALL VARIABLES # REFINEMENT MENUS THAT NEED ALL VARIABLES
# -------------------------------------- # --------------------------------------
self.drp_an_ref_ClassFinder_classVar.addItem(colname_pretty_string) self.modbox_analyses.ClassFinder.ref_drp_class_var.addItem(colname_pretty_string)
self.drp_an_ref_RunningLinRegr_indVar.addItem(colname_pretty_string) self.modbox_analyses.RunningLinReg.ref_drp_ind_var.addItem(colname_pretty_string)
self.drp_an_ref_BeforeAfterEvent_var.addItem(colname_pretty_string) self.modbox_analyses.BeforeAfterEvent.ref_drp_var.addItem(colname_pretty_string)
self.drp_gf_ref_LinRegrSimple_indVar.addItem(colname_pretty_string) self.drp_gf_ref_LinRegrSimple_indVar.addItem(colname_pretty_string)
# # OUTLIER DETECTION: Double-Differenced Time Series # # OUTLIER DETECTION: Double-Differenced Time Series
...@@ -534,11 +535,11 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -534,11 +535,11 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.drp_qc_ref_SignalStrengthIRGA.addItem(colname_pretty_string) self.drp_qc_ref_SignalStrengthIRGA.addItem(colname_pretty_string)
# Manual u* Threshold # Manual u* Threshold
if colname_tuple[0].endswith(tuple(USTAR)): # .endwith needs tuple if colname_tuple[0].endswith(tuple(USTAR_EDDYPRO)): # .endwith needs tuple
self.drp_qc_ref_UstarThresholdConstantManual.addItem(colname_pretty_string) self.drp_qc_ref_UstarThresholdConstantManual.addItem(colname_pretty_string)
# Detected, auto u* Threshold # Detected, auto u* Threshold
if colname_tuple[0].endswith(tuple(QCFLAGS_AMP_USTAR)): # .endwith needs tuple if any(fnmatch.fnmatch(colname_tuple[0], ids) for ids in QCFLAGS_AMP_USTAR):
self.drp_qc_ref_UstarThresDetectedAuto.addItem(colname_pretty_string) self.drp_qc_ref_UstarThresDetectedAuto.addItem(colname_pretty_string)
# EddyPro Raw Data Statistical Flags # EddyPro Raw Data Statistical Flags
...@@ -571,17 +572,17 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -571,17 +572,17 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
min_data_day_qt = qtc.QDate.fromString(min_data_day_str, 'yyyy-MM-dd') # Qt format min_data_day_qt = qtc.QDate.fromString(min_data_day_str, 'yyyy-MM-dd') # Qt format
max_data_day_qt = qtc.QDate.fromString(max_data_day_str, 'yyyy-MM-dd') max_data_day_qt = qtc.QDate.fromString(max_data_day_str, 'yyyy-MM-dd')
self.dte_mf_ref_CreateEvent_start.setDate(min_data_day_qt) self.modbox_modifications.CreateEvent.ref_dte_start.setDate(min_data_day_qt)
# self.dte_mf_ref_CreateEvent_start.setMinimumDate(min_data_day_qt) # self.dte_mf_ref_CreateEvent_start.setMinimumDate(min_data_day_qt)
# self.dte_mf_ref_CreateEvent_start.setMaximumDate(max_data_day_qt) # self.dte_mf_ref_CreateEvent_start.setMaximumDate(max_data_day_qt)
self.dte_mf_ref_CreateEvent_end.setDate(max_data_day_qt) self.modbox_modifications.CreateEvent.ref_dte_end.setDate(max_data_day_qt)
# self.dte_mf_ref_CreateEvent_end.setMinimumDate(min_data_day_qt) # self.dte_mf_ref_CreateEvent_end.setMinimumDate(min_data_day_qt)
# self.dte_mf_ref_CreateEvent_end.setMaximumDate(max_data_day_qt) # self.dte_mf_ref_CreateEvent_end.setMaximumDate(max_data_day_qt)
self.dte_mf_ref_LimitTimeRange_start.setDate(min_data_day_qt) self.modbox_modifications.LimitTimeRange.ref_dte_start.setDate(min_data_day_qt)
# self.dte_mf_ref_LimitTimeRange_start.setMinimumDate(min_data_day_qt) # self.dte_mf_ref_LimitTimeRange_start.setMinimumDate(min_data_day_qt)
# self.dte_mf_ref_LimitTimeRange_start.setMaximumDate(max_data_day_qt) # self.dte_mf_ref_LimitTimeRange_start.setMaximumDate(max_data_day_qt)
self.dte_mf_ref_LimitTimeRange_end.setDate(max_data_day_qt) self.modbox_modifications.LimitTimeRange.ref_dte_end.setDate(max_data_day_qt)
# self.dte_mf_ref_LimitTimeRange_end.setMinimumDate(min_data_day_qt) # self.dte_mf_ref_LimitTimeRange_end.setMinimumDate(min_data_day_qt)
# self.dte_mf_ref_LimitTimeRange_end.setMaximumDate(max_data_day_qt) # self.dte_mf_ref_LimitTimeRange_end.setMaximumDate(max_data_day_qt)
...@@ -1027,16 +1028,16 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1027,16 +1028,16 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.TabWidget.setCurrentIndex(tab_number) self.TabWidget.setCurrentIndex(tab_number)
else: else:
# Create tab # Create tab
self.MDS_Tab = gf_MDS.MakeNewTab(TabWidget=self.TabWidget, self.tab_mds = gf_MDS.MakeNewTab(TabWidget=self.TabWidget,
col_dict_tuples=self.selected_file_colnames_tuples_dict, col_dict_tuples=self.selected_file_colnames_tuples_dict,
col_list_pretty=self.selected_file_colnames_pretty_strings_list, col_list_pretty=self.selected_file_colnames_pretty_strings_list,
data_df=self.data_df) data_df=self.data_df)
self.MDS_Tab.btn_init.clicked.connect(self.mds_init_data) self.tab_mds.btn_init.clicked.connect(self.mds_init_data)
def mds_init_data(self): def mds_init_data(self):
"""Prepare data for MDS gap-filling.""" """Prepare data for MDS gap-filling."""
self.obj_mds = gf_MDS.RunMDS(mds_tab=self.MDS_Tab) self.obj_mds = gf_MDS.RunMDS(mds_tab=self.tab_mds)
# Start gap-filling when button is pressed # Start gap-filling when button is pressed
self.obj_mds.btn_qual_A.clicked.connect(lambda: self.mds_get_results(which='quality_A')) self.obj_mds.btn_qual_A.clicked.connect(lambda: self.mds_get_results(which='quality_A'))
...@@ -1070,51 +1071,14 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1070,51 +1071,14 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.TabWidget.setCurrentIndex(tab_number) self.TabWidget.setCurrentIndex(tab_number)
# pass # pass
else: else:
self.drp_an_ref_uStarDet_flux, \ self.tab_ustar_auto = an_uStarDetection.MakeNewTab(TabWidget=self.TabWidget,
self.drp_an_ref_uStarDet_TA, self.lne_an_ref_uStarDet_numClasses_TA, \ col_list_pretty=self.selected_file_colnames_pretty_strings_list,
self.drp_an_ref_uStarDet_uStar, self.lne_an_ref_uStarDet_numClasses_uStar, \ col_dict_tuples=self.selected_file_colnames_tuples_dict,
self.drp_an_ref_uStarDet_defineNighttime, self.btn_an_ref_uStarDet_run, \ data_df=self.data_df)
self.fig_an_ref_uStarDet, self.axesDict_an_ref_uStarDet, \ self.tab_ustar_auto.btn_run.clicked.connect(self.call_ustar_analysis)
self.drp_an_ref_uStarDet_seasons, self.lne_an_ref_uStarDet_fluxPercThres, \
self.drp_an_ref_uStarDet_templateReference, self.drp_an_ref_uStarDet_defineSeasonThres, \
self.drp_an_ref_uStarDet_defineOverallThres, self.lne_an_ref_uStarDet_TAvsUSTAR_corrThres, \
self.lne_an_ref_uStarDet_setToUstarDataPercentile, self.lne_an_ref_uStarDet_USTAR_allowedMinThres, \
self.lne_an_ref_uStarDet_numBootstrapRuns = \
an_uStarDetection.MakeNewTab(
TabWidget=self.TabWidget,
colname_pretty_string=self.selected_file_colnames_pretty_strings_list,
data_df=self.data_df).get_handles()
# Make plot if button_qual_A is pressed
self.btn_an_ref_uStarDet_run.clicked.connect(self.call_ustar_analysis)
def call_ustar_analysis(self): def call_ustar_analysis(self):
# todo this is not yet object-based, see MDS self.data_df = an_uStarDetection.RunUstarAnalysis(tab_ustar_auto=self.tab_ustar_auto).get_data_df()
# ustar_params = an_uStarDetection.get_ustar_params(self=self)
# an_uStarDetection.MakeUstarAnalysis(**ustar_params)
self.data_df = \
an_uStarDetection.MakeUstarAnalysis(
data_df=self.data_df,
fig=self.fig_an_ref_uStarDet,
col_dict_tuples=self.selected_file_colnames_tuples_dict,
col_list_pretty=self.selected_file_colnames_pretty_strings_list,
FLUX_data_col=self.drp_an_ref_uStarDet_flux.currentText(),
TA_data_col=self.drp_an_ref_uStarDet_TA.currentText(),
USTAR_data_col=self.drp_an_ref_uStarDet_uStar.currentText(),
TA_numClasses=int(self.lne_an_ref_uStarDet_numClasses_TA.text()),
USTAR_numClasses=int(self.lne_an_ref_uStarDet_numClasses_uStar.text()),
define_nighttime_as=self.drp_an_ref_uStarDet_defineNighttime.currentText(),
axes_dict=self.axesDict_an_ref_uStarDet,
seasons_type=self.drp_an_ref_uStarDet_seasons.currentText(),
FLUX_perc_thres=float(self.lne_an_ref_uStarDet_fluxPercThres.text()),
define_season_thres=self.drp_an_ref_uStarDet_defineSeasonThres.currentText(),
define_overall_thres=self.drp_an_ref_uStarDet_defineOverallThres.currentText(),
ta_ustar_corr_thres=float(self.lne_an_ref_uStarDet_TAvsUSTAR_corrThres.text()),
set_to_ustar_data_percentile=float(
self.lne_an_ref_uStarDet_setToUstarDataPercentile.text()),
allowed_min_ustar_thres=float(self.lne_an_ref_uStarDet_USTAR_allowedMinThres.text()),
num_bootstrap_runs=int(self.lne_an_ref_uStarDet_numBootstrapRuns.text()),
button=self.btn_an_ref_uStarDet_run).get_data_df()
self.update_gui_lists() self.update_gui_lists()
def make_tab_heatmap_plots(self): def make_tab_heatmap_plots(self):
...@@ -1261,9 +1225,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1261,9 +1225,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.focus_df, self.marker_col = \ self.focus_df, self.marker_col = \
an_ClassFinder.Call(data_df=self.data_df, an_ClassFinder.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict, col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_class=self.drp_an_ref_ClassFinder_classVar, drp_class=self.modbox_analyses.ClassFinder.ref_drp_class_var,
lower_lim=self.lne_an_ref_ClassFinder_lowerClassLimit, lower_lim=self.modbox_analyses.ClassFinder.ref_lne_lower_class_lim,
upper_lim=self.lne_an_ref_ClassFinder_upperClassLimit, upper_lim=self.modbox_analyses.ClassFinder.ref_lne_upper_class_lim,
**self.update_args()).get_results() **self.update_args()).get_results()
self.active_buttons(add=False, keep=True, remove=True, addFocus=True) self.active_buttons(add=False, keep=True, remove=True, addFocus=True)
...@@ -1275,10 +1239,10 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1275,10 +1239,10 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.focus_df, self.marker_col, self.twin_ax, self.twin_ax_active = \ self.focus_df, self.marker_col, self.twin_ax, self.twin_ax_active = \
an_RunningLinReg.Call(data_df=self.data_df, an_RunningLinReg.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict, col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_ind_var=self.drp_an_ref_RunningLinRegr_indVar, drp_ind_var=self.modbox_analyses.RunningLinReg.ref_drp_ind_var,
win_size=self.lne_an_ref_RunningLinRegr_windowSize, win_size=self.modbox_analyses.RunningLinReg.ref_lne_win_size,
win_min_vals=self.lne_an_ref_RunningLinRegr_windowMinVals, win_min_vals=self.modbox_analyses.RunningLinReg.ref_lne_win_min_vals,
win_step_size=self.lne_an_ref_RunningLinRegr_windowStepSize, win_step_size=self.modbox_analyses.RunningLinReg.ref_lne_win_step_size,
twin_ax=self.twin_ax, twin_ax_active=self.twin_ax_active, twin_ax=self.twin_ax, twin_ax_active=self.twin_ax_active,
**self.update_args()).get_results() **self.update_args()).get_results()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False) self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
...@@ -1287,9 +1251,10 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1287,9 +1251,10 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.focus_df, self.marker_col = \ self.focus_df, self.marker_col = \
an_BeforeAfterEvent.Call(data_df=self.data_df, an_BeforeAfterEvent.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict, col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_var=self.drp_an_ref_BeforeAfterEvent_var, drp_var=self.modbox_analyses.BeforeAfterEvent.ref_drp_var,
win_size=int(self.lne_an_ref_BeforeAfterEvent_windowSize.text()), win_size=int(self.modbox_analyses.BeforeAfterEvent.ref_lne_win_size.text()),
win_min_vals=int(self.lne_an_ref_BeforeAfterEvent_windowMinVals.text()), win_min_vals=int(
self.modbox_analyses.BeforeAfterEvent.ref_lne_win_min_vals.text()),
**self.update_args()).get_results() **self.update_args()).get_results()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False) self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
...@@ -1308,35 +1273,45 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo ...@@ -1308,35 +1273,45 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
def call_mf_ResampleTo(self): def call_mf_ResampleTo(self):
self.focus_df, self.marker_col = \ self.focus_df, self.marker_col = \
mf_ResampleToFreq.Call(to_freq=self.drp_mf_ref_ResampleToFreq_freq.currentText(), mf_ResampleToFreq.Call(to_freq=self.modbox_modifications.ResampleToFreq.ref_drp_freq.currentText(),
duration=self.lne_mf_ref_ResampleToFreq_freqDuration.text(), duration=self.modbox_modifications.ResampleToFreq.ref_lne_freq_duration.text(),
agg_method=self.drp_mf_ref_ResampleToFreq_agg.currentText(), agg_method=self.modbox_modifications.ResampleToFreq.ref_drp_agg.currentText(),
min_vals=self.lne_mf_ref_ResampleToFreq_minVals.text(), min_vals=self.modbox_modifications.ResampleToFreq.ref_lne_min_vals.text(),
**self.update_args()).resampling() **self.update_args()).resampling()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False) self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
def call_mf_CreateNewVarGain(self): def call_mf_CreateNewVarGain(self):
self.focus_df, self.marker_col = \ self.focus_df, self.marker_col = \
mf_CreateNewVarGain.Call(data_df=self.data_df, mf_CreateNewVarGain.Call(data_df=self.data_df,
gain=float(self.lne_mf_ref_CreateNewVarGain_gain.text()), gain=float(self.modbox_modifications.CreateNewVarWithGain.ref_lne_gain.text()),
units=self.lne_mf_ref_CreateNewVarGain_units.text(), units=self.modbox_modifications.CreateNewVarWithGain.ref_lne_units.text(),
**self.update_args()).make_new_col() **self.update_args()).make_new_col()
self.active_buttons(add=True, keep=False, remove=False, addFocus=True) self.active_buttons(add=True, keep=False, remove=False, addFocus=True)
def call_mf_AddSuffix(self):
self.data_df = mf_AddSuffix.Call(data_df=self.data_df,
string=self.modbox_modifications.AddSuffix.ref_lne_string.text(),
add_string_to=self.modbox_modifications.AddSuffix.ref_drp_add_string_to.currentText(),
**self.update_args()).rename_all_columns()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
self.update_gui_lists()
self.set_focus(action='load_file_data', marker_col='')
def call_mf_CreateEvent(self): def call_mf_CreateEvent(self):
self.data_df = \ self.data_df = \
mf_CreateEvent.Call(data_df=self.data_df, mf_CreateEvent.Call(data_df=self.data_df,
event_name=self.lne_mf_ref_CreateEvent_name.text(), event_name=self.modbox_modifications.CreateEvent.ref_lne_name.text(),
start_date=self.dte_mf_ref_CreateEvent_start.date().toPyDate(), start_date=self.modbox_modifications.CreateEvent.ref_dte_start.date().toPyDate(),
end_date=self.dte_mf_ref_CreateEvent_end.date().toPyDate()).make_new_col() end_date=self.modbox_modifications.CreateEvent.ref_dte_end.date().toPyDate()).make_new_col()
self.active_buttons(add=True, keep=False, remove=False, addFocus=True) self.active_buttons(add=True, keep=False, remove=False, addFocus=True)
self.update_gui_lists() self.update_gui_lists()
def call_mf_LimitTimeRange(self): def call_mf_LimitTimeRange(self):
self.data_df = \ self.data_df = \
mf_LimitTimeRange.Call(data_df=self.data_df, mf_LimitTimeRange.Call(data_df=self.data_df,
start_date=self.dte_mf_ref_LimitTimeRange_start.date().toPyDate(), start_date=self.modbox_modifications.LimitTimeRange.ref_dte_start.date().toPyDate(),
end_date=self.dte_mf_ref_LimitTimeRange_end.date().toPyDate()).apply_limit() end_date=self.modbox_modifications.LimitTimeRange.ref_dte_end.date().toPyDate()).apply_limit()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False) self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
# Update data_df plots, stats # Update data_df plots, stats
...@@ -1530,13 +1505,15 @@ class AppContext(ApplicationContext): # 1. Subclass ApplicationContext ...@@ -1530,13 +1505,15 @@ class AppContext(ApplicationContext): # 1. Subclass ApplicationContext
@cached_property @cached_property
def file_AmpCSV_30T(self): def file_AmpCSV_30T(self):
return self.get_resource( return self.get_resource(
# 'example_files/CH-DAV_Dataset_AMP-20191106-113233_Original-30T.csv') # Returns absolute path
'example_files/CH-OE2_Dataset_AMP-20191025-145003_Original-30T.csv') # Returns absolute path 'example_files/CH-OE2_Dataset_AMP-20191025-145003_Original-30T.csv') # Returns absolute path
# return self.get_resource('example_files/AmpCSV_30T.csv') # Returns absolute path # return self.get_resource('example_files/AmpCSV_30T.csv') # Returns absolute path
@cached_property @cached_property
def file_EddyProFullOutput_30T(self): def file_EddyProFullOutput_30T(self):
return self.get_resource('example_files/test1_eddypro_CH-CHA_full_output_2019-08-21T110549_adv.csv') # return self.get_resource('example_files/EddyProFullOutput_30T_with_some_empty_headers.csv')
# return self.get_resource('example_files/EddyProFullOutput_30T.csv') # return self.get_resource('example_files/test1_eddypro_CH-CHA_full_output_2019-08-21T110549_adv.csv')
return self.get_resource('example_files/EddyProFullOutput_30T.csv')
# Icons # Icons
@cached_property @cached_property
......
...@@ -34,16 +34,11 @@ class AddControlsToMain(): ...@@ -34,16 +34,11 @@ class AddControlsToMain():
self.add_option() self.add_option()
self.add_refinements() self.add_refinements()
def get_handles(self):
# Return handles so they can be accessed by others
return self.btn_an_opt_Aggregator, \
self.btn_an_ref_Aggregator_showInNewTab
def add_option(self): def add_option(self):
# One option button_qual_A that shows the refinements when pressed # One option button_qual_A that shows the refinements when pressed
self.btn_an_opt_Aggregator = GUI_Elements.grd_Button(lyt=self.opt_layout, self.opt_btn = GUI_Elements.grd_Button(lyt=self.opt_layout,
txt='Aggregator', css_id='', txt='Aggregator', css_id='',
row=6, col=0, rowspan=1, colspan=1) row=6, col=0, rowspan=1, colspan=1)
self.opt_stack.addWidget(self.opt_frame)