Repository navigation
Closed
Labels
enhancementImproving an existing feature
Milestone
Description
Description of the problem
I read an image of uint8 datatype with rioxarray.open_rasterio and plot with pygmt raise errors.
If I convert datatype to float, my script runs fluently.
Full error message
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3552, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-cbda221bbf05>", line 1, in <module>
runfile('D:/NutSync/code/funcs_lib_dg/plot_func/plot_raster_pygmt.py', wdir='D:/NutSync/code/funcs_lib_dg/plot_func')
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/NutSync/code/funcs_lib_dg/plot_func/plot_raster_pygmt.py", line 307, in <module>
xrd = main()
File "D:/NutSync/code/funcs_lib_dg/plot_func/plot_raster_pygmt.py", line 301, in main
rastr_plot.plot_raster_grid(figname=figname)
File "D:/NutSync/code/funcs_lib_dg/plot_func/plot_raster_pygmt.py", line 99, in plot_raster_grid
cmap=cpt
File "C:\ProgramData\Anaconda3\lib\site-packages\pygmt\helpers\decorators.py", line 586, in new_module
return module_func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\pygmt\helpers\decorators.py", line 726, in new_module
return module_func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\pygmt\src\grdimage.py", line 173, in grdimage
fname = stack.enter_context(file_context)
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 427, in enter_context
result = _cm_type.__enter__(cm)
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\ProgramData\Anaconda3\lib\site-packages\pygmt\clib\session.py", line 1341, in virtualfile_from_grid
self.put_matrix(gmt_grid, matrix)
File "C:\ProgramData\Anaconda3\lib\site-packages\pygmt\clib\session.py", line 895, in put_matrix
raise GMTCLibError(f"Failed to put matrix of type {matrix.dtype}.")
pygmt.exceptions.GMTCLibError: Failed to put matrix of type uint8.
System information
I use pygmt 0.5.0 with python 3.7.
Metadata
Metadata
Assignees
Labels
enhancementImproving an existing feature
Activity
seisman commentedon Jun 15, 2022
@De-Guo Thanks for your issue report.
I'm working on PR #1963, which should fix the issue. It would be great if you can try that PR to see if it works for you.
To install PyGMT in that branch, you can use:
De-Guo commentedon Jun 16, 2022
Thanks, @seisman !
I got a sense of what the problem is.
De-Guo commentedon Jun 16, 2022
I havenot test the
add-datatypesbranch due to my python version.ERROR: Package 'pygmt' requires a different Python: 3.7.10 not in '>=3.8seisman commentedon Jun 16, 2022
Unfortunately, we no longer support Python <= 3.7.
seisman commentedon Jun 16, 2022
FYI, I have merged the PR into main branch.
De-Guo commentedon Jun 16, 2022
Thanks for mention!