Skip to content

Write DZDXF/DZDYF derived from ZSF - #6

Open
masih-e wants to merge 1 commit into
mainfrom
add-terrain-gradients
Open

Write DZDXF/DZDYF derived from ZSF#6
masih-e wants to merge 1 commit into
mainfrom
add-terrain-gradients

Conversation

@masih-e

@masih-e masih-e commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Closes #5

Derives DZDXF/DZDYF from the reprojected ZSF and writes them alongside
NFUEL_CAT/ZSF.

Boundary handling. The issue specifies "equivalent to extending terrain at
the edge." I used a one-sided difference instead. Replicating the edge into a
ghost cell leaves the numerator z1-z0 over a denominator of 2h, which
reports half the true gradient, an O(1) error.

Map factor sense. Applied map factors, but multiplying where calc_dfdx (WPS) divides. WRF
measures grid spacing in projection space and treats the true inter-point
distance as dx/MAPFACdyn_em/module_diffusion_em.F:1894 builds its
physical mixing length as sqrt(dx/msftx * dy/msfty). So a physical gradient
multiplies by the map factor, and dividing doubles the error rather than
removing it. This reads like a WPS bug rather than a convention to match, but
flagging it since anyone diffing against a geogrid-produced file will see the
difference. Negligible at fire scale (5e-6 across the 40 km CT2 nest), 1.3%
across 2000 km, 8% across a continental domain.

CFBM reads the terrain gradients from the input file. Both gradients
are derived form the reprojected ZSF.

Sencil follows geogrid's calc_dfdz/calc_dfdy with centred difference in
the interior, one-sided at the edges.

Behavior unchanged for NFUEL_CAT and ZSF.

Portions drafted with Claude Opus 5.

Closes #5
@mefrediani

Copy link
Copy Markdown
Collaborator

Thank you @masih-e! Can you confirm that you tested the new code and checked the output?
@mkavulich do you want to double check it and let me know if we need anything else to approve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add DZDXF, DZDYF output when writing ZSF

2 participants