Skip to content

Reading/writing a matrix from/to a grid file (#3848) - #3856

Merged
seisman merged 2 commits into
6.1from
backport-3848-to-6.1
Aug 6, 2020
Merged

seisman merged 2 commits into
6.1from
backport-3848-to-6.1

Conversation

@seisman

@seisman seisman commented Aug 6, 2020

Copy link
Copy Markdown
Member

Backport #3848 to 6.1.

Fixes #

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

* Allow GMT_Read_Data to return a matrix from a grid file

Experimental.  INitially it just read an ascii table but it would be convenient to recognize file extensions *.grd and *.nc plus the remote grids @earth*.

* Complete plan for read/write matrix via grids

* Update testapi_grid2matrix.c

* Fix the chunk issue

* Create apimat2grd.ps

* Update some test codes to read OPINTS not SURFACE if ascii, and update PS

* Update api.rst
@seisman

seisman commented Aug 6, 2020

Copy link
Copy Markdown
Member Author

@PaulWessel There are two conflicts when picking PR #3848 into 6.1 branch. Please see how to resolve these two conflicts.

Comment thread src/gmt_api.c Outdated
Comment on lines +5036 to +5040
<<<<<<< HEAD
/* If neither TRB or TRP we call for a changed layout, which may or may not have been implemented */
GMT_Change_Layout (GMT->parent, GMT_IS_IMAGE, GMT->parent->GMT->current.gdal_read_in.O.mem_layout, 0, I, NULL, NULL);
=======
>>>>>>> 02af19c043... Reading/writing a matrix from/to a grid file (#3848)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflict 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like diff has a bug to me. This line involves a change to an image variable I, but we are doing grids in this function. This is completely crazy. It must have found some similar passage and placed it in the wrong spot. Those lines are found in the function gmtapi_expand_index_image, which is not involved in grid reading. So I guess delete?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, diff doesn't do a good job for big changes like this one.

Comment thread src/gmt_api.c Outdated
Comment on lines +5575 to +5583
<<<<<<< HEAD
if ((mode & GMT_CONTAINER_ONLY) && S_obj->region && S_obj->method == GMT_IS_FILE) {
GMT_Report (API, GMT_MSG_ERROR, "Cannot request a subset when just inquiring about the grid header\n");
return_null (API, GMT_SUBSET_NOT_ALLOWED);
=======
else {
GMT_Report (GMT->parent, GMT_MSG_ERROR, "Unrecognized source type %d in gmtapi_write_matrix\n", dest_type);
return (GMT_NOT_A_VALID_METHOD);
>>>>>>> 02af19c043... Reading/writing a matrix from/to a grid file (#3848)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflict 2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise craziness. That code under HEAD is found in gmtapi_import_grid, but we are in the matrix section! I know I moved large sections of code from around lines 3000 to below 5000 since the import and export matrix functions were calling import/export_grid functions that needed to be declared first. This must have really messed up diff.

@PaulWessel

Copy link
Copy Markdown
Contributor

How can I see this more in context? I need to look at more lines.

@seisman

seisman commented Aug 6, 2020

Copy link
Copy Markdown
Member Author

Just go to https://github.com/GenericMappingTools/gmt/pull/3856/files, and click "Load diff". There are a lot of changes in gmt_api.c. You can just search for <<<<<<< in your web browser.

@PaulWessel

Copy link
Copy Markdown
Contributor

So I can edit but I am now very distrustful of the diff...

@seisman

seisman commented Aug 6, 2020

Copy link
Copy Markdown
Member Author

I have resolve these two conflicts. We'd better run the full tests for this PR again to make sure it works for 6.1 branch.

@seisman
seisman merged commit 0d86f13 into 6.1 Aug 6, 2020
@seisman
seisman deleted the backport-3848-to-6.1 branch August 6, 2020 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants