Skip to content

Commit

Permalink
add order argument for interp to constant grid (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes authored Apr 7, 2022
1 parent 6ba8b3b commit 7cd67c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pydrad/parse/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_unique_grid(self) -> u.cm:
return np.unique(np.concatenate(all_coordinates).ravel()) * u.cm

@u.quantity_input
def to_constant_grid(self, name, grid: u.cm):
def to_constant_grid(self, name, grid: u.cm, order=1):
"""
Interpolate a given quantity onto a spatial grid that is the same at
each time step.
Expand All @@ -233,12 +233,14 @@ def to_constant_grid(self, name, grid: u.cm):
name : `str`
grid : `~astropy.units.Quantity`
Spatial grid to interpolate onto
order : `int`
Order of the spline interpolation. Defualt is 1.
"""
q_uniform = np.zeros(self.time.shape+grid.shape)
grid_cm = grid.to(u.cm).value
for i, p in enumerate(self):
q = getattr(p, name)
tsk = splrep(p.coordinate.to(u.cm).value, q.value,)
tsk = splrep(p.coordinate.to(u.cm).value, q.value, k=order)
q_uniform[i, :] = splev(grid_cm, tsk, ext=0)

return q_uniform * q.unit
Expand Down

0 comments on commit 7cd67c1

Please sign in to comment.