Repository navigation
Closed
Labels
enhancementImproving an existing feature
Milestone
Description
Description of the problem
Screen Errors when I try a fig.savefig when using filenames with a ".ps" extension ; same savefig works fine with 'eps' extension or 'png' extension
Full code that generated the error
#!/usr/bin/python3
import pygmt
fig = pygmt.Figure()
region = [176.5, 178.7, -39.8, -38.05]
print(region)
fig.basemap(region=region, projection="M4i", frame=True)
fig.coast(land="grey", water="azure1",shorelines=True)
fig.savefig("trythis_pygmt_map.ps")Full error message
(pygmt) [stephen@akatea autogps]$ python example.py
[176.5, 178.7, -39.8, -38.05]
Traceback (most recent call last):
File "example.py", line 11, in <module>
fig.savefig("trythis_pygmt_map.ps")
File "/sp/prj/tvz95/mypython8_pip_python3p6_pygmt/pygmt/figure.py", line 211, in savefig
raise GMTInvalidInput("Unknown extension '.{}'".format(ext))
pygmt.exceptions.GMTInvalidInput: Unknown extension '.ps'
System information
- Operating system: Linux
- Python installation (Anaconda, system, ETS): Anaconda
- Version of GMT: 6.0
- Version of Python: 3.6
- Version of this package:
"date": "2019-03-25T11:59:11-1000",
"full-revisionid": "5b8c6590ea7031c4e2a708d0dd94c1ec363bc198",
"version": "0.0.1a0+25.g5b8c659"
- If using conda, paste the output of
conda listbelow:
output of conda list
# # Name Version Build Channel asn1crypto 0.24.0 py36_1003 conda-forge basemap 1.2.0 py36h673bf1a_2 conda-forge ca-certificates 2019.3.9 hecc5488_0 conda-forge certifi 2019.3.9 py36_0 conda-forge cffi 1.12.2 py36hf0e25f4_1 conda-forge chardet 3.0.4 py36_1003 conda-forge cryptography 2.6.1 py36h72c5cf5_0 conda-forge cycler 0.10.0 py_1 conda-forge dbus 1.13.2 h714fa37_1 decorator 4.4.0 py_0 conda-forge expat 2.2.5 hf484d3e_1002 conda-forge fontconfig 2.13.1 he4413a7_1000 conda-forge freetype 2.10.0 he983fc9_0 conda-forge future 0.17.1 py36_1000 conda-forge geos 3.7.1 hf484d3e_1000 conda-forge gettext 0.19.8.1 hc5be6a0_1002 conda-forge glib 2.56.2 had28632_1001 conda-forge gst-plugins-base 1.14.0 hbbd80ab_1 gstreamer 1.14.0 hb453b48_1 icu 58.2 hf484d3e_1000 conda-forge idna 2.8 py36_1000 conda-forge jpeg 9c h14c3975_1001 conda-forge kiwisolver 1.0.1 py36h6bb024c_1002 conda-forge libblas 3.8.0 4_openblas conda-forge libcblas 3.8.0 4_openblas conda-forge libffi 3.2.1 he1b5a44_1006 conda-forge libgcc-ng 8.2.0 hdf63c60_1 libgfortran 3.0.0 1 conda-forge libgfortran-ng 7.3.0 hdf63c60_0 libiconv 1.15 h516909a_1005 conda-forge liblapack 3.8.0 4_openblas conda-forge libpng 1.6.36 h84994c4_1000 conda-forge libstdcxx-ng 8.2.0 hdf63c60_1 libtiff 4.0.10 h648cc4a_1001 conda-forge libuuid 2.32.1 h14c3975_1000 conda-forge libxcb 1.13 h14c3975_1002 conda-forge libxml2 2.9.8 h143f9aa_1005 conda-forge libxslt 1.1.32 h4785a14_1002 conda-forge lxml 4.3.3 py36h7ec2d77_0 conda-forge matplotlib 3.0.3 py36_0 conda-forge matplotlib-base 3.0.3 py36h167e16e_0 conda-forge ncurses 6.1 hf484d3e_1002 conda-forge numpy 1.16.2 py36h8b7e671_1 conda-forge obspy 1.1.1 py36h3010b51_0 conda-forge olefile 0.46 py_0 conda-forge openblas 0.3.5 ha44fe06_0 conda-forge openssl 1.1.1b h14c3975_1 conda-forge packaging 19.0 py_0 conda-forge pandas 0.24.2 py36hf484d3e_0 conda-forge pcre 8.43 he6710b0_0 pillow 6.0.0 py36he7afcd5_0 conda-forge pip 19.0.3 py36_0 conda-forge proj4 4.9.3 h470a237_8 conda-forge pthread-stubs 0.4 h14c3975_1001 conda-forge pycparser 2.19 py36_1 conda-forge pyopenssl 19.0.0 py36_0 conda-forge pyparsing 2.3.1 py_0 conda-forge pypdf2 1.26.0 py_2 conda-forge pyproj 1.9.5.1 py36h2944ce7_1006 conda-forge pyqt 5.6.0 py36h13b7fb3_1008 conda-forge pyshp 2.1.0 py_0 conda-forge pysocks 1.6.8 py36_1002 conda-forge python 3.6.7 h381d211_1004 conda-forge python-dateutil 2.8.0 py_0 conda-forge pytz 2018.9 py_0 conda-forge qt 5.6.3 h8bf5577_3 readline 7.0 hf8c457e_1001 conda-forge reportlab 3.5.17 py36h7d98c4e_0 conda-forge requests 2.21.0 py36_1000 conda-forge scipy 1.2.1 py36h09a28d5_1 conda-forge setuptools 40.8.0 py36_0 conda-forge sip 4.18.1 py36hf484d3e_1000 conda-forge six 1.12.0 py36_1000 conda-forge sqlalchemy 1.3.2 py36h516909a_0 conda-forge sqlite 3.26.0 h67949de_1001 conda-forge tk 8.6.9 h84994c4_1001 conda-forge tornado 6.0.2 py36h516909a_0 conda-forge urllib3 1.24.1 py36_1000 conda-forge wheel 0.33.1 py36_0 conda-forge xarray 0.12.0 py_0 conda-forge xorg-libxau 1.0.9 h14c3975_0 conda-forge xorg-libxdmcp 1.1.3 h516909a_0 conda-forge xz 5.2.4 h14c3975_1001 conda-forge zlib 1.2.11 h14c3975_1004 conda-forge
Metadata
Metadata
Assignees
Labels
enhancementImproving an existing feature
Activity
welcome commentedon Apr 5, 2019
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.
[-]savefig failed for .ps extension , ok for other extensions[/-][+]Figure.savefig should support postscript format[/+]leouieda commentedon Apr 24, 2019
👋 Hi @iceseismic thanks for reporting. This is a limitation on how the new GMT modern mode operates (this is the basis for pygmt). The postscript is built in the background by GMT and only finalized and given to the user when
psconvertis called or the session ends. The way we've structured PyGMT makes it impossible to get the underlying ps file (it will be incomplete).Is this something you really need? I've converted this into a feature request so we can keep track and maybe try to think of a way to do it.
PS: Thanks for completely filling out the template 🥇 You'd be surprised how many people completely ignore it.
iceseismic commentedon Apr 24, 2019
No worries - thanks for the explanation ; personally I would only need the postscript available when psconvert is called.
leouieda commentedon Apr 24, 2019
OK, good to know @iceseismic. That was our thinking as well in the design of GMT 6. Most people only care about png and pdf and only use the ps as an intermediate state.
3 remaining items
seisman commentedon May 27, 2021
Here is a minimal Python script to reproduce the issue:
Currently, PyGMT raises the following error:
If I change "map.ps" to "map.pdf", the equivalent GMT CLI calls are:
So, is there a possibility to allow "psconvert" to output the PS file? @PaulWessel
PaulWessel commentedon May 27, 2021
Hm, we do this in GMT somehow. Looking at function process_figures in gmt_init.c it looks like you need to avoid passing -A for PostScript output but we do pass -Tp for PostScript.
PaulWessel commentedon May 27, 2021
Also, I do not know where the "Unknown extension" message comes from - I cannot find it in the GMT source code?
seisman commentedon May 27, 2021
So, -Tp is an undocumented feature in GMT.
Changing -Tf to -Tp and removing -A, I can get the PS file, but it's incorrectly "cropped" due to the larger origin shifts in modern mode. See the screenshot below:
The "Unknown extension" message is from PyGMT, not GMT.
PaulWessel commentedon May 27, 2021
The 5 inch shift is only imposed for non-PS plots but not sure how that works in Pygmt. If we run something like this:
gmt basemap -R0/40/0/40 -JM6i -B -ps t -Vthen I get these messages
since I did not specifically ran gmt set or used PS_MEDIA. This also means margin is left at 1 inch and not set to 5. All this happens in gmt_plotinit. Since you pass - instead of ps to gmt figure then I suspect it does not know yet that you are doing PS.
PaulWessel commentedon May 27, 2021
The alternative answer is to convince anyone who wants to get a PS file that they are wrong and should get an EPS or PDF. PS serves no useful purpose as far as I know.
seisman commentedon May 27, 2021
OK. EPS also works for me.
I think for PyGMT, we should at least update the warning message to recommend ".eps" or ".pdf" when ".ps" is requested.
EJFielding commentedon May 27, 2021
Yes, recommending
.epsor.pdfsounds like the best plan to me.