New generate-history utility for creating synthetic history files#40
Open
ceblanton wants to merge 6 commits into
Open
New generate-history utility for creating synthetic history files#40ceblanton wants to merge 6 commits into
ceblanton wants to merge 6 commits into
Conversation
Extends the generate-history CLI with --grid-type cubed-sphere and
--grid-type tripolar, along with a new grid_spec.py module that
produces minimally functional FMS mosaic files for use with fregrid.
Cubed-sphere (--grid-type cubed-sphere --ntile N, requires mpirun -n 6):
- Uses define_cubic_mosaic with tile_count=6 so FMS writes per-tile
history files (stem.tile1.nc ... stem.tile6.nc)
- Writes C{N}_mosaic.nc + C{N}_grid.tile{1..6}.nc with gnomonic
equal-angle lat/lon geometry matching the GFDL make_hgrid convention
- Writes C{N}_scrip.nc for ESMF/esmpy compatibility
Tripolar ocean (--grid-type tripolar --nx N --ny N):
- Registers dual h/q grid axes (xh/yh for tracers, xq/yq for velocity)
- --q-vars selects which fields go on the q-grid
- Writes ocean_mosaic.nc + ocean_hgrid.nc + ocean_scrip.nc
Both grid types:
- Pad mosaic char variables with null bytes (not spaces) so fregrid
can parse filenames correctly
- Stamp interp_method = conserve_order1 on all data variables so
fregrid accepts the history files without extra configuration
All five verification tests pass: generate + fregrid for both grids.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- black + isort reformatted generate_history.py and grid_spec.py - strip trailing whitespace from README.md - remove spurious f-prefix from f"SCRIP grid file" (flake8 F541) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… line black 20.8b1 requires spaces around the exponentiation operator in expressions like `EARTH_RADIUS ** 2` (modern black omits the spaces). Also restore the two blank lines after imports that isort requires. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Installation instructions for GFDL systems: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
New pip-installed tool that uses pyfms to drive the FMS diag manager and produce synthetic but usable NetCDF history files without running a real model. It supports three grid types — regular lat/lon, cubed-sphere atmosphere (6-tile gnomonic, via mpirun -n 6), and tripolar ocean — and for each native grid it also writes the FMS mosaic and supergrid files needed to regrid the output with fregrid.
How Has This Been Tested?
I pip installed following the README instructions and used this example diag-yaml:
Then, I created 3 flavors of "history" output:
generate-history diag_table.yaml --nx 32 --ny 32 --nz 2 --calendar noleap --nsteps 8 --output-dir out.regular
mpirun -n 6 generate-history diag_table.yaml --grid-type cubed-sphere --ntile 6 --calendar=noleap --output-dir out.cubed --nsteps 8 --ntile 96
generate-history diag_table.yaml --grid-type tripolar --nx 60 --ny 40 --nz 2 --calendar noleap --nsteps 8 --output-dir out.tripolar
The output looked plausible in all 3 cases. Then I regridded the cubed-sphere and tripolar files, with usable mosaic files generate along with the history files.
fregrid --input_mosaic C96_mosaic.nc --input_file annual --scalar_field tas --output_file regridded.nc --nlat 90 --nlon 180
fregrid --input_mosaic ocean_mosaic.nc --input_file annual --scalar tas --output_file regridded.nc --nlat 90 --nlon 180
fregrid worked in both cases.
Checklist: