min_best_rescale¶
- astroplan.min_best_rescale(vals, min_val, max_val, less_than_min=1)[source]¶
rescales an input array
vals
to be a score (between zero and one), where themin_val
goes to one, and themax_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)
- less_than_min0 or 1
what is returned for
vals
belowmin_val
. (in some cases anything less thanmin_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 tomax_val
equal 0 and those equal tomin_val
equal 1
Examples
rescale airmasses to between 0 and 1, with the best (1) and worst (2.25). All values outside the range should return 0. >>> from astroplan.constraints import min_best_rescale >>> import numpy as np >>> airmasses = np.array([1, 1.5, 2, 3, 0]) >>> min_best_rescale(airmasses, 1, 2.25, less_than_min = 0) # doctest: +FLOAT_CMP array([ 1. , 0.6, 0.2, 0. , 0. ])