GithubHelp home page GithubHelp logo

Comments (2)

banesullivan avatar banesullivan commented on June 19, 2024

@lperozzi, this is an easy fix! The spatial reference of all meshes must be explicit - there cannot be any NaN values when it comes to the mesh's location in space.

NaN values are appropriate when it comes to describing that you do not have data at a given location on the mesh - so it would be more appropriate for you to define your mesh like so...

import pandas as pd
import omf
import omfvista
import pyvista as pv
import numpy as np

base_quaternary_df = pd.read_csv('mod_base_quaternary_300_nan.txt')
base_quaternary_df.head()

x = base_quaternary_df['x'].values
y = base_quaternary_df['y'].values
z = np.zeros_like(x)
# simply pass the numpy points to the PolyData constructor
cloud = pv.PolyData(np.c_[x,y,z])
# Add data values onto the mesh nodes
cloud['my data'] = base_quaternary_df['z'].values
             x             y   z
0  633025.9964  5.821552e+06 NaN
1  633325.9964  5.821552e+06 NaN
2  633625.9964  5.821552e+06 NaN
3  633925.9964  5.821552e+06 NaN
4  634225.9964  5.821552e+06 NaN
# Make a surface using the delaunay filter
surf = cloud.delaunay_2d()
surf.plot()

download

# Now warp by a scalar to have a more realistic surface
# Note the scaling factor that exagerates the surface
warped = surf.warp_by_scalar(factor=5.0)
warped.plot()

download

Then you could make an OMF object like:

# Create an OMF element that can be saved out
tris = warped.faces.reshape(surf.n_cells, 4)[:, 1:4]
base_quaternary_omf = omf.SurfaceElement(
    name='My Surface',
    description='This is a decription of "My Surface"',
    geometry=omf.SurfaceGeometry(vertices=warped.points,
                                 triangles=tris),
    data=[
        omf.ScalarData(
            name='My awesome data',
            array=np.array(surf['my data']),
            location='vertices'
        ),
    ],

    )
base_quaternary_omf.validate()

# Sanity check
omfvista.wrap(base_quaternary_omf).plot(notebook=False)

download

from pyvista-support.

banesullivan avatar banesullivan commented on June 19, 2024

Please note the scaling factor when I call:

warped = surf.warp_by_scalar(factor=5.0)

You likely do not want this and actually want:

warped = surf.warp_by_scalar()

from pyvista-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.