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

pg.meshtools.cellDataToNodeData does not take scalar fields #120

Closed
florian-wagner opened this issue Jan 4, 2018 · 0 comments
Closed

pg.meshtools.cellDataToNodeData does not take scalar fields #120

florian-wagner opened this issue Jan 4, 2018 · 0 comments

Comments

@florian-wagner
Copy link
Member

florian-wagner commented Jan 4, 2018

Problem description

pg.meshtools.cellDataToNodeData does not take scalar numpy arrays

Steps to reproduce

Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:

import pygimli as pg
import numpy as np
grid = pg.createGrid(x=[-1.0, 0.0, 1.0, 4.0], y=(-1.0, 0.0, 1.0, 4.0))
celldata = np.ones(grid.cellCount())
nodedata = pg.meshtools.cellDataToNodeData(grid, celldata)

Expected behavior

Nodes take averages of neighboring cells.

Actual behavior

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-63-6c40652ca48f> in <module>()
      1 grid = pg.createGrid(x=[-1.0, 0.0, 1.0, 4.0], y=(-1.0, 0.0, 1.0, 4.0))
      2 celldata = np.ones(grid.cellCount())
----> 3 nodedata = pg.meshtools.cellDataToNodeData(grid, celldata)

~/miniconda3/envs/agu17/lib/python3.6/site-packages/pygimli/meshtools/mapping.py in cellDataToNodeData(mesh, data, style)
     70             return pg.cellDataToPointData(mesh, data)
     71         elif mesh.dim() == 2:
---> 72             return np.array([pg.cellDataToPointData(mesh, data[:, 0]),
     73                              pg.cellDataToPointData(mesh, data[:, 1])]).T
     74         elif mesh.dim() == 3:

IndexError: too many indices for array
@florian-wagner florian-wagner changed the title pg.meshtools.cellDataToNodeData does not take scalar fields pg.meshtools.cellDataToNodeData does not take scalar fields Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant