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

x_min and y_min being a small float number instead of 0 #164

Closed
Xiaohua-Eric-Xu opened this issue Nov 5, 2018 · 9 comments
Closed

x_min and y_min being a small float number instead of 0 #164

Xiaohua-Eric-Xu opened this issue Nov 5, 2018 · 9 comments

Comments

@Xiaohua-Eric-Xu
Copy link

Description of the problem

Some grid generated with GMT API (GMT_Create_Grid) with specifying wesn and xinc/yinc have very small numbers like ?.???e-16 instead of 0.

Also, some GMT commands will show reading beyond domain, e.g. grdblend, grdsample, grdimage, etc. I am not sure whether this is from the same issue. p.s. The grdimage error (reading beyond domain) will sometimes go away if a smaller region is give. The grdsample/grdblend error shows up when I am sampling the grid with it's own -R/-I option.

Full script that generated the error

PASTE CODE HERE

Out = GMT_Create_Data(API, GMT_IS_GRID, GMT_IS_SURFACE, GMT_GRID_ALL, NULL, wesn, inc, GMT_GRID_PIXEL_REG, 0, NULL)

gmt grdblend p1.grd p2.grd p3.grd p4.grd -R118.829166667/121.99375001/-3.56770833333/0.145486111111 -I0.0006944444445/0.0006944444445 -Gtmp.grd -Vd

Full error message

