フィルターのクリア

TriScatteredInterp not interpolating as expected?

3 ビュー (過去 30 日間)
Bruno Rodriguez
Bruno Rodriguez 2017 年 9 月 5 日
編集済み: Bruno Rodriguez 2017 年 9 月 7 日
I tried to interpolate a set of radar reflectivity values using TriScatteredInterp (and later with scatteredInterpolant). As my initial data had quite a few NaN values, the final interpolation incorrectly created an entire array of NaNs. I tried repeating the interpolation by subbing "-50" in for the NaNs (I can erase bad data after), but when I do that, TriScatterdInterp still returns an antire array of NaNs, and scatteredInterpolant fills the entire array with -50, which is also incorrect. The data and code has been attached. Any ideas what may be wrong?
(I tested it out on a small sample of test data and it worked, but still returns all NaNs or all -50 when I apply it to my dataset).
"initial_heights.m" = z_radar_dn in code. "original_dbz.m" = dbz_dn_sub_thresh in code.
% Prep input arrays
heights = z_radar_dn(:,:)';
x = 1:4443;
x = repmat(x,413,1);
dbz_initial = dbz_dn_sub_thresh(:,:)';
dbz = dbz_initial;
% Replace NaN's with -50 for interpolation
replace = isnan(dbz);
dbz(replace) = -50;
% Flatten to vectors
%F_ref = scatteredInterpolant(double(x(:)),double(heights(:)),double(dbz(:)));
F_ref = TriScatteredInterp(double(x(:)),double(heights(:)),double(dbz(:)));
% Set up a perfect grid
xvec = [1:4443];
maxHeight = max(z_radar_dn(1,:))*1000;
n = floor(maxHeight/30);
zvec = [maxHeight:-30:maxHeight-(n*30)];
% Mesh them together
[xmat,zmat]=meshgrid(xvec,zvec);
% Interpolate
dbz_interpolated= F_ref(xmat(:),double(zmat(:)));
% Reshape
dbz_interpolated=reshape(dbz_interpolated, size(xmat));

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 5 日
When you create the interpolant the second variable corresponding to y is your height variable. When you go to use the interpolant you are passing z as the second variable. Most of your z are not in the same range as your height so the interpolant is applying its default extrapolation of putting in nan.
  2 件のコメント
Bruno Rodriguez
Bruno Rodriguez 2017 年 9 月 5 日
So if I understand correctly, it is overriding those "z" that DO lie within the range of heights? If so, I take it I need to limit my range of Z. However, for every x-coord, the range of heights I need interpolated differs, so I would not have a rectangular array...any idea how I could get around that?
Walter Roberson
Walter Roberson 2017 年 9 月 6 日
Each time you call
F = scatteredInterpolant(x, y, z)
you create a function F . You have to pass x and y coordinates to that function to get z outputs. But that isn't what you did. You passed in x and z instead.
The x and y that you pass in to the function do not need to be equally spaced. If you pass in vectors (of equal length) then only the points you indicate will be interpolated.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolating Gridded Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by