interpolation

Interpolation/subsampling of 3D data in python without VTK

删除回忆录丶 提交于 2019-11-29 15:36:59
问题 What I want to do is rather simple but I havent found a straightforward approach thus far: I have a 3D rectilinear grid with float values (therefore 3 coordinate axes -1D numpy arrays- for the centers of the grid cells and a 3D numpy array with the corresponding shape with a value for each cell center) and I want to interpolate (or you may call it subsample) this entire array to a subsampled array (e.g. size factor of 5) with linear interpolation. All the approaches I've seen this far involve

Speeding up an interpolation exercise

纵然是瞬间 提交于 2019-11-29 15:15:16
问题 I'm running about 45,000 local linear regressions (essentially) on about 1.2 million observations, so I'd appreciate some help trying to speed things up because I'm impatient. I'm basically trying to construct year-by-position wage contracts--the function wage(experience given firm,year,position)--for a bunch of firms. Here's the data (basic structure of) set I'm working with: > wages firm year position exp salary 1: 0007 1996 4 1 20029 2: 0007 1996 4 1 23502 3: 0007 1996 4 1 22105 4: 0007

Color interpolation between 3 colors

孤街浪徒 提交于 2019-11-29 15:11:34
问题 I use the following equation to get a nice color gradient from colorA to colorB, but I have no idea how to do the same for 3 colors, so the gradient goes from colorA to colorB to colorC colorT = colorA * p + colorB * (1.0 - p); where "p" is the a percentage from 0.0 to 1.0 Thanks 回答1: Well, for 3 colors, you can just to the same with p = 0.0 to 2.0: if p <= 1.0 colorT = colorA * p + colorB * (1.0 - p); else colorT = colorB * (p - 1.0) + colorC * (2.0 - p); Or scale it so you can still use p =

Bilinear interpolation with non-aligned input points

三世轮回 提交于 2019-11-29 14:36:40
问题 I have a non-grid-aligned set of input values associated with grid-aligned output values. Given a new input value I want to find the output: (These are X,Y coordinates, calibrating an imprecise not-square eye-tracking input device to exact locations on screen.) This looks like Bilinear Interpolation, but my input values are not grid-aligned. Given an input, how can I figure out a reasonable output value? Answer : In this case where I have sets of input and output points, what is actually

How to evaluate a shell variable each time it's used

倾然丶 夕夏残阳落幕 提交于 2019-11-29 14:31:57
Related to a similar problem I'm having: zsh not re-computing my shell prompt Is there any way to define a shell variable such that its value is calculated each time its called? for example if I do: my_date="today is $(date)" The value in my_date would be: today is Thu Aug 9 08:06:18 PDT 2012 but I want the date to be executed each time my_date is used. In the linked post, somebody recommended putting the value in single quotes: my_date='today is $(date)' but never evaluates anything, it just stays literally at $(date). I'm using zsh 5.0.0 That's not possible. Use a function instead: my_date()

Scipy interpolation how to resize/resample 3x3 matrix to 5x5?

回眸只為那壹抹淺笑 提交于 2019-11-29 13:09:26
问题 EDIT: Paul has solved this one below. Thanks! I'm trying to resample (upscale) a 3x3 matrix to 5x5, filling in the intermediate points with either interpolate.interp2d or interpolate.RectBivariateSpline (or whatever works). If there's a simple, existing function to do this, I'd like to use it, but I haven't found it yet. For example, a function that would work like: # upscale 2x2 to 4x4 matrixSmall = ([[-1,8],[3,5]]) matrixBig = matrixSmall.resample(4,4,cubic) So, if I start with a 3x3 matrix

Interpolation algorithms when downscaling

半城伤御伤魂 提交于 2019-11-29 11:38:21
问题 Im trying to understand downscaling. I can see how interpolation algorithms such as bicubic and nearest neighbour can be used when when upscaling, to "fill in the blanks" between the old, known points (pixels, in case of images). But downscaling? I cant see how any interpolation technique can be used there. There are no blanks to fill! Ive been stuck with this for far to long, give me a nudge in the right direction. How do you interpolate when you, in fact, remove known data? Edit : Lets

How do I escape #{ from string interpolation

大憨熊 提交于 2019-11-29 09:34:31
I have a heredoc where I am using #{} to interpolate some other strings, but there is an instance where I also want to write the actual text #{some_ruby_stuff} in my heredoc, WITHOUT it being interpolated. Is there a way to escape the #{. I've tried "\", but no luck. Although it escapes the #{} , it also includes the "\": >> <<-END #{RAILS_ENV} \#{RAILS_ENV} END => " development \#{RAILS_ENV}\n" I think the backslash-hash is just Ruby being helpful in some irb-only way. >> a,b = 1,2 #=> [1, 2] >> s = "#{a} \#{b}" #=> "1 \#{b}" >> puts s #=> 1 #{b} >> s.size #=> 6 So I think you already have

Fastest way to get all the points between two (X,Y) coordinates in python

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 08:52:04
So I have a shapely LineString : print np.round(shapely_intersecting_lines.coords).astype(np.int) >>> array([[ 1520, -1140], [ 1412, -973]]) This can be interpreted as a numpy array as well as seen above. I want to get all the points in between, that is I want to get the points of the line in between as integer values. The output should be something like this: array([[ 1520, -1140], [ 1519, -1139], [ 1519, -1138], ..., [ 1413, -975], [ 1412, -974], [ 1412, -973]], dtype=int32) I posted this earlier in gis.stackexchange hoping there was a solution in shapely that was efficient. The solution was

Algorithm: how calculate INVERSE of bilinear interpolation?

拈花ヽ惹草 提交于 2019-11-29 07:49:28
Bilinear interpolation is trivial to compute. But I need an algorithm that does the INVERSE operation. (algorithm will be useful to me in pseudo-code, or any widely-used computer language) For example, here is a Visual Basic implementation of bilinear interpolation. ' xyWgt ranges (0..1) in x and y. (0,0) will return X0Y0, (0,1) will return X0Y1, etc. ' For example, if xyWgt is relative location within an image, ' and the XnYn values are GPS coords at the 4 corners of the image, ' The result is GPS coord corresponding to xyWgt. ' E.g. given (0.5, 0.5), the result will be the GPS coord at