Skip to content
Back to skills

Docs

ASecurity

Generate every L0 morphological input mHM needs as aligned ESRI ASCII grids and matching classdefinition files: terrain, flow direction/accumulation, soil, geology, land cover/LAI, and gauge grid.

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

Works with

  • cli

Security analysis

A100/100

Pro scans all 16 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-dc2866eb/badge)](https://www.skillsdirectory.com/skills/lzwei196-docs-dc2866eb)

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
# s2_morphology Skill

## Purpose

Generate every L0 morphological input mHM needs as aligned ESRI ASCII grids and matching classdefinition files: terrain, flow direction/accumulation, soil, geology, land cover/LAI, and gauge grid.

## Inputs

- `config.json` and `domain_info.json`.
- DEM raster for `tools/s2_morphology/prepare_morpho_data.py`.
- Optional MERIT D8 clip from s1 when using `--fdir_source merit`.
- HWSD raster and MDB for soil.
- GLiM shapefile for geology, or a fallback default class.
- AVHRR land-cover raster; this KI expects the UMD legend by default.
- Gauge longitude, latitude, and integer gauge id.

## Outputs

- `input/morph/dem.asc`, `slope.asc`, `aspect.asc`, `fdir.asc`, `facc.asc`.
- `input/morph/soil_class.asc` and `soil_classdefinition.txt`.
- `input/morph/geology_class.asc` and `geology_classdefinition.txt`.
- Land-use grids and `lai_classdefinition.txt`.
- `input/morph/idgauges.asc`.

## Procedure

Create terrain and routing predictors:

```bash
python tools/s2_morphology/prepare_morpho_data.py \
  --config runs/wangjiaba/config.json \
  --domain_info runs/wangjiaba/domain_info.json \
  --dem_path KISSPATH_DATA/china_dem_90m/china_dem_90m.tif \
  --fdir_source merit \
  --merit_dir_tif runs/basin/wangjiaba_merit_dir.tif
```

Create soil, geology, and land-cover inputs:

```bash
python tools/s2_morphology/hwsd_to_mhm_soil.py \
  --config runs/wangjiaba/config.json \
  --domain_info runs/wangjiaba/domain_info.json

python tools/s2_morphology/glim_to_mhm_geology.py \
  --config runs/wangjiaba/config.json \
  --domain_info runs/wangjiaba/domain_info.json

python tools/s2_morphology/landcover_to_mhm_luse.py \
  --config runs/wangjiaba/config.json \
  --domain_info runs/wangjiaba/domain_info.json \
  --legend umd
```

Place the gauge id on the L0 grid and validate all morphology headers:

```bash
python tools/s2_morphology/generate_gauge_grid.py \
  --config runs/wangjiaba/config.json \
  --domain_info runs/wangjiaba/domain_info.json \
  --gauge_lat 32.433 \
  --gauge_lon 115.617 \
  --gauge_id 51030

python tools/s2_morphology/validate_morph_grids.py \
  --morph_dir runs/wangjiaba/input/morph
```

## Verification

Every ASCII grid in `input/morph` must share the same header:

```bash
python tools/s2_morphology/validate_morph_grids.py \
  --morph_dir runs/wangjiaba/input/morph
```

Check the D8 code set and classdefinition files:

```bash
test -s runs/wangjiaba/input/morph/soil_classdefinition.txt
test -s runs/wangjiaba/input/morph/geology_classdefinition.txt
python - <<'PY'
from pathlib import Path
vals=set()
for line in Path("runs/wangjiaba/input/morph/fdir.asc").read_text().splitlines()[6:]:
    vals.update(int(float(x)) for x in line.split())
bad=vals - {-9999,0,1,2,4,8,16,32,64,128}
assert not bad, bad
print("fdir codes OK")
PY
```

## Traps

- `dt_r01` in `../diagnostics/triplets.yaml`: mismatched ASCII headers crash mHM.
- `dt_r05` and `dt_r13`: wrong D8 convention or cycles in `fdir.asc` can zero routing or hang mRM startup.
- `dt_r11` and `dt_v003`: DEM nodata handling and geographic cellsize affect DEM-derived slope/aspect.
- `dt_s01`: wrong soil classdefinition column order silently corrupts Ksat and porosity.
- `dt_s12`: AVHRR must use `--legend umd`; uniform land cover disables land-cover MPR behavior.
- `dt_r04` and `dt_v002`: the gauge id must land on the correct valid routing cell.

## Example

For Wangjiaba, pair the MERIT shapefile from s1 with `--fdir_source merit` and `--legend umd`, then run `validate_morph_grids.py` before generating MPR parameters.

Files in this skill

  • REFERENCES.md1.1 KB
  • format_spec.yaml37.1 KB
  • papers.json5.2 KB
  • s0_config_skill.md2.7 KB
  • s10_regionalize_skill.md2.5 KB
  • s1_domain_skill.md2.6 KB
  • s2_morphology_skill.md3.5 KB
  • s3_mpr_skill.md2.2 KB
  • s4_forcing_skill.md2.2 KB
  • s5_gauge_skill.md1.9 KB
  • s6_namelist_skill.md2.9 KB
  • s7_execute_skill.md2 KB
  • s8_postprocess_skill.md2.4 KB
  • s9_calibration_skill.md2.6 KB
  • validation_convention.yaml12.2 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…