CONVERT THIS MATLAB CODE TO PYTHON.
Calculate the number of consecutive days above the threshold for each
period using the function aboveThresholdConsecutive in the module
UserFunctions.py. Then subsequently use the Python function max to
extract the number of days in the longest period. Just use uf.__________ when you're converting the code as that is the abbrviation for the module UserFunctions.py where this code is being defined in. REMEMBER ONLY PYTHON LANGUAGE SO NO n's, ends, or mslice (or anything else that would need to further be defined)!
function nexceed_array = exceed_consecutive(array, threshold)
is_consecutive = 0;
n = 0;
nexceed_array = [];
for i = 1:length(array)
if array(i) > threshold
n = n + 1;
is_consecutive = 1;
else
if is_consecutive
nexceed_array(end+1) = n;
n = 0;
is_consecutive = 0;
end
end
end
if array(end) > threshold
if length(nexceed_array) == 0
nexceed_array = 0;
end