astroplan icon indicating copy to clipboard operation
astroplan copied to clipboard

Initilize score_array as Quantity

Open rprechelt opened this issue 7 years ago • 0 comments

global_constraints = [constraints.AltitudeConstraint(min=30*units.deg, boolean_constraint=True)]

works correctly.

However, if I want to score objects by altitude, the docs suggest

global_constraints = [constraints.AltitudeConstraint(min=30*units.deg, boolean_constraint=False)

This throws an exception. create_score_array calls constraint() to get the constraint value for every object at every time-step. For boolean_constraint=False, constraint() returns a Astropy.Quantity object (containing a np.ndarray). This is then multiplied by score_array in create_score_array which is initialized using np.ones. This is a type error (np.ndarray *= Quantity)

To fix this, we need to initialize score_array as a Astropy.Quantity object containing all ones. This now works for both boolean and non-boolean constraints.

rprechelt avatar Feb 25 '18 07:02 rprechelt