Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Lpzie
Nov 20, 2006

Does anybody have experience with scipy's interpolate.griddata? I have 3 1d arrays that I want interpolated with the purpose of retrieving values. This is in python 2.7.

I have:

Python code:
import numpy as np
from scipy import interpolate

x = [ long array ]
y = [ long array ]
z = [ long array ]

#creates the grid
xi,yi = np.mgrid[ min(x):max(x):2000j, min(y):max(y):2000j ]

#interpolates
zi = scipy.interpolate.griddata( (x,y), z, (xi, yi), method='cubic' )
Now I need to be able to give zi any x and y value that's within the domain given by xi,yi and retrieve an interpolated z value. Does anybody know how to do this? (I'm not even sure if my interpolation method is right, tbh. Cannot test it without z values to compare.)




Edit: Nvm. I figured it out. I was complicating things. Simply using zi = scipy.interpolate.interp2d(x,y,z, kind='cubic') and then doing zi_ = zi(x_, y_) where x_ and y_ are the values I want interpolated works.

Lpzie fucked around with this message at 23:01 on Apr 20, 2016

Adbot
ADBOT LOVES YOU

Lpzie
Nov 20, 2006

What's the preferred method to do a calculation multiple times and store them in a list?

My goto method is

Python code:
G = 6.67e-8
m = [1.90e33, 2.00e33, 2.10e33, 2.20e33]
r = [5.00e10, 5.10e10, 5.20e10, 5.30e10]

logg = []

for i in range( len(r) ):
    logg.append( np.log10( G * m[i] / r[i]**2 ) )
Isn't there some way to do this using that fancy lambda thing?

Lpzie
Nov 20, 2006

Thanks. It's surface gravity, yeah.


EDIT: VVV Thanks.

Lpzie fucked around with this message at 00:49 on Apr 23, 2016

  • Locked thread