extrapolation

Extrapolate with LinearNDInterpolator

泄露秘密 提交于 2019-12-03 20:39:11
I've got a 3D dataset that I want to interpolate AND extrapolate linearly. The interpolation can be done easily with scipy.interpolate.LinearNDInterpolator . The module can only fill in a constant/nan for values outside the parameter range, but I don't see why it would not offer an option to turn on extrapolation. Looking at the code, I see that the module is written in cython. With no experience in cython, it is hard to play around with the code to implement extrapolation. I can write it in pure python code, but maybe someone else here has a better idea? My particular case involves a constant

Extrapolating data with interp not producing accurate image

拟墨画扇 提交于 2019-12-03 20:38:31
I have a graph where the extrapolation does not match the initial interpolation. I would like the heatmap to fill the entire image. First, the interpolation code: library(akima) library(reshape2) xmin <- signif(min(CBLo2$MD1)) xmax <- signif(max(CBLo2$MD1)) ymin <- signif(min(CBLo2$MD2)) ymax <- signif(max(CBLo2$MD2)) gridint <- 100 fld <- with(CBLo2, interp(x = MD1, y = MD2, z = Abundance, xo=seq(xmin, xmax, length=gridint), yo=seq(ymin, ymax, length=gridint) )) df <- melt(fld$z, na.rm = TRUE) names(df) <- c("MD1", "MD2", "Abundance") df$MD1 <- fld$x[df$MD1] df$MD2 <- fld$y[df$MD2] contour

Extrapolation beyond a grid of data

风格不统一 提交于 2019-12-02 21:13:33
问题 I have a grid of (x, y, z) values and I want a function that can approximate z-values when it is given (x,y) points that lie beyond the grid. I have tried to solve the question using the Akima package (code block 3), but I can't seem to get the interp function to work with the linear=FALSE option that is required to extrapolate beyond the grid. Data: # Grid data x <- seq(0,1,length.out=6) y <- seq(0,1,length.out=6) z <- outer(x,y,function(x,y){sqrt(x^2+y^3)}) Visualize data (not essential for

Matlab interp2 extrapolation

泪湿孤枕 提交于 2019-12-02 12:50:06
I am doing a 2-D interpolation using interp2 . For some data values, the interp2 command returns NaN because one of the dimensions are outside of the range defined by the vector of known values. Its possible to extrapolate with the interp1 command. However, Is there a way to do this for interp2 ? Thanks Here is the code in which I am using the interp2 command: function [Cla] = AirfoilLiftCurveSlope(obj,AFdata,Rc,M) % Input: % AFdata: Airfoil coordinates. % Rc: Local Reynolds number. % M: Mach number for Prandtle Glauert compressibility correction. % Output: % Cla: 2 dimensional lift curve

How can I extrapolate to higher values in Matlab? [closed]

回眸只為那壹抹淺笑 提交于 2019-12-02 05:04:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I have the following data: T=[0,100,300] and a=[2.8796,2.8785,2.886] and I want to extrapolate and know what a will I get at T=600 in Matlab. How can I do that? 回答1: If its linear the code below solves this clear all close all T=[0,100,300]; a=[2.8796,2.8785,2.886]; reg = polyfit

Speeding up an interpolation exercise

风流意气都作罢 提交于 2019-11-30 10:29:22
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 1996 4 2 23124 5: 0007 1996 4 2 22700 --- 1175141: 994 2012 5 2 47098 1175142: 994 2012 5 2 45488 1175143

Interpolate (or extrapolate) only small gaps in pandas dataframe

久未见 提交于 2019-11-30 07:36:26
I have a pandas DataFrame with time as index (1 min Freq) and several columns worth of data. Sometimes the data contains NaN. If so, I want to interpolate only if the gap is not longer than 5 Minutes. In this case this would be a maximum of 5 consecutive NaNs. The data may look like this (several test cases, which show the problems): import numpy as np import pandas as pd from datetime import datetime start = datetime(2014,2,21,14,50) data = pd.DataFrame(index=[start + timedelta(minutes=1*x) for x in range(0, 8)], data={'a': [123.5, np.NaN, 136.3, 164.3, 213.0, 164.3, 213.0, 221.1], 'b': [433

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

Interpolate (or extrapolate) only small gaps in pandas dataframe

微笑、不失礼 提交于 2019-11-29 04:00:45
问题 I have a pandas DataFrame with time as index (1 min Freq) and several columns worth of data. Sometimes the data contains NaN. If so, I want to interpolate only if the gap is not longer than 5 Minutes. In this case this would be a maximum of 5 consecutive NaNs. The data may look like this (several test cases, which show the problems): import numpy as np import pandas as pd from datetime import datetime start = datetime(2014,2,21,14,50) data = pd.DataFrame(index=[start + timedelta(minutes=1*x)

Extrapolate Pandas DataFrame

浪尽此生 提交于 2019-11-27 13:32:35
问题 It is easy to interpolate values in a Pandas.DataFrame using Series.interpolate , how can extrapolation be done? For example, given a DataFrame as shown, how can we extrapolate it 14 more months to 2014-12-31? Linear extrapolation is fine. X1 = range(10) X2 = map(lambda x: x**2, X1) df = pd.DataFrame({'x1': X1, 'x2': X2}, index=pd.date_range('20130101',periods=10,freq='M')) I am thinking that a new DataFrame must first be created, with the DateTimeIndex starting from 2013-11-31 and extending