You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.8 KiB
52 lines
1.8 KiB
'''
|
|
Fecha: 15/03/25
|
|
Codigo definitivo para la interpolacion de datos en coordenadas esfericas (polares)
|
|
|
|
--> El metodo de ajuste devuelve datos equiespaciados (por tanto no hay que proyectar constantemente)
|
|
|
|
--> Se añade un punto al final y principio, esto siempre mejora la precision del metodo porque es una condicion necesaria (alpha = 2pi + alpha)
|
|
|
|
NOTA: Este codigo ignora los 0's por tanto es compatible con filtroz, porque ademas se encarga de ordenar ascendentemente phi
|
|
'''
|
|
|
|
import numpy as np
|
|
from scipy.interpolate import PchipInterpolator
|
|
|
|
def newinterpolate2(matrizsph,n):
|
|
|
|
tiempo = matrizsph.shape[0]
|
|
MSph = np.empty((tiempo,n,3)) # OBJETIVO
|
|
|
|
theta = np.zeros(n) + np.pi/2
|
|
MSph[:,:,1] = theta
|
|
|
|
for t in range(tiempo):
|
|
|
|
frame = matrizsph[t]
|
|
mask = ~np.all(frame == 0, axis=1) # seleccionamos valores distintos de 0
|
|
frame = frame[mask]
|
|
|
|
if frame.shape[0] < 2:
|
|
raise ValueError(f"No hay suficientes puntos para interpolar en el tiempo {t}.")
|
|
|
|
x = frame[:,2] # esto es phi
|
|
y = frame[:,0] # esto es r
|
|
|
|
indices_ordenados = np.argsort(x)
|
|
|
|
x = x[indices_ordenados] # ordenados ascendentemente
|
|
y = y[indices_ordenados]
|
|
|
|
x = np.concatenate(([x[-1] - 2*np.pi], x, [x[0] + 2*np.pi]))
|
|
y = np.concatenate(([y[-1]], y, [y[0]]))
|
|
|
|
interp = PchipInterpolator(x, y)
|
|
|
|
#x_new = np.linspace(0, 2*np.pi, n) # 500 puntos en el intervalo de x EQUIESPACIADO
|
|
x_new = np.linspace(0, 2*np.pi, n,endpoint = False) # 500 puntos en el intervalo de x EQUIESPACIADO
|
|
y_new = interp(x_new)
|
|
|
|
MSph[t,:,2] = x_new # phi
|
|
MSph[t,:,0] = y_new # r(phi)
|
|
|
|
return MSph
|
|
|