Skip to content

Improve the two-step grid reading when source is a matrix#3510

Merged
PaulWessel merged 11 commits intomasterfrom
add-failing-API-test
Jun 21, 2020
Merged

Improve the two-step grid reading when source is a matrix#3510
PaulWessel merged 11 commits intomasterfrom
add-failing-API-test

Conversation

@PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Jun 20, 2020

Description of proposed changes

See #3408 for the initial problem. Here is what goes wrong:

  1. We first read the container header from a file. The file is a memory reference to a matrix. This returns a grid structure with a header.
  2. Then grdgradient is called with the same file to make an intensity grid. This all works.
  3. Later, we wish to read the data from the matrix source. However, despite me implementing more meaningful memory file names like @gmtapi@-S-I-G-M-G-N-000000, the old code has not been updated: It loops over the registered objects and finds the first one that matches the specs (image, input, etc). This turns out to be the grid header from (1) above instead of item 0. So we go down the rabbit hole and do strange things.

Time to implement a new scheme that extracts the information directly from the filename.

Closes #3408.

See #3408 for background.  Need to add this to the repo to debug in Xcode.
Grid headers read via matrices must still remember they came from a matrix since when GMT_Read_Data is called a second time to get the data they still need to fall into that method.
@PaulWessel
Copy link
Member Author

PaulWessel commented Jun 21, 2020

I have made a few changes. First, I am parsing the full name and get the various items. For now I am only checking direction and return the object ID. I also made a small change that when we check for the validity of a given object I ignore if it has been used before (it has). I added @seisman example C code as well and two tests (with and without shading) which both passes. All other tests pass as well. There are more simplifications that can be done in gmt_api.c but I want to do that very carefully...
I also fixed a memory leak from grdimage.

@PaulWessel PaulWessel changed the title WIP Improve the two-step grid reading when source is a matrix Improve the two-step grid reading when source is a matrix Jun 21, 2020
@PaulWessel PaulWessel requested review from joa-quim and seisman June 21, 2020 01:06
@PaulWessel
Copy link
Member Author

Closes #3408.

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.

grdimage shading fails with external matrix

2 participants