{"action":"created","comment":{"url":"https://api.github.com/repos/cmweiss/geomag/pulls/comments/82502960","pull_request_review_id":3408844,"id":82502960,"diff_hunk":"@@ -0,0 +1,109 @@\n+from __future__ import division\n+\n+import math\n+\n+\n+def normalise_plus_minus_range(value, norm_range):\n+    '''Normalise a value to within a positive and negative range\n+\n+    **Parameters**\n+\n+        value\n+           input value to be limited\n+        norm_range : {'lat','lon',*number*}\n+           A number will limit the range between +/- that value. 'lat'\n+           and 'lon' will limit within +/-90 and 180 respectively.\n+\n+    '''\n+    norm_range_dict = {'lat': 90, 'lon': 180}\n+    try:\n+        valid_range = norm_range_dict[norm_range]\n+        value = value % ([-1, 1][value > 0] * valid_range * 2)\n+    except KeyError:\n+        valid_range = norm_range\n+    if abs(value) > valid_range:\n+        return value % ([1, -1][value > 0] * valid_range)\n+    else:\n+        return value\n+\n+\n+class LatLon(object):\n+    '''Impliments a latitude Longditude class with conversion to spherical co-ords\n+    '''\n+\n+    def __init__(self, latitude, longditude, unit='degrees'):\n+        '''\n+        Performs conversion and stored both degrees and radians.\n+        The range is limited to within +-90 and +-180 degrees\n+        '''\n+\n+        if unit == 'degrees':\n+            _latitude_deg = normalise_plus_minus_range(latitude, 'lat')\n+            _longditude_deg = normalise_plus_minus_range(longditude, 'lon')\n+            _latitude_rad = math.radians(_latitude_deg)\n+            _longditude_rad = math.radians(_longditude_deg)\n+        elif unit == 'radians':\n+            _latitude_deg = normalise_plus_minus_range(\n+                math.degrees(latitude), 'lat')\n+            _longditude_deg = normalise_plus_minus_range(\n+                math.degrees(longditude), 'lon')\n+            _latitude_rad = math.radians(_latitude_deg)\n+            _longditude_rad = math.radians(_longditude_deg)\n+        else:\n+            raise Exception\n+        self._lat = _latitude_deg\n+        self._lon = _longditude_deg\n+        self._lat_rad = _latitude_rad\n+        self._lon_rad = _longditude_rad\n+\n+        self._default_unit = unit\n+\n+    @property\n+    def lat(self):\n+        'Return Latitude'\n+        return self._lat\n+\n+    @property\n+    def lon(self):\n+        'Return Longditude'\n+        return self._lon\n+\n+    @property\n+    def lon_rad(self):\n+        'Return Longditude'\n+        return self._lon_rad\n+\n+    @property\n+    def lat_rad(self):\n+        'Return Longditude'\n+        return self._lat_rad\n+\n+    def __call__(self):\n+        return self._lat_lon()\n+\n+    def __str__(self):\n+        return \"({} N,{} W)\".format(*self._lat_lon())\n+\n+    def _lat_lon(self):\n+        return(self.lat, self.lon)","path":"geomag/latlon.py","position":null,"original_position":88,"commit_id":"3519d066ee91ef6e9c862ca6938e2bff5e588fd3","original_commit_id":"65e918ff215b2d8c2486f8f477e069e2833d7eb5","user":{"login":"todd-dembrey","id":6338661,"avatar_url":"https://avatars.githubusercontent.com/u/6338661?v=3","gravatar_id":"","url":"https://api.github.com/users/todd-dembrey","html_url":"https://github.com/todd-dembrey","followers_url":"https://api.github.com/users/todd-dembrey/followers","following_url":"https://api.github.com/users/todd-dembrey/following{/other_user}","gists_url":"https://api.github.com/users/todd-dembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/todd-dembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/todd-dembrey/subscriptions","organizations_url":"https://api.github.com/users/todd-dembrey/orgs","repos_url":"https://api.github.com/users/todd-dembrey/repos","events_url":"https://api.github.com/users/todd-dembrey/events{/privacy}","received_events_url":"https://api.github.com/users/todd-dembrey/received_events","type":"User","site_admin":false},"body":"8c22f3","created_at":"2016-10-08T14:02:30Z","updated_at":"2016-10-08T14:02:30Z","html_url":"https://github.com/cmweiss/geomag/pull/3#discussion_r82502960","pull_request_url":"https://api.github.com/repos/cmweiss/geomag/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/comments/82502960"},"html":{"href":"https://github.com/cmweiss/geomag/pull/3#discussion_r82502960"},"pull_request":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/cmweiss/geomag/pulls/3","id":49075088,"html_url":"https://github.com/cmweiss/geomag/pull/3","diff_url":"https://github.com/cmweiss/geomag/pull/3.diff","patch_url":"https://github.com/cmweiss/geomag/pull/3.patch","issue_url":"https://api.github.com/repos/cmweiss/geomag/issues/3","number":3,"state":"open","locked":false,"title":"Reworked Geomag","user":{"login":"todd-dembrey","id":6338661,"avatar_url":"https://avatars.githubusercontent.com/u/6338661?v=3","gravatar_id":"","url":"https://api.github.com/users/todd-dembrey","html_url":"https://github.com/todd-dembrey","followers_url":"https://api.github.com/users/todd-dembrey/followers","following_url":"https://api.github.com/users/todd-dembrey/following{/other_user}","gists_url":"https://api.github.com/users/todd-dembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/todd-dembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/todd-dembrey/subscriptions","organizations_url":"https://api.github.com/users/todd-dembrey/orgs","repos_url":"https://api.github.com/users/todd-dembrey/repos","events_url":"https://api.github.com/users/todd-dembrey/events{/privacy}","received_events_url":"https://api.github.com/users/todd-dembrey/received_events","type":"User","site_admin":false},"body":"Major rework, changes include:\r\n* rewrite of method\r\n* change of names to better reflect process\r\n* creation of documentation\r\n* additional testing\r\n* example\r\n\r\nWorks with both 2/3 python and backwards compatible.\r\n\r\nHappy to discuss further changes if required?\r\n\r\n","created_at":"2015-10-28T22:18:40Z","updated_at":"2016-10-08T14:02:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f05a54dae0b30452f94c2c778969033d415b144e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cmweiss/geomag/pulls/3/commits","review_comments_url":"https://api.github.com/repos/cmweiss/geomag/pulls/3/comments","review_comment_url":"https://api.github.com/repos/cmweiss/geomag/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cmweiss/geomag/issues/3/comments","statuses_url":"https://api.github.com/repos/cmweiss/geomag/statuses/3519d066ee91ef6e9c862ca6938e2bff5e588fd3","head":{"label":"todd-dembrey:master","ref":"master","sha":"3519d066ee91ef6e9c862ca6938e2bff5e588fd3","user":{"login":"todd-dembrey","id":6338661,"avatar_url":"https://avatars.githubusercontent.com/u/6338661?v=3","gravatar_id":"","url":"https://api.github.com/users/todd-dembrey","html_url":"https://github.com/todd-dembrey","followers_url":"https://api.github.com/users/todd-dembrey/followers","following_url":"https://api.github.com/users/todd-dembrey/following{/other_user}","gists_url":"https://api.github.com/users/todd-dembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/todd-dembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/todd-dembrey/subscriptions","organizations_url":"https://api.github.com/users/todd-dembrey/orgs","repos_url":"https://api.github.com/users/todd-dembrey/repos","events_url":"https://api.github.com/users/todd-dembrey/events{/privacy}","received_events_url":"https://api.github.com/users/todd-dembrey/received_events","type":"User","site_admin":false},"repo":{"id":43212017,"name":"geomag","full_name":"todd-dembrey/geomag","owner":{"login":"todd-dembrey","id":6338661,"avatar_url":"https://avatars.githubusercontent.com/u/6338661?v=3","gravatar_id":"","url":"https://api.github.com/users/todd-dembrey","html_url":"https://github.com/todd-dembrey","followers_url":"https://api.github.com/users/todd-dembrey/followers","following_url":"https://api.github.com/users/todd-dembrey/following{/other_user}","gists_url":"https://api.github.com/users/todd-dembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/todd-dembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/todd-dembrey/subscriptions","organizations_url":"https://api.github.com/users/todd-dembrey/orgs","repos_url":"https://api.github.com/users/todd-dembrey/repos","events_url":"https://api.github.com/users/todd-dembrey/events{/privacy}","received_events_url":"https://api.github.com/users/todd-dembrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/todd-dembrey/geomag","description":"Automatically exported from code.google.com/p/geomag","fork":true,"url":"https://api.github.com/repos/todd-dembrey/geomag","forks_url":"https://api.github.com/repos/todd-dembrey/geomag/forks","keys_url":"https://api.github.com/repos/todd-dembrey/geomag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/todd-dembrey/geomag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/todd-dembrey/geomag/teams","hooks_url":"https://api.github.com/repos/todd-dembrey/geomag/hooks","issue_events_url":"https://api.github.com/repos/todd-dembrey/geomag/issues/events{/number}","events_url":"https://api.github.com/repos/todd-dembrey/geomag/events","assignees_url":"https://api.github.com/repos/todd-dembrey/geomag/assignees{/user}","branches_url":"https://api.github.com/repos/todd-dembrey/geomag/branches{/branch}","tags_url":"https://api.github.com/repos/todd-dembrey/geomag/tags","blobs_url":"https://api.github.com/repos/todd-dembrey/geomag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/todd-dembrey/geomag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/todd-dembrey/geomag/git/refs{/sha}","trees_url":"https://api.github.com/repos/todd-dembrey/geomag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/todd-dembrey/geomag/statuses/{sha}","languages_url":"https://api.github.com/repos/todd-dembrey/geomag/languages","stargazers_url":"https://api.github.com/repos/todd-dembrey/geomag/stargazers","contributors_url":"https://api.github.com/repos/todd-dembrey/geomag/contributors","subscribers_url":"https://api.github.com/repos/todd-dembrey/geomag/subscribers","subscription_url":"https://api.github.com/repos/todd-dembrey/geomag/subscription","commits_url":"https://api.github.com/repos/todd-dembrey/geomag/commits{/sha}","git_commits_url":"https://api.github.com/repos/todd-dembrey/geomag/git/commits{/sha}","comments_url":"https://api.github.com/repos/todd-dembrey/geomag/comments{/number}","issue_comment_url":"https://api.github.com/repos/todd-dembrey/geomag/issues/comments{/number}","contents_url":"https://api.github.com/repos/todd-dembrey/geomag/contents/{+path}","compare_url":"https://api.github.com/repos/todd-dembrey/geomag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/todd-dembrey/geomag/merges","archive_url":"https://api.github.com/repos/todd-dembrey/geomag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/todd-dembrey/geomag/downloads","issues_url":"https://api.github.com/repos/todd-dembrey/geomag/issues{/number}","pulls_url":"https://api.github.com/repos/todd-dembrey/geomag/pulls{/number}","milestones_url":"https://api.github.com/repos/todd-dembrey/geomag/milestones{/number}","notifications_url":"https://api.github.com/repos/todd-dembrey/geomag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/todd-dembrey/geomag/labels{/name}","releases_url":"https://api.github.com/repos/todd-dembrey/geomag/releases{/id}","deployments_url":"https://api.github.com/repos/todd-dembrey/geomag/deployments","created_at":"2015-09-26T16:01:09Z","updated_at":"2016-01-29T17:01:26Z","pushed_at":"2016-10-08T14:01:07Z","git_url":"git://github.com/todd-dembrey/geomag.git","ssh_url":"git@github.com:todd-dembrey/geomag.git","clone_url":"https://github.com/todd-dembrey/geomag.git","svn_url":"https://github.com/todd-dembrey/geomag","homepage":null,"size":216,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"cmweiss:master","ref":"master","sha":"1d58f458c9374bca9393ac14470bc2f926755ff5","user":{"login":"cmweiss","id":827703,"avatar_url":"https://avatars.githubusercontent.com/u/827703?v=3","gravatar_id":"","url":"https://api.github.com/users/cmweiss","html_url":"https://github.com/cmweiss","followers_url":"https://api.github.com/users/cmweiss/followers","following_url":"https://api.github.com/users/cmweiss/following{/other_user}","gists_url":"https://api.github.com/users/cmweiss/gists{/gist_id}","starred_url":"https://api.github.com/users/cmweiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmweiss/subscriptions","organizations_url":"https://api.github.com/users/cmweiss/orgs","repos_url":"https://api.github.com/users/cmweiss/repos","events_url":"https://api.github.com/users/cmweiss/events{/privacy}","received_events_url":"https://api.github.com/users/cmweiss/received_events","type":"User","site_admin":false},"repo":{"id":32107396,"name":"geomag","full_name":"cmweiss/geomag","owner":{"login":"cmweiss","id":827703,"avatar_url":"https://avatars.githubusercontent.com/u/827703?v=3","gravatar_id":"","url":"https://api.github.com/users/cmweiss","html_url":"https://github.com/cmweiss","followers_url":"https://api.github.com/users/cmweiss/followers","following_url":"https://api.github.com/users/cmweiss/following{/other_user}","gists_url":"https://api.github.com/users/cmweiss/gists{/gist_id}","starred_url":"https://api.github.com/users/cmweiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmweiss/subscriptions","organizations_url":"https://api.github.com/users/cmweiss/orgs","repos_url":"https://api.github.com/users/cmweiss/repos","events_url":"https://api.github.com/users/cmweiss/events{/privacy}","received_events_url":"https://api.github.com/users/cmweiss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmweiss/geomag","description":"Automatically exported from code.google.com/p/geomag","fork":false,"url":"https://api.github.com/repos/cmweiss/geomag","forks_url":"https://api.github.com/repos/cmweiss/geomag/forks","keys_url":"https://api.github.com/repos/cmweiss/geomag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmweiss/geomag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmweiss/geomag/teams","hooks_url":"https://api.github.com/repos/cmweiss/geomag/hooks","issue_events_url":"https://api.github.com/repos/cmweiss/geomag/issues/events{/number}","events_url":"https://api.github.com/repos/cmweiss/geomag/events","assignees_url":"https://api.github.com/repos/cmweiss/geomag/assignees{/user}","branches_url":"https://api.github.com/repos/cmweiss/geomag/branches{/branch}","tags_url":"https://api.github.com/repos/cmweiss/geomag/tags","blobs_url":"https://api.github.com/repos/cmweiss/geomag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmweiss/geomag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmweiss/geomag/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmweiss/geomag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmweiss/geomag/statuses/{sha}","languages_url":"https://api.github.com/repos/cmweiss/geomag/languages","stargazers_url":"https://api.github.com/repos/cmweiss/geomag/stargazers","contributors_url":"https://api.github.com/repos/cmweiss/geomag/contributors","subscribers_url":"https://api.github.com/repos/cmweiss/geomag/subscribers","subscription_url":"https://api.github.com/repos/cmweiss/geomag/subscription","commits_url":"https://api.github.com/repos/cmweiss/geomag/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmweiss/geomag/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmweiss/geomag/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmweiss/geomag/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmweiss/geomag/contents/{+path}","compare_url":"https://api.github.com/repos/cmweiss/geomag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmweiss/geomag/merges","archive_url":"https://api.github.com/repos/cmweiss/geomag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmweiss/geomag/downloads","issues_url":"https://api.github.com/repos/cmweiss/geomag/issues{/number}","pulls_url":"https://api.github.com/repos/cmweiss/geomag/pulls{/number}","milestones_url":"https://api.github.com/repos/cmweiss/geomag/milestones{/number}","notifications_url":"https://api.github.com/repos/cmweiss/geomag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmweiss/geomag/labels{/name}","releases_url":"https://api.github.com/repos/cmweiss/geomag/releases{/id}","deployments_url":"https://api.github.com/repos/cmweiss/geomag/deployments","created_at":"2015-03-12T22:52:29Z","updated_at":"2016-08-20T16:50:54Z","pushed_at":"2016-10-08T14:01:07Z","git_url":"git://github.com/cmweiss/geomag.git","ssh_url":"git@github.com:cmweiss/geomag.git","clone_url":"https://github.com/cmweiss/geomag.git","svn_url":"https://github.com/cmweiss/geomag","homepage":null,"size":212,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/3"},"html":{"href":"https://github.com/cmweiss/geomag/pull/3"},"issue":{"href":"https://api.github.com/repos/cmweiss/geomag/issues/3"},"comments":{"href":"https://api.github.com/repos/cmweiss/geomag/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cmweiss/geomag/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/cmweiss/geomag/statuses/3519d066ee91ef6e9c862ca6938e2bff5e588fd3"}}}}
{"actor":{"display_login":"todd-dembrey"}}