Supprimer les RuntimeWarnings: NaN dans nanmean et cast uint8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -391,7 +391,8 @@ def generate_mslrm(dem_file, basename, vis_dir, resolution):
|
|||||||
lrm_stack.append(lrm_norm.astype(np.float32))
|
lrm_stack.append(lrm_norm.astype(np.float32))
|
||||||
|
|
||||||
lrm_array = np.array(lrm_stack)
|
lrm_array = np.array(lrm_stack)
|
||||||
mslrm = np.sqrt(np.nanmean(lrm_array ** 2, axis=0))
|
with np.errstate(invalid='ignore'):
|
||||||
|
mslrm = np.sqrt(np.nanmean(lrm_array ** 2, axis=0))
|
||||||
mslrm[nan_mask] = np.nan
|
mslrm[nan_mask] = np.nan
|
||||||
_save_tif(output, mslrm.astype(np.float32), transform, crs)
|
_save_tif(output, mslrm.astype(np.float32), transform, crs)
|
||||||
logger.info(f" ✓ MSRM terminé ({time.time()-t0:.1f}s){gpu_tag}")
|
logger.info(f" ✓ MSRM terminé ({time.time()-t0:.1f}s){gpu_tag}")
|
||||||
@ -658,7 +659,8 @@ def generate_wavelet(dem_file, basename, vis_dir, resolution):
|
|||||||
response = response / std_val
|
response = response / std_val
|
||||||
wavelet_stack.append(response)
|
wavelet_stack.append(response)
|
||||||
|
|
||||||
combined = np.sqrt(np.nanmean(np.array(wavelet_stack) ** 2, axis=0))
|
with np.errstate(invalid='ignore'):
|
||||||
|
combined = np.sqrt(np.nanmean(np.array(wavelet_stack) ** 2, axis=0))
|
||||||
combined[nan_mask] = np.nan
|
combined[nan_mask] = np.nan
|
||||||
|
|
||||||
_save_tif(output, combined.astype(np.float32), transform, crs)
|
_save_tif(output, combined.astype(np.float32), transform, crs)
|
||||||
@ -714,7 +716,8 @@ def generate_texture(dem_file, basename, vis_dir, resolution):
|
|||||||
|
|
||||||
# Entropy — compute bin-by-bin to avoid large 3D allocation
|
# Entropy — compute bin-by-bin to avoid large 3D allocation
|
||||||
n_bins = 16
|
n_bins = 16
|
||||||
img_uint8 = np.clip(img * 255, 0, 255).astype(np.uint8)
|
img_clean = np.nan_to_num(img, nan=0.0)
|
||||||
|
img_uint8 = np.clip(img_clean * 255, 0, 255).astype(np.uint8)
|
||||||
quantized = (img_uint8 // (256 // n_bins)).astype(np.int32)
|
quantized = (img_uint8 // (256 // n_bins)).astype(np.int32)
|
||||||
entropy = np.zeros_like(img, dtype=np.float64)
|
entropy = np.zeros_like(img, dtype=np.float64)
|
||||||
win_area = max(window * window, 1)
|
win_area = max(window * window, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user