interpolation

bounded circular interpolation in python

别等时光非礼了梦想. 提交于 2020-01-21 04:37:04
问题 My question is something similar to the question here. In simple term I have a time series angle data which is bounded between [0, 360]. I need to compute an iterpolation between measurements. Currently, I am using scipy.interpolate.interp1d. To make my question clear here is an example, import numpy as np from scipy import interpolate data = np.array([[0, 2, 4], [1, 359, 1]]) # first row time index, second row angle measurements f = interpolate.interp1d(data[0, :], data[1, :], kind='linear',

In bash, how do I execute the contents of a variable, VERBATIM, as though they were a command line?

耗尽温柔 提交于 2020-01-17 04:25:12
问题 I need to construct a complex command that includes quoted arguments. As it happens, they are arguments to grep, so I'll use that as my example and deeply simplify the command to just enough to demonstrate the error. Let's start with a working example: > COMMAND='/usr/bin/grep _' > echo $COMMAND /usr/bin/grep _ > $COMMAND foo <- I type this, and grep filters it out. foo_ <- I type this, and..... foo_ <- ... it matches, so grep emits it. "foo" is not echoed back because it lacks an underscore,

Interpolation Search, searching on a descending array

拈花ヽ惹草 提交于 2020-01-16 19:45:08
问题 I want to modify this algorithm so that it can find values within an array which has been sorted in descending order. This currently only works for ascending. public static int interpo(double[] array, double key, int order) { int low = 0, high = array.Length - 1; int pos = 0; int count = 0; while ((low <= high) && (key >= array[low]) && (key <= array[high])) { count++; pos = Convert.ToInt32(low + (high - low) / (array[high] - array[low]) * (key - array[low])); if (array[pos] == key) { //

Convert Scatter to Contour, every dot turns into a highland

╄→尐↘猪︶ㄣ 提交于 2020-01-16 09:11:31
问题 How to build a Contour plot (specifically, topographic map) based on a Scatter plot, so that every scatter dot is converted into a circular area being the highest one in a given radius , i.e., any adjoining area is lower than the original dot’s area? On the exemplary image, the yellow adjoining area is lower than the highland #6. Note, I am not trying to build a data density plot. All input scatter dots are higher than the green grass level. I tried to interpolate the x, y, and z coordinates

Cannot cast array data from dtype('<M8[ns]') to dtype('float64') according to the rule 'safe'

对着背影说爱祢 提交于 2020-01-15 06:35:07
问题 I am using numpy interp to interpolate datapoint but was given Cannot cast array data from dtype(' Code snippet: import pandas as pd import numpy as np def interpolate_fwd_price(row, fx): res = np.interp(row['SA_M'], fx['TENOR_DT'], fx['RATE']) return res df = pd.DataFrame({'SA_M': ['2018-02-28','2018-03-10']}) df['SA_M'] = pd.to_datetime(df['SA_M']) data = pd.DataFrame({'TENOR_DT': ['2017-02-09','2017-03-02','2017-04-03','2017-05-02'], 'RATE':[1.0, 1.2, 1.5, 1.8]}) data['TENOR_DT'] = pd.to

Circular interpolation in Python

邮差的信 提交于 2020-01-14 19:13:50
问题 I have two systems, each of which has a direction sensor (0-360 degrees), but the sensors can provide wildly different values depending on the orientation of each system and the linearity of each sensor. I have a mechanical reference that I can use to generate a table of where each system is actually pointing. This yields a table with three columns: Physical SystemA SystemB -------- ------- ------- 000.0 005.7 182.3 005.0 009.8 178.4 ... ... ... From just the data shown, we can see that

R: Interpolation between raster layers of different dates

心不动则不痛 提交于 2020-01-14 13:31:29
问题 Let's say I have 4 raster layers with the same extend with data of 4 different years: 2006,2008,2010 and 2012: library(raster) r2006<-raster(ncol=3, nrow=3) values(r2006)<-1:9 r2008<-raster(ncol=3, nrow=3) values(r2008)<-3:11 r2010<-raster(ncol=3, nrow=3) values(r2010)<-5:13 r2012<-raster(ncol=3, nrow=3) values(r2012)<-7:15 Now I want to create raster layers for every year between 2006 and 2013 (or even longer) by inter-/extrapolating (a linear method should be a good start) the values of the

Efficiently find indices of nearest points on non-rectangular 2D grid

℡╲_俬逩灬. 提交于 2020-01-14 10:16:16
问题 I have an irregular (non-rectangular) lon/lat grid and a bunch of points in lon/lat coordinates, which should correspond to points on the grid (though they might be slightly off for numerical reasons). Now I need the indices of the corresponding lon/lat points. I've written a function which does this, but it is REALLY slow. def find_indices(lon,lat,x,y): lonlat = np.dstack([lon,lat]) delta = np.abs(lonlat-[x,y]) ij_1d = np.linalg.norm(delta,axis=2).argmin() i,j = np.unravel_index(ij_1d,lon

Efficiently find indices of nearest points on non-rectangular 2D grid

倖福魔咒の 提交于 2020-01-14 10:16:05
问题 I have an irregular (non-rectangular) lon/lat grid and a bunch of points in lon/lat coordinates, which should correspond to points on the grid (though they might be slightly off for numerical reasons). Now I need the indices of the corresponding lon/lat points. I've written a function which does this, but it is REALLY slow. def find_indices(lon,lat,x,y): lonlat = np.dstack([lon,lat]) delta = np.abs(lonlat-[x,y]) ij_1d = np.linalg.norm(delta,axis=2).argmin() i,j = np.unravel_index(ij_1d,lon

Interpolation in JavaScript

女生的网名这么多〃 提交于 2020-01-13 08:39:06
问题 I have this jQuery code $("#selector").html('<a href=url>text</a>'); where url and text are JavaScript variables. How would I evaluate them inside quotes? 回答1: You just concatenate the strings together with + : $('#selector').html('<a href='+url+'>'+text+'</a>'); 回答2: While @kingjiv's answer is absolutely right, if you'll be doing a lot of templating with jQuery it might be worth checking out the tmpl* plugin to help keep things organized. * note: This plugin never made it past beta, and is