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

nearneighbor search radius unit ignored #105

Closed
anbj opened this issue Oct 1, 2018 · 5 comments
Closed

nearneighbor search radius unit ignored #105

anbj opened this issue Oct 1, 2018 · 5 comments

Comments

@anbj
Copy link
Contributor

anbj commented Oct 1, 2018

If not given, the default nearneighbor search radius unit is in meter (http://gmt.soest.hawaii.edu/doc/latest/nearneighbor.html). Specifying the unit (e) makes nearneighbor think its dealing with geographic data. Both cases should be in cartesian data.

nearneighbor -I.2 dat -S20e -R0/100/0/100 -Vd -Gwith_e_debug.nc

outputs

...
nearneighbor [INFORMATION]: Your distance unit (e) implies geographic data; -fg has been set.
...

The diff between the two commands nearneighbor -I.2 dat -S20e -R0/100/0/100 -Vd -Gwith_e_debug.nc and nearneighbor -I.2 dat -S20e -R0/100/0/100 -Vd -Gwith_e_debug.nc (one with the UNIT specified and the other not) gives

$ bash nearneighbor_unit.sh
45,51c45,49
< nearneighbor [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
< nearneighbor [INFORMATION]: Your distance unit (e) implies geographic data; -fg has been set.
< nearneighbor [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
< nearneighbor [DEBUG]: Geographic input grid, longitudes span less than 360
< nearneighbor [DEBUG]: Chosen boundary condition for all edges: geographic
< nearneighbor [DEBUG]: Geographic input grid, longitudes span less than 360
< nearneighbor [DEBUG]: Object ID 0 : Registered Grid Memory Reference 194c3f0 as an Input resource with geometry Surface [n_objects = 1]
---
> nearneighbor [DEBUG]: Map distance calculation will be Cartesian
> nearneighbor [INFORMATION]: Cartesian input grid
> nearneighbor [DEBUG]: Chosen boundary condition for all edges: natural
> nearneighbor [INFORMATION]: Cartesian input grid
> nearneighbor [DEBUG]: Object ID 0 : Registered Grid Memory Reference 12fd3f0 as an Input resource with geometry Surface [n_objects = 1]
60c58
< nearneighbor [INFORMATION]: Max node-search half-widths are: half_x = 1, half_y = 251
---
> nearneighbor [INFORMATION]: Max node-search half-widths are: half_x = 100, half_y = 100
70c68
< nearneighbor [INFORMATION]: Processed record       1599
---
> nearneighbor [INFORMATION]: Processed record       1786
73c71
< nearneighbor [DEBUG]: Object ID 2 : Registered Grid File with_e_debug.nc as an Output resource with geometry Surface [n_objects = 3]
---
> nearneighbor [DEBUG]: Object ID 2 : Registered Grid File without_e_debug.nc as an Output resource with geometry Surface [n_objects = 3]
76c74
< nearneighbor [INFORMATION]: Writing grid to file with_e_debug.nc
---
> nearneighbor [INFORMATION]: Writing grid to file without_e_debug.nc
81c79
< nearneighbor [INFORMATION]: No valid values in grid [with_e_debug.nc]
---
> nearneighbor [DEBUG]: packed z-range: [0,9.78769]
83,85c81,83
< nearneighbor [INFORMATION]: 0 nodes were assigned an average value
< nearneighbor [INFORMATION]: 2452 nodes failed sector criteria and 248549 nodes had no neighbor points (all set to NaN)
< nearneighbor [DEBUG]: gmtapi_garbage_collection: Destroying object: C=0 A=0 ID=0 W=Input F=Grid M=Memory Reference S=Unused P=194c3f0 N=(null)
---
> nearneighbor [INFORMATION]: 247350 nodes were assigned an average value
> nearneighbor [INFORMATION]: 3651 nodes failed sector criteria and 0 nodes had no neighbor points (all set to NaN)
> nearneighbor [DEBUG]: gmtapi_garbage_collection: Destroying object: C=0 A=0 ID=0 W=Input F=Grid M=Memory Reference S=Unused P=12fd3f0 N=(null)

Script to produce the diff with included dummy_data.txt:

nearneighbor -I.2 dummy_data.txt -S20e -R0/100/0/100 -Vd -Gwith_e_debug.nc 2> with_e_debug.log
nearneighbor -I.2 dummy_data.txt -S20 -R0/100/0/100 -Vd -Gwithout_e_debug.nc 2> without_e_debug.log
diff with_e_debug.log without_e_debug.log

rm with_e_debug.log without_e_debug.log with_e_debug.nc without_e_debug.nc

gmt clear history 
  • Version of GMT: 6.0.0_821bce2
@welcome
Copy link

welcome bot commented Oct 1, 2018

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute!

@PaulWessel
Copy link
Member

If your data are Cartesian, why are you giving a unit? The e, k, M, and other units are only needed if you are providing geographic data in lon,lat format. For Cartesian data the increment is used as is.

@anbj
Copy link
Contributor Author

anbj commented Oct 2, 2018

I'm confused. So e.g. -S500e is not the same as -S500? Why is e then the default unit?

@PaulWessel
Copy link
Member

It is the Default unit for geographic data. For Cartesian data there cannot possibly be a default units since how would we know if it is time, distance, weight, chemical concentrations, etc etc.

@anbj
Copy link
Contributor Author

anbj commented Oct 2, 2018

Alright. Dont know why I got so confused about this.

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

No branches or pull requests

2 participants