interpolation

Best way to interpolate a numpy.ndarray along an axis

我们两清 提交于 2019-12-04 21:07:18
问题 I have 4-dimensional data, say for the temperature, in an numpy.ndarray . The shape of the array is (ntime, nheight_in, nlat, nlon) . I have corresponding 1D arrays for each of the dimensions that tell me which time, height, latitude, and longitude a certain value corresponds to, for this example I need height_in giving the height in metres. Now I need to bring it onto a different height dimension, height_out , with a different length. The following seems to do what I want: ntime, nheight_in,

inverse distance weighting interpolation

核能气质少年 提交于 2019-12-04 20:34:19
I would like to compute a weight as reciprocal of a distance for something like inverse distance weighting interpolation . double wgt = 0, wgt_tmp, result = 0; for (int i = 0; i < num; i++) { wgt_tmp = 1.0/dist[i]; wgt += wgt_tmp; result += wgt_tmp * values[i]; } results /= wgt; However the distance can be 0 and I need to make the weight suitable for computation. If there is only one distance dist[i] is 0 , I would like its corresponding value values[i] to be dominant . If there are several distances are 0 , I would like to have their values to contribute equally to the result. Also even if

Fix interpolated polar contour plot function to works with current R and (possibly) use ggplot

有些话、适合烂在心里 提交于 2019-12-04 20:02:23
The question R interpolated polar contour plot shows an excellent way to produce interpolated polar plots in R. I include the very slightly modified version I'm using: PolarImageInterpolate <- function( ### Plotting data (in cartesian) - will be converted to polar space. x, y, z, ### Plot component flags contours=TRUE, # Add contours to the plotted surface legend=TRUE, # Plot a surface data legend? axes=TRUE, # Plot axes? points=TRUE, # Plot individual data points extrapolate=FALSE, # Should we extrapolate outside data points? ### Data splitting params for color scale and contours col_breaks

Matplotlib: Data cubic interpolation (or FIT) for Contour plot

浪子不回头ぞ 提交于 2019-12-04 19:45:33
I have a series of data from device. How can i make cubic interpolation or FIT for this plot? import matplotlib.pyplot as plt a = [[1,1,1],[2,2,2],[3,3,3]] b = [[1,2,3],[1,2,3],[1,2,3]] c = [[3,2,1],[1,4,2],[4,5,1]] fig1 = plt.figure() ax1 = fig1.add_subplot(111) fig1.set_size_inches(3.54,3.54) #Create Contour plot contour=ax1.contour(a,b,c) plt.show() Saullo G. P. Castro You can adapt @Joe Kington's suggestion and use scipy.ndimage.zoom which for your case of a cubic interpolation fits perfectly: import matplotlib.pyplot as plt import numpy as np from scipy.ndimage import zoom from mpl

Rails 3, Paperclip - Custom Interpolations

不羁的心 提交于 2019-12-04 18:41:19
问题 I've been having some troubles making custom Interpolation, gone through every example I could find on web, but no matter what I did, had no success. At the moment I have this: Model has_attached_file :photo, :path => ":rails_root/public/images/:img_name-:style.:extension", :styles => { :original => '100x100', :thumb => '30x30' } initializers/paperclip.rb Paperclip.interpolates :img_name do |attachment, style| attachment.instance.img_name end img_name is field populated in form on upload with

How to do bilinear interpolation of normals over a quad?

喜欢而已 提交于 2019-12-04 18:14:56
问题 I'm working on a Minecraft-like engine as a hobby project to see how far the concept of voxel terrains can be pushed on modern hardware and OpenGL >= 3. So, all my geometry consists of quads, or squares to be precise. I've built a raycaster to estimate ambient occlusion, and use the technique of "bent normals" to do the lighting. So my normals aren't perpendicular to the quad, nor do they have unit length; rather, they point roughly towards the space where least occlusion is happening, and

Image Processing Issue: Fill NaNs in image, which mostly consists of NaNs

大兔子大兔子 提交于 2019-12-04 17:25:16
I have a dataset / image DD like the one in this image: (by the way: is there a way of uploading small data sets here, so that you can actually work with the same data I use, without having to put them in the code?) Colored pixels in the image represent height/depth ranging from 0 to about 400 meters. Blue pixels are NaN . Now what I need to do is to interpolate the pixel values WITHIN the displayed object, but without interpolating the whole image. I tried using the function inpaint_nans from the file-exchange, which has helped me quite often and again, it did a decent job: imagesc(inpaint

Finding 3 dimentional B-spline controll points from given array of points from spline solution?

好久不见. 提交于 2019-12-04 16:21:27
Wa are talking about Non-uniform rational B-spline . We have some simple 3 dimentional array like {1,1,1} {1,2,3} {1,3,3} {2,4,5} {2,5,6} {4,4,4} Which are points from a plane created by some B-spline How to find controll points of spline that created that plane? (I know its a hard task because of weights that need to be calculated but I really hope it is solvable) For thouse who did not got idea of question - sory my writting is wwbad - we have points that are part of plane rendered here and we need to find controll points that form a spline which solution is that rendered plane. There are

Scala2.10新特性之 String Interpolation

你。 提交于 2019-12-04 14:28:14
String Interpolation http://docs.scala-lang.org/overviews/core/string-interpolation.html 2013-1-7 (英语四级未过,借助各种词典、翻译,历时两个晚上,终于翻译完了,如有翻译错误或用词不当,欢迎指正) 介绍 从 Scala2.10.0 开始,Scala提供一个新的机制,通过你的数据创建字符串:字符串插值(String Interpolation)。它允许用户将变量的引用直接嵌入到处理字符串字面量(processed string literals)中。例如: val name = "James" println(s"Hello, $name") // Hello, James 上文中,s"Hello, $name"是一个处理字符串字面量,这意味着编译器做了一些额外的工作。处理字符串字面量被表示为一个在"(双引号)之前的字符集合(原文:A processed string literal is denoted by a set of characters precedding the ". 这句没太看懂) 用法 Scala提供了三个开箱即用的字符串插入方法:s,f和raw 插值器s 在任何字符串字面量前追加s,这个字符串就允许直接包含变量。前面已经看过示例。 在示例中,

Interpolate function using Apache Commons Math

房东的猫 提交于 2019-12-04 13:28:58
I'm trying to implement some Interpolation functions to plot some values where the X value = Date.seconds and the Y value = double. I'v been researching using the Apache Commons Math lib to achieve this and I've found a method I think I might be able to use here The method I'm trying to understand: public double linearInterp(double[] x, double[] y, double xi) { // return linear interpolation of (x,y) on xi LinearInterpolator li = new LinearInterpolator(); PolynomialSplineFunction psf = li.interpolate(x, y); double yi = psf.value(xi); return yi; } I don't understand where I'm supposed to get