Skip to content

Commit

Permalink
minor refactor after changing x0
Browse files Browse the repository at this point in the history
  • Loading branch information
jhkennedy committed Oct 11, 2023
1 parent 34692e6 commit ec383b1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/asf_tools/flood_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ def estimate_flood_depth(label, hand, flood_labels, estimator='iterative', water
with warnings.catch_warnings():
warnings.filterwarnings('ignore', r'Mean of empty slice')

if estimator.lower() == "iterative" or estimator.lower() == "nmad":
if estimator.lower() == "iterative":
water_levels = np.arange(*iterative_bounds)
return iterative(hand, flood_labels == label,
water_levels=water_levels, minimization_metric=minimization_metric)

if estimator.lower() == "nmad":
hand_mean = np.nanmean(hand[flood_labels == label])
hand_std = stats.median_abs_deviation(hand[flood_labels == label], scale='normal',
nan_policy='omit')
if estimator.lower() == "iterative":
water_levels = np.arange(*iterative_bounds)
return iterative(hand, flood_labels == label,
water_levels=water_levels, minimization_metric=minimization_metric)
hand_std = stats.median_abs_deviation(hand[flood_labels == label], scale='normal', nan_policy='omit')

if estimator.lower() == "numpy":
hand_mean = np.nanmean(hand[flood_labels == label])
hand_std = np.nanstd(hand[flood_labels == label])
Expand Down Expand Up @@ -190,7 +191,7 @@ def make_flood_map(out_raster: Union[str, Path], vv_raster: Union[str, Path],
known_water_threshold: Threshold for extracting the known water area in percent.
If `None`, the threshold is calculated.
iterative_bounds: Bounds on basin-hopping algorithm used in iterative estimation
min_metric : Evaluation method to minimize in iterative estimation
minimization_metric : Evaluation method to minimize in iterative estimation
References:
Jean-Francios Pekel, Andrew Cottam, Noel Gorelik, Alan S. Belward. 2016. <https://doi:10.1038/nature20584>
Expand Down

0 comments on commit ec383b1

Please sign in to comment.