This can be done simply by ( again, pseudocode): bCube = griddata((x, y, z), b, (X, Y, Z), method = 'linear', fill_value=nan)īCubeNearest = griddata((x, y, z), b, (X, Y, Z), method = 'nearest') This is effective and stable, but crude because your field can end up with patterned features (like stripes or beams radiating out from the hull), often visually unappealing or, worse, unacceptable in terms of data smoothnessĭepending on the density of data, you could use the nearest scattered datapoint instead of the nearest non-NaN regular point. Nearest neighbourįor each of the regular NaN points, find the nearest non-NaN and assign that value. X, y, z, b = np.loadtxt(scatteredfile, unpack = True)Ĭons: This produces a sharp discontinuity in gradient of the interpolated field at the hull boundary, fairly heavily biases the mean scalar field value and doesn't respect the functional form of the data. Sorry, this is pseudocode as I don't use numpy at all, but it'll probably be fairly clear # With a unit cube, and selected scalar value This might be the average value of the scalar field associated with your scattered points. "Blended botching it"Īssume that at the corners of your domain, you apply some value. In the numpy docs you'll see this is done with:īCube = griddata((x, y, z), b, (X, Y, Z), method = 'linear', fill_value=s)Ĭons: This produces a sharp discontinuity in the interpolated field at the hull boundary, heavily biases the mean scalar field value and doesn't respect the functional form of the data. Botch itĪssign some scalar value outside the hull. Let's go through some ways of doing that. In that region, algorithms like griddata choose to return NaN - this is the safest way of informing the scientist that s/he must choose a sensible way of extrapolating. There's no general rule for how to do it. Outside it, you have to extrapolate.Įxtrapolation is hard. Less formally, the convex hull ( which you can compute easily with scipy) is like stretching a balloon over a frame, where the frame corners are the outermost points of your scattered cluster.Īt the regular grid location inside the balloon you're surrounded by known points.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |