Skip to content
Snippets Groups Projects
Commit 3db6a7d6 authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

i am back

parent c38034ff
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,8 @@ def flagDispatch(func_name, *args, **kwargs): ...@@ -14,7 +14,8 @@ def flagDispatch(func_name, *args, **kwargs):
"mad": flagMad, "mad": flagMad,
"constant": flagConstant, "constant": flagConstant,
"range": flagRange, "range": flagRange,
"generic": flagGeneric} "generic": flagGeneric,
"soilMoistureByFrost": flagSoilMoistureBySoilFrost}
func = func_map.get(func_name, None) func = func_map.get(func_name, None)
if func is not None: if func is not None:
...@@ -156,10 +157,6 @@ def flagSoilMoistureBySoilFrost(data, flags, field, flagger, soil_temp_reference ...@@ -156,10 +157,6 @@ def flagSoilMoistureBySoilFrost(data, flags, field, flagger, soil_temp_reference
# retrieve data series input: # retrieve data series input:
dataseries = pd.Series(data[field].values, index=pd.to_datetime(data.index)) dataseries = pd.Series(data[field].values, index=pd.to_datetime(data.index))
# retrieve reference input:
#if reference is a string, it refers to data field
# if reference series is part of input data frame, evaluate input data flags: # if reference series is part of input data frame, evaluate input data flags:
flag_mask = flagger.isFlagged(flags)[soil_temp_reference] flag_mask = flagger.isFlagged(flags)[soil_temp_reference]
# retrieve reference series # retrieve reference series
...@@ -193,3 +190,37 @@ def flagSoilMoistureBySoilFrost(data, flags, field, flagger, soil_temp_reference ...@@ -193,3 +190,37 @@ def flagSoilMoistureBySoilFrost(data, flags, field, flagger, soil_temp_reference
flags.loc[mask.values, field] = flagger.setFlag(flags.loc[mask, field], **kwargs) flags.loc[mask.values, field] = flagger.setFlag(flags.loc[mask, field], **kwargs)
return data, flags return data, flags
def flagSoilMoistureByPrecipitationEvents(data, flags, field, flagger, precipitation_reference, sensor_meas_depth=0,
sensor_accuracy=0, soil_porosity=0, **kwargs):
"""Function flags Soil moisture measurements by flagging moisture rises that do not follow up a sufficient
precipitation event. If measurement depth, sensor accuracy of the soil moisture sensor and the porosity of the
surrounding soil is passed to the function, an inferior level of precipitation, that has to preceed a significant
moisture raise within 24 hours, can be estimated. If those values are not delivered, this inferior bound is set
to zero. In that case, any non zero precipitation count will justify any soil moisture raise.
:param data: The pandas dataframe, holding the data-to-be flagged.
:param flags: A dataframe holding the flags/flag-entries associated with "data".
:param field: Fieldname of the Soil moisture measurements field in data.
:param flagger: A flagger - object.
:param precipitation_reference: Fieldname of the precipitation meassurements in data.
:param sensor_meas_depth: Measurement depth of the soil moisture sensor in meter [m].
:param sensor_accuracy: Accuracy of the soil moisture sensor [-].
:param soil_porosity: Porosity of moisture sensors surrounding soil.
"""
# retrieve data series input:
dataseries = pd.Series(data[field].values, index=pd.to_datetime(data.index))
# if reference series is part of input data frame, evaluate input data flags:
flag_mask = flagger.isFlagged(flags)[precipitation_reference]
# retrieve reference series
refseries = pd.Series(data[precipitation_reference].values, index=pd.to_datetime(data.index))
# drop flagged values:
refseries = refseries.loc[~np.array(flag_mask)]
# make refseries index a datetime thingy
refseries.index = pd.to_datetime(refseries.index)
# drop nan values from reference series, since those are values you dont want to refer to.
refseries = refseries.dropna()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment