GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
747 stars 216 forks source link

pygmt.surface fails with recent GMT dev #1184

Closed seisman closed 3 years ago

seisman commented 3 years ago

Python script to reproduce the issue:

import pygmt

ship_data = pygmt.datasets.load_sample_bathymetry()
data = ship_data.values
output = pygmt.surface(data=data, spacing="5m", region=[245, 255, 20, 30])

Error messages:

[Session pygmt-session (2)]: Error returned from GMT API: GMT_NOT_A_VALID_ID (38)
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    output = pygmt.surface(data=data, spacing="5m", region=[245, 255, 20, 30])
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 296, in new_module
    return module_func(*args, **kwargs)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 437, in new_module
    return module_func(*args, **kwargs)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/src/surface.py", line 103, in surface
    lib.call_module(module="surface", args=arg_str)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 504, in call_module
    raise GMTCLibError(
pygmt.exceptions.GMTCLibError: Module 'surface' failed with status code 79:

Adding verbose="d" to the pygmt.surface() gives more debugging messages:

surface [DEBUG]: Look for file 245/255/20/30 in /Users/seisman/.gmt
surface [DEBUG]: Look for file 245/255/20/30 in /Users/seisman/.gmt/data,/Users/seisman/Gits/gmt-china/china-geospatial-data
surface [DEBUG]: Look for file 245/255/20/30 in /Users/seisman/.gmt/cache
surface [DEBUG]: Look for file 245/255/20/30 in /Users/seisman/.gmt/server
surface [DEBUG]: Got regular w/e/s/n for region (245/255/20/30)
surface [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
surface [DEBUG]: Geographic input grid, longitudes span less than 360
surface [DEBUG]: Chosen boundary condition for all edges: geographic
surface [DEBUG]: Geographic input grid, longitudes span less than 360
surface [DEBUG]: Object ID 1 : Registered Grid Memory Reference 7f918f7e8df0 as an Input resource with geometry Surface [n_objects = 2]
surface [DEBUG]: Successfully created a new Grid container
surface [INFORMATION]: Grid domain: W: 245 E: 255 S: 20 N: 30 n_columns: 120 n_rows: 120 [gridline registration]
surface [INFORMATION]: Processing input table data
surface [DEBUG]: gmtapi_init_import: Passed family = Data Table and geometry = Point
surface (gmtapi_init_import): tried to free unallocated memory
[Session pygmt-session (2)]: Error returned from GMT API: GMT_NOT_A_VALID_ID (38)
surface [DEBUG]: GMT_Init_IO: Returned first Input object ID = -1
surface [DEBUG]: GMT_Begin_IO: Mode value 1 not considered (ignored)
surface [DEBUG]: GMT_Begin_IO: Initialize record-by-record access for Input
surface [DEBUG]: gmtlib_garbage_collection: Destroying object: C=0 A=0 ID=1 W=Input F=Grid M=Memory Reference S=Unused P=7f918f7e8df0 N=(null)
surface [DEBUG]: GMTAPI_Garbage_Collection freed 1 memory objects
surface [DEBUG]: gmtlib_unregister_io: Unregistering object no 1 [n_objects = 1]
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    output = pygmt.surface(data=data, spacing="5m", region=[245, 255, 20, 30], verbose='d')
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 296, in new_module
    return module_func(*args, **kwargs)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 437, in new_module
    return module_func(*args, **kwargs)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/src/surface.py", line 103, in surface
    lib.call_module(module="surface", args=arg_str)
  File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 504, in call_module
    raise GMTCLibError(
pygmt.exceptions.GMTCLibError: Module 'surface' failed with status code 79:
seisman commented 3 years ago

Ping @PaulWessel

seisman commented 3 years ago

All pygmt.surface tests pass for v6.2.0rc1. Closing the issue.