Skip to content
Back to skills

Docs

ASecurity

Convert external meteorological data (CMFD, MSWX, or other sources) to the SWAP .met file format with correct units and structure.

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

Security analysis

A100/100

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

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
# S1: Meteorological Forcing Conversion

## Purpose
Convert external meteorological data (CMFD, MSWX, or other sources) to the SWAP .met file format with correct units and structure.

## Inputs
- **CMFD forcing**: NetCDF files with prec (mm/day), temp (K), srad (W/m²), lrad (W/m²), wind (m/s), pres (Pa), shum (kg/kg)
- **MSWX forcing**: NetCDF with Tair (K), P (mm/3hr), SWd (W/m²), LWd (W/m²), wind (m/s), Pres (Pa), spechum (kg/kg)
- **Site coordinates**: lat, lon for nearest grid point extraction

## Outputs
- SWAP .met file with columns: Station, DD, MM, YYYY, Rad, Tmin, Tmax, Hum, Wind, Rain, ETref, Wet

## Procedure
1. **Extract grid point**: Find nearest lat/lon in forcing NetCDF
2. **Aggregate to daily**: MSWX is 3-hourly → daily aggregation needed
3. **Convert radiation**: W/m² → kJ/m²/d (multiply by 86.4 = 86400/1000)
4. **Convert temperature**: K → °C (subtract 273.15). For daily: extract Tmin and Tmax
5. **Convert humidity**: Specific humidity (kg/kg) + pressure (Pa) → vapor pressure (kPa):
   ```
   e_kPa = q * (P/1000) / (0.622 + 0.378 * q)
   ```
6. **Convert rainfall**: CMFD mm/day → direct. MSWX mm/3hr → sum 8 timesteps for mm/day
7. **Wind speed**: Direct (m/s). Ensure ALTW matches measurement height
8. **Set ETref**: Use -99.9 if not available (SWETR=0 will calculate from weather data)
9. **Write .met**: Header comments + CSV data rows
10. **Validate**: Check all ranges (Rad 0-50000, T -50..60, Hum 0-10 kPa, etc.)

## Verification
- `wc -l file.met` matches expected days + header lines
- `awk -F, '{print $5}' file.met | sort -n | tail -1` → max Rad < 50000 kJ/m²/d
- Hum values in 0.1-7 kPa range (NOT 0-1 range, NOT 0-100 range)
- No negative radiation or wind values
- Rain values in mm/d (0-500 reasonable, >500 suspect)

## Traps

### TRAP 1: Humidity units (CRITICAL — silent error)
SWAP expects **actual vapor pressure in kPa**, not relative humidity. If you pass:
- Relative humidity (0-1): ET will be massively overestimated (SWAP thinks air is bone-dry)
- Relative humidity (0-100): Values will be interpreted as >10 kPa → ET underestimated
- Specific humidity (kg/kg): Values near 0.01 → interpreted as 0.01 kPa → extreme drying

### TRAP 2: Radiation units (CRITICAL — silent error)
SWAP expects kJ/m²/d. Common mistakes:
- W/m² passed directly → values 0-400 interpreted as kJ/m²/d → 200× too low → no ET
- MJ/m²/d passed → values 0-30 → extremely low → minimal ET
- J/m²/d passed → values 0-4e7 → 1000× too high → extreme ET

### TRAP 3: Temperature in Kelvin
If K not converted to °C: values around 293 → SWAP interprets as 293°C → crash or nonsense

### TRAP 4: MSWX 3-hourly rainfall not aggregated
If 3-hourly values written as daily: rainfall 8× too low

## Example
```python
# CMFD → SWAP conversion
rad_kj = srad_wm2 * 86400 / 1000     # W/m² → kJ/m²/d
temp_c = temp_k - 273.15              # K → °C
e_kpa = shum * (pres/1000) / (0.622 + 0.378 * shum)  # kg/kg,Pa → kPa
rain_mm = prec_mm                     # CMFD already mm/day
```

Files in this skill

  • format_spec.yaml33.5 KB
  • papers.json7.1 KB
  • s0_configuration_skill.md2 KB
  • s1_met_forcing_skill.md3 KB
  • s2_soil_parameters_skill.md3 KB
  • s4_execution_skill.md3.2 KB
  • s5_output_parsing_skill.md3.1 KB
  • s6_visualization_skill.md2.8 KB
  • validation_convention.yaml19.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…