Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supergrids from internal FV3 grids. #118

Merged
merged 3 commits into from
Oct 13, 2021
Merged

Conversation

ngs333
Copy link
Contributor

@ngs333 ngs333 commented Oct 7, 2021

The PR modifies make_hgrid to correctly make supergrids from internal FV3 grids. Make_hgrid already contained a procedure to
read NetCDF files that contained the four fields grid_lon, grid_lont, grid_lat, and grid_latt. These fileds would be read, the points (lat and lon coordiantes) would be used as supergrid cell verticies and centroids, and the supergrid cell face midpoints would be calculated from them.
To correctly make this work, these changes were made to make_hgrid :
a) create_grid_from_file() function was modified so that the angular midpoints (lat and lon) between two points on the sphere (actually, two neighboring cell vertices) are the angles corresponding to the spatial midpoint on the great circle. The old method calculated the mid latitude as a simple 0.5 * (angular sum of neighbor latitudes); and similarly for the longitudes .
b) make_hgrid() function was modified to correcly allocate space for the supergrid when more than one tile is specified (in this case where the grid_type is "from_file").

Finally, a legacy flag was added as an "already deprecated" feature (to be removed in a future PR) to temporarily allow the use of the old/legacy method for calculating midpoints. (the new method is the default method)

Miguel Zuniga added 3 commits September 28, 2021 16:49
… two angles

as the midpoint on the great circle vs simple half of angular sum. Needed for FV3
internal grids.
@ngs333 ngs333 linked an issue Oct 7, 2021 that may be closed by this pull request
Copy link

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. As far as I can tell the big changes are to simply add the revised midpoint calculation and move the older algorithm to be an option.

This is a very nice improvement to this tool. Thanks for making this change.

Copy link

@bensonr bensonr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngs333 - I know you've tested the updates with the Cubed-Sphere. Have you also checked a regular lat-lon grid from file?

@ngs333
Copy link
Contributor Author

ngs333 commented Oct 8, 2021

@ngs333 - I know you've tested the updates with the Cubed-Sphere. Have you also checked a regular lat-lon grid from file?

@bensonr
I have not. Would this be an easy way to do it : Generate the ll-grid supergrid with make_hgrid standard args ( with args --grid_type regular_lonlat_grid ). Then extract the subset that is the B-grid (corner vertices) and possibly also the centroid. Then have make_hgrid generate the supergrid from that info and check it agrees with the original supergrid?

@bensonr
Copy link

bensonr commented Oct 8, 2021

@ngs333 - short of finding some CM2.1 or ESM2 datasets and mosaics, that's probably the easiest way to do it.

@ngs333
Copy link
Contributor Author

ngs333 commented Oct 8, 2021

Still working on testing alternate branch as @bensonr suggest, but I've been able to verify that
for regular lat-lon supergrid created from input from text file agree 100% with those
created the "common way" (see below). E.g. the text file generate by this python code:

import os
## making 1D lat list and 1D lon list for a
##    30 x 10 Reg LL grid ( 60 x 20 RLL supergrid) starting at (0,50)
stepsize = 1
lonMin = 0
lonMax = 61
latMin = 100
latMax = 121
fileo = open("ll_grid_30x10.txt", 'w')
fileo.write ("x-grid\n")
for x in range (lonMin, lonMax, stepsize) : 
    fileo.write (str(x * 0.5 ) + "\n")
fileo.write ("y-grid\n")
for y in range (latMin, latMax, stepsize):
    fileo.write (str(y * 0.5) + "\n")
fileo.close()

is a list of 61 supergrid longitudes in [0,30] incrementing by 0.5; and also 21 latitudes in [50,60]. It is used as input (ll_grid_30x10.txt below ) to make_hgrid as :

make_hgrid --grid_type from_file  --my_grid ll_grid_30x10.txt  \
	   --grid_name llgy --nlon 60 --nlat 20
``
and the resulting supergrid is in 100% agrement ( by ```nccmp -df``)  with the regular llat-lon sgrid made the "common way ":
```make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2   --xbnd 0,30 --ybnd 50,60  --nlon 60 --nlat 20
``


@ngs333
Copy link
Contributor Author

ngs333 commented Oct 12, 2021

@bensonr
I finally tested with a NetCDF input file that is like an FV3 internal grid (i.e. not a supergrid, but the model grid points, as far as I can tell, created by https://github.com/ngs333/gfdl_misc/blob/master/src/cpp_execs/fv3_regll_gen.cpp ) that is a regular lat-lon grid. I verified that this entered the "uniform grids" section of function create_grid_from_file() which wasnt tested before. The resultant supergrid that make_hgrid generated was same as the one made the "common way" . Thanks for the tip.

@ngs333 ngs333 merged commit f9aa019 into NOAA-GFDL:master Oct 13, 2021
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.

Supergrids from internal FV3 grids - make_hgrid related.
3 participants