{"action":"created","comment":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/comments/62474410","id":62474410,"diff_hunk":"@@ -0,0 +1,82 @@\n+# Copyright 2014 - 2016 The ODL development group\n+#\n+# This file is part of ODL.\n+#\n+# ODL 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+# ODL 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 GNU General Public License\n+# along with ODL.  If not, see <http://www.gnu.org/licenses/>.\n+\n+\"\"\"SPECT geometry.\"\"\"\n+\n+# Imports for common Python 2/3 codebase\n+from __future__ import print_function, division, absolute_import\n+from future import standard_library\n+standard_library.install_aliases()\n+from builtins import super\n+\n+import numpy as np\n+\n+from odl.tomo.geometry.geometry import AxisOrientedGeometry\n+from odl.tomo.geometry.parallel import Parallel3dAxisGeometry\n+\n+__all__ = ('ParallelHoleCollimatorGeometry', )\n+\n+\n+class ParallelHoleCollimatorGeometry(Parallel3dAxisGeometry):\n+\n+    \"\"\"Geometry for SPECT Parallel hole collimator.\"\"\"\n+\n+    def __init__(self, apart, dpart, axis=[0, 0, 1], det_rad=0.0,\n+                 **kwargs):\n+        \"\"\"Initialize a new instance.\n+        Parameters\n+        ----------\n+        apart : 1-dim. `RectPartition`\n+            Partition of the angle interval\n+        dpart : 2-dim. `RectPartition`\n+            Partition of the detector parameter rectangle\n+        axis : `array-like`, shape ``(3,)``, optional\n+            Fixed rotation axis.\n+        det_rad : nonnegative `float`, optional\n+            Radius of the circular acquisition curve\n+        orig_to_det_init : `array-like`, shape ``(3,)``, optional\n+            Vector pointing towards the detector reference point in\n+            the initial position. The zero vector is only allowed if\n+            ``det_init_axes`` is explicitly given.\n+            By default, a `perpendicular_vector` to ``axis`` is used.\n+        det_init_axes : 2-tuple of `array-like` (shape ``(3,)``), optional\n+            Initial axes defining the detector orientation.\n+            By default, the normalized cross product of ``axis`` and\n+            ``det_init_pos`` is used as first axis and ``axis`` as second.\n+        \"\"\"\n+        # Use det_init_pos to initialize the detector position, then rescale\n+        orig_to_det_init = kwargs.pop('orig_to_det_init', None)\n+        if orig_to_det_init is not None:\n+            kwargs['det_init_pos'] = orig_to_det_init\n+        super().__init__(apart, dpart, axis, **kwargs)\n+        self._det_radius = float(det_rad)\n+        if self.det_radius < 0:\n+            raise ValueError('expected a nonnegative radius, got {}.'\n+                             ''.format(det_rad))\n+\n+        # Make sure that the initial position lies on the specified circle\n+        init_pos_norm = np.linalg.norm(self._det_init_pos)\n+        if init_pos_norm > 1e-10:\n+            self._det_init_pos *= self.det_radius / init_pos_norm","path":"odl/tomo/geometry/spect.py","position":74,"original_position":74,"commit_id":"bbc118eb75b191ab79107735c5857d9731e41bfe","original_commit_id":"bbc118eb75b191ab79107735c5857d9731e41bfe","user":{"login":"kohr-h","id":5030250,"avatar_url":"https://avatars.githubusercontent.com/u/5030250?v=3","gravatar_id":"","url":"https://api.github.com/users/kohr-h","html_url":"https://github.com/kohr-h","followers_url":"https://api.github.com/users/kohr-h/followers","following_url":"https://api.github.com/users/kohr-h/following{/other_user}","gists_url":"https://api.github.com/users/kohr-h/gists{/gist_id}","starred_url":"https://api.github.com/users/kohr-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohr-h/subscriptions","organizations_url":"https://api.github.com/users/kohr-h/orgs","repos_url":"https://api.github.com/users/kohr-h/repos","events_url":"https://api.github.com/users/kohr-h/events{/privacy}","received_events_url":"https://api.github.com/users/kohr-h/received_events","type":"User","site_admin":false},"body":"> Second thought, we are chaging the meaning of this guy here. In the parent class, this is a vector to the detector reference point. Here you change it to mean a unit vector towards the detector reference point.\r\n\r\nNo, the meaning is the same. It is only ensured that radius and `orig_to_det_init` give consistent information. Probably the doc should say so, but the vector is interpreted (and rescaled) as a unit vector, multiplied by the radius, so the initial position is correct.\r\n\r\n\r\n\r\n> The proper way to do this would be to let det_init_pos keep its meaning, but perhaps scale this one by det_rad so you get the correct length. This could be done prior to calling super()\r\n\r\nIn view of the confusion, I think it would be cleaner to do the rescaling first and feed that into the parent class in `super`.","created_at":"2016-05-09T09:52:40Z","updated_at":"2016-05-09T09:52:40Z","html_url":"https://github.com/odlgroup/odl/pull/304#discussion_r62474410","pull_request_url":"https://api.github.com/repos/odlgroup/odl/pulls/304","_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments/62474410"},"html":{"href":"https://github.com/odlgroup/odl/pull/304#discussion_r62474410"},"pull_request":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/304"}}},"pull_request":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/304","id":62363743,"html_url":"https://github.com/odlgroup/odl/pull/304","diff_url":"https://github.com/odlgroup/odl/pull/304.diff","patch_url":"https://github.com/odlgroup/odl/pull/304.patch","issue_url":"https://api.github.com/repos/odlgroup/odl/issues/304","number":304,"state":"open","locked":false,"title":"Issue 303  spect geometry","user":{"login":"niinimaki","id":15814505,"avatar_url":"https://avatars.githubusercontent.com/u/15814505?v=3","gravatar_id":"","url":"https://api.github.com/users/niinimaki","html_url":"https://github.com/niinimaki","followers_url":"https://api.github.com/users/niinimaki/followers","following_url":"https://api.github.com/users/niinimaki/following{/other_user}","gists_url":"https://api.github.com/users/niinimaki/gists{/gist_id}","starred_url":"https://api.github.com/users/niinimaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niinimaki/subscriptions","organizations_url":"https://api.github.com/users/niinimaki/orgs","repos_url":"https://api.github.com/users/niinimaki/repos","events_url":"https://api.github.com/users/niinimaki/events{/privacy}","received_events_url":"https://api.github.com/users/niinimaki/received_events","type":"User","site_admin":false},"body":"Added a class for SPECT parallel hole geometry and tests for it.","created_at":"2016-03-10T09:52:00Z","updated_at":"2016-05-09T09:52:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db63cdbe280ea8ac08f7fc2d4aca7a7b4fc34bdb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/odlgroup/odl/pulls/304/commits","review_comments_url":"https://api.github.com/repos/odlgroup/odl/pulls/304/comments","review_comment_url":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odlgroup/odl/issues/304/comments","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/bbc118eb75b191ab79107735c5857d9731e41bfe","head":{"label":"odlgroup:issue-303__spect_geometry","ref":"issue-303__spect_geometry","sha":"bbc118eb75b191ab79107735c5857d9731e41bfe","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","deployments_url":"https://api.github.com/repos/odlgroup/odl/deployments","created_at":"2015-11-05T07:57:55Z","updated_at":"2016-02-03T10:05:06Z","pushed_at":"2016-05-09T09:18:07Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":null,"size":17461,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":103,"forks":3,"open_issues":103,"watchers":3,"default_branch":"master"}},"base":{"label":"odlgroup:master","ref":"master","sha":"4c45462f6e96354d0c52a9a09b457c8d95bd319f","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","deployments_url":"https://api.github.com/repos/odlgroup/odl/deployments","created_at":"2015-11-05T07:57:55Z","updated_at":"2016-02-03T10:05:06Z","pushed_at":"2016-05-09T09:18:07Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":null,"size":17461,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":103,"forks":3,"open_issues":103,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/304"},"html":{"href":"https://github.com/odlgroup/odl/pull/304"},"issue":{"href":"https://api.github.com/repos/odlgroup/odl/issues/304"},"comments":{"href":"https://api.github.com/repos/odlgroup/odl/issues/304/comments"},"review_comments":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/304/comments"},"review_comment":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/304/commits"},"statuses":{"href":"https://api.github.com/repos/odlgroup/odl/statuses/bbc118eb75b191ab79107735c5857d9731e41bfe"}}}}