From 1e02414900f25aadd3833bd8e3c7663317b00aed Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Wed, 4 Nov 2020 13:19:10 -0600 Subject: [PATCH] snapshot... --- modules/util/util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/util/util.py b/modules/util/util.py index bc1f2798..2e93ee97 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -114,4 +114,10 @@ def pressure_to_altitude(pres, temp, prof_pres, prof_temp, sfc_pres, sfc_temp, s # http://fourier.eng.hmc.edu/e176/lectures/NM/node25.html def minimize_quadratic(xa, xb, xc, ya, yb, yc): x_m = xb + 0.5*(((ya-yb)*(xc-xb)*(xc-xb) - (yc-yb)*(xb-xa)*(xb-xa)) / ((ya-yb)*(xc-xb) + (yc-yb)*(xb-xa))) - return x_m \ No newline at end of file + return x_m + + +def value_to_index(nda, value): + diff = np.abs(nda - value) + idx = np.argmin(diff) + return idx \ No newline at end of file -- GitLab