Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uint8 datatype issue #1960

Closed
De-Guo opened this issue Jun 15, 2022 · 6 comments · Fixed by #1963
Closed

uint8 datatype issue #1960

De-Guo opened this issue Jun 15, 2022 · 6 comments · Fixed by #1963
Labels
enhancement Improving an existing feature
Milestone

Comments

@De-Guo
Copy link

De-Guo commented Jun 15, 2022

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.

@De-Guo De-Guo added the bug Something isn't working label Jun 15, 2022
@seisman seisman added this to the 0.7.0 milestone Jun 15, 2022
@seisman
Copy link
Member

seisman commented 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:

pip install https://github.com/GenericMappingTools/pygmt/archive/refs/heads/add-datatypes.zip

@seisman seisman added enhancement Improving an existing feature and removed bug Something isn't working labels Jun 16, 2022
@De-Guo
Copy link
Author

De-Guo commented Jun 16, 2022

Thanks, @seisman !
I got a sense of what the problem is.

@De-Guo De-Guo closed this as completed Jun 16, 2022
@De-Guo
Copy link
Author

De-Guo commented Jun 16, 2022

I havenot test the add-datatypes branch due to my python version.
ERROR: Package 'pygmt' requires a different Python: 3.7.10 not in '>=3.8

@seisman
Copy link
Member

seisman commented Jun 16, 2022

Unfortunately, we no longer support Python <= 3.7.

@seisman
Copy link
Member

seisman commented Jun 16, 2022

FYI, I have merged the PR into main branch.

@De-Guo
Copy link
Author

De-Guo commented Jun 16, 2022

Thanks for mention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants