Psconvert transparency error please downgrade gs from 9.52 to 9.50 (anaconda installation)

Hello, I recently set a pygmt environment on a new machine. I used anaconda and the version 0.3.0 package available on condaforge (conda install -c conda-forge pygmt=0.3.0).

I was running a script that uses the transparency option ( fig.grdimage(,C="shakemap_pgv_mks.cpt",t=60)) and I got the following warning:
psconvert [WARNING]: Input file has transparency but your gs version 9.52 has a bug preventing it - please downgrade to 9.50

And sure enough the transparency option was ignored and the plot was generated without the required transparency.

My question is how can I downgrade gmt (and thus psconvert) to an older version that supports the transparency option?

I tried conda install -c conda-forge gmt=6.1.1 but I still get the same error.

This will reproduce the error (if you create an fresh anaconda enviroment using the current version 0.3.0 of gmt in anaconda forge).

import pygmt 
import pandas as pd
import xarray as xr
import numpy as np

### constants
sw4origin = (39.3058,-120.0052)
#sw4Xlength,sw4Ylength = 34000,34000 #in meters
#figure out the end of my region based on these dimenstions
#sw4OriginUTM = utm.from_latlon(sw4origin[0],sw4origin[1],11,"N")
#sw4EndX,sw4EndY = sw4OriginUTM[1]+sw4Xlength,sw4OriginUTM[0]+sw4Ylength
sw4EndLat,sw4EndLong = (39.62135044626656, -119.62277186293804)
region = [-120.0052,sw4EndLong,39.3058,sw4EndLat]
lat0,lon0=(39.310047, -119.999954)
latend,lonend = (39.610416, -119.61958)

### generate 2 fake xarrays
sampleXarray = np.zeros(shape=(128,145),dtype=np.float32)
for i in range(sampleXarray.shape[0]):
    for j in range(sampleXarray.shape[1]):
        sampleXarray[i,j] = i+j
underlayedXarray = np.copy(sampleXarray)
sampleXarray = np.abs(np.sin(sampleXarray))
#correctly georeference these fake xarray
xcoords = np.arange(lat0,latend,(latend-lat0)/sampleXarray.shape[0])
ycoords = np.arange(lon0,lonend,(lonend-lon0)/sampleXarray.shape[1])
dims = ['x','y']
coords = {"x":xcoords,"y":ycoords}
sampleXarray = xr.DataArray(sampleXarray,dims=dims,coords=coords)
underlayedXarray = xr.DataArray(underlayedXarray,dims=dims,coords=coords)

#attempt to plot, show that transparency is ignored
fig = pygmt.Figure()
fig.basemap(region=region,projection="M8i", frame=True)
#plot the underlying xarray (in my real problem this would be my hillshade)

pygmt.makecpt(cmap="viridis", series=[0.0, np.max(], continuous=True)
fig.grdimage(sampleXarray, C=True, t=60)

Thank You,

Hi @firstkingofrome, thanks for trying out PyGMT! Are you on Windows/macOS/Linux, also could you please provide the output of pygmt.show_versions() (after import pygmt)? That will help us to debug things better.

The latest version of PyGMT is actually 0.3.1 (not 0.3.0), and you can probably upgrade ghostscript to v9.53.3 rather than downgrading. I.e. try conda install -c conda-forge pygmt=0.3.1 ghostscript=9.53.3 . Let us know if that works :smile:

1 Like

Hey thank you that fixed it! (I had this problem on SUSE Linux Enterprise Server 15), interestingly the anaconda recipe works fine on my CENTOS desktop (without the ghost script modification).