Skip to content
Back to skills

Docs

ASecurity

Prepare the HexWatershed JSON configuration file and basin definitions. This stage produces the two primary input files that control all model behavior: the main configuration JSON and the optional basin configuration JSON.

  • 200 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 11, 2026
toolspythongobash

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned September 11, 2026

npx -y skills add lzwei196/KISS---Knowledge-Infrastructure-for-Scientific-Simulation --skill docs --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docs?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docs
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lzwei196-docs-b905a547/badge)](https://www.skillsdirectory.com/skills/lzwei196-docs-b905a547)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Stage 0: Configuration — Skill Document

## Purpose

Prepare the HexWatershed JSON configuration file and basin definitions.
This stage produces the two primary input files that control all model behavior:
the main configuration JSON and the optional basin configuration JSON.

## Inputs

| Input                    | Source                | Format      | Unit/Notes                     |
|-------------------------|-----------------------|-------------|--------------------------------|
| Study area extent       | User-defined          | Lat/lon box | Decimal degrees (GCS)          |
| Mesh type selection     | User decision         | String      | hexagon, square, latlon, mpas, dggrid, tin |
| Mesh resolution         | User decision         | meters      | Edge length of hex cells       |
| DEM path                | Preprocessed raster   | GeoTIFF     | EPSG:4326, meters elevation    |
| Outlet coordinates      | User-defined          | lat/lon     | Decimal degrees                |
| Flowline data (optional)| NHDPlus / HydroSHEDS  | Shapefile   | GCS coordinates                |

## Outputs

| Output                              | Format | Description                             |
|-------------------------------------|--------|-----------------------------------------|
| `hexwatershed_config.json`          | JSON   | Main configuration with all parameters  |
| `basins.json` (if stream burning)   | JSON   | Basin definitions with outlet + flowline paths |

## Procedure

1. **Select mesh type** based on domain:
   - Regional watershed: `hexagon` (eliminates directional bias)
   - Global simulation: `mpas` or `dggrid`
   - Comparison study: `square` (for D8 benchmarking)

2. **Set workspace paths** — all paths MUST be absolute:
   ```json
   {
     "sWorkspace_input": "/absolute/path/to/mesh",
     "sWorkspace_output": "/absolute/path/to/output",
     "sWorkspace_output_hexwatershed": "/absolute/path/to/output/hexwatershed"
   }
   ```

3. **Set stream definition method**:
   - `iFlag_stream_grid_option = 1`: Use burned-in streams (requires flowlines)
   - `iFlag_stream_grid_option = 2`: Use accumulation threshold (no flowlines needed)

4. **Set accumulation threshold** carefully:
   - Value < 1.0 → treated as **ratio** of maximum accumulation (e.g., 0.01 = top 1%)
   - Value ≥ 1.0 → treated as **absolute cell count**
   - Typical regional: 0.01 – 0.05
   - Typical global: 0.001 – 0.01

5. **Set missing value** to match DEM nodata exactly:
   ```json
   {"dMissing_value_dem": -9999.0}
   ```

6. **Configure optional features**:
   - `iFlag_hillslope = 1` for hillslope decomposition
   - `iFlag_vtk = 1` for 3D visualization
   - `iFlag_elevation_profile = 1` for elevation profiles

7. **If using stream burning** (`iFlag_flowline = 1`):
   - Create `basins.json` with outlet cell IDs matching actual mesh cells
   - Set `dBreach_threshold` (meters) to allow stream crossing corrections
   - Provide flowline file paths in basin config

## Verification

```bash
# Validate JSON syntax
python3 -c "import json; json.load(open('hexwatershed_config.json'))"

# Check all paths exist
python3 -c "
import json, os
cfg = json.load(open('hexwatershed_config.json'))
for key in ['sWorkspace_input', 'sWorkspace_output']:
    path = cfg.get(key, '')
    print(f'{key}: {path} -> {\"EXISTS\" if os.path.exists(path) else \"MISSING\"}')"

# Validate missing value matches DEM
# (requires GDAL)
python3 -c "
from osgeo import gdal
ds = gdal.Open('/path/to/dem.tif')
print('DEM nodata:', ds.GetRasterBand(1).GetNoDataValue())"
```

## Traps

### TRAP: Accumulation threshold dual interpretation (dt_007)
A threshold of 100 means "100 cells" (absolute), while 0.01 means "top 1%" (ratio).
Accidentally swapping these produces either zero streams or every-cell-is-a-stream.
**Always verify** which interpretation applies by checking if value < 1.0.

### TRAP: Missing value mismatch (dt_014)
If `dMissing_value_dem` is -9999.0 but DEM nodata is -3.4e38 (float min), valid cells
near nodata will be silently excluded. Always check: `gdalinfo dem.tif | grep NoData`.

### TRAP: Relative vs absolute paths
All `sWorkspace_*` and `sFilename_*` values must be absolute paths. Relative paths
cause "file not found" errors at runtime with unhelpful messages.

### TRAP: Wrong outlet cell ID (dt_008)
`lCellID_outlet` must exactly match a cell in the mesh JSON. If no cell has that ID,
the entire watershed is silently skipped with no error message. Use the flowline_converter
tool with `--mesh-json` to auto-detect the nearest cell.

## Example

```json
{
  "sMesh_type": "hexagon",
  "iFlag_global": 0,
  "iFlag_flowline": 0,
  "iFlag_multiple_outlet": 0,
  "iFlag_stream_grid_option": 2,
  "iFlag_hillslope": 1,
  "iFlag_vtk": 0,
  "iFlag_debug": 0,
  "nOutlet": 1,
  "iCase_index": 1,
  "dMissing_value_dem": -9999.0,
  "dAccumulation_threshold": 0.01,
  "dBreach_threshold": 0.0,
  "sWorkspace_input": "/data/hexwatershed/mesh",
  "sWorkspace_output": "/data/hexwatershed/output",
  "sWorkspace_output_hexwatershed": "/data/hexwatershed/output/hexwatershed",
  "sDate": "2026-03-26"
}
```

Files in this skill

  • REFERENCES.md1.4 KB
  • format_spec.yaml24.8 KB
  • papers.json5 KB
  • s0_configuration_skill.md5 KB
  • s1_mesh_generation_skill.md5.5 KB
  • s2_flowline_preparation_skill.md5.7 KB
  • s3_execution_skill.md6.5 KB
  • s4_output_analysis_skill.md6.2 KB
  • s5_validation_skill.md6.8 KB
  • validation_convention.yaml16.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…