Exo-TiC / ExoTiC-LD

Limb-darkening package to calculate the coefficients for specific instruments, stars, and wavelength ranges
https://exotic-ld.readthedocs.io
MIT License
8 stars 6 forks source link

Tri-linear interpolation #27

Closed hrwakeford closed 1 year ago

hrwakeford commented 1 year ago

Add in the tri-linear interpolation to better approximate the stellar values based on the input Teff, M/H, and log g.

Based on IDL code version

PRO tri_linear_interp, p0, x, y, z, c, v
; INPUTS
;   p0 - array containing the starting values of (x,y,z)
;   x - 2 element array containing the lower bound of x and upper bound of x
;       x = [x0, x1]
;   y - 2 element array containing the lower bound of y and upper bound of y
;       y = [y0, y1]
;   z - 2 element array containing the lower bound of z and upper bound of z
;       z = [z0, z1]
;   c - [2,2,2] array of the values to interpolate
;       [[x0,x1], [y0,y1], [z0,z1]]
;   value - interpolated value of 
;
; ----------------------------------------

xd = (p0[0] - x[0]) / (x[1] - x[0])
yd = (p0[1] - y[0]) / (y[1] - y[0])
zd = (p0[2] - z[0]) / (z[1] - z[0])

; ----------------------------------------

c00 = (c[0,0,0]*(1 - xd)) + (c[0,1,0]*xd)

c01 = (c[1,0,0]*(1 - xd)) + (c[1,1,0]*xd)

c10 = (c[0,0,1]*(1 - xd)) + (c[0,1,1]*xd)

c11 = (c[1,0,1]*(1 - xd)) + (c[1,1,1]*xd)

; ----------------------------------------

c0 = c00*(1-yd) + c10*yd

c1 = c01*(1-yd) + c11*yd

; ----------------------------------------

v = c0*(1-zd) + c1*zd

END
hrwakeford commented 1 year ago

It looks like this could be done using the scipy library

https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interpn.html#scipy.interpolate.interpn