Skip to content

Commit

Permalink
Merge pull request #551 from michaelbaisch/altitude_constraint_fix_re…
Browse files Browse the repository at this point in the history
…scale

AltitudeConstraint: Adjust max_best_rescale() to prevent unexpected output
  • Loading branch information
bmorris3 committed Jul 27, 2023
2 parents bc8788e + e598f44 commit 2e6c766
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion astroplan/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def compute_constraint(self, times, observer, targets):
uppermask = alt <= self.max
return lowermask & uppermask
else:
return max_best_rescale(alt, self.min, self.max)
return max_best_rescale(alt, self.min, self.max, greater_than_max=0)


class AirmassConstraint(AltitudeConstraint):
Expand Down
11 changes: 11 additions & 0 deletions astroplan/tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ def test_observability_table():
assert 'time observable' in stab.colnames


def test_altitude_constraint():
subaru = Observer.at_site("Subaru")
time = Time('2001-02-03 15:35:00')
time_range = Time([time, time+3*u.hour])

constraint = AltitudeConstraint(min=40*u.deg, max=50*u.deg, boolean_constraint=False)
results = constraint(subaru, vega, times=time_grid_from_range(time_range))
# Check if below min and above max values are 0
assert np.all([results != 0][0] == [False, False, True, True, False, False])


def test_compare_altitude_constraint_and_observer():
time = Time('2001-02-03 04:05:06')
time_ranges = [Time([time, time+1*u.hour]) + offset
Expand Down

0 comments on commit 2e6c766

Please sign in to comment.