Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AltitudeConstraint: Adjust max_best_rescale() to prevent unexpected output #551

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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