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

Let grdimage resample 2nd grid used for intensities #5363

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

PaulWessel
Copy link
Member

This follows up on issue #5347. Turns out -I already can handle a second datagrid combined with the derive-modifiers, but the two grids have to have the same size and registration. This PR changes this so that if -I specifies a second data grid from which intensities shall be derived (rather than from the input grid), we ensure the secondary grid is resampled to the resolution of the primary grid if it is not already matching. I added a new test script that shows the use of different resolution grids. Closes #5347.

twogrids

If -I specifies a second data grid from which intensities shall be derived (rather than from the input grid), we ensure the secondary grid is resampled to the resolution of the primary grid if it is not matching.
@PaulWessel PaulWessel added the new feature PR that implements a new feature or capability in GMT label Jun 20, 2021
@PaulWessel PaulWessel self-assigned this Jun 20, 2021
@joa-quim
Copy link
Member

I think that it should also check that GRD2 totally encloses GRD1.

@PaulWessel
Copy link
Member Author

Yes, that is reasonable, too. Maybe later today. It is Father's Day in the US and that means forced meals, activities and fewer therapeutic debugging sessions.

@Esteban82
Copy link
Member

Happy Father's Day!! It is also in Argentina.

It would be possible to use irregular grid like the following link from the forum?

https://forum.generic-mapping-tools.org/uploads/default/original/2X/f/fd6eb02da35af9f2471aa44c9a3ab56bea2e6671.png

@PaulWessel
Copy link
Member Author

Likewise @Esteban82 . I am not sure I understand what you mean by "irregular grids" since all grids in GMT have to be equidistant and not irregular?

@Esteban82
Copy link
Member

With "irregular" I mean its shape (not the spacing between nodes). Like the previous link where there is no data in the edges.

@PaulWessel
Copy link
Member Author

And by shape you mean there are NaNs? The shape of all grids is rectangular but many only have data in some of that rectangle. I think NaNs are fine - you just are not going to get any shading from that part.

@PaulWessel
Copy link
Member Author

OK @joa-quim I added a region check, insisting that the secondary grid covers the same region (or more).

src/grdimage.c Outdated
if (Grid_orig && (I_data->header->n_columns != Grid_orig->header->n_columns || I_data->header->n_rows != Grid_orig->header->n_rows)) {
char int_z_grd[GMT_VF_LEN] = {""}, *res = "gp";
if (I_data->header->wesn[XLO] > region[XLO] || I_data->header->wesn[XHI] < region[XHI] || I_data->header->wesn[YLO] > region[YLO] || I_data->header->wesn[YHI] < region[YHI]) {
GMT_Report (API, GMT_MSG_ERROR, "Your secondary data grid given vie -A does not cover the same area as the primary grid - aborting\n");
Copy link
Member

Choose a reason for hiding this comment

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

Typo. via not vie

Copy link
Member Author

Choose a reason for hiding this comment

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

Also not via -A... but -I. Fixed

@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jun 21, 2021
@PaulWessel PaulWessel merged commit f90d8ea into master Jun 21, 2021
@PaulWessel PaulWessel deleted the grdimage-resmple branch June 21, 2021 00:54
@maxrjones maxrjones added new core module feature PR that implements a new core module feature and removed new feature PR that implements a new feature or capability in GMT labels Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-changelog Add PR to the changelog new core module feature PR that implements a new core module feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow grdview -G option in grdimage
4 participants