Skip to content

PS_CONVERT has no effect when using Figure.show/Figure.savefig/Figure.psconvert #4256

@seisman

Description

@seisman

Description of the problem

PS_CONVERT is a GMT configuration parameter that can store a comma-separate list of options to use when calling psconvert implicitely when gmt end is called. The GMT documentation is at https://docs.generic-mapping-tools.org/6.6/gmt.conf.html#term-PS_CONVERT.

Comma-separated list of optional module arguments that we should supply when psconvert is called implicitly under modern mode [A]. Ignored when psconvert is called on the command line explicitly. The option arguments must be listed without their leading option hyphen.

In PyGMT, Figure.show/Figure.savefig calls psconvert internally, so this option has no effect, which is expected according to the GMT documentation. As a workaround, we can explicitely add these options when calling Figure.show/Figure.savefig, but it's a little tedious.

Possible solutions are:

  1. Document that PS_CONVERT is ignored in PyGMT.
  2. In Figure.psconvert, parse the values of PS_CONVERT and append them to the argument list when calling psconvert.
  3. Thinking about if there is a more Pythonic and elegant way to implement the same feature.

Solution 2 is not that hard to implement, but need time to think about solution 3.

Minimal Complete Verifiable Example

import pygmt
pygmt.config(PS_CONVERT="C-I/home/xxx/.gmt")
fig = pygmt.Figure()
fig.basemap(region="g", projection="H8c", frame=True)
fig.savefig("map.png", verbose="d")

Full error message

pygmt-session [DEBUG]: Revised options: -A -Fmap -Qg2 -Qt2 -Tg -Vd
psconvert [DEBUG]: Ghostscript executable full name:
psconvert [DEBUG]: gmt_run_process_get_first_line: Pass to popen: [gs --version 2> /dev/null]
psconvert [DEBUG]: gs --version 2> /dev/null was successful
psconvert [DEBUG]: Ghostscript version: 10.06.0

Options in PS_CONVERT are not shown in the first line of the debugging message.

The bug was originally found in #3220.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions