{"action":"created","comment":{"url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/comments/198267092","pull_request_review_id":132162471,"id":198267092,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODI2NzA5Mg==","diff_hunk":"@@ -1912,6 +1912,122 @@ def subcube_from_ds9region(self, ds9region, allow_empty=False):\n         # that we can now crop out\n         return masked_subcube.minimal_subcube(spatial_only=True)\n \n+    def subcube_from_ds9region_new(self, ds9region, allow_empty=False):\n+        \"\"\"\n+        Extract a masked subcube from a ds9 region\n+        (only functions on celestial dimensions)\n+\n+        Parameters\n+        ----------\n+        ds9region: str\n+            The region to extract\n+        allow_empty: bool\n+            If this is False, an exception will be raised if the region\n+            contains no overlap with the cube\n+        \"\"\"\n+        import regions\n+\n+        if isinstance(ds9region, six.string_types):\n+            ds9region = regions.DS9Parser(ds9region).shapes.to_regions()\n+        else:\n+            raise TypeError(\"{0} should be a DS9 string\".format(ds9region))\n+\n+        return self.subcube_from_regions(ds9region, allow_empty)\n+\n+    def subcube_from_crtf(self, region, allow_empty=False):\n+        \"\"\"\n+        Extract a masked subcube from a CRTF region\n+        (only functions on celestial dimensions)\n+\n+        Parameters\n+        ----------\n+        region: str\n+            The CRTF region string to extract\n+        allow_empty: bool\n+            If this is False, an exception will be raised if the region\n+            contains no overlap with the cube\n+        \"\"\"\n+        import regions\n+\n+        if isinstance(region, six.string_types):\n+            region = regions.CRTFParser(region).shapes.to_regions()\n+        else:\n+            raise TypeError(\"{0} should be a CRTF string\".format(region))\n+\n+        return self.subcube_from_regions(region, allow_empty)\n+\n+    def subcube_from_regions(self, region_list, allow_empty=False):\n+        \"\"\"\n+        Extract a masked subcube from a list of `regions.Region` object\n+        (only functions on celestial dimensions)\n+\n+        Parameters\n+        ----------\n+        region_list: `regions.Region` list\n+            The region to extract\n+        allow_empty: bool\n+            If this is False, an exception will be raised if the region\n+            contains no overlap with the cube\n+        \"\"\"\n+        import regions\n+\n+        # Every region should be a `regions.PixelRegion` object.\n+        regs = []\n+        for x in region_list:\n+            if isinstance(x, regions.SkyRegion):\n+                regs.append(x.to_pixel(self.wcs.celestial))\n+            elif isinstance(x, regions.PixelRegion):\n+                regs.append(x)\n+            else:\n+                raise TypeError(\"'{}' should be `regions.Region` object\".format(x))\n+\n+        # List of regions are converted to a `regions.CompoundPixelRegion` object.\n+        compound_region = _compound_region(regs)\n+\n+        # Compound mask of all the regions.\n+        mask = compound_region.to_mask()\n+\n+        # Checking for frequency/velocity range of each region.\n+        ranges = [x.meta.get('range', None) for x in regs]","path":"spectral_cube/spectral_cube.py","position":89,"original_position":89,"commit_id":"7a1baa871e91c1e8f5c872f80b79bc8f39afe2e3","original_commit_id":"7a1baa871e91c1e8f5c872f80b79bc8f39afe2e3","user":{"login":"keflavich","id":143715,"node_id":"MDQ6VXNlcjE0MzcxNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/143715?v=4","gravatar_id":"","url":"https://api.github.com/users/keflavich","html_url":"https://github.com/keflavich","followers_url":"https://api.github.com/users/keflavich/followers","following_url":"https://api.github.com/users/keflavich/following{/other_user}","gists_url":"https://api.github.com/users/keflavich/gists{/gist_id}","starred_url":"https://api.github.com/users/keflavich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keflavich/subscriptions","organizations_url":"https://api.github.com/users/keflavich/orgs","repos_url":"https://api.github.com/users/keflavich/repos","events_url":"https://api.github.com/users/keflavich/events{/privacy}","received_events_url":"https://api.github.com/users/keflavich/received_events","type":"User","site_admin":false},"body":"ooh, this is a bit ugly, since they could technically be different....  we will need additional machinery to create the masks for each PPV sub-region instead of using the compound region (or at least, instead of *just* using the compound region)","created_at":"2018-06-26T19:17:47Z","updated_at":"2018-06-26T19:18:34Z","html_url":"https://github.com/radio-astro-tools/spectral-cube/pull/488#discussion_r198267092","pull_request_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/comments/198267092"},"html":{"href":"https://github.com/radio-astro-tools/spectral-cube/pull/488#discussion_r198267092"},"pull_request":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488"}}},"pull_request":{"url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488","id":194956167,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0OTU2MTY3","html_url":"https://github.com/radio-astro-tools/spectral-cube/pull/488","diff_url":"https://github.com/radio-astro-tools/spectral-cube/pull/488.diff","patch_url":"https://github.com/radio-astro-tools/spectral-cube/pull/488.patch","issue_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/488","number":488,"state":"open","locked":false,"title":"WIP : replacing pyregions with regions.","user":{"login":"sushobhana","id":22423652,"node_id":"MDQ6VXNlcjIyNDIzNjUy","avatar_url":"https://avatars0.githubusercontent.com/u/22423652?v=4","gravatar_id":"","url":"https://api.github.com/users/sushobhana","html_url":"https://github.com/sushobhana","followers_url":"https://api.github.com/users/sushobhana/followers","following_url":"https://api.github.com/users/sushobhana/following{/other_user}","gists_url":"https://api.github.com/users/sushobhana/gists{/gist_id}","starred_url":"https://api.github.com/users/sushobhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushobhana/subscriptions","organizations_url":"https://api.github.com/users/sushobhana/orgs","repos_url":"https://api.github.com/users/sushobhana/repos","events_url":"https://api.github.com/users/sushobhana/events{/privacy}","received_events_url":"https://api.github.com/users/sushobhana/received_events","type":"User","site_admin":false},"body":"work in progress PR","created_at":"2018-06-14T16:51:33Z","updated_at":"2018-06-26T19:18:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2646a5b7c58fb28620eea332536ec118febceb2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488/commits","review_comments_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488/comments","review_comment_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/comments{/number}","comments_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/488/comments","statuses_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/statuses/7a1baa871e91c1e8f5c872f80b79bc8f39afe2e3","head":{"label":"sushobhana:regions","ref":"regions","sha":"7a1baa871e91c1e8f5c872f80b79bc8f39afe2e3","user":{"login":"sushobhana","id":22423652,"node_id":"MDQ6VXNlcjIyNDIzNjUy","avatar_url":"https://avatars0.githubusercontent.com/u/22423652?v=4","gravatar_id":"","url":"https://api.github.com/users/sushobhana","html_url":"https://github.com/sushobhana","followers_url":"https://api.github.com/users/sushobhana/followers","following_url":"https://api.github.com/users/sushobhana/following{/other_user}","gists_url":"https://api.github.com/users/sushobhana/gists{/gist_id}","starred_url":"https://api.github.com/users/sushobhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushobhana/subscriptions","organizations_url":"https://api.github.com/users/sushobhana/orgs","repos_url":"https://api.github.com/users/sushobhana/repos","events_url":"https://api.github.com/users/sushobhana/events{/privacy}","received_events_url":"https://api.github.com/users/sushobhana/received_events","type":"User","site_admin":false},"repo":{"id":136868833,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY4Njg4MzM=","name":"spectral-cube","full_name":"sushobhana/spectral-cube","owner":{"login":"sushobhana","id":22423652,"node_id":"MDQ6VXNlcjIyNDIzNjUy","avatar_url":"https://avatars0.githubusercontent.com/u/22423652?v=4","gravatar_id":"","url":"https://api.github.com/users/sushobhana","html_url":"https://github.com/sushobhana","followers_url":"https://api.github.com/users/sushobhana/followers","following_url":"https://api.github.com/users/sushobhana/following{/other_user}","gists_url":"https://api.github.com/users/sushobhana/gists{/gist_id}","starred_url":"https://api.github.com/users/sushobhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushobhana/subscriptions","organizations_url":"https://api.github.com/users/sushobhana/orgs","repos_url":"https://api.github.com/users/sushobhana/repos","events_url":"https://api.github.com/users/sushobhana/events{/privacy}","received_events_url":"https://api.github.com/users/sushobhana/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sushobhana/spectral-cube","description":"Library for reading and analyzing astrophysical spectral data cubes","fork":true,"url":"https://api.github.com/repos/sushobhana/spectral-cube","forks_url":"https://api.github.com/repos/sushobhana/spectral-cube/forks","keys_url":"https://api.github.com/repos/sushobhana/spectral-cube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sushobhana/spectral-cube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sushobhana/spectral-cube/teams","hooks_url":"https://api.github.com/repos/sushobhana/spectral-cube/hooks","issue_events_url":"https://api.github.com/repos/sushobhana/spectral-cube/issues/events{/number}","events_url":"https://api.github.com/repos/sushobhana/spectral-cube/events","assignees_url":"https://api.github.com/repos/sushobhana/spectral-cube/assignees{/user}","branches_url":"https://api.github.com/repos/sushobhana/spectral-cube/branches{/branch}","tags_url":"https://api.github.com/repos/sushobhana/spectral-cube/tags","blobs_url":"https://api.github.com/repos/sushobhana/spectral-cube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sushobhana/spectral-cube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sushobhana/spectral-cube/git/refs{/sha}","trees_url":"https://api.github.com/repos/sushobhana/spectral-cube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sushobhana/spectral-cube/statuses/{sha}","languages_url":"https://api.github.com/repos/sushobhana/spectral-cube/languages","stargazers_url":"https://api.github.com/repos/sushobhana/spectral-cube/stargazers","contributors_url":"https://api.github.com/repos/sushobhana/spectral-cube/contributors","subscribers_url":"https://api.github.com/repos/sushobhana/spectral-cube/subscribers","subscription_url":"https://api.github.com/repos/sushobhana/spectral-cube/subscription","commits_url":"https://api.github.com/repos/sushobhana/spectral-cube/commits{/sha}","git_commits_url":"https://api.github.com/repos/sushobhana/spectral-cube/git/commits{/sha}","comments_url":"https://api.github.com/repos/sushobhana/spectral-cube/comments{/number}","issue_comment_url":"https://api.github.com/repos/sushobhana/spectral-cube/issues/comments{/number}","contents_url":"https://api.github.com/repos/sushobhana/spectral-cube/contents/{+path}","compare_url":"https://api.github.com/repos/sushobhana/spectral-cube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sushobhana/spectral-cube/merges","archive_url":"https://api.github.com/repos/sushobhana/spectral-cube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sushobhana/spectral-cube/downloads","issues_url":"https://api.github.com/repos/sushobhana/spectral-cube/issues{/number}","pulls_url":"https://api.github.com/repos/sushobhana/spectral-cube/pulls{/number}","milestones_url":"https://api.github.com/repos/sushobhana/spectral-cube/milestones{/number}","notifications_url":"https://api.github.com/repos/sushobhana/spectral-cube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sushobhana/spectral-cube/labels{/name}","releases_url":"https://api.github.com/repos/sushobhana/spectral-cube/releases{/id}","deployments_url":"https://api.github.com/repos/sushobhana/spectral-cube/deployments","created_at":"2018-06-11T03:16:01Z","updated_at":"2018-06-11T03:16:03Z","pushed_at":"2018-06-23T18:45:21Z","git_url":"git://github.com/sushobhana/spectral-cube.git","ssh_url":"git@github.com:sushobhana/spectral-cube.git","clone_url":"https://github.com/sushobhana/spectral-cube.git","svn_url":"https://github.com/sushobhana/spectral-cube","homepage":"http://spectral-cube.rtfd.org","size":2192,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"radio-astro-tools:master","ref":"master","sha":"e9c6c97fda60f460c09e8dc1c25c04578a5ad49e","user":{"login":"radio-astro-tools","id":7228695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMjg2OTU=","avatar_url":"https://avatars0.githubusercontent.com/u/7228695?v=4","gravatar_id":"","url":"https://api.github.com/users/radio-astro-tools","html_url":"https://github.com/radio-astro-tools","followers_url":"https://api.github.com/users/radio-astro-tools/followers","following_url":"https://api.github.com/users/radio-astro-tools/following{/other_user}","gists_url":"https://api.github.com/users/radio-astro-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/radio-astro-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radio-astro-tools/subscriptions","organizations_url":"https://api.github.com/users/radio-astro-tools/orgs","repos_url":"https://api.github.com/users/radio-astro-tools/repos","events_url":"https://api.github.com/users/radio-astro-tools/events{/privacy}","received_events_url":"https://api.github.com/users/radio-astro-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":18766007,"node_id":"MDEwOlJlcG9zaXRvcnkxODc2NjAwNw==","name":"spectral-cube","full_name":"radio-astro-tools/spectral-cube","owner":{"login":"radio-astro-tools","id":7228695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMjg2OTU=","avatar_url":"https://avatars0.githubusercontent.com/u/7228695?v=4","gravatar_id":"","url":"https://api.github.com/users/radio-astro-tools","html_url":"https://github.com/radio-astro-tools","followers_url":"https://api.github.com/users/radio-astro-tools/followers","following_url":"https://api.github.com/users/radio-astro-tools/following{/other_user}","gists_url":"https://api.github.com/users/radio-astro-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/radio-astro-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radio-astro-tools/subscriptions","organizations_url":"https://api.github.com/users/radio-astro-tools/orgs","repos_url":"https://api.github.com/users/radio-astro-tools/repos","events_url":"https://api.github.com/users/radio-astro-tools/events{/privacy}","received_events_url":"https://api.github.com/users/radio-astro-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/radio-astro-tools/spectral-cube","description":"Library for reading and analyzing astrophysical spectral data cubes","fork":false,"url":"https://api.github.com/repos/radio-astro-tools/spectral-cube","forks_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/forks","keys_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/teams","hooks_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/hooks","issue_events_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/events{/number}","events_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/events","assignees_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/assignees{/user}","branches_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/branches{/branch}","tags_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/tags","blobs_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/git/refs{/sha}","trees_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/statuses/{sha}","languages_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/languages","stargazers_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/stargazers","contributors_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/contributors","subscribers_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/subscribers","subscription_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/subscription","commits_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/commits{/sha}","git_commits_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/git/commits{/sha}","comments_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/comments{/number}","issue_comment_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/comments{/number}","contents_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/contents/{+path}","compare_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/merges","archive_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/downloads","issues_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues{/number}","pulls_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls{/number}","milestones_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/milestones{/number}","notifications_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/labels{/name}","releases_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/releases{/id}","deployments_url":"https://api.github.com/repos/radio-astro-tools/spectral-cube/deployments","created_at":"2014-04-14T15:33:50Z","updated_at":"2018-06-18T21:25:25Z","pushed_at":"2018-06-23T18:45:23Z","git_url":"git://github.com/radio-astro-tools/spectral-cube.git","ssh_url":"git@github.com:radio-astro-tools/spectral-cube.git","clone_url":"https://github.com/radio-astro-tools/spectral-cube.git","svn_url":"https://github.com/radio-astro-tools/spectral-cube","homepage":"http://spectral-cube.rtfd.org","size":2103,"stargazers_count":26,"watchers_count":26,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"archived":false,"open_issues_count":72,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":30,"open_issues":72,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488"},"html":{"href":"https://github.com/radio-astro-tools/spectral-cube/pull/488"},"issue":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/488"},"comments":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/issues/488/comments"},"review_comments":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488/comments"},"review_comment":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/pulls/488/commits"},"statuses":{"href":"https://api.github.com/repos/radio-astro-tools/spectral-cube/statuses/7a1baa871e91c1e8f5c872f80b79bc8f39afe2e3"}},"author_association":"NONE"}}
{"actor":{"display_login":"keflavich"}}