{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/meas_base/pulls/comments/46737351","id":46737351,"diff_hunk":"@@ -0,0 +1,153 @@\n+#!/usr/bin/env python\n+#\n+# LSST Data Management System\n+# Copyright 2008-2015 AURA/LSST.\n+#\n+# This product includes software developed by the\n+# LSST Project (http://www.lsst.org/).\n+#\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the LSST License Statement and\n+# the GNU General Public License along with this program.  If not,\n+# see <https://www.lsstcorp.org/LegalNotices/>.\n+#\n+import collections\n+\n+import lsst.pex.logging\n+import lsst.pex.exceptions\n+import lsst.afw.table\n+import lsst.afw.image\n+import lsst.coadd.utils\n+from lsst.geom import convexHull\n+\n+class PerTractCcdDataIdContainer(lsst.coadd.utils.CoaddDataIdContainer):\n+    \"\"\"A version of lsst.pipe.base.DataIdContainer that combines raw data IDs (defined as whatever we use\n+    for 'src') with a tract.\n+    \"\"\"\n+\n+    def castDataIds(self, butler):\n+        \"\"\"Validate data IDs and cast them to the correct type (modify idList in place).\n+\n+        @param butler: data butler\n+        \"\"\"\n+        try:\n+            idKeyTypeDict = butler.getKeys(datasetType=\"src\", level=self.level)\n+        except KeyError as e:\n+            raise KeyError(\"Cannot get keys for datasetType %s at level %s: %s\" % (\"src\", self.level, e))\n+\n+        idKeyTypeDict = idKeyTypeDict.copy()\n+        idKeyTypeDict[\"tract\"] = int\n+\n+        for dataDict in self.idList:\n+            for key, strVal in dataDict.iteritems():\n+                try:\n+                    keyType = idKeyTypeDict[key]\n+                except KeyError:\n+                    validKeys = sorted(idKeyTypeDict.keys())\n+                    raise KeyError(\"Unrecognized ID key %r; valid keys are: %s\" % (key, validKeys))\n+                if keyType != str:\n+                    try:\n+                        castVal = keyType(strVal)\n+                    except Exception:\n+                        raise TypeError(\"Cannot cast value %r to %s for ID key %r\" % (strVal, keyType, key,))\n+                    dataDict[key] = castVal\n+\n+    def _addDataRef(self, namespace, dataId, tract):\n+        \"\"\"Construct a dataRef based on dataId, but with an added tract key\"\"\"\n+        forcedDataId = dataId.copy()\n+        forcedDataId['tract'] = tract\n+        dataRef = namespace.butler.dataRef(datasetType=self.datasetType, dataId=forcedDataId)\n+        self.refList.append(dataRef)\n+\n+    def makeDataRefList(self, namespace):\n+        \"\"\"Make self.refList from self.idList\n+        \"\"\"\n+        if self.datasetType is None:\n+            raise RuntimeError(\"Must call setDatasetType first\")\n+        skymap = None\n+        log = None","path":"python/lsst/meas/base/dataIds.py","position":null,"original_position":77,"commit_id":"6ec5c117c11d482cfc4a1de21315c49ea89d75fc","original_commit_id":"6d7a8b96f02ebbb15d4795fa9434075de7671f27","user":{"login":"laurenam","id":10424871,"avatar_url":"https://avatars.githubusercontent.com/u/10424871?v=3","gravatar_id":"","url":"https://api.github.com/users/laurenam","html_url":"https://github.com/laurenam","followers_url":"https://api.github.com/users/laurenam/followers","following_url":"https://api.github.com/users/laurenam/following{/other_user}","gists_url":"https://api.github.com/users/laurenam/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenam/subscriptions","organizations_url":"https://api.github.com/users/laurenam/orgs","repos_url":"https://api.github.com/users/laurenam/repos","events_url":"https://api.github.com/users/laurenam/events{/privacy}","received_events_url":"https://api.github.com/users/laurenam/received_events","type":"User","site_admin":false},"body":"The dance has been removed in favor of just initializing the log regardless of the presence of a tract argument in the id.","created_at":"2015-12-04T21:57:43Z","updated_at":"2015-12-04T21:57:43Z","html_url":"https://github.com/lsst/meas_base/pull/27#discussion_r46737351","pull_request_url":"https://api.github.com/repos/lsst/meas_base/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/comments/46737351"},"html":{"href":"https://github.com/lsst/meas_base/pull/27#discussion_r46737351"},"pull_request":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/meas_base/pulls/27","id":52546345,"html_url":"https://github.com/lsst/meas_base/pull/27","diff_url":"https://github.com/lsst/meas_base/pull/27.diff","patch_url":"https://github.com/lsst/meas_base/pull/27.patch","issue_url":"https://api.github.com/repos/lsst/meas_base/issues/27","number":27,"state":"open","locked":false,"title":"Review of DM-4373 (HSC backport: Add tract conveniences)","user":{"login":"jdswinbank","id":460854,"avatar_url":"https://avatars.githubusercontent.com/u/460854?v=3","gravatar_id":"","url":"https://api.github.com/users/jdswinbank","html_url":"https://github.com/jdswinbank","followers_url":"https://api.github.com/users/jdswinbank/followers","following_url":"https://api.github.com/users/jdswinbank/following{/other_user}","gists_url":"https://api.github.com/users/jdswinbank/gists{/gist_id}","starred_url":"https://api.github.com/users/jdswinbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdswinbank/subscriptions","organizations_url":"https://api.github.com/users/jdswinbank/orgs","repos_url":"https://api.github.com/users/jdswinbank/repos","events_url":"https://api.github.com/users/jdswinbank/events{/privacy}","received_events_url":"https://api.github.com/users/jdswinbank/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-03T15:11:43Z","updated_at":"2015-12-04T21:57:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bdad1f3028d6b99c2888e85ba268deb00afc3ea3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lsst/meas_base/pulls/27/commits","review_comments_url":"https://api.github.com/repos/lsst/meas_base/pulls/27/comments","review_comment_url":"https://api.github.com/repos/lsst/meas_base/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/meas_base/issues/27/comments","statuses_url":"https://api.github.com/repos/lsst/meas_base/statuses/6ec5c117c11d482cfc4a1de21315c49ea89d75fc","head":{"label":"lsst:u/lauren/DM-4373","ref":"u/lauren/DM-4373","sha":"6ec5c117c11d482cfc4a1de21315c49ea89d75fc","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013356,"name":"meas_base","full_name":"lsst/meas_base","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/meas_base","description":"LSST Data Management: core astronomical measurement algorithms","fork":false,"url":"https://api.github.com/repos/lsst/meas_base","forks_url":"https://api.github.com/repos/lsst/meas_base/forks","keys_url":"https://api.github.com/repos/lsst/meas_base/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/meas_base/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/meas_base/teams","hooks_url":"https://api.github.com/repos/lsst/meas_base/hooks","issue_events_url":"https://api.github.com/repos/lsst/meas_base/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/meas_base/events","assignees_url":"https://api.github.com/repos/lsst/meas_base/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/meas_base/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/meas_base/tags","blobs_url":"https://api.github.com/repos/lsst/meas_base/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/meas_base/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/meas_base/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/meas_base/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/meas_base/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/meas_base/languages","stargazers_url":"https://api.github.com/repos/lsst/meas_base/stargazers","contributors_url":"https://api.github.com/repos/lsst/meas_base/contributors","subscribers_url":"https://api.github.com/repos/lsst/meas_base/subscribers","subscription_url":"https://api.github.com/repos/lsst/meas_base/subscription","commits_url":"https://api.github.com/repos/lsst/meas_base/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/meas_base/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/meas_base/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/meas_base/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/meas_base/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/meas_base/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/meas_base/merges","archive_url":"https://api.github.com/repos/lsst/meas_base/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/meas_base/downloads","issues_url":"https://api.github.com/repos/lsst/meas_base/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/meas_base/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/meas_base/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/meas_base/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/meas_base/labels{/name}","releases_url":"https://api.github.com/repos/lsst/meas_base/releases{/id}","created_at":"2014-08-16T07:45:37Z","updated_at":"2015-04-21T20:29:36Z","pushed_at":"2015-12-04T21:36:45Z","git_url":"git://github.com/lsst/meas_base.git","ssh_url":"git@github.com:lsst/meas_base.git","clone_url":"https://github.com/lsst/meas_base.git","svn_url":"https://github.com/lsst/meas_base","homepage":"http://dm.lsst.org/","size":2419,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"e96a9f53938338551ab4de5bca24adaeecb99894","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013356,"name":"meas_base","full_name":"lsst/meas_base","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/meas_base","description":"LSST Data Management: core astronomical measurement algorithms","fork":false,"url":"https://api.github.com/repos/lsst/meas_base","forks_url":"https://api.github.com/repos/lsst/meas_base/forks","keys_url":"https://api.github.com/repos/lsst/meas_base/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/meas_base/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/meas_base/teams","hooks_url":"https://api.github.com/repos/lsst/meas_base/hooks","issue_events_url":"https://api.github.com/repos/lsst/meas_base/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/meas_base/events","assignees_url":"https://api.github.com/repos/lsst/meas_base/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/meas_base/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/meas_base/tags","blobs_url":"https://api.github.com/repos/lsst/meas_base/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/meas_base/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/meas_base/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/meas_base/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/meas_base/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/meas_base/languages","stargazers_url":"https://api.github.com/repos/lsst/meas_base/stargazers","contributors_url":"https://api.github.com/repos/lsst/meas_base/contributors","subscribers_url":"https://api.github.com/repos/lsst/meas_base/subscribers","subscription_url":"https://api.github.com/repos/lsst/meas_base/subscription","commits_url":"https://api.github.com/repos/lsst/meas_base/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/meas_base/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/meas_base/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/meas_base/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/meas_base/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/meas_base/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/meas_base/merges","archive_url":"https://api.github.com/repos/lsst/meas_base/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/meas_base/downloads","issues_url":"https://api.github.com/repos/lsst/meas_base/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/meas_base/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/meas_base/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/meas_base/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/meas_base/labels{/name}","releases_url":"https://api.github.com/repos/lsst/meas_base/releases{/id}","created_at":"2014-08-16T07:45:37Z","updated_at":"2015-04-21T20:29:36Z","pushed_at":"2015-12-04T21:36:45Z","git_url":"git://github.com/lsst/meas_base.git","ssh_url":"git@github.com:lsst/meas_base.git","clone_url":"https://github.com/lsst/meas_base.git","svn_url":"https://github.com/lsst/meas_base","homepage":"http://dm.lsst.org/","size":2419,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/27"},"html":{"href":"https://github.com/lsst/meas_base/pull/27"},"issue":{"href":"https://api.github.com/repos/lsst/meas_base/issues/27"},"comments":{"href":"https://api.github.com/repos/lsst/meas_base/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/meas_base/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/meas_base/statuses/6ec5c117c11d482cfc4a1de21315c49ea89d75fc"}}}}