Remove LRM, TPI, aspect, curvature, paths + add flow accumulation, directional Gabor wavelets, multi-radius ray-tracing
This commit is contained in:
@ -47,52 +47,8 @@ class TestSlope:
|
||||
assert np.nanmax(data) <= 90
|
||||
|
||||
|
||||
class TestAspect:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_aspect
|
||||
result = generate_aspect(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
def test_aspect_values_0_360(self, synthetic_dem, tmp_output_dir):
|
||||
import rasterio
|
||||
from lidar_pipeline.visualizations import generate_aspect
|
||||
result = generate_aspect(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
with rasterio.open(result) as src:
|
||||
data = src.read(1)
|
||||
valid = data[~np.isnan(data)]
|
||||
assert np.nanmin(valid) >= 0
|
||||
assert np.nanmax(valid) <= 360
|
||||
|
||||
|
||||
class TestCurvature:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_curvature
|
||||
result = generate_curvature(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
|
||||
# --- GPU-accelerated visualizations ---
|
||||
|
||||
class TestLRM:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_lrm
|
||||
result = generate_lrm(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
def test_lrm_has_positive_negative(self, synthetic_dem, tmp_output_dir):
|
||||
import rasterio
|
||||
from lidar_pipeline.visualizations import generate_lrm
|
||||
result = generate_lrm(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
with rasterio.open(result) as src:
|
||||
data = src.read(1)
|
||||
# LRM should have both positive and negative values
|
||||
assert np.nanmax(data) > 0
|
||||
assert np.nanmin(data) < 0
|
||||
|
||||
|
||||
class TestSVF:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_svf
|
||||
@ -133,15 +89,6 @@ class TestMSLRM:
|
||||
assert result.exists()
|
||||
|
||||
|
||||
class TestTPI:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_tpi
|
||||
result = generate_tpi(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
|
||||
|
||||
class TestSAILORE:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_sailore
|
||||
@ -167,14 +114,6 @@ class TestRoughness:
|
||||
assert np.nanmin(data) >= 0
|
||||
|
||||
|
||||
class TestAnomalies:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_anomalies
|
||||
result = generate_anomalies(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
|
||||
class TestWavelet:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_wavelet
|
||||
@ -183,50 +122,38 @@ class TestWavelet:
|
||||
assert result.exists()
|
||||
|
||||
|
||||
class TestFlow:
|
||||
class TestFlowAccumulation:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_flow
|
||||
result = generate_flow(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
from lidar_pipeline.visualizations import generate_flow_accumulation
|
||||
result = generate_flow_accumulation(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
|
||||
def test_flow_log_values(self, synthetic_dem, tmp_output_dir):
|
||||
import rasterio
|
||||
from lidar_pipeline.visualizations import generate_flow
|
||||
result = generate_flow(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
from lidar_pipeline.visualizations import generate_flow_accumulation
|
||||
result = generate_flow_accumulation(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
with rasterio.open(result) as src:
|
||||
data = src.read(1)
|
||||
# log1p(x) >= 0 for x >= 0
|
||||
# log10(x) >= 0 for x >= 1
|
||||
valid = data[~np.isnan(data)]
|
||||
assert np.nanmin(valid) >= 0
|
||||
|
||||
|
||||
class TestLocalDominance:
|
||||
def test_generates_tif(self, synthetic_dem, tmp_output_dir):
|
||||
from lidar_pipeline.visualizations import generate_local_dominance
|
||||
result = generate_local_dominance(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
assert result is not None
|
||||
assert result.exists()
|
||||
assert result.suffix == ".tif"
|
||||
|
||||
def test_dominance_values_0_1(self, synthetic_dem, tmp_output_dir):
|
||||
class TestRayTrace:
|
||||
def test_rays_are_traced(self, synthetic_dem, tmp_output_dir):
|
||||
"""Verify _ray_trace_horizons returns expected shapes."""
|
||||
from lidar_pipeline.visualizations import _ray_trace_horizons, _prepare_dem_for_raycast
|
||||
import rasterio
|
||||
from lidar_pipeline.visualizations import generate_local_dominance
|
||||
result = generate_local_dominance(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
with rasterio.open(result) as src:
|
||||
data = src.read(1)
|
||||
valid = data[~np.isnan(data)]
|
||||
assert np.nanmin(valid) >= 0, "Local dominance should be >= 0"
|
||||
assert np.nanmax(valid) <= 1, "Local dominance should be <= 1"
|
||||
|
||||
def test_dominance_nan_mask_preserved(self, synthetic_dem, tmp_output_dir):
|
||||
"""Check that NaN zones from original DEM are preserved."""
|
||||
import rasterio
|
||||
from lidar_pipeline.visualizations import generate_local_dominance
|
||||
result = generate_local_dominance(synthetic_dem, "test", tmp_output_dir, 5.0)
|
||||
# The synthetic DEM has no NaN, so this just verifies the output is valid
|
||||
with rasterio.open(result) as src:
|
||||
data = src.read(1)
|
||||
# Shape should match input
|
||||
assert data.shape[0] > 0
|
||||
assert data.shape[1] > 0
|
||||
with rasterio.open(synthetic_dem) as src:
|
||||
dem_np = src.read(1)
|
||||
rows, cols = dem_np.shape
|
||||
# Create a simple filled DEM for testing
|
||||
import numpy as np
|
||||
filled = np.nan_to_num(dem_np, nan=0)
|
||||
# Test with numpy (no GPU)
|
||||
pos, neg = _ray_trace_horizons(
|
||||
filled, rows, cols, 5.0, n_dirs=4, max_dist=10, radii_m=[25, 50]
|
||||
)
|
||||
assert pos.shape == (4, 2, rows, cols)
|
||||
assert neg.shape == (4, 2, rows, cols)
|
||||
|
||||
Reference in New Issue
Block a user