Skip to content

uint8 datatype issue #1960

Closed
Closed

Description

@De-Guo

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.

Activity

  1. added
    bug
    on Jun 15, 2022
  2. added this to the 0.7.0 milestone on Jun 15, 2022
  3. seisman commented on Jun 15, 2022

    @seisman
    Member

    @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
    
  4. added
    enhancement
    and removed
    bug
    on Jun 16, 2022
  5. De-Guo commented on Jun 16, 2022

    @De-Guo
    Author

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

  6. De-Guo commented on Jun 16, 2022

    @De-Guo
    Author

    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

  7. seisman commented on Jun 16, 2022

    @seisman
    Member

    Unfortunately, we no longer support Python <= 3.7.

  8. seisman commented on Jun 16, 2022

    @seisman
    Member

    FYI, I have merged the PR into main branch.

  9. De-Guo commented on Jun 16, 2022

    @De-Guo
    Author

    Thanks for mention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions