Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 11 commits into from
Jun 21, 2020

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