{"action":"created","comment":{"url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/comments/24067792","id":24067792,"diff_hunk":"@@ -367,3 +367,50 @@ def test_nonconvex_polygon(self):\n             pyy = numpy.array([1.5, 2.0, 2.0])\n             dist = utils.point_to_polygon_distance(polygon, pxx, pyy)\n             numpy.testing.assert_almost_equal(dist, [0.5, 1, 2])\n+\n+\n+class PlaneFit(unittest.TestCase):\n+    \"\"\"\n+    In order to test the method we fit a plane to a cloud of points\n+    generated from a given plane equation.\n+\n+    ax + by + cz + d = 0\n+    \"\"\"\n+\n+    def setUp(self):\n+        # Set the seed of the random number generator\n+        numpy.random.seed(41)\n+        # Compute the x and y coordinates of the points which lay on the plane\n+        self.npts = 20\n+        self.points = numpy.zeros((self.npts, 3))\n+        self.points[:, 0] = (numpy.random.random(self.npts) - 0.5) * 10.\n+        self.points[:, 1] = (numpy.random.random(self.npts) - 0.5) * 10.\n+        # Plane equation coefficients\n+        self.c = numpy.random.random(4)\n+        # Normalise the plane equation coefficients to get the direction\n+        # cosines\n+        self.c[0:3] = self.c[0:3] / (sum(self.c[0:3]**2.))**0.5\n+        # Compute the TODO\n+        self.c[-1] = -abs(self.c[-1])\n+        # Compute the z coordinate of the points\n+        self.points[:, 2] = (-self.points[:, 0] * self.c[0] +\n+                             -self.points[:, 1] * self.c[1] +\n+                             -self.c[3]) / self.c[2]\n+\n+    def test_plane_fit01(self):\n+        \"\"\"\n+        Tests the parameters of the plane obtained through the regression.\n+        \"\"\"\n+        pnt, par = utils.plane_fit(self.points)\n+        self.assertTrue(numpy.all(numpy.abs(self.c[0:3] - par) < 1e-5))\n+        self.assertAlmostEqual(self.c[-1], -sum(par*pnt))\n+\n+    def test_plane_fit02(self):\n+        \"\"\"\n+        Tests the parameters of the plane obtained through the regression.\n+        In this second case we add noise to the z values\n+        \"\"\"\n+        self.points[:, 2] += numpy.random.random(self.npts) * 0.01\n+        pnt, par = utils.plane_fit(self.points)\n+        self.assertTrue(numpy.all(numpy.abs(self.c[0:3] - par) < 1e-1))","path":"openquake/hazardlib/tests/geo/utils_test.py","position":49,"original_position":49,"commit_id":"e1ef33c85e7afd3ee0a72875bf5a0c0099530f95","original_commit_id":"e1ef33c85e7afd3ee0a72875bf5a0c0099530f95","user":{"login":"micheles","id":2463856,"avatar_url":"https://avatars.githubusercontent.com/u/2463856?v=3","gravatar_id":"","url":"https://api.github.com/users/micheles","html_url":"https://github.com/micheles","followers_url":"https://api.github.com/users/micheles/followers","following_url":"https://api.github.com/users/micheles/following{/other_user}","gists_url":"https://api.github.com/users/micheles/gists{/gist_id}","starred_url":"https://api.github.com/users/micheles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheles/subscriptions","organizations_url":"https://api.github.com/users/micheles/orgs","repos_url":"https://api.github.com/users/micheles/repos","events_url":"https://api.github.com/users/micheles/events{/privacy}","received_events_url":"https://api.github.com/users/micheles/received_events","type":"User","site_admin":false},"body":"Same as before","created_at":"2015-02-04T08:01:21Z","updated_at":"2015-02-04T08:01:21Z","html_url":"https://github.com/gem/oq-hazardlib/pull/283#discussion_r24067792","pull_request_url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283","_links":{"self":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/comments/24067792"},"html":{"href":"https://github.com/gem/oq-hazardlib/pull/283#discussion_r24067792"},"pull_request":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283"}}},"pull_request":{"url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283","id":28596617,"html_url":"https://github.com/gem/oq-hazardlib/pull/283","diff_url":"https://github.com/gem/oq-hazardlib/pull/283.diff","patch_url":"https://github.com/gem/oq-hazardlib/pull/283.patch","issue_url":"https://api.github.com/repos/gem/oq-hazardlib/issues/283","number":283,"state":"open","locked":false,"title":"Gridsource","user":{"login":"mmpagani","id":318811,"avatar_url":"https://avatars.githubusercontent.com/u/318811?v=3","gravatar_id":"","url":"https://api.github.com/users/mmpagani","html_url":"https://github.com/mmpagani","followers_url":"https://api.github.com/users/mmpagani/followers","following_url":"https://api.github.com/users/mmpagani/following{/other_user}","gists_url":"https://api.github.com/users/mmpagani/gists{/gist_id}","starred_url":"https://api.github.com/users/mmpagani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmpagani/subscriptions","organizations_url":"https://api.github.com/users/mmpagani/orgs","repos_url":"https://api.github.com/users/mmpagani/repos","events_url":"https://api.github.com/users/mmpagani/events{/privacy}","received_events_url":"https://api.github.com/users/mmpagani/received_events","type":"User","site_admin":false},"body":"This PR adds a new surface typology called gridded surface. This is needed for the implementation of the 2012 model for Japan developed by NIED. The PR also includes a utility function to fit a plane given a cloud of points. This function will be used by future improvements of this surface typology. Tests are green https://ci.openquake.org/job/zdevel_oq-hazardlib/195/\r\n\r\n","created_at":"2015-02-03T22:43:45Z","updated_at":"2015-02-04T08:01:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d7a5808a4677e49bfab51af0697a9fa8327eaf2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283/commits","review_comments_url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283/comments","review_comment_url":"https://api.github.com/repos/gem/oq-hazardlib/pulls/comments/{number}","comments_url":"https://api.github.com/repos/gem/oq-hazardlib/issues/283/comments","statuses_url":"https://api.github.com/repos/gem/oq-hazardlib/statuses/e1ef33c85e7afd3ee0a72875bf5a0c0099530f95","head":{"label":"mmpagani:gridsource","ref":"gridsource","sha":"e1ef33c85e7afd3ee0a72875bf5a0c0099530f95","user":{"login":"mmpagani","id":318811,"avatar_url":"https://avatars.githubusercontent.com/u/318811?v=3","gravatar_id":"","url":"https://api.github.com/users/mmpagani","html_url":"https://github.com/mmpagani","followers_url":"https://api.github.com/users/mmpagani/followers","following_url":"https://api.github.com/users/mmpagani/following{/other_user}","gists_url":"https://api.github.com/users/mmpagani/gists{/gist_id}","starred_url":"https://api.github.com/users/mmpagani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmpagani/subscriptions","organizations_url":"https://api.github.com/users/mmpagani/orgs","repos_url":"https://api.github.com/users/mmpagani/repos","events_url":"https://api.github.com/users/mmpagani/events{/privacy}","received_events_url":"https://api.github.com/users/mmpagani/received_events","type":"User","site_admin":false},"repo":{"id":17060414,"name":"oq-hazardlib","full_name":"mmpagani/oq-hazardlib","owner":{"login":"mmpagani","id":318811,"avatar_url":"https://avatars.githubusercontent.com/u/318811?v=3","gravatar_id":"","url":"https://api.github.com/users/mmpagani","html_url":"https://github.com/mmpagani","followers_url":"https://api.github.com/users/mmpagani/followers","following_url":"https://api.github.com/users/mmpagani/following{/other_user}","gists_url":"https://api.github.com/users/mmpagani/gists{/gist_id}","starred_url":"https://api.github.com/users/mmpagani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmpagani/subscriptions","organizations_url":"https://api.github.com/users/mmpagani/orgs","repos_url":"https://api.github.com/users/mmpagani/repos","events_url":"https://api.github.com/users/mmpagani/events{/privacy}","received_events_url":"https://api.github.com/users/mmpagani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mmpagani/oq-hazardlib","description":"","fork":true,"url":"https://api.github.com/repos/mmpagani/oq-hazardlib","forks_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/forks","keys_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/teams","hooks_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/hooks","issue_events_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/issues/events{/number}","events_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/events","assignees_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/assignees{/user}","branches_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/branches{/branch}","tags_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/tags","blobs_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/statuses/{sha}","languages_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/languages","stargazers_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/stargazers","contributors_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/contributors","subscribers_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/subscribers","subscription_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/subscription","commits_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/issues/comments/{number}","contents_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/contents/{+path}","compare_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/merges","archive_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/downloads","issues_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/issues{/number}","pulls_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/pulls{/number}","milestones_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/milestones{/number}","notifications_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/labels{/name}","releases_url":"https://api.github.com/repos/mmpagani/oq-hazardlib/releases{/id}","created_at":"2014-02-21T15:28:35Z","updated_at":"2014-08-26T04:56:23Z","pushed_at":"2015-02-03T22:01:55Z","git_url":"git://github.com/mmpagani/oq-hazardlib.git","ssh_url":"git@github.com:mmpagani/oq-hazardlib.git","clone_url":"https://github.com/mmpagani/oq-hazardlib.git","svn_url":"https://github.com/mmpagani/oq-hazardlib","homepage":"","size":33703,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gem:master","ref":"master","sha":"6cd62553065b5eeb2638dda27a7c8a4f20585247","user":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"repo":{"id":2986762,"name":"oq-hazardlib","full_name":"gem/oq-hazardlib","owner":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gem/oq-hazardlib","description":"Openquake Hazard Library","fork":false,"url":"https://api.github.com/repos/gem/oq-hazardlib","forks_url":"https://api.github.com/repos/gem/oq-hazardlib/forks","keys_url":"https://api.github.com/repos/gem/oq-hazardlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gem/oq-hazardlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gem/oq-hazardlib/teams","hooks_url":"https://api.github.com/repos/gem/oq-hazardlib/hooks","issue_events_url":"https://api.github.com/repos/gem/oq-hazardlib/issues/events{/number}","events_url":"https://api.github.com/repos/gem/oq-hazardlib/events","assignees_url":"https://api.github.com/repos/gem/oq-hazardlib/assignees{/user}","branches_url":"https://api.github.com/repos/gem/oq-hazardlib/branches{/branch}","tags_url":"https://api.github.com/repos/gem/oq-hazardlib/tags","blobs_url":"https://api.github.com/repos/gem/oq-hazardlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gem/oq-hazardlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gem/oq-hazardlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/gem/oq-hazardlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gem/oq-hazardlib/statuses/{sha}","languages_url":"https://api.github.com/repos/gem/oq-hazardlib/languages","stargazers_url":"https://api.github.com/repos/gem/oq-hazardlib/stargazers","contributors_url":"https://api.github.com/repos/gem/oq-hazardlib/contributors","subscribers_url":"https://api.github.com/repos/gem/oq-hazardlib/subscribers","subscription_url":"https://api.github.com/repos/gem/oq-hazardlib/subscription","commits_url":"https://api.github.com/repos/gem/oq-hazardlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/gem/oq-hazardlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/gem/oq-hazardlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/gem/oq-hazardlib/issues/comments/{number}","contents_url":"https://api.github.com/repos/gem/oq-hazardlib/contents/{+path}","compare_url":"https://api.github.com/repos/gem/oq-hazardlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gem/oq-hazardlib/merges","archive_url":"https://api.github.com/repos/gem/oq-hazardlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gem/oq-hazardlib/downloads","issues_url":"https://api.github.com/repos/gem/oq-hazardlib/issues{/number}","pulls_url":"https://api.github.com/repos/gem/oq-hazardlib/pulls{/number}","milestones_url":"https://api.github.com/repos/gem/oq-hazardlib/milestones{/number}","notifications_url":"https://api.github.com/repos/gem/oq-hazardlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gem/oq-hazardlib/labels{/name}","releases_url":"https://api.github.com/repos/gem/oq-hazardlib/releases{/id}","created_at":"2011-12-15T10:14:46Z","updated_at":"2015-02-02T12:54:06Z","pushed_at":"2015-02-02T14:05:28Z","git_url":"git://github.com/gem/oq-hazardlib.git","ssh_url":"git@github.com:gem/oq-hazardlib.git","clone_url":"https://github.com/gem/oq-hazardlib.git","svn_url":"https://github.com/gem/oq-hazardlib","homepage":"http://www.globalquakemodel.org/openquake/","size":43706,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":3,"forks":32,"open_issues":3,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283"},"html":{"href":"https://github.com/gem/oq-hazardlib/pull/283"},"issue":{"href":"https://api.github.com/repos/gem/oq-hazardlib/issues/283"},"comments":{"href":"https://api.github.com/repos/gem/oq-hazardlib/issues/283/comments"},"review_comments":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283/comments"},"review_comment":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/gem/oq-hazardlib/pulls/283/commits"},"statuses":{"href":"https://api.github.com/repos/gem/oq-hazardlib/statuses/e1ef33c85e7afd3ee0a72875bf5a0c0099530f95"}}}}