interpolation

RBF interpolation: LinAlgError: singular matrix

末鹿安然 提交于 2019-12-06 01:02:49
问题 The following call: rbf = Rbf(points[0], points[1], values,epsilon=2) results in an error: LinAlgError: singular matrix with the following values: In [3]: points Out[3]: (array([71, 50, 48, 84, 71, 74, 89, 76, 70, 77, 74, 79, 83, 71, 72, 78, 73, 84, 75, 65, 73, 82, 48, 86, 74, 86, 66, 74, 68, 74, 81, 74, 88, 66, 57, 50, 72, 86, 72, 92, 81, 67, 82, 78, 69, 70, 73, 71, 76, 72, 74, 75]), array([32, 34, 4, 35, 1, 7, 47, 16, 37, 14, 65, 18, 32, 4, 3, 27, 25, 34, 18, 25, 6, 25, 34, 41, 16, 35, 44,

Python: interpolating in a triangular mesh

孤街浪徒 提交于 2019-12-06 00:57:37
Is there any decent Pythonic way to interpolate in a triangular mesh, or would I need to implement that myself? That is to say, given a (X,Y) point we'll call P, and a mesh (vertices at (X,Y) with value Z, forming triangular facets), estimate the value at P. So that means first find the facet that contains the point, then interpolate - ideally a higher order interpolation than just "linearly between the facet's vertices" (i.e., taking into account the neighboring facets)? I could implement it myself, but if there's already something available in Python.... (I checked scipy.interpolate, but its

Interpolating data from one latitude-longitude grid onto a different one?

守給你的承諾、 提交于 2019-12-06 00:45:02
I have two data arrays that are on lat-lon grids. The first one, A, has the shape (89, 180). The second one, B, has the shape (94, 192). A's latitudes are in descending order from 88. to -88. & longitudes are in ascending order from 0. to 358. B's latitudes are in descending order from 88.54199982 to -88.54199982 & longitudes are in ascending order from 0. to 358.125. I want to regrid/interpolate B's data onto A's coordinate system so that I can get both arrays the same size and calculate the spatial correlation between them. (I can also regrid/interpolate A's data onto B's coordinate system

How to use griddata from scipy.interpolate

↘锁芯ラ 提交于 2019-12-06 00:32:25
问题 I have a three-column (x-pixel, y-pixel, z-value) data with one million lines. The data is from an image and there are duplicated z-values. Now I need to make a surface plot. This image is a perfect example. But now the output image is null. Could someone check the code please? import numpy as np from enthought.mayavi import mlab from scipy.interpolate import griddata x,y,z = np.loadtxt('test.csv',delimiter=',',usecols=(0,1,2),unpack=True) xi,yi = np.mgrid[0:3000:3000j, 0:3000:3000j] zi =

Pandas: interpolation where first and last data point in column is NaN

走远了吗. 提交于 2019-12-05 22:51:08
I would like to use the interpolate function, but only between known data values in a pandas DataFrame column. The issue is that the first and last values in the column are often NaN and sometimes it can be many rows before a value is not NaN: col 1 col 2 0 NaN NaN 1 NaN NaN ... 1000 1 NaN 1001 NaN 1 <----- 1002 3 NaN <----- only want to fill in these 'in between value' rows 1003 4 3 ... 3999 NaN NaN 4000 NaN NaN I am tying together a dataset which is updated 'on event' but separately for each column, and is indexed via Timestamp. This means that there are often rows where no data is recorded

Bicubic Interpolation on Scattered Data in Matlab

对着背影说爱祢 提交于 2019-12-05 22:05:03
I was wondering if there is a way to do bicubic interpolation on a scattered data set (2d)? I did some online searches and figured out that bicubic patches (not sure what these are) need to be fitted on scattered data. Not sure how to proceed from here. Any help will be appreciated! Note: I understand that Matlab recommends TriScatteredInterp and griddata to interpolate on scattered points. However, TriScatteredInterp is a triangulation interpolation and does not uses splines to interpolate the data. The data which I have looks something like this (x, y, val): x = [0 0 0 0 0.28 0.28 0.28 0.28

How can I interpolate between 2 points when drawing with canvas?

血红的双手。 提交于 2019-12-05 21:59:58
I have a paint-style application that works with touch events. The JavaScript code is... var RADIUS = 10; var ctx = document.querySelector("canvas").getContext("2d"); var getRandomColorFragment = function () { return Math.floor(Math.random() * 255); }; document.body.addEventListener("touchstart", function (event) { ctx.fillStyle = "rgb(" + [getRandomColorFragment(), getRandomColorFragment(), getRandomColorFragment()].join() + ")"; }); document.body.addEventListener("touchmove", function (event) { // Prevent default behavior of scrolling elements. event.preventDefault(); // Get a reference to

How do I create a new scale() function in d3.js? I would like to create a cumulative distribution function

删除回忆录丶 提交于 2019-12-05 21:20:02
How do I create my own scale() function in d3? I am trying to replace the nice linear scale in d3 d3.scale.linear() with a different function that I would like to create myself. My new scale would be based on a cumulative distribution function, so that the median value would appear in the center of the x axis, and a value that was two standard deviations from the median would appear twice as far from the center of the x axis as something that was one standard deviation from the mean. Here is a link to my jsfiddle page: http://jsfiddle.net/tbcholla/kR2PS/3/ (I would appreciate any other

What is the algorithm used to interpolate in Matlab's imresize function?

て烟熏妆下的殇ゞ 提交于 2019-12-05 20:01:04
I am using the Matlab/Octave imresize() function which resamples a given 2D array. I want to understand how a particular interpolation algorithm used in imresize works. (I am using octave on windows) e.g. A = 1 2 3 4 is a 2D array. Then I use the command b=imresize(a,2,'linear'); basically upsampling row and columns by 2. The output is 1.0000 1.3333 1.6667 2.0000 1.6667 2.0000 2.3333 2.6667 2.3333 2.6667 3.0000 3.3333 3.0000 3.3333 3.6667 4.0000 I don't understand how this linear interpolation is working. It is said to use bi linear interpolation, but how does it pad the data at boundaries and

linear interpolation between two data points

旧街凉风 提交于 2019-12-05 19:53:16
I have two data points x and y : x = 5 (value corresponding to 95%) y = 17 (value corresponding to 102.5%) No I would like to calculate the value for xi which should correspond to 100%. x = 5 (value corresponding to 95%) xi = ?? (value corresponding to 100%) y = 17 (value corresponding to 102.5%) How should I do this using python? MaxU is that what you want? In [145]: s = pd.Series([5, np.nan, 17], index=[95, 100, 102.5]) In [146]: s Out[146]: 95.0 5.0 100.0 NaN 102.5 17.0 dtype: float64 In [147]: s.interpolate(method='index') Out[147]: 95.0 5.0 100.0 13.0 102.5 17.0 dtype: float64 Tim We can