You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code excludes the first and last recession segments of the flow record, when the recession segments are partial (if the timeseries starts during recession, or the timeseries ends during recession).
This is generally fine (and may be more appropriate) for long time-series data; however, it can lead to an issue for short time frames, where you don't wanna miss any recession segments.
Proposed Solution:
I added a Python code snippet that accounts for the first and last recession flows (background: I've been translating this to Python).
I apologize that it is not in Matlab. I've documented this here to provide information for others who may encounter the same issue. I'm not looking for an immediate fix right now—rather thank you for your great work! The whole McMillan Lab has been keep using your TOSSH codes.
# Identify timesteps with decreasing flow (same as original)
_decreasing_flow = Q[1:].to_numpy() < (
Q[:-1].to_numpy() + eps
)
# The index for the first decreasing flow
# [ADDED: If the flow record starts from decreasing values, set the first starting point as the first "non-decreasing" index, so that it gets detected by np.diff]
if _decreasing_flow[0]:
start_point = 0
else:
start_point = np.where(_decreasing_flow == 0)[0][0]
# Get the decreasing flow section (same as original)
decreasing_flow = _decreasing_flow[start_point:]
# [ADDED: If the flow record starts from decreasing values, change the first value of decreasing_flow to False, so that it gets detected by np.diff]
if _decreasing_flow[0]:
decreasing_flow[0] = False
# Find start and end of decreasing sections (same as original)
_flow_change = np.where(np.diff(decreasing_flow) != 0)[0] + start_point
# [ADDED: If the flow is still decreasing at the end of the period, append that to flow change]
if decreasing_flow[-1]:
_flow_change = np.append(_flow_change, len(Q))
# Detect the flow change (same as original)
flow_change = _flow_change[: 2 * (len(_flow_change) // 2)].reshape(-1, 2)
The text was updated successfully, but these errors were encountered:
TOSSH/TOSSH_code/utility_functions/util_RecessionSegments.m
Lines 95 to 104 in 23de41d
Issue Description:
The current code excludes the first and last recession segments of the flow record, when the recession segments are partial (if the timeseries starts during recession, or the timeseries ends during recession).
This is generally fine (and may be more appropriate) for long time-series data; however, it can lead to an issue for short time frames, where you don't wanna miss any recession segments.
Proposed Solution:
I added a Python code snippet that accounts for the first and last recession flows (background: I've been translating this to Python).
I apologize that it is not in Matlab. I've documented this here to provide information for others who may encounter the same issue. I'm not looking for an immediate fix right now—rather thank you for your great work! The whole McMillan Lab has been keep using your TOSSH codes.
The text was updated successfully, but these errors were encountered: