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):
return frm_FocusArea
def add_modbox_Plots(self):
# CATEGORY 0: PLOTS (ModBox)
self.modbox_plots = modbox_pl.AddControls(grd_Categories=self.grd_categories,
stk_Options=self.stk_category_options,
stk_Refinements=self.stk_option_refinements,
......@@ -468,87 +467,28 @@ class Ui_MainWindow(object):
self.lne_gf_ref_LinInterp_limit.setText('1')
def add_modbox_Analyses(self):
self.btn_an_cat_Analyses_showStack, \
self.btn_an_opt_ClassFinder, \
self.an_ref_ClassFinder_stackTab, \
self.drp_an_ref_ClassFinder_classVar, \
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,
self.modbox_analyses = 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()
ctx=self.ctx)
# Default values
self.lne_an_ref_ClassFinder_lowerClassLimit.setText('0')
self.lne_an_ref_ClassFinder_upperClassLimit.setText('20')
self.lne_an_ref_RunningLinRegr_windowSize.setText('480') ## 10 days @30min files
self.lne_an_ref_RunningLinRegr_windowMinVals.setText('321') ## more than 2/3 available
self.lne_an_ref_RunningLinRegr_windowStepSize.setText('480')
self.lne_an_ref_BeforeAfterEvent_windowSize.setText('7')
self.lne_an_ref_BeforeAfterEvent_windowMinVals.setText('72')
self.modbox_analyses.ClassFinder.ref_lne_lower_class_lim.setText('0')
self.modbox_analyses.ClassFinder.ref_lne_upper_class_lim.setText('20')
self.modbox_analyses.RunningLinReg.ref_lne_win_size.setText('480') ## 10 days @30min files
self.modbox_analyses.RunningLinReg.ref_lne_win_min_vals.setText('321') ## more than 2/3 available
self.modbox_analyses.RunningLinReg.ref_lne_win_step_size.setText('480')
self.modbox_analyses.BeforeAfterEvent.ref_lne_win_size.setText('7')
self.modbox_analyses.BeforeAfterEvent.ref_lne_win_min_vals.setText('72')
def add_modbox_Modifications(self):
self.btn_mf_cat_Conversions_showStack, \
self.mf_ref_ResampleToFreq_stackTab, \
self.btn_mf_opt_ResampleToFreq, \
self.lne_mf_ref_ResampleToFreq_freqDuration, \
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,
self.modbox_modifications = 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()
ctx=self.ctx)
# Default values
self.lne_mf_ref_ResampleToFreq_freqDuration.setText('1')
self.lne_mf_ref_ResampleToFreq_minVals.setText('1')
self.lne_mf_ref_CreateNewVarGain_gain.setText('1')
self.modbox_modifications.ResampleToFreq.ref_lne_freq_duration.setText('1')
self.modbox_modifications.ResampleToFreq.ref_lne_min_vals.setText('1')
self.modbox_modifications.CreateNewVarWithGain.ref_lne_gain.setText('1')
def add_modbox_Corrections(self):
self.btn_cr_cat_Corrections_showStack, \
......
......@@ -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'],
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}
data_df = pd.read_csv(filepath, **merged_args)
......
......@@ -19,6 +19,8 @@ GAPFILLED_GENERAL_SCALARS = ['*-f*']
MONIN_OBUKHOV_STABILITY = ['(z-d)/L']
NIGHTTIME_DETECTION = ['*SW_IN*', '*daytime*']
# ==============================================================================================
# QC FLAGS /////////////////////////////////////////////////////////////////////////////////////
# ==============================================================================================
......@@ -38,7 +40,7 @@ SIGNAL_STRENGTH_IRGA = ['signal_strength*', 'window_dirtiness*', 'status_byte*']
SPECTRAL_CORRECTION_FACTOR =['_scf']
STORAGE = ['_strg']
USTAR = ['u*']
USTAR_EDDYPRO = ['u*']
VPD = ['*VPD*']
......
......@@ -39,6 +39,7 @@ from modboxes.GapFilling import MDS as gf_MDS
from modboxes.GapFilling import RunningSimple as gf_RunningMedianSimple
from modboxes.HiResTests import HiResTests_gui as hrt_HiResTests_gui
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 CreateNewVarWithGain as mf_CreateNewVarGain
from modboxes.Modifications import LimitTimeRange as mf_LimitTimeRange
......@@ -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)
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)
mf_Modifications_gui.connect(self=self, opt_tab_idx=5) # MODIFICATIONS (ref stackTab 27-31)
cr_Corrections_gui.connect(self=self, opt_tab_idx=6) # CORRECTIONS (ref stackTab 32)
hrt_HiResTests_gui.connect(self=self, opt_tab_idx=7) # HI-RES TESTS (ref stackTab 33)
pn_Pipelines_gui.connect(self=self, opt_tab_idx=8) # PIPELINES (ref stackTab 34)
ex_Export_gui.connect(self=self, opt_tab_idx=9) # EXPORT (ref stackTab 35-36)
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 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 35)
ex_Export_gui.connect(self=self, opt_tab_idx=9) # EXPORT (ref stackTab 35-37)
# --------------------------------
# CONNECTIONS CONTROLS -----------
......@@ -158,7 +159,7 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
if self.load_initial_data:
self.select_source(action='load_initial_data')
# 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='AGGREGATOR')
# self.make_tab(make_tab='SCATTER')
......@@ -444,9 +445,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.lst_Variables.clear()
# Reset modBox drop-down menus
self.drp_an_ref_ClassFinder_classVar.clear()
self.drp_an_ref_RunningLinRegr_indVar.clear()
self.drp_an_ref_BeforeAfterEvent_var.clear()
self.modbox_analyses.ClassFinder.ref_drp_class_var.clear()
self.modbox_analyses.RunningLinReg.ref_drp_ind_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_SignalStrengthIRGA.clear()
self.drp_qc_ref_SpectralCorrectionFactor.clear()
......@@ -500,9 +501,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
# REFINEMENT MENUS THAT NEED ALL VARIABLES
# --------------------------------------
self.drp_an_ref_ClassFinder_classVar.addItem(colname_pretty_string)
self.drp_an_ref_RunningLinRegr_indVar.addItem(colname_pretty_string)
self.drp_an_ref_BeforeAfterEvent_var.addItem(colname_pretty_string)
self.modbox_analyses.ClassFinder.ref_drp_class_var.addItem(colname_pretty_string)
self.modbox_analyses.RunningLinReg.ref_drp_ind_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)
# # OUTLIER DETECTION: Double-Differenced Time Series
......@@ -534,11 +535,11 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.drp_qc_ref_SignalStrengthIRGA.addItem(colname_pretty_string)
# 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)
# 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)
# EddyPro Raw Data Statistical Flags
......@@ -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
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.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.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.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.setMaximumDate(max_data_day_qt)
......@@ -1027,16 +1028,16 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.TabWidget.setCurrentIndex(tab_number)
else:
# 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_list_pretty=self.selected_file_colnames_pretty_strings_list,
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):
"""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
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
self.TabWidget.setCurrentIndex(tab_number)
# pass
else:
self.drp_an_ref_uStarDet_flux, \
self.drp_an_ref_uStarDet_TA, self.lne_an_ref_uStarDet_numClasses_TA, \
self.drp_an_ref_uStarDet_uStar, self.lne_an_ref_uStarDet_numClasses_uStar, \
self.drp_an_ref_uStarDet_defineNighttime, self.btn_an_ref_uStarDet_run, \
self.fig_an_ref_uStarDet, self.axesDict_an_ref_uStarDet, \
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):
# todo this is not yet object-based, see MDS
# 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,
self.tab_ustar_auto = an_uStarDetection.MakeNewTab(TabWidget=self.TabWidget,
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()
col_dict_tuples=self.selected_file_colnames_tuples_dict,
data_df=self.data_df)
self.tab_ustar_auto.btn_run.clicked.connect(self.call_ustar_analysis)
def call_ustar_analysis(self):
self.data_df = an_uStarDetection.RunUstarAnalysis(tab_ustar_auto=self.tab_ustar_auto).get_data_df()
self.update_gui_lists()
def make_tab_heatmap_plots(self):
......@@ -1261,9 +1225,9 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.focus_df, self.marker_col = \
an_ClassFinder.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_class=self.drp_an_ref_ClassFinder_classVar,
lower_lim=self.lne_an_ref_ClassFinder_lowerClassLimit,
upper_lim=self.lne_an_ref_ClassFinder_upperClassLimit,
drp_class=self.modbox_analyses.ClassFinder.ref_drp_class_var,
lower_lim=self.modbox_analyses.ClassFinder.ref_lne_lower_class_lim,
upper_lim=self.modbox_analyses.ClassFinder.ref_lne_upper_class_lim,
**self.update_args()).get_results()
self.active_buttons(add=False, keep=True, remove=True, addFocus=True)
......@@ -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 = \
an_RunningLinReg.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_ind_var=self.drp_an_ref_RunningLinRegr_indVar,
win_size=self.lne_an_ref_RunningLinRegr_windowSize,
win_min_vals=self.lne_an_ref_RunningLinRegr_windowMinVals,
win_step_size=self.lne_an_ref_RunningLinRegr_windowStepSize,
drp_ind_var=self.modbox_analyses.RunningLinReg.ref_drp_ind_var,
win_size=self.modbox_analyses.RunningLinReg.ref_lne_win_size,
win_min_vals=self.modbox_analyses.RunningLinReg.ref_lne_win_min_vals,
win_step_size=self.modbox_analyses.RunningLinReg.ref_lne_win_step_size,
twin_ax=self.twin_ax, twin_ax_active=self.twin_ax_active,
**self.update_args()).get_results()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
......@@ -1287,9 +1251,10 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
self.focus_df, self.marker_col = \
an_BeforeAfterEvent.Call(data_df=self.data_df,
col_dict_tuples=self.selected_file_colnames_tuples_dict,
drp_var=self.drp_an_ref_BeforeAfterEvent_var,
win_size=int(self.lne_an_ref_BeforeAfterEvent_windowSize.text()),
win_min_vals=int(self.lne_an_ref_BeforeAfterEvent_windowMinVals.text()),
drp_var=self.modbox_analyses.BeforeAfterEvent.ref_drp_var,
win_size=int(self.modbox_analyses.BeforeAfterEvent.ref_lne_win_size.text()),
win_min_vals=int(
self.modbox_analyses.BeforeAfterEvent.ref_lne_win_min_vals.text()),
**self.update_args()).get_results()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
......@@ -1308,35 +1273,45 @@ class Amp(QtWidgets.QMainWindow, Ui_MainWindow, GUI_BuildingBlocks.SettingsWindo
def call_mf_ResampleTo(self):
self.focus_df, self.marker_col = \
mf_ResampleToFreq.Call(to_freq=self.drp_mf_ref_ResampleToFreq_freq.currentText(),
duration=self.lne_mf_ref_ResampleToFreq_freqDuration.text(),
agg_method=self.drp_mf_ref_ResampleToFreq_agg.currentText(),
min_vals=self.lne_mf_ref_ResampleToFreq_minVals.text(),
mf_ResampleToFreq.Call(to_freq=self.modbox_modifications.ResampleToFreq.ref_drp_freq.currentText(),
duration=self.modbox_modifications.ResampleToFreq.ref_lne_freq_duration.text(),
agg_method=self.modbox_modifications.ResampleToFreq.ref_drp_agg.currentText(),
min_vals=self.modbox_modifications.ResampleToFreq.ref_lne_min_vals.text(),
**self.update_args()).resampling()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
def call_mf_CreateNewVarGain(self):
self.focus_df, self.marker_col = \
mf_CreateNewVarGain.Call(data_df=self.data_df,
gain=float(self.lne_mf_ref_CreateNewVarGain_gain.text()),
units=self.lne_mf_ref_CreateNewVarGain_units.text(),
gain=float(self.modbox_modifications.CreateNewVarWithGain.ref_lne_gain.text()),
units=self.modbox_modifications.CreateNewVarWithGain.ref_lne_units.text(),
**self.update_args()).make_new_col()
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):
self.data_df = \
mf_CreateEvent.Call(data_df=self.data_df,
event_name=self.lne_mf_ref_CreateEvent_name.text(),
start_date=self.dte_mf_ref_CreateEvent_start.date().toPyDate(),
end_date=self.dte_mf_ref_CreateEvent_end.date().toPyDate()).make_new_col()
event_name=self.modbox_modifications.CreateEvent.ref_lne_name.text(),
start_date=self.modbox_modifications.CreateEvent.ref_dte_start.date().toPyDate(),
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.update_gui_lists()
def call_mf_LimitTimeRange(self):
self.data_df = \
mf_LimitTimeRange.Call(data_df=self.data_df,
start_date=self.dte_mf_ref_LimitTimeRange_start.date().toPyDate(),
end_date=self.dte_mf_ref_LimitTimeRange_end.date().toPyDate()).apply_limit()
start_date=self.modbox_modifications.LimitTimeRange.ref_dte_start.date().toPyDate(),
end_date=self.modbox_modifications.LimitTimeRange.ref_dte_end.date().toPyDate()).apply_limit()
self.active_buttons(add=False, keep=False, remove=False, addFocus=False)
# Update data_df plots, stats
......@@ -1530,13 +1505,15 @@ class AppContext(ApplicationContext): # 1. Subclass ApplicationContext
@cached_property
def file_AmpCSV_30T(self):
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
# return self.get_resource('example_files/AmpCSV_30T.csv') # Returns absolute path
@cached_property
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.csv')
# return self.get_resource('example_files/EddyProFullOutput_30T_with_some_empty_headers.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
@cached_property
......
......@@ -34,14 +34,9 @@ class AddControlsToMain():
self.add_option()
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):
# 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='',
row=6, col=0, rowspan=1, colspan=1)
......@@ -55,7 +50,7 @@ class AddControlsToMain():
ModBoxes_shared.add_header(layout=ref_layout, header='AN: Aggregator')
self.btn_an_ref_Aggregator_showInNewTab = \
self.ref_btn_showInNewTab = \
GUI_Elements.grd_Button(lyt=ref_layout,
txt='+ Show in New Tab', css_id='',
row=1, col=0, rowspan=1, colspan=2)
......
......@@ -9,42 +9,49 @@ from modboxes.Analyses import uStarDetection
def connect(self, opt_tab_idx):
self.btn_an_cat_Analyses_showStack.clicked.connect((lambda: self.view_stk_option(tab_idx=opt_tab_idx)))
# Option: Class Finder
self.btn_an_opt_ClassFinder.clicked.connect((lambda: self.view_stk_refinement(
tab_idx=self.an_ref_ClassFinder_stackTab)))
self.btn_an_ref_ClassFinder_showPlot.clicked.connect(lambda: self.call_an_ClassFinder())
# Option: Running Linear Regression
self.btn_an_opt_RunningLinRegr.clicked.connect((lambda: self.view_stk_refinement(
tab_idx=self.an_ref_RunningLinRegr_stackTab)))
self.btn_an_ref_RunningLinRegr_showPlot.clicked.connect(lambda: self.call_an_RunningLinRegr())
# Option: uStar Threshold Detection
self.btn_an_opt_uStarDetection.clicked.connect((lambda: self.view_stk_refinement(
tab_idx=self.an_ref_uStarDetection_stackTab)))
self.btn_an_ref_uStarDetection_showInNewTab.clicked.connect(lambda: self.make_tab(make_tab='USTAR_DETECTION'))
# Option: Gap Finder
self.btn_an_opt_GapFinder.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.an_ref_GapFinder_stackTab))
self.btn_an_ref_GapFinder_showPlot.clicked.connect(lambda: self.call_an_GapFinder())
# Option: Before / After Event
self.btn_an_opt_BeforeAfterEvent.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.an_ref_BeforeAfterEvent_stackTab))
self.btn_an_ref_BeforeAfterEvent_showPlot.clicked.connect(lambda: self.call_an_BeforeAfterEvent())
# Option: Aggregator
self.btn_an_opt_Aggregator.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.an_ref_Aggregator_stackTab))
self.btn_an_ref_Aggregator_showInNewTab.clicked.connect(lambda: self.make_tab(make_tab='AGGREGATOR'))
# Option: Net GHG Balance
self.btn_an_opt_NetGHGBalance.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.an_ref_NetGHGBalance_stackTab))
self.btn_an_ref_NetGHGBalance_showInNewTab.clicked.connect(lambda: self.make_tab(make_tab='NET_GHG_BALANCE'))
"""Connect ModBox buttons to functions."""
self.modbox_analyses.cat_btn_showStack.clicked.connect((lambda: self.view_stk_option(tab_idx=opt_tab_idx)))
# Option: CLASS FINDER
self.modbox_analyses.ClassFinder.opt_btn.clicked.connect((
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_ClassFinder_stackTab)))
self.modbox_analyses.ClassFinder.ref_btn_showInPlot.clicked.connect(lambda: self.call_an_ClassFinder())
# Option: RUNNING LINEAR REGRESSION
self.modbox_analyses.RunningLinReg.opt_btn.clicked.connect((
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_RunningLinRegr_stackTab)))
self.modbox_analyses.RunningLinReg.ref_btn_showInPlot.clicked.connect(
lambda: self.call_an_RunningLinRegr())
# Option: uSTAR THRESHOLD DETECTION
self.modbox_analyses.uStarDetection.opt_btn.clicked.connect((
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_uStarDetection_stackTab)))
self.modbox_analyses.uStarDetection.ref_btn_showInNewTab.clicked.connect(
lambda: self.make_tab(make_tab='USTAR_DETECTION'))
# Option: GAP FINDER
self.modbox_analyses.GapFinder.opt_btn.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_GapFinder_stackTab))
self.modbox_analyses.GapFinder.ref_btn_showInPlot.clicked.connect(
lambda: self.call_an_GapFinder())
# Option: BEFORE / AFTER EVENT
self.modbox_analyses.BeforeAfterEvent.opt_btn.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_BeforeAfterEvent_stackTab))
self.modbox_analyses.BeforeAfterEvent.ref_btn_showInPlot.clicked.connect(
lambda: self.call_an_BeforeAfterEvent())
# Option: AGGREGATOR
self.modbox_analyses.Aggregator.opt_btn.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_Aggregator_stackTab))
self.modbox_analyses.Aggregator.ref_btn_showInNewTab.clicked.connect(
lambda: self.make_tab(make_tab='AGGREGATOR'))
# Option: NET GHG BALANCE
self.modbox_analyses.NetGHGBalance.opt_btn.clicked.connect(
lambda: self.view_stk_refinement(tab_idx=self.modbox_analyses.an_ref_NetGHGBalance_stackTab))
self.modbox_analyses.NetGHGBalance.ref_btn_showInNewTab.clicked.connect(
lambda: self.make_tab(make_tab='NET_GHG_BALANCE'))
return self
......@@ -69,104 +76,45 @@ class AddControls:
# Aggregator
self.an_ref_Aggregator_stackTab = 20
self.btn_an_opt_Aggregator, \
self.btn_an_ref_Aggregator_showInNewTab = \
Aggregator.AddControlsToMain(opt_stack=stk_Options, opt_frame=opt_frame, opt_layout=opt_layout,
ref_stack=stk_Refinements).get_handles()
self.Aggregator = Aggregator.AddControlsToMain(opt_stack=stk_Options, opt_frame=opt_frame,
opt_layout=opt_layout, ref_stack=stk_Refinements)
# Before / After Event
self.an_ref_BeforeAfterEvent_stackTab = 21 # index of the tab in refinements box, called in main
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 = \
BeforeAfterEvent.AddControls(opt_stack=stk_Options, opt_frame=opt_frame, opt_layout=opt_layout,
ref_stack=stk_Refinements).get_handles()
self.BeforeAfterEvent = BeforeAfterEvent.AddControls(opt_stack=stk_Options, opt_frame=opt_frame,
opt_layout=opt_layout, ref_stack=stk_Refinements)
# Class Finder
self.an_ref_ClassFinder_stackTab = 22 # index of the tab in refinements box, called in main
self.btn_an_opt_ClassFinder, \
self.drp_an_ref_ClassFinder_classVar, \
self.lne_an_ref_ClassFinder_lowerClassLimit, \
self.lne_an_ref_ClassFinder_upperClassLimit, \
self.btn_an_ref_ClassFinder_showPlot = \
ClassFinder