Skip to content

Fix wrong noise direction in grdsample wesn checking - #7469

Merged
PaulWessel merged 3 commits into
masterfrom
grdsample-update
May 22, 2023
Merged

PaulWessel merged 3 commits into
masterfrom
grdsample-update

Conversation

@PaulWessel

@PaulWessel PaulWessel commented May 21, 2023 •

Copy link
Copy Markdown
Contributor

This relates to #7453 but does not fix it. When grdsample was changed by #7356 we got the sign of the error slop (ince) wrong for the x-direction. I addition to fixing that, I have also broken some long lines into 2-lines so easier to do debug. With this fix the original problem fixed by #7356 is still fixed but now the grdcut command yields the correct sub-region. However, the spikes in the corners are still there and are there for different reasons, as discussed below. I recommend we approve and merge this PR though.

The commented out verbose statements in grdsample would print this before the April 7 "fix":

gmt grdcut @earth_relief_03s_g -R-10/-9.8/4.9/5.0 -Glixo03s.grd
wesn_i = -10/-9.8/4.89583/5
wesn_o = -10/-9.8/4.9/5

which is incorrect for the south limit in wesn_i (but fortuitously gives a better plot). They should be the same as wesn_o. After this PR we get the correct

wesn_i = -10/-9.8/4.9/5
wesn_o = -10/-9.8/4.9/5

I am pretty sure the spikes at the WS and NW corners have the same source. Remember, we are resampling the 15s grid (pixel) at the 3s grid (gridline). Here are items that conspire:

  1. The 3s tile ends at west = -10 and hence the boundary rows/cols are produced by the boundary conditions, not neighbour tile data.
  2. We are extrapolating the 15s grid beyond the last nodes in the corners and hence things are driven almost exclusively by the boundary conditions. Just like for the 3s grid on even degrees, the 15s data is tiled at 10x10 degrees and hence at -10 we have the same situation: padding completely determined by BC and not neighbor tile data.

Here is a zoom in on the SW corner and where we wish to estimate 15s (red dots) from the blue dots.

zoom

Thus, the fix to this issue may be complicated, but perhaps something like this:

  • When processing the remote data set tiles, extend exact tile by 2 rows/cols.
  • When reading/processing these tiles, GMT knows that it should:
  • a) Read the tile with no pad requested (so we read it as is including the extra nodes)
  • b) Change the region inwards by 2 steps and set padding to 2. Now we have data in the internal grids boundary pad
  • c) The interpolation would now not have crazy artefacts of PCs imposed (natural BC) since the underlying data is continuous and now only data are used as BC nodes.

This obviously means a wholesale revision of the remote data set structures, how gmt_remote.c operators, etc. but probably the best solution. In fact, we should have been smart enough to think of this when the global tiling was first proposed and introduced.

Other solutions seems much messier, e.g., to somehow get the neighbouring tile data into the boundary pads, i.e., read in strips of the neighbor tiles and insert into pad. I would hate to be the coder for that.

FYI, if we just decide to cut out the 15s subset (the raw grid) and then use grdsample to sample it at the 3s nodes (i.e., no blending at all, just 15s resampled), you can still see the four corners having "lips":

gmt grdcut ~/.gmt/server/earth/earth_relief/earth_relief_15s_p/N00W010.earth_relief_15s_p.nc -R-10/-9.8/4.9/5.0 -Glixo15s_raw.grd
gmt grdsample lixo15s_raw.grd -T -I3s -Gtmp.grd
gmt grdview tmp.grd -R-10/-9.75/4.85/5/-2200/-900 -Bxaf -Byaf -Bzaf -BWSZ+t"Blend" -JZ2i -p135/35 -png p

p

So even without any grdblend calls happening you can see the 2-D BCR extrapolation at the corners lack real BC constraints. If we just plot the 15s as is: No lips:

map15s

So the spikes are all produced by teh BCR extrapolation into the voids.

This relates to #7453 but does not fix it.  When grdsample was changed by #7356 we got the sign of the error slop wrong for the x-direction.  I have also broken some long lines into 2-lines so easier to do debug.  With this fix the original problem fixed by #7356 is still fixed but now the grdcut command yields the correct sub-region.  However, the spike in the corners are still there and are there for different reasons.
@PaulWessel PaulWessel added the bug Something isn't working label May 21, 2023
@PaulWessel PaulWessel added this to the 6.5.0 milestone May 21, 2023
@PaulWessel
PaulWessel requested review from joa-quim and seisman May 21, 2023 08:56
@PaulWessel PaulWessel self-assigned this May 21, 2023
@PaulWessel
PaulWessel requested review from Esteban82 and maxrjones May 21, 2023 08:56
@PaulWessel

Copy link
Copy Markdown
Contributor Author

If you extend the west boundary to further west, e.g. -10:02, then the surface will show a visible “seam” along Lon = 10, and ending in the two spike lips. While I think this is BCs, we should also examine the BCR for outside corner cases as here

@Esteban82 Esteban82 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blind approval. Let me know if I do you want to test it.

@PaulWessel

Copy link
Copy Markdown
Contributor Author

Blind approval. Let me know if I do you want to test it.

You could try to play with view points etc on something like this

gmt grdview @earth_relief_03s_g -R-10.1/-9.9/4.9/5.0/-2200/-900 -Bxaf -Byaf -Bzaf -JZ2i -p135/35 -pdf t

which I think shows the seam + the lips

@PaulWessel

Copy link
Copy Markdown
Contributor Author

But no merging yet.

@PaulWessel
PaulWessel merged commit 0067ef0 into master May 22, 2023
@PaulWessel
PaulWessel deleted the grdsample-update branch May 22, 2023 18:02
PaulWessel added a commit that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants