max_best_rescale¶
-
astroplan.
max_best_rescale
(vals, min_val, max_val, greater_than_max=1)[source]¶ rescales an input array
vals
to be a score (between zero and one), where themax_val
goes to one, and themin_val
goes to zero.Parameters: vals : array-like
the values that need to be rescaled to be between 0 and 1
min_val : float
worst acceptable value (rescales to 0)
max_val : float
best value cared about (rescales to 1)
greater_than_max : 0 or 1
what is returned for
vals
abovemax_val
. (in some cases anything higher thanmax_val
should also return one, in some cases it should return zero)Returns: array of floats between 0 and 1 inclusive rescaled so that
vals
equal tomin_val
equal 0 and those equal tomax_val
equal 1Examples
rescale an array of altitudes to be between 0 and 1, with the best (60) going to 1 and worst (35) going to 0. For values outside the range, the rescale should return 0 below 35 and 1 above 60. >>> from astroplan.constraints import max_best_rescale >>> import numpy as np >>> altitudes = np.array([20, 30, 40, 45, 55, 70]) >>> max_best_rescale(altitudes, 35, 60) array([ 0. , 0. , 0.2, 0.4, 0.8, 1. ])