[cryosat:cases/palu4/blend] xix016% gmt grdblend p1.grd p2.grd p3.grd p4.grd -R118.829166667/121.99375001/-3.56770833333/0.145486111111 -I0.0006944444445/0.0006944444445 -Gtmp.grd -Vd
gmt: GMT->session.HOMEDIR = /Users/xix016
gmt: GMT->session.USERDIR = /Users/xix016/.gmt [created]
gmt: GMT->session.CACHEDIR = /Users/xix016/.gmt/cache [created]
gmt: GMT: 1. gmt_getsharepath trying current dir
gmt: GMT: 2. gmt_getsharepath trying USERDIR /Users/xix016/.gmt
gmt: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/xix016/.gmt/postscriptlight
gmt: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/local/share/gmt/postscriptlight
gmt: Map distance calculation will be Cartesian
gmt: The PROJ_GEODESIC set to Vincenty
gmt: GMT_Create_Session initialized GMT structure
gmt: Shared Library # 0 (core). Path = libgmt.dylib
gmt: Loading core GMT shared library: libgmt.dylib
gmt: Loading GMT plugins from: /opt/local/lib/gmt/plugins
gmt: Shared Library # 1 (supplements). Path = /opt/local/lib/gmt/plugins/supplements.so
grdblend: History: Process -R118.829166667/121.99375001/-3.56770833333/0.145486111111.
grdblend: Grid is Cartesian
grdblend: Given domain implies x_inc = 0.000694444
grdblend: Given domain implies y_inc = 0.000694444
grdblend: Chosen boundary condition for all edges: natural
grdblend: Grid is Cartesian
grdblend: Object ID 0 : Registered GMT Grid Memory Reference 7f99d4c09d40 as an Input resource with geometry Surface [n_objects = 1]
grdblend: Successfully created a new GMT Grid container
grdblend: Processing input grids
grdblend: Object ID 1 : Registered GMT Grid File p1.grd as an Input resource with geometry Surface [n_objects = 2]
grdblend: api_begin_io: Input resource access is now enabled [container]
grdblend: api_import_grid: Passed ID = 1 and mode = 33
grdblend: Geographic grid, longitudes span less than 360
grdblend: GMT_End_IO: Input resource access is now disabled
grdblend: File p1.grd coordinates are phase-shifted w.r.t. the output grid - must resample
grdblend: Resample p1.grd via grdsample p1.grd -R120.611111117/121.99375001/-3.56770833333/-0.228819444444 -G/var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc -Vd -fg --GMT_HISTORY=false
grdblend (gmtlib_free_tmp_arrays): tried to free unallocated memory
grdsample: History: Process -R120.611111117/121.99375001/-3.56770833333/-0.228819444444.
grdsample: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
grdsample: Processing input grid
grdsample: Object ID 2 : Registered GMT Grid File p1.grd as an Input resource with geometry Surface [n_objects = 3]
grdsample: api_begin_io: Input resource access is now enabled [container]
grdsample: api_import_grid: Passed ID = 2 and mode = 1
grdsample: Geographic grid, longitudes span less than 360
grdsample: GMT_End_IO: Input resource access is now disabled
grdsample: Grid/Image dimensions imply w/e/s/n = 120.611/121.994/-3.56771/-0.228819, inc = 0.000694444/0.000694444, pixel registration, n_layers = 1
grdsample: Geographic grid, longitudes span less than 360
grdsample: Given domain implies x_inc = 0.000694444
grdsample: Given domain implies y_inc = 0.000694444
grdsample: Chosen boundary condition for all edges: geographic
grdsample: Geographic grid, longitudes span less than 360
grdsample: Object ID 3 : Registered GMT Grid Memory Reference 7f99d4f00d30 as an Input resource with geometry Surface [n_objects = 4]
grdsample: Successfully created a new GMT Grid container
grdsample: Input grid (120.611111121/122.00000001/-3.56944444444/-0.229166666666) n_columns = 2000 n_rows = 4810 dx = 0.0006944444445 dy = 0.000694444444443 registration = 1
grdsample: Output grid (120.611111117/121.99375001/-3.56770833333/-0.228819444444) n_columns = 1991 n_rows = 4808 dx = 0.000694444446509 dy = 0.000694444444444 registration = 1
grdsample: api_begin_io: Input resource access is now enabled [container]
grdsample: api_import_grid: Passed ID = 2 and mode = 2
grdsample: Warning: Region exceeds grid domain. Region reduced to grid domain.
grdsample: Warning: (s - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdsample: Warning: s reset from -3.56770833333 to -3.56805555555
grdsample: Reading grid from file p1.grd
grdsample: processing at most 32 (32x1) chunks at a time (31.1 MiB)...
grdsample: packed z-range: [-3.1411,3.14119]
grdsample: Geographic grid, longitudes span less than 360
grdsample: Chosen boundary condition for left edge: geographic
grdsample: Chosen boundary condition for right edge: extended data
grdsample: Chosen boundary condition for bottom edge: extended data
grdsample: Chosen boundary condition for top edge: geographic
grdsample: Set boundary condition for left edge: natural
grdsample: Set boundary condition for top edge: natural
grdsample: GMT_End_IO: Input resource access is now disabled
grdsample: Warning: Output sampling interval in y exceeds input interval and may lead to aliasing.
grdsample: Output grid extrema [-3.9113/3.91023] exceeds extrema of input grid [-3.1411/3.14119]; to clip output use -n...+c
grdsample: Object ID 4 : Registered GMT Grid File /var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc as an Output resource with geometry Surface [n_objects = 5]
grdsample: api_begin_io: Output resource access is now enabled [container]
grdsample: api_export_grid: Passed ID = 4 and mode = 0
grdsample: Writing grid to file /var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc
grdsample: region: 0 0, grid: 120.611 121.994
grdsample: -> region: 120.611 121.994, grid: 120.611 121.994
grdsample: row: 0 4807, col: 0 1990
grdsample: netCDF Library version: 4
grdsample: processing at most 480 (32x15) chunks at a time (31.6 MiB)...
grdsample: packed z-range: [-3.9113,3.91023]
grdsample: GMT_End_IO: Output resource access is now disabled
grdsample: gmtapi_garbage_collection: Destroying object: C=0 A=0 ID=2 W=Input F=GMT Grid M=File S=Used P=7f99d4f00cf0 D=7f99d4f00cf0 N=p1.grd
grdsample: gmtapi_garbage_collection: Destroying object: C=0 A=0 ID=3 W=Input F=GMT Grid M=Memory Reference S=Unused P=7f99d4f00d30 D=7f99d4f00d30 N=(null)
grdsample: GMTAPI_Garbage_Collection freed 2 memory objects
grdsample: gmtapi_unregister_io: Unregistering object no 2 [n_objects = 4]
grdsample: gmtapi_unregister_io: Unregistering object no 3 [n_objects = 3]
grdsample: gmtapi_unregister_io: Unregistering object no 4 [n_objects = 2]
grdsample (gmtlib_free_tmp_arrays): tried to free unallocated memory
grdblend (gmtapi_close_grd): tried to free unallocated memory
grdblend: GMT_Destroy_Data: freed memory for a GMT Grid for object 1
grdblend: gmtapi_unregister_io: Unregistering object no 1 [n_objects = 1]
grdblend: gmtapi_unregister_io: Object no 1 has non-NULL data pointer
grdblend: Object ID 5 : Registered GMT Grid File /var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc as an Input resource with geometry Surface [n_objects = 2]
grdblend: api_begin_io: Input resource access is now enabled [container]
grdblend: api_import_grid: Passed ID = 5 and mode = 33
grdblend (gmtlib_nc_get_att_text): tried to free unallocated memory
grdblend (gmtlib_nc_get_att_text): tried to free unallocated memory
grdblend: Round-off patrol changed grid limit for ymin from -3.567708333330247 to -3.567708333330247
grdblend: Round-off patrol changed grid limit for ymax from -0.2288194444442465 to -0.2288194444442465
grdblend: Geographic grid, longitudes span less than 360
grdblend: GMT_End_IO: Input resource access is now disabled
grdblend: Grid /var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc: out: 2566/4556/5346/539 in: 2565/4567/5350/538 skip: 0 offset: 0
grdblend: Blend file /var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_0.nc in 120.611/122/-3.56944/-0.229167 with normal weight 1 [539-5346]
grdblend (gmtapi_close_grd): tried to free unallocated memory
grdblend: GMT_Destroy_Data: freed memory for a GMT Grid for object 5
grdblend: gmtapi_unregister_io: Unregistering object no 5 [n_objects = 1]
grdblend: gmtapi_unregister_io: Object no 5 has non-NULL data pointer
grdblend: Object ID 6 : Registered GMT Grid File p2.grd as an Input resource with geometry Surface [n_objects = 2]
grdblend: api_begin_io: Input resource access is now enabled [container]
grdblend: api_import_grid: Passed ID = 6 and mode = 33
grdblend: Geographic grid, longitudes span less than 360
grdblend: GMT_End_IO: Input resource access is now disabled
grdblend: File p2.grd coordinates are phase-shifted w.r.t. the output grid - must resample
grdblend: Resample p2.grd via grdsample p2.grd -R120.041666671/121.319444452/-3.43090277777/-0.111458333333 -G/var/folders/47/bjcllxpd16g8jhrqwl6121xw00019g/T//grdblend_resampled_6157_1.nc -Vd -fg --GMT_HISTORY=false
grdblend (gmtlib_free_tmp_arrays): tried to free unallocated memory
grdsample: History: Process -R120.041666671/121.319444452/-3.43090277777/-0.111458333333.
grdsample: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
grdsample: Processing input grid
grdsample: Object ID 7 : Registered GMT Grid File p2.grd as an Input resource with geometry Surface [n_objects = 3]
grdsample: api_begin_io: Input resource access is now enabled [container]
grdsample: api_import_grid: Passed ID = 7 and mode = 1
grdsample: Geographic grid, longitudes span less than 360
grdsample: GMT_End_IO: Input resource access is now disabled
grdsample: Grid/Image dimensions imply w/e/s/n = 120.042/121.319/-3.4309/-0.111458, inc = 0.000694444/0.000694444, pixel registration, n_layers = 1
grdsample: Geographic grid, longitudes span less than 360
grdsample: Given domain implies x_inc = 0.000694444
grdsample: Given domain implies y_inc = 0.000694444
grdsample: Chosen boundary condition for all edges: geographic
grdsample: Geographic grid, longitudes span less than 360
grdsample: Object ID 8 : Registered GMT Grid Memory Reference 7f99d4e00030 as an Input resource with geometry Surface [n_objects = 4]
grdsample: Successfully created a new GMT Grid container
grdsample: Input grid (120.041666667/121.319444444/-3.43055555556/-0.111111111111) n_columns = 1840 n_rows = 4780 dx = 0.000694444444022 dy = 0.000694444444445 registration = 1
grdsample: Output grid (120.041666671/121.319444452/-3.43090277777/-0.111458333333) n_columns = 1840 n_rows = 4780 dx = 0.000694444446196 dy = 0.000694444444443 registration = 1
grdsample: api_begin_io: Input resource access is now enabled [container]
grdsample: api_import_grid: Passed ID = 7 and mode = 2
grdsample: Warning: Region exceeds grid domain. Region reduced to grid domain.
grdsample: Warning: (n - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdsample: Warning: n reset from -0.111458333333 to -0.111111111111
grdsample: Reading grid from file p2.grd
grdsample (gmt_nc_read_grd): Tried to read beyond grid domain [p2.grd]

PASTE ERROR MESSAGE HERE

System information

  • Operating system:
  • Version of GMT:

5.4.4

@welcome
Copy link

welcome bot commented Nov 5, 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

Would you be able to places your p?.grd files somewhere and sent us a link so we can pick them up? Think I need to run this in debug to see what is happening.

@Xiaohua-Eric-Xu
Copy link
Author

Dear Developers,

Here is a link on the files.
https://drive.google.com/open?id=1bsyljDDraqXEzW4PecpuNUczBMEyGMUO

Cheers,
Xiaohua(Eric)

@PaulWessel
Copy link
Member

Sorry, got side-tracked but downloaded the files. Cannot find anything called p?.grd, but lots of other grids in intf_all.

@Xiaohua-Eric-Xu
Copy link
Author

Hi Paul,

I just got a sharable link on google drive. Not sure what happened.

https://drive.google.com/open?id=1gpItAqyPC7sBE-VSPb3xX9oLxlWmPq3o

Thanks,
Xiaohua(Eric)

@PaulWessel
Copy link
Member

Thanks got them.

PaulWessel added a commit that referenced this issue Nov 7, 2018
Allow a slop up to 10^-4 instead of 10^-8 in w/e/s/n comparisons to fix issue #164
PaulWessel added a commit that referenced this issue Nov 7, 2018
Sloppy grid limit comparisons, again fixing #164 but in the 5.4 branch,
@PaulWessel
Copy link
Member

Hi @sddyxxh , I have fixed this by being more gentle in comparing limits using a sloppier threshold of 10^-4 * inc instead of 10^-8. Your case passes and I know we have used this level of slop in the past. Once the team approves the pull requests it will be fixed in 5.4 and master.

joa-quim pushed a commit that referenced this issue Nov 7, 2018
Allow a slop up to 10^-4 instead of 10^-8 in w/e/s/n comparisons to fix issue #164
joa-quim pushed a commit that referenced this issue Nov 7, 2018
Sloppy grid limit comparisons, again fixing #164 but in the 5.4 branch,
@PaulWessel
Copy link
Member

Hi @sddyxxh, can you confirm that this fixed worked for you as well so I can close this issue?

@PaulWessel
Copy link
Member

Closing this as fixed since no further feedback.

obaney pushed a commit to obaney/gmt that referenced this issue Aug 18, 2021
…ls#188)

Use a callback function passed to `GMT_Create_Session` to log error
messages instead of redirecting them to a file using
`GMT_Handle_Messages`. It's a lot cleaner and the code is more legible.
Other functions don't need to do anything to have their errors logged,
it's automatic.
The logged messaged are also printed to stderr so they will show up in
the Jupyter notebook.
This is useful when using the verbose mode (`V="d"`) in modules.

Switch to the Fatiando a Terra CI scripts and enable OSX testing on 
Travis.
Fatiando provides scripts for handling all of the CI tasks we need: 
https://github.com/fatiando/continuous-integration 
Use them instead of rewriting everything.

Fixes GenericMappingTools#164 
The Segmentation fault on OSX was happening because of the log file
that we used to capture the GMT output and include in the exception.
I have no idea why this happens.
But removing that fixes the issue so I'm happy not knowing.
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