Skip to content
Back to skills

Docs

ASecurity

Build SFINCS topography (sfincs.dep), active cell mask (sfincs.msk), and index (sfincs.ind) files from a DEM. The quality of flood simulation depends critically on DEM accuracy and vertical datum consistency.

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

Security analysis

A100/100

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

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: Topography & Bathymetry — Skill Document

## Purpose

Build SFINCS topography (sfincs.dep), active cell mask (sfincs.msk), and index (sfincs.ind) files from a DEM. The quality of flood simulation depends critically on DEM accuracy and vertical datum consistency.

## Prerequisites

- grid_info.json from s1_domain (mmax, nmax, dx, dy, x0, y0, epsg)
- DEM raster covering the domain:
  - China: `data/dem/china_dem_90m/china_dem_90m.tif` (90m, EGM96)
  - Global: Copernicus GLO-30 (30m, EGM2008) — auto-downloaded by hydrobasin
  - Coastal: GEBCO bathymetry (for underwater topography)

## Inputs

| Input | Type | Source | Required |
|-------|------|--------|----------|
| grid_info.json | JSON | s1_domain | Yes |
| DEM raster | GeoTIFF | Auto-detect or user-specified | Auto |
| Basin shapefile | .shp | Delineation | Optional (for masking) |

## Procedure

1. **Run tool**: `build_sfincs_topobathy.py --grid_info <json> --shp_path <shp> --output_dir <dir>`
   - DEM auto-selects: China DEM for locations in China, otherwise requires user DEM or Copernicus.

2. **Check topobathy_summary.json**:
   - `active_cells > 0` — if zero, CRS mismatch (dt_019)
   - `elevation_min` and `elevation_max` are reasonable for the domain
   - `outflow_cells > 0` — edge cells allow water to exit (dt_007)

3. **Verify vertical datum**:
   - China DEM 90m: EGM96 geoid heights
   - Copernicus GLO-30: EGM2008 (difference from EGM96: < 1m typically)
   - CaMa-Flood sfcelv: relative to geoid (consistent with China DEM)
   - If using tidal BC (coastal): verify datum matches DEM (dt_004)

4. **For coastal domains**: Merge DEM topography with GEBCO bathymetry below sea level.
   The current tool uses land DEM only. For coastal applications, pre-merge using:
   ```python
   merged = np.where(dem > 0, dem, gebco)  # Use GEBCO for underwater areas
   ```

## Expected Outputs

| Output | Path | Size | Verification |
|--------|------|------|-------------|
| sfincs.dep | `{output_dir}/sfincs.dep` | **n_active * 4 bytes** (compressed, dt_v023) | Elevation range correct |
| sfincs.msk | `{output_dir}/sfincs.msk` | **n_active * 1 byte** (compressed, dt_v023) | Active cells > 0 |
| sfincs.ind | `{output_dir}/sfincs.ind` | **(n_active + 1) * 4 bytes** | int32 n_active header, then 1-based FORTRAN-order (n fastest, row 0 = SOUTH) indices |
| topobathy_summary.json | `{output_dir}/topobathy_summary.json` | - | Statistics |

## Validation Checks

1. File sizes match: dep = n_active * 4, msk = n_active * 1, man = n_active * 4, ind = (n_active + 1) * 4.
   These are COMPRESSED maps holding only the active cells in sfincs.ind order — a full
   nmax*mmax grid makes SFINCS silently simulate a scrambled fragment (dt_v023).
2. Active cells > 0 (mask values > 0)
3. Edge active cells have mask=2 (outflow), not mask=3
4. Elevation range is physically reasonable (not all -9999)
5. No extreme elevation spikes (check max-min < 10000m)

## Common Pitfalls

- **dt_004**: Vertical datum mismatch (EGM96 vs WGS84 ellipsoid = 20-40m offset). For coastal modeling, this is CRITICAL.
- **dt_006**: Grid origin displacement after reprojection. Tool reads from grid_info.json (single source of truth).
- **dt_007**: All edge cells set to mask=3. Tool auto-detects edges and sets to mask=2.
- **dt_019**: Mask all zeros — shapefile CRS does not match grid EPSG.
- **dt_008**: Subgrid ratio > 30x causes artifacts. Keep computational:subgrid ratio at 5-20x.

Files in this skill

  • REFERENCES.md1.5 KB
  • format_spec.yaml44.1 KB
  • papers.json5.8 KB
  • s1_domain_skill.md2.5 KB
  • s2_topobathy_skill.md3.4 KB
  • s3_roughness_skill.md2.1 KB
  • s4_forcing_skill.md4.2 KB
  • s5_structures_skill.md2.1 KB
  • s6_config_skill.md2.7 KB
  • s7_execution_skill.md2.6 KB
  • s8_postprocess_skill.md3.1 KB
  • validation_convention.yaml8.6 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…