diff --git a/modules/util/util.py b/modules/util/util.py index bc1f27985193c5531e1e327ec858042c03b50009..2e93ee9762d2220eade83be339eb8557277b8262 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