Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions podpac/core/coordinates/stacked_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def coordinates(self):
dtype = dtypes[0]
else:
dtype = object
return np.dstack([c.coordinates.astype(dtype) for c in self._coords]).squeeze()
return np.stack([c.coordinates.astype(dtype) for c in self._coords], axis=-1)
Comment thread
scranford1 marked this conversation as resolved.

@property
def xcoords(self):
Expand Down Expand Up @@ -469,7 +469,6 @@ def _index_len(self, index: "Coordinates"):
return stop - start
return len(index)


def _and_indices(self, indices: List["Coordinates"]):
"""logical AND of the selection in each dimension"""
if all(isinstance(index, slice) for index in indices):
Expand Down
3 changes: 3 additions & 0 deletions podpac/core/coordinates/test/test_stacked_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,15 @@ def test_issubset(self):
sc_3 = StackedCoordinates([lat[::-1], lon], name="lat_lon") # same coordinates, paired differently
sc_t = sc.transpose("lon", "lat")
sc_time = StackedCoordinates([lat, lon, time], name="lat_lon_time")
sc_single_value = StackedCoordinates([lat[0], lon[0]], name="lat_lon")

assert sc.issubset(sc)
assert sc[:2].issubset(sc)
assert not sc.issubset(sc[:2])
assert not sc_2.issubset(sc)
assert not sc_3.issubset(sc)
assert sc_single_value.issubset(sc_single_value)
assert sc_single_value.issubset(sc)

Comment thread
scranford1 marked this conversation as resolved.
assert sc_t.issubset(sc)

Expand Down
6 changes: 3 additions & 3 deletions podpac/core/interpolation/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def _use_source_units(self):

@property
def outputs(self):
""" Pass through outputs from source """
"""Pass through outputs from source"""
return self.source.outputs

@property
def coordinates(self):
""" Pass through coordinates from source """
"""Pass through coordinates from source"""
return self.source.coordinates

@property
Expand Down Expand Up @@ -247,7 +247,7 @@ def _eval(self, coordinates, output=None, _selector=None):
# if requested crs is differented than coordinates,
# fabricate a new output with the original coordinates and new values
if self._evaluated_coordinates.crs != coordinates.crs:
output = self.create_output_array(self._evaluated_coordinates.drop(extra_dims), data=output[:].values)
output = self.create_output_array(self._evaluated_coordinates.udrop(extra_dims), data=output[:].values)
Comment thread
scranford1 marked this conversation as resolved.

# save output to private for debugging
if settings["DEBUG"]:
Expand Down
4 changes: 2 additions & 2 deletions podpac/core/interpolation/rasterio_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def interpolate(self, udims, source_coordinates, source_data, eval_coordinates,

with rasterio.Env():
src_transform = transform.Affine.from_gdal(*source_coordinates.geotransform)
src_crs = rasterio.crs.CRS.from_proj4(source_coordinates.crs)
src_crs = rasterio.crs.CRS.from_string(source_coordinates.crs)
Comment thread
scranford1 marked this conversation as resolved.
# Need to make sure array is c-contiguous
source = np.ascontiguousarray(source_data.data)

dst_transform = transform.Affine.from_gdal(*eval_coordinates.geotransform)
dst_crs = rasterio.crs.CRS.from_proj4(eval_coordinates.crs)
dst_crs = rasterio.crs.CRS.from_string(eval_coordinates.crs)
# Need to make sure array is c-contiguous
if not output_data.data.flags["C_CONTIGUOUS"]:
destination = np.ascontiguousarray(output_data.data)
Expand Down
20 changes: 20 additions & 0 deletions podpac/core/interpolation/test/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ def test_stacked_coords_with_partial_dims_issue123(self):
o3 = node.eval(Coordinates(["2018-01-01"], dims=["time"]))
assert o3.data[0] == 0

def test_stacked_coordinates_with_extra_dimension_and_non_default_crs(self):
"""
Test interpolation for a request with stacked coordinates containing an extra dimension and non-default CRS.
Interpolation is set to "none" to ensure the _fix_coordinates_for_none_interp method is invoked.
"""
node = Array(
source=[0, 1, 2],
coordinates=Coordinates([[[0, 2, 1], [10, 12, 11]]], dims=["lat_lon"]),
).interpolate(interpolation="none")

o1 = node.eval(
coordinates=Coordinates(
[[[0, 2, 1], [10, 12, 11], ["2018-01-01", "2018-01-02", "2018-01-03"]]],
dims=["lat_lon_time"],
crs="EPSG:4326",
)
)

assert_array_equal(o1.data, [0, 1, 2])

def test_ignored_interpolation_params_issue340(self, caplog):
node = Array(source=[0, 1, 2], coordinates=Coordinates([[0, 2, 1]], dims=["time"])).interpolate(
interpolation={"method": "nearest", "params": {"fake_param": 1.1, "spatial_tolerance": 1}}
Expand Down
Loading