Skip to content

blockmedian fails with x,y,z options and not table. #1351

Closed

Description

@leonfoks

Description of the problem
Im trying to use block median before surface and I want to specify x, y, z instead of casting into a dataframe or other format.
I'm looking at the docs here which state this is possible.

It would be good to have examples in the documentation for the block filtering and surface methods (as a side note :) )
Thanks in advance for your help!

Full code that generated the error

import numpy as np
from pygmt import blockmedian
x = np.random.randn(10000)
y = np.random.randn(10000)
z = np.random.randn(10000)

pd = blockmedian(x=x, y=y, z=z, I=(0.1, 0.1), R=[-4, 4])

Full error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<path>/pygmt/helpers/decorators.py", line 288, in new_module
    return module_func(*args, **kwargs)
  File "<path>/pygmt/helpers/decorators.py", line 432, in new_module
    return module_func(*args, **kwargs)
TypeError: blockmedian() missing 1 required positional argument: 'table'

System information

Please paste the output of python -c "import pygmt; pygmt.show_versions()":

PyGMT information:
  version: v0.3.1
System information:
  python: 3.8.10 | packaged by conda-forge | (default, May 11 2021, 06:39:48)  [Clang 11.1.0 ]
  executable: <path>/bin/python
  machine: macOS-10.14.6-x86_64-i386-64bit
Dependency information:
  numpy: 1.20.3
  pandas: 1.2.4
  xarray: 0.18.2
  netCDF4: 1.5.6
  packaging: 20.9
  ghostscript: 9.54.0
  gmt: 6.1.1
GMT library information:
  binary dir: <path>/bin
  cores: 8
  grid layout: rows
  library path: <path>/lib/libgmt.dylib
  padding: 2
  plugin dir: <path>/lib/gmt/plugins
  share dir: <path>/share/gmt
  version: 6.1.1

Activity

  1. added
    bug
    on Jun 23, 2021
  2. weiji14 commented on Jun 23, 2021

    @weiji14
    Member

    Hi @leonfoks, the xyz input into pygmt.blockmedian is a feature available in PyGMT v0.4.0 (done in #1319), but it appears that you have PyGMT v0.3.1 installed. Could you try upgrading and see if it works?

    It would be good to have examples in the documentation for the block filtering and surface methods (as a side note :) ) Thanks in advance for your help!

    And yes, agree that we should have some examples for those methods. Would you prefer a full tutorial or just a gallery example? I did make a blockmedian/surface example a while ago at a workshop (see https://github.com/GenericMappingTools/foss4g2019oceania/blob/v1/3_lidar_to_surface.ipynb) but definitely should have it in the PyGMT docs somewhere for better visibility.

  3. leonfoks commented on Jun 23, 2021

    @leonfoks
    Author

    Hi @weiji14 , Another easy one from me. Thanks for the quick response. I updated and it's working just fine!

    Personally, I think a gallery example would suffice. Perhaps containing a surface example, then a surface example that produces the block median warning message and finally use of the block median to reduce and then use surface, showing that the images look visually the same before and after reduction.
    Great link to the lidar example, I would parse that down a little for the gallery but the data would be a good set.

    Thanks again!

  4. added
    wontfix
    and removed
    bug
    on Jun 23, 2021
  5. weiji14 commented on Jun 23, 2021

    @weiji14
    Member

    Hi @weiji14 , Another easy one from me. Thanks for the quick response. I updated and it's working just fine!

    No worries :)

    Personally, I think a gallery example would suffice. Perhaps containing a surface example, then a surface example that produces the block median warning message and finally use of the block median to reduce and then use surface, showing that the images look visually the same before and after reduction.
    Great link to the lidar example, I would parse that down a little for the gallery but the data would be a good set.

    Ok, I'll open a separate issue for this documentation suggestion, and maybe someone will work on it for the upcoming SciPy sprint in July.

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

    wontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions