Skip to content

pygmt.config doesn't work with values that have whitespaces #2298

Description

@seisman

Description of the problem

Some GMT defaults can accept values that have whitespaces. For example, FORMAT_TIME_STAMP's default value is %Y %b %d %H:%M:%S.

See the example below. pygmt.config doesn't work with values that contain whitespaces. We need to do some work like #1487.

Minimal Complete Verifiable Example

import pygmt

fig = pygmt.Figure()
with pygmt.config(FORMAT_TIME_STAMP="%Y %b %d %H:%M:%S"):
    fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True, timestamp=True)
fig.show()

Full error message

gmtset [ERROR]: Unrecognized keyword %b.
gmtset [WARNING]: Last GMT Defaults parameter from command options had no value
gmtset [ERROR]:  1 GMT Defaults conversion errors from command options
Traceback (most recent call last):
  File "/home/seisman/Syncthing/test.py", line 5, in <module>
    fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True, timestamp=True)
  File "/home/seisman/OSS/gmt/pygmt/pygmt/src/config.py", line 213, in __exit__
    lib.call_module(module="set", args=arg_str)
  File "/home/seisman/OSS/gmt/pygmt/pygmt/clib/session.py", line 510, in call_module
    raise GMTCLibError(
pygmt.exceptions.GMTCLibError: Module 'set' failed with status code 72:
gmtset [ERROR]: Unrecognized keyword %b.
gmtset [ERROR]:  1 GMT Defaults conversion errors from command options

System information

PyGMT information:
  version: v0.8.1.dev9+g9852724e
System information:
  python: 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03)  [GCC 10.4.0]
  executable: /home/seisman/opt/miniconda/bin/python3.9
  machine: Linux-6.0.9-300.fc37.x86_64-x86_64-with-glibc2.36
Dependency information:
  numpy: 1.23.4
  pandas: 1.5.1
  xarray: 2022.10.0
  netCDF4: 1.6.1
  packaging: 21.3
  geopandas: None
  ghostscript: 9.56.1
GMT library information:
  binary version: 6.5.0_8b8bc2e_2023.01.01
  cores: 80
  grid layout: rows
  library path: /home/seisman/opt/GMT-master/lib64/libgmt.so
  padding: 2
  plugin dir: /home/seisman/opt/GMT-master/lib64/gmt/plugins
  share dir: /home/seisman/opt/GMT-master/share
  version: 6.5.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions