Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit bands into indexes of DEM class (#340) #6

Merged
merged 1 commit into from
Mar 2, 2023
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
10 changes: 10 additions & 0 deletions tests/test_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pyproj
import pytest
import rasterio as rio
from geoutils.georaster.raster import _default_rio_attrs

import xdem
Expand Down Expand Up @@ -65,6 +66,15 @@ def test_init(self) -> None:
)
)

# Check that an error is raised when more than one band is provided
with pytest.raises(ValueError, match="DEM rasters should be composed of one band only"):
xdem.DEM.from_array(
data=np.zeros(shape=(2, 5, 5)),
transform=rio.transform.from_bounds(0, 0, 1, 1, 5, 5),
crs=None,
nodata=None,
)

def test_copy(self) -> None:
"""
Test that the copy method works as expected for DEM. In particular
Expand Down
2 changes: 1 addition & 1 deletion xdem/coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ def _fit_func(

# Iteratively run the analysis until the maximum iterations or until the error gets low enough
if verbose:
print(" Iteratively estimating horizontal shit:")
print(" Iteratively estimating horizontal shift:")

# If verbose is True, will use progressbar and print additional statements
pbar = trange(self.max_iterations, disable=not verbose, desc=" Progress")
Expand Down
4 changes: 2 additions & 2 deletions xdem/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def __init__(
warnings.filterwarnings("ignore", message="Parse metadata from file not implemented")
super().__init__(filename_or_dataset, silent=silent, **kwargs)

# self.nbands can be None when data is not loaded through the Raster class
if self.nbands is not None and self.nbands > 1:
# self.indexes can be None when data is not loaded through the Raster class
if self.indexes is not None and len(self.indexes) > 1:
raise ValueError("DEM rasters should be composed of one band only")

# user input
Expand Down