diff --git a/modules/util/util.py b/modules/util/util.py index 726644216aa4f352b3549ee5ea5064a3d3fc5149..ed605e94abb2ae3a9b9a54bd2c51817d5b231376 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -185,6 +185,23 @@ def value_to_index(nda, value): return idx +def find_bin_index(nda, value): + idxs = np.arange(nda.shape[0]) + + above = nda >= value + if not above.any(): + return -1 + + below = nda < value + if not below.any(): + return -1 + + iL = idxs[above].max() + + return iL + + + # array solzen must be degrees, missing values must NaN. For small roughly 50x50km regions only def is_day(solzen, test_angle=80.0): solzen = solzen.flatten()