-
Notifications
You must be signed in to change notification settings - Fork 31
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
CubedSphere grid cell area calculated by exchange grid tool has discontinuous values around the two poles #44
Comments
@nikizadehgfdl |
@ngs333 thanks for the observation. As you noted, the problem with GC algorithm is that currently it only works with 1st order interpolation. Whereas almost everyone wants to use 2nd order conservative method. Also, it produces non-convex exchange cells for stretched grids which renders it totally useless with our flux-exchange code (models crash). I suspect that the bump in the cell area is due to a bug and is not a feature of these grids because the exact Gauss-Bonnet formula used in make_hgrid.c does not show it. Perhaps when you use GC algorithm the exact formula is used (rather than a call to the function poly_area())? I'll probably get to this next week. |
@nikizadehgfdl I'll try to see if I can find a bug in poly_area(). But I am also thinking of changing make_coupler_mosaic to be able to use spherical_excess() in lieu of poly_area(). Do you think that could lead to something usefull? |
I think the spherical_excess() is the accurate geometrical formula everywhere on sphere (discovered by Lambert in 1760's for sphere and extended by Gauss and Bonnet to arbitrary surfaces). I don't know why poly_area() was created/used instead of spherical_excess(). I think your suggestion of using the spherical_excess() in make_coupler_mosaic is in the right direction. |
Update from week of Jan 3, 2022: |
@nikizadehgfdl In email you clarified Might we need a third function as poly area has too many assumptions for its use with the exchange grids at issue? Consider the signature of the function: |
@nikizadehgfdl First there is the publication “Stokes’s Theorem, Data, and the Polar Ice Caps”, by Baryshnikov and Ghrist that hose some new formula (see formula 6) that should be super accurate, plus they outline how to deal with the pole singularities (see last section). Finally, they mention another, slightly older publication that may also be of help: Chamberlain, R. G., Duquette, W. H. (2007). Some algorithms for polygons on a sphere. JPL Publication 07-3. Pasadena, CA: JPL NASA. Reading the Baryshnikov paper gave me an idea, which is when a polygon encloses a pole, calculate its are by dividing the polygon in two and summing the areas of the two but in the manner the image describes . In the attached PDF, the two polygons (one is a triangle) are formed by inserting two additional lines : one between the pole and any point (say P), and a second between the pole and the the point preceding (of following) P in circular order. For those two new sub-polygons, function poly_area can be used. Or perhaps |
Yes, this bug has nothing to do with stretched grid, it was seen in regular CS c256 grid.It's probably a bug in poly_area() formula when an edge of the grid cell passes through a pole. I am not sure if the same discontinuity happens when grid cell totally encloses a pole (as your figures on the left show). |
@nikizadehgfdl, @bensonr , @ceblanton , @jwdGFDL MZ Current (1/19/2022) status: I am starting again from 1A. I had done 1A, 2A, 3A, 3B, 4C but I think now that I must have made some mistakes or missed something. |
@nikizadehgfdl, @bensonr , @ceblanton , @jwdGFDL Is make_coupler_mosaic making "five sided squares" at the poles? But at a pole they are being specified by 5 points : An extra line in the path of the integral can be the extra value that the area is getting. |
Some data and notes :
|
@nikizadehgfdl The plot does not show the discontinuity, but there seems to be a dip at the pole. |
@nikizadehgfdl |
I looks like rotating (away from the poles) the two polygons that are input arguments to the polygon clipping algorithm (PS The graphics code is in Python using numpy and matplot3d. It is in my gfdl_misc repository, directory src/python, file polydis3d.py (or https://github.com/ngs333/gfdl_misc/blob/master/src/python/polydis3D.py ) |
@ngs333, this is odd. What are the two grids you are using and what are the coordinates of the corners of the two cells? Does this happen with the bronx-19 fre-nctools exec? |
@nikizadehgfdl |
@bensonr , @nikizadehgfdl This is the current tail end of the make_coupler_mosaic report:
The tiling error above is more than two orders of magnitude better than without the rotation. The most interesting thing is that tile 3 is now almost completely devoid of errors, while tile 6 is a little worse! |
This is just to note the effect of the changes (latest code is now here : https://github.com/ngs333/FRE-NCtools/tree/polyarea2 ) with the C256 streched grid Niki suggested. The changes include:
|
Describe the bug
The cubed sphere grid cell area calculated by the exchange grid tool has bumps around the two poles (see figures below). These bumps are not there in the cell area calculated by make_hgrid itself, the tool that creates the CS grid. Note that make_hgrid uses spherical_excess_area() (Gauss-Bonnet formula area_of_polygon = sum of interior spherical angles - 2pi) , whereas the exchange grid tool uses poly_area() ( area_of_polygon = line_intergal sin(lat) d(lon) ). The question is which one of these formulas are more accurate near the singular poles?
Non-GCA Stretched grids have the same symptoms which results in tiling errors.
To Reproduce
Get a version of frenctools with more verbosity for the exchange grid creation tool:
Now create any coupled mosaic grid with a uniform CS grid, e.g., Test03-grid_coupled_model.sh
Plot the calculated area_atm in land_mask_tile6.nc
Expected behavior
computed area in C48_grid.tile6.nc does not have a bump at the pole.
System Environment
FRE-NCTOOLS build on PAN
Additional context
We already know that the poly_area() formula is not correct when side of polygon crosses a pole.
Figure below shows area of ATM grid cells along the longitude passing through pole (at the peak) calculated by the exchange grid tool (poly_area) for c256_om4p25 grid
Same ATM grid cell area as above calculated by the make_hgrid.c (spherical_excess_area())
The text was updated successfully, but these errors were encountered: