Skip to content

Commit f786056

Browse files
committed
Split upsampling coords (easy) from interpolation
1 parent 9ae3b4e commit f786056

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sarsen/scene.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def transform_dem_3d(
8282
return dem_3d_crs
8383

8484

85-
def upsample(
85+
def upsample_coords(
8686
data: xr.DataArray, dtype: str | None = None, **factors: int
8787
) -> xr.DataArray:
8888
coords = {}
@@ -93,6 +93,13 @@ def upsample(
9393
stop = coord[-1].values + coord_delta / 2 - coord_delta / factor / 2
9494
values = np.linspace(start, stop, num=coord.size * factor, dtype=dtype)
9595
coords[dim] = values
96+
return coords
97+
98+
99+
def upsample(
100+
data: xr.DataArray, dtype: str | None = None, **factors: int
101+
) -> xr.DataArray:
102+
coords = upsample_coords(data, dtype, **factors)
96103
return data.interp(coords, kwargs={"fill_value": "extrapolate"})
97104

98105

0 commit comments

Comments
 (0)