Welcome to the new DiscussCESM forum!
We are still working on the website migration, so you may experience downtime during this process.

Existing users, please reset your password before logging in here: https://xenforo.cgd.ucar.edu/cesm/index.php?lost-password/

Grid tools python library

cermak

Rob Cermak
New Member
An assembly of useful python code is in progress at ESMG/gridtools. The current release is 0.1.1 with some very basic functionality to assist in generation of an ocean grid in a few projections. General instructions for installation and use of the application can be found in the repository.

The library only generates an ocean_hgrid.nc file (supergrid) for MOM6 at present. Here is a list of tasks and important references collected so far.

Contributions welcome from additional code to do X, Y or Z, exercising existing code and shoring up algorithm implementation, correcting documentation and/or code attribution. This library is leveraging code from several repositories. If there are additional attribution required, please let us know. Once documentation processes are established, the method of citation will be consolidated. This will need to be solved soon as some documentation should really go into or just point back to the MOM6 documentation instead of duplicated in this repository.

If there is code out there that could be useful, we can take a look at that too. It does not have to be written in python.

Pull requests should be sent against the dev branch for review.

We are still tackling basic issues at the moment to form out initial core functionality:
  • Regional MOM6 grid generation; reading existing MOM6 grids
  • Internal tide parameterization through implementation of Niki Zadah's set of tools to generate model topography given model grid and observation data (**)
  • Several options for field regridding to MOM6 grids (**)
  • Plotting model results
  • Universal hashing method (and other useful metadata) that can be applied and checked to help prove reproducibility of grids/fields across platforms
(**) expected in the 0.2.0 release

The repository does not have a stated license at present. Adoption of the MOM6 license (version 3 of the Gnu Lesser General Public License) is being considered.

Is there any objection?
 

cermak

Rob Cermak
New Member
Announcing Release 0.2.0 of the gridtools library

General Release Notes

- Adopt MOM6 license for the gridtools library.
- Add the ability for basic plotting of a single variable.
- Add the ability to write out FMS mosaic files.
- Given `MINIMUM_DEPTH`, `MAXIMUM_DEPTH` and `MASKING_DEPTH`, the
appropriate masks are written to the exchange grids for
`tile1` for any given bathymetry grid.
- Ability to generate a topography/bathymetry grid from any
data source. This routine also generates fractional ocean mask.
- Ability to generate a topography/bathymetry grid from any
data source and generate a roughness parameter (h2) using
a mesh refinement method.
- Add the ability to convert a ROMS model grid to a MOM6
model grid.
- Use sphinx as the documentation pathway for the python
library.
- HTML and PDF documentation rendered to
Welcome to Gridtools library’s documentation! — Gridtools library 0.2.0 documentation
- Add cluster notes for chinook@UAF and triton@RU.
- Add installation notes on RasPi4, an aarch64 platform type
for independent platform comparisons.
- References to papers and code being relocated to a
central bibtex file used by sphinx (WIP).
- Fixing up references to previously implemented code (WIP).
- Remove extraneous whitespace.
- Implement a catalog system for data sources (WIP). It should not interfere
with using files directly on a local system.


# Bug Fixes

- In the application, saving a remote file now goes to
the specified filename and directory.
- Pin version of python docutils to 0.16 to fix rendering
of bullet items for Read the Docs.


# API Changes

- Use openGrid()/readGrid() to open and read existing MOM6 model grids.
- Use openDataset() to open and read other gridded information.



We are looking for "alpha" testers as these tools are still in the very early stages of development. There is room for huge amounts of improvement. I am writing up additional TODOs as I write this message...

In summary, this version should let users develop a grid. Select a bathymetry source and utilize one of two functions. One will allow creation of a bathymetry grid and ocean mask fraction. Another will create a bathymetry grid with a roughness parameter (h2). Once a bathymetry grid is created, a set of FMS mosaic files for a regional run can be saved using user defined: MINIMUM_DEPTH, MASKING_DEPTH and MAXIMUM_DEPTH. If the bathymetry grid is modified by an external utility, gridtools can be used to rewrite the FMS mosaic files so the land and ocean masks are correct.

We are monitoring a MOM6 PR#1428(Bugfix: Minor changes on clipping topography from file by herrwang0 · Pull Request #1428 · NOAA-GFDL/MOM6) that might require a change to how the masking is created for the ocean and land.

What is also in this release is additional generation of metadata to check to see if we are able to reproduce similar grids (bitwise) between platforms due to the large variance of software and hardware. If a minor difference creeps in, we can see which variable or variables the change occurred. There is a lot to be done on this front...


netcdf LCC_20x30_Example7 {
dimensions:
nyp = 61 ;
nxp = 41 ;
nx = 40 ;
ny = 60 ;
variables:
double x(nyp, nxp) ;
x:standard_name = "geographic_longitude" ;
x:units = "degrees_east" ;
x:sha256 = "6ec5434f2ba03c46bed25a9f65ee203b5e35ab7bc36e69663c3d361d596bfe8b" ;
double y(nyp, nxp) ;
y:standard_name = "geographic_latitude" ;
y:units = "degrees_north" ;
y:sha256 = "4bbe10e025229ff860e40d50a9453bccd9b1651f76fc7a3522e8772f965e390a" ;
string tile ;
double dx(nyp, nx) ;
dx:standard_name = "grid_edge_x_distance" ;
dx:units = "meters" ;
dx:sha256 = "4bbe7c452ce8845cebe087b8819dae52b96c5cb620c356a2c2e8a7c3f2b8cae0" ;
double dy(ny, nxp) ;
dy:standard_name = "grid_edge_y_distance" ;
dy:units = "meters" ;
dy:sha256 = "726b36eb3db5fb375a48738b1de3a9db24821b98feac98667173a56707548425" ;
double angle_dx(nyp, nxp) ;
angle_dx:units = "radians" ;
angle_dx:sha256 = "a2c1493631388d7a3eb6010b3b1c4693edc38a803b3c37797b12f37ef659e895" ;
double area(ny, nx) ;
area:standard_name = "grid_cell_area" ;
area:units = "m2" ;
area:sha256 = "959d3830ac95ff5058d6cef6ba45f4da1f10ed885babb40c55ee11d222077061" ;



Our next release target will contain a port of the ROMS land mask editor for MOM6 grids.

Here is an outline of available grid generation pathways:

Gridtools_GridGenPathways.png

Model Grid


LCC_20x30_ModelGrid.png
Model Grid and Grid Cells

LCC_20x30_ModelGridCells.png

Model Grid - Bathymetry

LCC_20x30_OrigBathy.png

Model Grid - Roughness (h2)

LCC_20x30_h2.png

Model Grid - Bathymetry Method #2

LCC_20x30_Bathy_Example8.png


Model Grid - Ocean mask as a fraction (not just 1 or 0)

LCC_20x30_OceanMask_Example8.png








 

cermak

Rob Cermak
New Member
Gridtools Release 0.3.0

This release includes ocean mask editors. This is the first version of these tools.

We have ported the ROMS pylab editor from pyroms to gridtools. It is still very slow but it is at least available to edit ROMS ocean masks. This will likely be rewritten to try and optimize speed as we have done for the jupyter editor. The available path allows you to edit ROMS grids and then pass them through the ROMS to MOM6 converter and continue on your way.

A MOM6 grid editor is available in gridtools. To optimize speed, you only see a small subset of the grid. When you are done editing, you can update the INPUT files.

Pylab editor

pylabEditor1.png

pylabEditor2.png

Jupyter editor

1625942478250.png

Here is where the editors fit in the operational diagram for gridtools.

GridtoolsOperationalPaths_0.3.0.png
 
Top