-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Constraints #61
Constraints #61
Conversation
@eteq – The travis build failed on some Python 3 runs because |
Nice! I'm digging this. I was talking to @astrofrog earlier about a use case that would be nice to have: given an observer, a single time, a list of targets, constraints, and (optionally) a list of exposure times (or is this an attribute of Amateur astronomers would probably also find this useful -- we could imagine building a way to, given a catalog name, return all objects that are visible (e.g., what Messier objects are observable right now from XX?) Thinking a bit more long term, it would also be straightforward to build a web front-end with Flask and yadda yadda... |
This looks good! I like the |
A wishlist of constraints that could/should be added is developing on my wiki. Contribute if there's anything missing! @astroplanners/astroplanners-contributors: @jberlanga brought up one type of constraint that we haven't discussed in a while – target-intrinsic constraints. For example: give me all targets in this list with 11<V<14. Of course, by themselves these target-intrinsic constraints could be sorted out by the user in a simple for loop before they hit the One option for doing this could be to allow users to add their own kwargs to from astroplan import FixedTarget
from astroplan.constraints import Constraint
polaris = FixedTarget.from_name("Polaris", Bmag=2.62)
aldebaran = FixedTarget.from_name("Aldebaran", Bmag=2.4)
algol = FixedTarget.from_name("Algol", Bmag=2.07)
class TargetPropertyConstraint(Constraint):
def __init__(self, property_keyword, min=None, max=None):
self.min = min
self.max = max
self.property_keyword = property_keyword
def _compute_constraint(self, time_range, observer, targets):
if self.min is None:
mask = [self.min < target[self.property_keyword]
for target in targets]
elif self.max is None:
mask = [self.max > target[self.property_keyword]
for target in targets]
elif self.min is not None and self.max is not None:
mask = [self.min < target[self.property_keyword]
for target in targets] & [self.max > target[self.property_keyword]
for target in targets]
return mask How would you like to see this? |
def is_always_observable(constraints, time_range, targets, observer): | ||
""" | ||
Are the ``targets`` always observable throughout ``time_range`` given | ||
constraints in ``constraints_list`` for ``observer``? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like "constraints_list" should be changed to "constraints" to match the code?
@cdeil and others: there are some high level docs for the |
write must be as well. | ||
|
||
In this example, let's design our constraint to ensure that all targets must be | ||
within some number of degrees from Vega – we'll call it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"number of degrees" -> "angular separation"?
I've left a bunch of inline comments. Two more big-picture comments:
|
I forgot to say: IMO this is nice and it's been open for a while, so @bmorris3, if you want to merge it, I'd say go ahead! Or leave it open for one more day and ping the others for final review one more time, as you like. |
@@ -0,0 +1,255 @@ | |||
:orphan: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary - it was needed in the past when there was no index pointing to the tutorials, but now there is, so you should not use :orphan:
(it indicates that the document in question isn't linked to from anywhere else).
Ok, I'm done with my review - mostly doc suggestions (although one possibly-complicated bit about user-defined constraints... we may want to discuss that more on slack) This has already been discussed some on slack, but I think the whole constraints tutorial should be doctest-ed. Annoyingly the easiest way is probably to add |
Updates done, tests passed, merging! Feel free to leave more comments in issues if I jumped the gun on anything. |
🎈 🎈 🎈 🎉 🎈 🎈 🎈 |
🎆 |
Here's a first implementation of the constraints module, based on a rough pseudocode sketch for the inheritance scheme by @eteq.
To see how this constraints module would be used, take a peek at this demo notebook. UPDATE: I've added high level docs for you to inspect also.
This PR is intended to be a conversation starter. I've made some decisions in naming that will likely be controversial, so let's discuss!