You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned, for this endeavor, we should also reconsider the resampling / interpolation methods of Solution objects. Currently, this is only possible for 1D solutions (i.e. SolutionIO). However, we might want to also do this with ND-objects.
Here is a prototype that works for multiple dimensions:
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import RegularGridInterpolator
from scipy import stats
time = np.linspace(0, 10, 11)
axial_positions = np.linspace(0, 1, 5)
components = np.arange(0, 2)
dimensions = {
'time': np.linspace(0, 10, 11),
'axial_positions': np.linspace(0, 10, 11),
# 'radial_positions': np.linspace(0, 10, 11),
'channels': [0, 1, 2],
'components': ['A', 'B'],
}
continuous_dimensions = [key for key, value in dimensions.items() if isinstance(value, np.ndarray)]
discrete_dimensions = [key for key, value in dimensions.items() if not isinstance(value, np.ndarray)]
fig, ax = plt.subplots()
c = np.zeros((len(time), len(axial_positions), len(components)))
for i in range(len(axial_positions)):
solution = stats.norm.pdf(time, i + 3, 1)
c[:, i, 1] = solution
ax.plot(time, solution)
interpolators = []
for comp in components:
interp = RegularGridInterpolator((time, axial_positions), c[..., comp], method='linear')
interpolators.append(interp)
time_new = np.linspace(0, 10, 101)
axial_directions_new = np.linspace(0, 1, 11)
arrs = np.meshgrid(time_new, axial_directions_new, indexing='ij')
test_points = np.array([dim.ravel() for dim in arrs]).T
foo = interpolators[1](test_points).reshape(len(time_new), len(axial_directions_new))
for i in range(len(axial_directions_new)):
solution = foo[:, i]
ax.plot(time_new, solution, 'k--')
A challenge here is that we have independent (i.e. discrete) dimensions (e.g. components, channels) and continuous dimensions (space-time). While for interpolation, we only want to interpolate between the continuous dimensions, we still want to provide a uniform interface...
SolutionBase
and make use of internal dimensions.The text was updated successfully, but these errors were encountered: