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 the max_val goes to one, and the min_val goes to zero.

Parameters
valsarray-like

the values that need to be rescaled to be between 0 and 1

min_valfloat

worst acceptable value (rescales to 0)

max_valfloat

best value cared about (rescales to 1)

greater_than_max0 or 1

what is returned for vals above max_val. (in some cases anything higher than max_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 to min_val equal 0 and those equal to
max_val equal 1

Examples

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) # doctest: +FLOAT_CMP array([ 0. , 0. , 0.2, 0.4, 0.8, 1. ])