{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/astroplan/pulls/comments/38472105","id":38472105,"diff_hunk":"@@ -0,0 +1,238 @@\n+:orphan:\n+\n+.. doctest-skip-all\n+\n+******************************\n+Defining Observing Constraints\n+******************************\n+\n+Contents\n+========\n+\n+* :ref:`constraints-built_in_constraints`\n+* :ref:`constraints-user_defined_constraints`\n+\n+.. _constraints-built_in_constraints:\n+\n+Built-In Constraints\n+====================\n+\n+Frequently, we have a long list of targets that we want to observe, and we need\n+to know which ones are observable given a set of constraints imposed on our\n+observations by a wide range of limitations. For example, your telescope may\n+only point over a limited range of altitudes, your targets are only useful\n+in a range of airmasses, and they must be separated from the moon by some\n+large angle. The `astroplan.constraints` module is here to help!\n+\n+Say we're planning to observe from Subaru Observatory in Hawaii on August 1,\n+2015 from 06:00-12:00 UTC. First, let's set up an `astroplan.Observer` object::\n+\n+    from astroplan import Observer, FixedTarget\n+    from astropy.time import Time\n+    subaru = Observer.at_site(\"Subaru\")\n+    time_range = Time([\"2015-08-01 06:00\", \"2015-08-01 12:00\"])\n+\n+We're keeping a list of targets in a text file called `targets.txt`, which looks\n+like this::\n+\n+    # name ra_degrees dec_degrees\n+    Polaris 37.95456067 89.26410897\n+    Vega 279.234734787 38.783688956\n+    Albireo 292.68033548 27.959680072\n+    Algol 47.042218553 40.955646675\n+    Rigel 78.634467067 -8.201638365\n+    Regulus 152.092962438 11.967208776\n+\n+We'll read in this list of targets using `astropy.io.ascii`, and create a list\n+of `astroplan.FixedTarget` objects out of them::\n+\n+    # Read in the table of targets\n+    from astropy.io import ascii\n+    target_table = ascii.read('targets.txt')\n+\n+    # Create astroplan.FixedTarget objects for each one in the table\n+    from astropy.coordinates import SkyCoord\n+    import astropy.units as u\n+    targets = [FixedTarget(coord=SkyCoord(ra=ra*u.deg, dec=dec*u.deg), name=name)\n+               for name, ra, dec in target_table]\n+\n+We will build a bulleted list of our constraints first, then implement them in\n+code below.\n+\n+* Our observations with Subaru can only occur between altitudes of ~10-80\n+  degrees, which we can define using the\n+  `astroplan.constraints.AltitudeConstraint` class.\n+\n+* We place an upper limit on the airmass of each target during observations\n+  using the `astroplan.constraints.AirmassConstraint` class.\n+\n+* Since we're optical observers, we only want to observe targets at night, so\n+  we'll also call the `astroplan.constraints.AtNightConstraint` class. We're\n+  not terribly worried about sky brightness for these bright stars, so we'll\n+  define \"night\" times as those between civil twilights by using the class\n+  method `AtNightConstraint.twilight_civil`::\n+\n+    from astroplan import (AltitudeConstraint, AirmassConstraint,\n+                           AtNightConstraint)\n+    constraints = [AltitudeConstraint(10*u.deg, 80*u.deg),\n+                   AirmassConstraint(5), AtNightConstraint.twilight_civil()]\n+\n+This list of constraints can now be applied to our target list to determine\n+whether:\n+\n+* the targets are observable given the constraints at *any* times in the time\n+  range, using `astroplan.constraints.is_observable`,\n+\n+* the targets are observable given the constraints at *all* times in the time\n+  range, using `astroplan.constraints.is_always_observable`::\n+\n+    from astroplan import is_observable, is_always_observable\n+    # Are targets *ever* observable in the time range?\n+    ever_observable = is_observable(constraints, subaru, targets, time_range=time_range)\n+\n+    # Are targets *always* observable in the time range?\n+    always_observable = is_always_observable(constraints, subaru, targets, time_range=time_range)\n+\n+These two functions will return boolean arrays which tell you whether or not\n+each target is observable given your constraints. Let's print these results in\n+tabular form:\n+\n+    >>> from astropy.table import Table\n+    >>> import numpy as np\n+    >>> observability_array = np.array([[t.name, ever, always]  for t, ever, always in","path":"docs/tutorials/constraints.rst","position":102,"original_position":102,"commit_id":"69273dee4218514cc422d3960cde9557effcb3a4","original_commit_id":"69273dee4218514cc422d3960cde9557effcb3a4","user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"body":"This is not a good way to build the `Table`.\r\nAs you can see in the output below, it leads to the bool columns being string columns.\r\n\r\nInstead I'd suggest this:\r\n```\r\ntable = Table()\r\ntable['targets'] = [target.name for target in targets]\r\ntable['ever_observable'] = ever_observable\r\ntable['always_observable'] = always_observable\r\n```","created_at":"2015-09-01T21:05:51Z","updated_at":"2015-09-01T21:05:51Z","html_url":"https://github.com/astropy/astroplan/pull/61#discussion_r38472105","pull_request_url":"https://api.github.com/repos/astropy/astroplan/pulls/61","_links":{"self":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/comments/38472105"},"html":{"href":"https://github.com/astropy/astroplan/pull/61#discussion_r38472105"},"pull_request":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/61"}}},"pull_request":{"url":"https://api.github.com/repos/astropy/astroplan/pulls/61","id":42296601,"html_url":"https://github.com/astropy/astroplan/pull/61","diff_url":"https://github.com/astropy/astroplan/pull/61.diff","patch_url":"https://github.com/astropy/astroplan/pull/61.patch","issue_url":"https://api.github.com/repos/astropy/astroplan/issues/61","number":61,"state":"open","locked":false,"title":"Constraints","user":{"login":"bmorris3","id":3497584,"avatar_url":"https://avatars.githubusercontent.com/u/3497584?v=3","gravatar_id":"","url":"https://api.github.com/users/bmorris3","html_url":"https://github.com/bmorris3","followers_url":"https://api.github.com/users/bmorris3/followers","following_url":"https://api.github.com/users/bmorris3/following{/other_user}","gists_url":"https://api.github.com/users/bmorris3/gists{/gist_id}","starred_url":"https://api.github.com/users/bmorris3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmorris3/subscriptions","organizations_url":"https://api.github.com/users/bmorris3/orgs","repos_url":"https://api.github.com/users/bmorris3/repos","events_url":"https://api.github.com/users/bmorris3/events{/privacy}","received_events_url":"https://api.github.com/users/bmorris3/received_events","type":"User","site_admin":false},"body":"Here's a first implementation of the constraints module, based on a rough pseudocode sketch for the inheritance scheme by @eteq. \r\n\r\nTo see how this constraints module would be used, take a peek at this [demo notebook](https://github.com/bmorris3/gsoc2015/blob/master/constraints-demo.ipynb). UPDATE: I've added [high level docs](http://staff.washington.edu/bmmorris/_build/html/tutorials/constraints.html) for you to inspect also.\r\n\r\nThis PR is intended to be a conversation starter. I've made some decisions in naming that will likely be controversial, so let's discuss!","created_at":"2015-08-12T22:26:42Z","updated_at":"2015-09-01T21:05:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f16fc18b118458d89c5e3efc201e66102bd8c71","assignee":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/astropy/astroplan/milestones/1","html_url":"https://github.com/astropy/astroplan/milestones/0.1%20release","labels_url":"https://api.github.com/repos/astropy/astroplan/milestones/1/labels","id":1087263,"number":1,"title":"0.1 release","description":"First release","creator":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":43,"state":"open","created_at":"2015-04-28T11:35:13Z","updated_at":"2015-09-01T19:51:25Z","due_on":"2015-08-27T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/astropy/astroplan/pulls/61/commits","review_comments_url":"https://api.github.com/repos/astropy/astroplan/pulls/61/comments","review_comment_url":"https://api.github.com/repos/astropy/astroplan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/astroplan/issues/61/comments","statuses_url":"https://api.github.com/repos/astropy/astroplan/statuses/69273dee4218514cc422d3960cde9557effcb3a4","head":{"label":"bmorris3:constraints","ref":"constraints","sha":"69273dee4218514cc422d3960cde9557effcb3a4","user":{"login":"bmorris3","id":3497584,"avatar_url":"https://avatars.githubusercontent.com/u/3497584?v=3","gravatar_id":"","url":"https://api.github.com/users/bmorris3","html_url":"https://github.com/bmorris3","followers_url":"https://api.github.com/users/bmorris3/followers","following_url":"https://api.github.com/users/bmorris3/following{/other_user}","gists_url":"https://api.github.com/users/bmorris3/gists{/gist_id}","starred_url":"https://api.github.com/users/bmorris3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmorris3/subscriptions","organizations_url":"https://api.github.com/users/bmorris3/orgs","repos_url":"https://api.github.com/users/bmorris3/repos","events_url":"https://api.github.com/users/bmorris3/events{/privacy}","received_events_url":"https://api.github.com/users/bmorris3/received_events","type":"User","site_admin":false},"repo":{"id":34740000,"name":"astroplan","full_name":"bmorris3/astroplan","owner":{"login":"bmorris3","id":3497584,"avatar_url":"https://avatars.githubusercontent.com/u/3497584?v=3","gravatar_id":"","url":"https://api.github.com/users/bmorris3","html_url":"https://github.com/bmorris3","followers_url":"https://api.github.com/users/bmorris3/followers","following_url":"https://api.github.com/users/bmorris3/following{/other_user}","gists_url":"https://api.github.com/users/bmorris3/gists{/gist_id}","starred_url":"https://api.github.com/users/bmorris3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmorris3/subscriptions","organizations_url":"https://api.github.com/users/bmorris3/orgs","repos_url":"https://api.github.com/users/bmorris3/repos","events_url":"https://api.github.com/users/bmorris3/events{/privacy}","received_events_url":"https://api.github.com/users/bmorris3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bmorris3/astroplan","description":"Observation planning package for astronomers","fork":true,"url":"https://api.github.com/repos/bmorris3/astroplan","forks_url":"https://api.github.com/repos/bmorris3/astroplan/forks","keys_url":"https://api.github.com/repos/bmorris3/astroplan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bmorris3/astroplan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bmorris3/astroplan/teams","hooks_url":"https://api.github.com/repos/bmorris3/astroplan/hooks","issue_events_url":"https://api.github.com/repos/bmorris3/astroplan/issues/events{/number}","events_url":"https://api.github.com/repos/bmorris3/astroplan/events","assignees_url":"https://api.github.com/repos/bmorris3/astroplan/assignees{/user}","branches_url":"https://api.github.com/repos/bmorris3/astroplan/branches{/branch}","tags_url":"https://api.github.com/repos/bmorris3/astroplan/tags","blobs_url":"https://api.github.com/repos/bmorris3/astroplan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bmorris3/astroplan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bmorris3/astroplan/git/refs{/sha}","trees_url":"https://api.github.com/repos/bmorris3/astroplan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bmorris3/astroplan/statuses/{sha}","languages_url":"https://api.github.com/repos/bmorris3/astroplan/languages","stargazers_url":"https://api.github.com/repos/bmorris3/astroplan/stargazers","contributors_url":"https://api.github.com/repos/bmorris3/astroplan/contributors","subscribers_url":"https://api.github.com/repos/bmorris3/astroplan/subscribers","subscription_url":"https://api.github.com/repos/bmorris3/astroplan/subscription","commits_url":"https://api.github.com/repos/bmorris3/astroplan/commits{/sha}","git_commits_url":"https://api.github.com/repos/bmorris3/astroplan/git/commits{/sha}","comments_url":"https://api.github.com/repos/bmorris3/astroplan/comments{/number}","issue_comment_url":"https://api.github.com/repos/bmorris3/astroplan/issues/comments{/number}","contents_url":"https://api.github.com/repos/bmorris3/astroplan/contents/{+path}","compare_url":"https://api.github.com/repos/bmorris3/astroplan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bmorris3/astroplan/merges","archive_url":"https://api.github.com/repos/bmorris3/astroplan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bmorris3/astroplan/downloads","issues_url":"https://api.github.com/repos/bmorris3/astroplan/issues{/number}","pulls_url":"https://api.github.com/repos/bmorris3/astroplan/pulls{/number}","milestones_url":"https://api.github.com/repos/bmorris3/astroplan/milestones{/number}","notifications_url":"https://api.github.com/repos/bmorris3/astroplan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bmorris3/astroplan/labels{/name}","releases_url":"https://api.github.com/repos/bmorris3/astroplan/releases{/id}","created_at":"2015-04-28T15:47:16Z","updated_at":"2015-04-28T15:47:16Z","pushed_at":"2015-09-01T19:49:44Z","git_url":"git://github.com/bmorris3/astroplan.git","ssh_url":"git@github.com:bmorris3/astroplan.git","clone_url":"https://github.com/bmorris3/astroplan.git","svn_url":"https://github.com/bmorris3/astroplan","homepage":"https://astroplan.readthedocs.org/","size":4043,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"astropy:master","ref":"master","sha":"9bcf1ce58c357f5d780c382a4dcef189b23c3f30","user":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"repo":{"id":34693515,"name":"astroplan","full_name":"astropy/astroplan","owner":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/astropy/astroplan","description":"Observation planning package for astronomers","fork":false,"url":"https://api.github.com/repos/astropy/astroplan","forks_url":"https://api.github.com/repos/astropy/astroplan/forks","keys_url":"https://api.github.com/repos/astropy/astroplan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/astroplan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/astroplan/teams","hooks_url":"https://api.github.com/repos/astropy/astroplan/hooks","issue_events_url":"https://api.github.com/repos/astropy/astroplan/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/astroplan/events","assignees_url":"https://api.github.com/repos/astropy/astroplan/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/astroplan/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/astroplan/tags","blobs_url":"https://api.github.com/repos/astropy/astroplan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/astroplan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/astroplan/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/astroplan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/astroplan/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/astroplan/languages","stargazers_url":"https://api.github.com/repos/astropy/astroplan/stargazers","contributors_url":"https://api.github.com/repos/astropy/astroplan/contributors","subscribers_url":"https://api.github.com/repos/astropy/astroplan/subscribers","subscription_url":"https://api.github.com/repos/astropy/astroplan/subscription","commits_url":"https://api.github.com/repos/astropy/astroplan/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/astroplan/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/astroplan/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/astroplan/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/astroplan/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/astroplan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/astroplan/merges","archive_url":"https://api.github.com/repos/astropy/astroplan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/astroplan/downloads","issues_url":"https://api.github.com/repos/astropy/astroplan/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/astroplan/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/astroplan/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/astroplan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/astroplan/labels{/name}","releases_url":"https://api.github.com/repos/astropy/astroplan/releases{/id}","created_at":"2015-04-27T22:00:00Z","updated_at":"2015-08-25T20:19:34Z","pushed_at":"2015-09-01T19:50:18Z","git_url":"git://github.com/astropy/astroplan.git","ssh_url":"git@github.com:astropy/astroplan.git","clone_url":"https://github.com/astropy/astroplan.git","svn_url":"https://github.com/astropy/astroplan","homepage":"https://astroplan.readthedocs.org/","size":4462,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":27,"forks":10,"open_issues":27,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/61"},"html":{"href":"https://github.com/astropy/astroplan/pull/61"},"issue":{"href":"https://api.github.com/repos/astropy/astroplan/issues/61"},"comments":{"href":"https://api.github.com/repos/astropy/astroplan/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/astroplan/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/astroplan/statuses/69273dee4218514cc422d3960cde9557effcb3a4"}}}}