Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:16:48+00:00 2026-05-24T20:16:48+00:00

I have a largish 3D numpy array of scalar values (OK call it a

  • 0

I have a largish 3D numpy array of scalar values (OK call it a “volume” if you must). I want to interpolate a smooth scalar field over this at a succession of irregular, not all
known up-front non-integral xyz coordinates.

Now Scipy’s support for this is just excellent: I filter the volume with

filtered_volume = scipy.ndimage.interpolation.spline_filter(volume)

and invoke

scipy.ndimage.interpolation.map_coordinates(
    filtered_volume,
    [[z],[y],[x]],
    prefilter=False)

for (x,y,z) of interest to obtain apparently nicely behaved (smooth etc) interpolated values.

So far so good. However, my application also needs the local derivatives of the interpolated field. Currently I obtain these by central-differencing: I also sample the volume at 6 additional points (this can at least be done with just one call to map_coordinates) and calculate e.g the x derivative from (i(x+h,y,z)-i(x-h,y,z))/(2*h). (Yes I know I could reduce the number of additional taps to 3 and do “one sided” differences, but the asymmetry would annoy me.)

My instinct is that there ought to be a more direct way of obtaining the gradient
but I don’t know enough spline math (yet) to figure it out, or understand what’s
going on in the guts of the Scipy implementation: scipy/scipy/ndimage/src/ni_interpolation.c.

Is there a better way of obtaining my gradients “more directly” than central differencing ? Preferably one which allows them to be obtained using the existing functionality rather than hacking on Scipy’s innards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:16:49+00:00Added an answer on May 24, 2026 at 8:16 pm

    Aha: according to the classic paper on splines cited in the numpy code, splines of order n and their derivatives are related by

       n          n-1           n-1
     dB (x)/dx = B   (x+1/2) - B   (x-1/2)
    

    So using SciPy’s spline interpolation I could get my derivatives by also maintaining a lower-order prefiltered volume and querying that a couple of times per derivative. This means adding a fair amount of memory (maybe competition with the “main” volume for cache), but presumably evaluation of the lower order splines is faster, so it’s not obvious to me whether it would be faster or not overall than the central differencing using small offsets I’m doing currently. Haven’t tried it yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a largish array of string that I want to use as a
(This question specifically in C#, but applies generally to .NET) I have a largish
I have a largish Mercurial repository that I've decided would be better as several
I have a largish complex app around 27k lines. Its essentially a rule drive
I have an asp.net website that allows the user to download largish files -
Does Java 6 consume more memory than you expect for largish applications? I have
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
Have finally got a responsive site working (of a fashion). What I want to
have Googled the cr*p out of this one so apologies if the answer is
Have some dates in my local Oracle 11g database that are in this format:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.