Skip to content

Commit

Permalink
Switching back code towards final review version
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoyer committed Aug 27, 2024
1 parent 628cfe8 commit 3860ada
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/source/changelog/pending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Enhancements
* Added a new wrapper function for clearsky filters (:pull:`412`)
* Improve test coverage, especially for the newly added filter capabilities (:pull:`413`)
* Added codecov.yml configuration file (:pull:`420`)
* Added new methods perfect_clean_complex and inferred_clean_complex which detects negative shifts and piecewise changes in the slope for soiling detection in :py:func:`~rdtools.soiling.soiling_srr`(:pull:`426`)

Bug fixes
---------
Expand Down
4 changes: 2 additions & 2 deletions docs/system_availability_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -663,7 +663,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
23 changes: 12 additions & 11 deletions rdtools/soiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ def _calc_daily_df(self, day_scale=13, clean_threshold="infer", recenter=True,
# step, slope change detection
# 1/6/24 Note several errors in soiling fit due to ffill for rolling
# median change to day_scale/2 Matt
df_ffill = df.copy()
df_ffill = df.ffill(limit=int(round((day_scale / 2), 0)))
#df_ffill = df.copy()
#df_ffill = df.ffill(limit=int(round((day_scale / 2), 0)))
df_ffill = df.fillna(method='ffill', limit=day_scale).copy()
# Calculate rolling median
df["pi_roll_med"] = df_ffill.pi_norm.rolling(day_scale, center=True).median()

Expand All @@ -204,12 +205,12 @@ def _calc_daily_df(self, day_scale=13, clean_threshold="infer", recenter=True,
# Matt added these lines but the function "_collapse_cleaning_events"
# was written by Asmund, it reduces multiple days of cleaning events
# in a row to a single event
'''
reduced_cleaning_events = _collapse_cleaning_events(
df.clean_event_detected, df.delta.values, 5
)
df["clean_event_detected"] = reduced_cleaning_events
'''
if piecewise is True:
reduced_cleaning_events = _collapse_cleaning_events(
df.clean_event_detected, df.delta.values, 5
)
df["clean_event_detected"] = reduced_cleaning_events

##########################################################################
precip_event = df["precip"] > precip_threshold

Expand Down Expand Up @@ -438,7 +439,7 @@ def _calc_result_df(self, trim=False, max_relative_slope_error=500.0, max_negati
results.loc[filt, "run_slope"] = 0
results.loc[filt, "run_slope_low"] = 0
results.loc[filt, "run_slope_high"] = 0
results.loc[filt, "valid"] = False
# results.loc[filt, "valid"] = False

# Calculate the next inferred start loss from next valid interval
results["next_inferred_start_loss"] = np.clip(
Expand All @@ -465,10 +466,10 @@ def _calc_result_df(self, trim=False, max_relative_slope_error=500.0, max_negati
results.loc[results.clean_event, "inferred_begin_shift"] = np.clip(
results.inferred_begin_shift, 0, 1)
#######################################################################
'''

if neg_shift is False:
results.loc[filt, "valid"] = False
'''

if len(results[results.valid]) == 0:
raise NoValidIntervalError("No valid soiling intervals were found")
new_start = results.start.iloc[0]
Expand Down

0 comments on commit 3860ada

Please sign in to comment.