HmsArf¶
Areal reduction factor helpers for design-storm workflows.
hms_commander.HmsArf
¶
HmsArf - Areal Reduction Factor (ARF) Operations
This module provides static methods for applying Areal Reduction Factors to HEC-HMS meteorologic model files. ARFs adjust precipitation depths to account for the spatial variability of rainfall over large drainage areas.
All methods are static and designed to be used without instantiation.
HmsArf
¶
Areal Reduction Factor (ARF) application for HEC-HMS met files.
Applies ARF scalars to precipitation depths in .met files, scaling point precipitation to areal averages based on subbasin-specific reduction factors.
Supports two workflows:
- Compute: Per-junction ARF values from DAR curves and CDA
(compute_kcda_cdas, lookup_arf_from_dar, build_kcda_arf_table)
- Apply: ARF scalar to global depths in a met file (apply_arf)
All methods are static - no instantiation required.
Example
from hms_commander import HmsArf dar_curve = [(10, 1.0), (100, 0.97), (1000, 0.92), (10000, 0.85)] table = HmsArf.build_kcda_arf_table( ... "watershed.basin", ["J-Outlet"], dar_curve ... ) result = HmsArf.apply_arf("model.met", arf=table.loc[0, 'arf']) print(f"Updated {result['depths_modified']} depths")
Source code in hms_commander/HmsArf.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
validate_arf_table(met_path, arf_table, hms_object=None)
staticmethod
¶
Verify all subbasins in met file have ARF values in the table.
Parameters¶
met_path : str or Path Path to the .met file arf_table : dict or pd.DataFrame If dict: {subbasin_name: arf_scalar}. If DataFrame: must have columns 'subbasin' and 'arf'. hms_object : optional Optional HmsPrj instance
Returns¶
dict Validation result with keys: - valid: bool — True if all subbasins have ARF values - met_subbasins: list — subbasins found in met file - arf_subbasins: list — subbasins in ARF table - missing: list — subbasins in met file but not in ARF table - extra: list — subbasins in ARF table but not in met file
Example¶
result = HmsArf.validate_arf_table("model.met", arf_table) if not result['valid']: ... print(f"Missing ARFs for: {result['missing']}")
Source code in hms_commander/HmsArf.py
apply_arf(met_path, arf_table=None, arf=None, preserve_original=True, hms_object=None)
staticmethod
¶
Apply Areal Reduction Factors to precipitation depths in a met file.
Two usage modes:
Mode 1 – Direct scalar (A03 workflow, "Frequency Based Hypothetical"):
Pass arf as a float. All Depth: lines inside the
Precip Method Parameters: block are multiplied by the scalar.
This correctly handles met files where subbasin blocks are empty
and depths live only in the global parameters block.
Mode 2 – Per-subbasin table (met files with per-subbasin depth lines):
Pass arf_table as a dict or DataFrame. Each subbasin block that
contains Depth: lines is updated with its own ARF scalar. Falls
back to mean-ARF global modification when no subbasin blocks have depths.
Parameters¶
met_path : str or Path
Path to the .met file
arf_table : dict or pd.DataFrame, optional
If dict: {subbasin_name: arf_scalar}.
If DataFrame: must have columns 'subbasin' and 'arf'.
Ignored when arf is provided.
arf : float, optional
Single scalar ARF applied to ALL Depth: lines in the
Precip Method Parameters: block. Takes precedence over
arf_table when provided.
preserve_original : bool, default True
If True, creates a backup copy (.met.bak) before modifying.
hms_object : optional
Optional HmsPrj instance
Returns¶
dict Summary with keys: - subbasins_updated: int - subbasins_skipped: int - depths_modified: int — number of Depth: lines changed - changes: list of dict — per-subbasin/global change details - backup_path: str or None
Example¶
A03: Apply 0.92 ARF to all global depths¶
result = HmsArf.apply_arf("model.met", arf=0.92) print(f"Modified {result['depths_modified']} depth values")
Per-subbasin ARF table¶
arf_table = {'Subbasin-1': 0.92, 'Subbasin-2': 0.88} result = HmsArf.apply_arf("model.met", arf_table=arf_table)
Notes¶
ARF scalars are typically between 0.0 and 1.0, where 1.0 means no reduction. Values > 1.0 are allowed but will produce a warning.
Source code in hms_commander/HmsArf.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
compute_kcda_cdas(basin_path, kcda_junctions, hms_object=None)
staticmethod
¶
Compute Contributing Drainage Area (CDA) at each KCDA junction.
Traverses the basin network upstream from each KCDA junction and sums the subbasin areas to obtain the Contributing Drainage Area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basin_path
|
Union[str, Path]
|
Path to the .basin file |
required |
kcda_junctions
|
List[str]
|
List of KCDA junction names (analysis points) |
required |
hms_object
|
Optional HmsPrj instance |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Example
cdas = HmsArf.compute_kcda_cdas( ... "watershed.basin", ["J-Outlet", "J-Fork-A"] ... ) print(cdas[['junction', 'cda_acres', 'subbasin_count']])
Source code in hms_commander/HmsArf.py
lookup_arf_from_dar(cda, dar_curve, duration_hours=24.0)
staticmethod
¶
Interpolate ARF from a DAR (Depth-Area Reduction) curve at a given CDA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cda
|
float
|
Contributing drainage area (same units as dar_curve 'area' column or first element of each tuple) |
required |
dar_curve
|
Union[DataFrame, List[Tuple[float, float]], Dict]
|
One of: - DataFrame with columns ['area', 'arf'] - List of (area, arf) tuples, sorted or unsorted - Dict keyed by duration_hours → list of (area, arf) tuples, e.g. {6.0: [(10, 1.0), ...], 24.0: [(10, 1.0), ...]} |
required |
duration_hours
|
float
|
Used only when dar_curve is a duration-keyed dict. Selects the nearest available duration key. |
24.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
ARF value in [min_curve_arf, 1.0]. |
float
|
Returns 1.0 if CDA is at or below the minimum curve area |
|
float
|
(no reduction for very small areas). Extrapolation beyond the |
|
float
|
maximum curve area returns the last (smallest) ARF value. |
Example
dar = [(10, 1.0), (100, 0.97), (1000, 0.92), (10000, 0.85)] HmsArf.lookup_arf_from_dar(500, dar) # between 100 and 1000 0.945 # approx
Source code in hms_commander/HmsArf.py
build_kcda_arf_table(basin_path, kcda_junctions, dar_curve, duration_hours=24.0, hms_object=None)
staticmethod
¶
Compute ARF for each KCDA junction from DAR curves and drainage area.
Combines compute_kcda_cdas() and lookup_arf_from_dar() into a
single call. Specify outlet junctions → traverse upstream → sum subbasin
areas → CDA → look up ARF from DAR curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basin_path
|
Union[str, Path]
|
Path to the .basin file |
required |
kcda_junctions
|
List[str]
|
KCDA junction names (analysis points) |
required |
dar_curve
|
Union[DataFrame, List[Tuple[float, float]], Dict]
|
DAR curve (see |
required |
duration_hours
|
float
|
Storm duration for DAR curve lookup (default: 24) |
24.0
|
hms_object
|
Optional HmsPrj instance |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame sorted ascending by CDA with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Example
dar_curve = [(10, 1.0), (100, 0.97), (1000, 0.92), (10000, 0.85)] table = HmsArf.build_kcda_arf_table( ... "watershed.basin", ... ["J-Outlet", "J-Mid", "J-Headwater"], ... dar_curve, ... duration_hours=24, ... ) print(table[['junction', 'cda_acres', 'arf']])