{"action":"created","comment":{"url":"https://api.github.com/repos/fatiando/verde/pulls/comments/257832253","pull_request_review_id":204958115,"id":257832253,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1NzgzMjI1Mw==","diff_hunk":"@@ -281,3 +282,64 @@ def grid_to_table(grid):\n     coord_dict.update(var_dict)\n     data = pd.DataFrame(coord_dict)\n     return data\n+\n+\n+def load_surfer(fname, dtype='float64'):\n+    \"\"\"\n+    Read data from a Surfer ASCII grid file.\n+\n+    Surfer is a contouring, griding and surface mapping software\n+    from GoldenSoftware. The names and logos for Surfer and Golden\n+    Software are registered trademarks of Golden Software, Inc.\n+\n+    http://www.goldensoftware.com/products/surfer\n+\n+    This feature was ported from Fatiando, but instead of\n+    output being a dictionary, in verde the output is a `xarray.DataArray`\n+    that contains the easting and northing coordinates, and data values.\n+\n+    Parameters:\n+\n+    * fname : str\n+        Name of the Surfer grid file\n+    * dtype : numpy dtype object or string\n+        The type of variable used for the data. Default is numpy.float64. Use\n+        numpy.float32 if the data are large and precision is not an issue.\n+\n+    Returns:\n+\n+    * data : :class: `xarray.DataArray`\n+        A 2D grid with the data variables.\n+    \"\"\"\n+    # Surfer ASCII grid structure\n+    # DSAA            Surfer ASCII GRD ID\n+    # nCols nRows     number of columns and rows\n+    # xMin xMax       X min max\n+    # yMin yMax       Y min max\n+    # zMin zMax       Z min max\n+    # z11 z21 z31 ... List of Z values\n+    with open(fname) as input_file:\n+        # DSAA is a Surfer ASCII GRD ID (discard it for now)\n+        input_file.readline()\n+        # Read the number of columns (ny) and rows (nx)\n+        ydims, xdims = [int(s) for s in input_file.readline().split()]\n+        # Our x points North, so the first thing we read is y, not x.\n+        ymin, ymax = [float(s) for s in input_file.readline().split()]\n+        xmin, xmax = [float(s) for s in input_file.readline().split()]\n+        dmin, dmax = [float(s) for s in input_file.readline().split()]\n+        field = np.fromiter((float(s)\n+                             for line in input_file\n+                             for s in line.split()),\n+                            dtype=dtype)\n+        nans = field >= 1.70141e+38\n+        if np.any(nans):\n+            field = np.ma.masked_where(nans, field)\n+        err_msg = \"{} of data ({}) doesn't match one from file ({}).\"\n+        assert np.allclose(dmin, field.min()), err_msg.format('Min', dmin,\n+                                                              field.min())\n+        assert np.allclose(dmax, field.max()), err_msg.format('Max', dmax,\n+                                                              field.max())","path":"verde/utils.py","position":68,"original_position":68,"commit_id":"ef12dfe7463bba050486af187737f56a447f162b","original_commit_id":"ef12dfe7463bba050486af187737f56a447f162b","user":{"login":"leouieda","id":290082,"node_id":"MDQ6VXNlcjI5MDA4Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/290082?v=4","gravatar_id":"","url":"https://api.github.com/users/leouieda","html_url":"https://github.com/leouieda","followers_url":"https://api.github.com/users/leouieda/followers","following_url":"https://api.github.com/users/leouieda/following{/other_user}","gists_url":"https://api.github.com/users/leouieda/gists{/gist_id}","starred_url":"https://api.github.com/users/leouieda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leouieda/subscriptions","organizations_url":"https://api.github.com/users/leouieda/orgs","repos_url":"https://api.github.com/users/leouieda/repos","events_url":"https://api.github.com/users/leouieda/events{/privacy}","received_events_url":"https://api.github.com/users/leouieda/received_events","type":"User","site_admin":false},"body":"Would you mind converting the `assert` statements to `if ...: raise IOError(...)` blocks instead? ","created_at":"2019-02-18T21:35:33Z","updated_at":"2019-02-18T21:53:40Z","html_url":"https://github.com/fatiando/verde/pull/169#discussion_r257832253","pull_request_url":"https://api.github.com/repos/fatiando/verde/pulls/169","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/fatiando/verde/pulls/comments/257832253"},"html":{"href":"https://github.com/fatiando/verde/pull/169#discussion_r257832253"},"pull_request":{"href":"https://api.github.com/repos/fatiando/verde/pulls/169"}}},"pull_request":{"url":"https://api.github.com/repos/fatiando/verde/pulls/169","id":253154681,"node_id":"MDExOlB1bGxSZXF1ZXN0MjUzMTU0Njgx","html_url":"https://github.com/fatiando/verde/pull/169","diff_url":"https://github.com/fatiando/verde/pull/169.diff","patch_url":"https://github.com/fatiando/verde/pull/169.patch","issue_url":"https://api.github.com/repos/fatiando/verde/issues/169","number":169,"state":"open","locked":false,"title":"Surfer reader feature","user":{"login":"jessepisel","id":12752033,"node_id":"MDQ6VXNlcjEyNzUyMDMz","avatar_url":"https://avatars3.githubusercontent.com/u/12752033?v=4","gravatar_id":"","url":"https://api.github.com/users/jessepisel","html_url":"https://github.com/jessepisel","followers_url":"https://api.github.com/users/jessepisel/followers","following_url":"https://api.github.com/users/jessepisel/following{/other_user}","gists_url":"https://api.github.com/users/jessepisel/gists{/gist_id}","starred_url":"https://api.github.com/users/jessepisel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessepisel/subscriptions","organizations_url":"https://api.github.com/users/jessepisel/orgs","repos_url":"https://api.github.com/users/jessepisel/repos","events_url":"https://api.github.com/users/jessepisel/events{/privacy}","received_events_url":"https://api.github.com/users/jessepisel/received_events","type":"User","site_admin":false},"body":"ported the surfer reader from fatiando and changed the output to a xarray Data Array. Ran tests and formatted locally. \r\n\r\nI ported the surfer reader feature from fatiando and changed the output from a dict to an xarray data array. Will you look through it to make sure it's what you had in mind for this feature. Do you want me to add examples to the docstring as well? Right now it just has the docstring from fatiando modified as appropriate.\r\n\r\nFixes #38\r\n\r\n**Reminders**\r\n\r\n- [x] Run `make format` and `make check` to make sure the code follows the style guide.\r\n- [x] Add tests for new features or tests that would have caught the bug that you're fixing.\r\n- [x] Add new public functions/methods/classes to `doc/api/index.rst` and `verde/__init__.py`.\r\n- [x] Write detailed docstrings for all functions/classes/methods.\r\n- [ ] If adding new functionality, add an example to the docstring, gallery, and/or tutorials.\r\n","created_at":"2019-02-14T17:14:54Z","updated_at":"2019-02-18T21:53:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fatiando/verde/pulls/169/commits","review_comments_url":"https://api.github.com/repos/fatiando/verde/pulls/169/comments","review_comment_url":"https://api.github.com/repos/fatiando/verde/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fatiando/verde/issues/169/comments","statuses_url":"https://api.github.com/repos/fatiando/verde/statuses/ef12dfe7463bba050486af187737f56a447f162b","head":{"label":"jessepisel:surfer_reader_feature","ref":"surfer_reader_feature","sha":"ef12dfe7463bba050486af187737f56a447f162b","user":{"login":"jessepisel","id":12752033,"node_id":"MDQ6VXNlcjEyNzUyMDMz","avatar_url":"https://avatars3.githubusercontent.com/u/12752033?v=4","gravatar_id":"","url":"https://api.github.com/users/jessepisel","html_url":"https://github.com/jessepisel","followers_url":"https://api.github.com/users/jessepisel/followers","following_url":"https://api.github.com/users/jessepisel/following{/other_user}","gists_url":"https://api.github.com/users/jessepisel/gists{/gist_id}","starred_url":"https://api.github.com/users/jessepisel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessepisel/subscriptions","organizations_url":"https://api.github.com/users/jessepisel/orgs","repos_url":"https://api.github.com/users/jessepisel/repos","events_url":"https://api.github.com/users/jessepisel/events{/privacy}","received_events_url":"https://api.github.com/users/jessepisel/received_events","type":"User","site_admin":false},"repo":{"id":155474195,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU0NzQxOTU=","name":"verde","full_name":"jessepisel/verde","private":false,"owner":{"login":"jessepisel","id":12752033,"node_id":"MDQ6VXNlcjEyNzUyMDMz","avatar_url":"https://avatars3.githubusercontent.com/u/12752033?v=4","gravatar_id":"","url":"https://api.github.com/users/jessepisel","html_url":"https://github.com/jessepisel","followers_url":"https://api.github.com/users/jessepisel/followers","following_url":"https://api.github.com/users/jessepisel/following{/other_user}","gists_url":"https://api.github.com/users/jessepisel/gists{/gist_id}","starred_url":"https://api.github.com/users/jessepisel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessepisel/subscriptions","organizations_url":"https://api.github.com/users/jessepisel/orgs","repos_url":"https://api.github.com/users/jessepisel/repos","events_url":"https://api.github.com/users/jessepisel/events{/privacy}","received_events_url":"https://api.github.com/users/jessepisel/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jessepisel/verde","description":"Processing and gridding spatial data using Green's functions","fork":true,"url":"https://api.github.com/repos/jessepisel/verde","forks_url":"https://api.github.com/repos/jessepisel/verde/forks","keys_url":"https://api.github.com/repos/jessepisel/verde/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jessepisel/verde/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jessepisel/verde/teams","hooks_url":"https://api.github.com/repos/jessepisel/verde/hooks","issue_events_url":"https://api.github.com/repos/jessepisel/verde/issues/events{/number}","events_url":"https://api.github.com/repos/jessepisel/verde/events","assignees_url":"https://api.github.com/repos/jessepisel/verde/assignees{/user}","branches_url":"https://api.github.com/repos/jessepisel/verde/branches{/branch}","tags_url":"https://api.github.com/repos/jessepisel/verde/tags","blobs_url":"https://api.github.com/repos/jessepisel/verde/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jessepisel/verde/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jessepisel/verde/git/refs{/sha}","trees_url":"https://api.github.com/repos/jessepisel/verde/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jessepisel/verde/statuses/{sha}","languages_url":"https://api.github.com/repos/jessepisel/verde/languages","stargazers_url":"https://api.github.com/repos/jessepisel/verde/stargazers","contributors_url":"https://api.github.com/repos/jessepisel/verde/contributors","subscribers_url":"https://api.github.com/repos/jessepisel/verde/subscribers","subscription_url":"https://api.github.com/repos/jessepisel/verde/subscription","commits_url":"https://api.github.com/repos/jessepisel/verde/commits{/sha}","git_commits_url":"https://api.github.com/repos/jessepisel/verde/git/commits{/sha}","comments_url":"https://api.github.com/repos/jessepisel/verde/comments{/number}","issue_comment_url":"https://api.github.com/repos/jessepisel/verde/issues/comments{/number}","contents_url":"https://api.github.com/repos/jessepisel/verde/contents/{+path}","compare_url":"https://api.github.com/repos/jessepisel/verde/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jessepisel/verde/merges","archive_url":"https://api.github.com/repos/jessepisel/verde/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jessepisel/verde/downloads","issues_url":"https://api.github.com/repos/jessepisel/verde/issues{/number}","pulls_url":"https://api.github.com/repos/jessepisel/verde/pulls{/number}","milestones_url":"https://api.github.com/repos/jessepisel/verde/milestones{/number}","notifications_url":"https://api.github.com/repos/jessepisel/verde/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jessepisel/verde/labels{/name}","releases_url":"https://api.github.com/repos/jessepisel/verde/releases{/id}","deployments_url":"https://api.github.com/repos/jessepisel/verde/deployments","created_at":"2018-10-31T00:23:40Z","updated_at":"2018-10-31T00:23:42Z","pushed_at":"2019-02-14T17:09:16Z","git_url":"git://github.com/jessepisel/verde.git","ssh_url":"git@github.com:jessepisel/verde.git","clone_url":"https://github.com/jessepisel/verde.git","svn_url":"https://github.com/jessepisel/verde","homepage":"https://www.fatiando.org/verde","size":30935,"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":"fatiando:master","ref":"master","sha":"7f22989e664f470e9825a8d72cac6024bd776b09","user":{"login":"fatiando","id":8174113,"node_id":"MDEyOk9yZ2FuaXphdGlvbjgxNzQxMTM=","avatar_url":"https://avatars2.githubusercontent.com/u/8174113?v=4","gravatar_id":"","url":"https://api.github.com/users/fatiando","html_url":"https://github.com/fatiando","followers_url":"https://api.github.com/users/fatiando/followers","following_url":"https://api.github.com/users/fatiando/following{/other_user}","gists_url":"https://api.github.com/users/fatiando/gists{/gist_id}","starred_url":"https://api.github.com/users/fatiando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatiando/subscriptions","organizations_url":"https://api.github.com/users/fatiando/orgs","repos_url":"https://api.github.com/users/fatiando/repos","events_url":"https://api.github.com/users/fatiando/events{/privacy}","received_events_url":"https://api.github.com/users/fatiando/received_events","type":"Organization","site_admin":false},"repo":{"id":131073898,"node_id":"MDEwOlJlcG9zaXRvcnkxMzEwNzM4OTg=","name":"verde","full_name":"fatiando/verde","private":false,"owner":{"login":"fatiando","id":8174113,"node_id":"MDEyOk9yZ2FuaXphdGlvbjgxNzQxMTM=","avatar_url":"https://avatars2.githubusercontent.com/u/8174113?v=4","gravatar_id":"","url":"https://api.github.com/users/fatiando","html_url":"https://github.com/fatiando","followers_url":"https://api.github.com/users/fatiando/followers","following_url":"https://api.github.com/users/fatiando/following{/other_user}","gists_url":"https://api.github.com/users/fatiando/gists{/gist_id}","starred_url":"https://api.github.com/users/fatiando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatiando/subscriptions","organizations_url":"https://api.github.com/users/fatiando/orgs","repos_url":"https://api.github.com/users/fatiando/repos","events_url":"https://api.github.com/users/fatiando/events{/privacy}","received_events_url":"https://api.github.com/users/fatiando/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/fatiando/verde","description":"Processing and gridding spatial data using Green's functions","fork":false,"url":"https://api.github.com/repos/fatiando/verde","forks_url":"https://api.github.com/repos/fatiando/verde/forks","keys_url":"https://api.github.com/repos/fatiando/verde/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fatiando/verde/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fatiando/verde/teams","hooks_url":"https://api.github.com/repos/fatiando/verde/hooks","issue_events_url":"https://api.github.com/repos/fatiando/verde/issues/events{/number}","events_url":"https://api.github.com/repos/fatiando/verde/events","assignees_url":"https://api.github.com/repos/fatiando/verde/assignees{/user}","branches_url":"https://api.github.com/repos/fatiando/verde/branches{/branch}","tags_url":"https://api.github.com/repos/fatiando/verde/tags","blobs_url":"https://api.github.com/repos/fatiando/verde/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fatiando/verde/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fatiando/verde/git/refs{/sha}","trees_url":"https://api.github.com/repos/fatiando/verde/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fatiando/verde/statuses/{sha}","languages_url":"https://api.github.com/repos/fatiando/verde/languages","stargazers_url":"https://api.github.com/repos/fatiando/verde/stargazers","contributors_url":"https://api.github.com/repos/fatiando/verde/contributors","subscribers_url":"https://api.github.com/repos/fatiando/verde/subscribers","subscription_url":"https://api.github.com/repos/fatiando/verde/subscription","commits_url":"https://api.github.com/repos/fatiando/verde/commits{/sha}","git_commits_url":"https://api.github.com/repos/fatiando/verde/git/commits{/sha}","comments_url":"https://api.github.com/repos/fatiando/verde/comments{/number}","issue_comment_url":"https://api.github.com/repos/fatiando/verde/issues/comments{/number}","contents_url":"https://api.github.com/repos/fatiando/verde/contents/{+path}","compare_url":"https://api.github.com/repos/fatiando/verde/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fatiando/verde/merges","archive_url":"https://api.github.com/repos/fatiando/verde/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fatiando/verde/downloads","issues_url":"https://api.github.com/repos/fatiando/verde/issues{/number}","pulls_url":"https://api.github.com/repos/fatiando/verde/pulls{/number}","milestones_url":"https://api.github.com/repos/fatiando/verde/milestones{/number}","notifications_url":"https://api.github.com/repos/fatiando/verde/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fatiando/verde/labels{/name}","releases_url":"https://api.github.com/repos/fatiando/verde/releases{/id}","deployments_url":"https://api.github.com/repos/fatiando/verde/deployments","created_at":"2018-04-25T23:21:08Z","updated_at":"2019-01-30T00:54:22Z","pushed_at":"2019-02-14T17:14:55Z","git_url":"git://github.com/fatiando/verde.git","ssh_url":"git@github.com:fatiando/verde.git","clone_url":"https://github.com/fatiando/verde.git","svn_url":"https://github.com/fatiando/verde","homepage":"https://www.fatiando.org/verde","size":38673,"stargazers_count":64,"watchers_count":64,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":16,"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":15,"open_issues":16,"watchers":64,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fatiando/verde/pulls/169"},"html":{"href":"https://github.com/fatiando/verde/pull/169"},"issue":{"href":"https://api.github.com/repos/fatiando/verde/issues/169"},"comments":{"href":"https://api.github.com/repos/fatiando/verde/issues/169/comments"},"review_comments":{"href":"https://api.github.com/repos/fatiando/verde/pulls/169/comments"},"review_comment":{"href":"https://api.github.com/repos/fatiando/verde/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fatiando/verde/pulls/169/commits"},"statuses":{"href":"https://api.github.com/repos/fatiando/verde/statuses/ef12dfe7463bba050486af187737f56a447f162b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"leouieda"}}