analogy to scipy.interpolate.griddata?

2024/11/16 16:22:17

I want to interpolate a given 3D point cloud:

I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]].

But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.*

So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud?

*edit: "no grid look" means my input looks like this:

x = [0,4,17]
y = [-7,25,116]
z = [50,112,47]
Answer

This is a function I use for this kind of stuff:

from numpy import linspace, meshgriddef grid(x, y, z, resX=100, resY=100):"Convert 3 column data to matplotlib grid"xi = linspace(min(x), max(x), resX)yi = linspace(min(y), max(y), resY)Z = griddata(x, y, z, xi, yi)X, Y = meshgrid(xi, yi)return X, Y, Z

Then use it like this:

  X, Y, Z = grid(x, y, z)
https://en.xdnf.cn/q/71325.html

Related Q&A

Mongodb TTL expires documents early

I am trying insert a document into a Mongo database and have it automatically expire itself after a predetermine time. So far, my document get inserted but always get deleted from the database from 0 -…

sqlalchemy, hybrid property case statement

This is the query Im trying to produce through sqlalchemySELECT "order".id AS "id", "order".created_at AS "created_at", "order".updated_at AS "u…

Whats the newest way to develop gnome panel applets (using python)

Today Ive switched to GNOME (from XFCE) and found some of the cool stuff missing and I would like to (try to) do them on my own. I tried to find information on how to develop Gnome applets (items you p…

How to install opencv-python in python 3.8

Im having problem during the installation of opencv-python in pycharm. After opening pycharm I click on settings and then project interpreter, I click on + and search for the correct module, I started …

python augmented assignment for boolean operators

Does Python have augmented assignment statements corresponding to its boolean operators?For example I can write this:x = x + 1or this:x += 1Is there something I can write in place of this:x = x and yT…

Change a pandas DataFrame column value based on another column value

I have a dataframe with two columns each of which represents an organism. They are called ORG1 and ORG2 I want to move the values of ORG2 into ORG1 for the corresponding index value.So, if ORG1 is A a…

How to lock a sqlite3 database in Python?

Is there a way to explicitly acquire a lock on a sqlite3 database in Python?

How to install pyzmq on an Alpine Linux container?

I have a container with the python:3.6-alpine kernel. I have a problem installing the pyzmq via pip on this: Dockerfile: FROM python:3.6-alpineRUN mkdir /code RUN apk add vim WORKDIR / ADD . /codedocke…

How to Get Value Out from the Tkinter Slider (Scale)?

So, here is the code I have, and as I run it, the value of the slider bar appears above the slider, I wonder is there a way to get that value out? Maybe let a=that value. ;)from Tkinter import *contr…

Python cassandra-driver OperationTimeOut on every query in Celery task

I have a problem with every insert query (little query) which is executed in celery tasks asynchronously. In sync mode when i do insert all done great, but when it executed in apply_async() i get this:…