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

poly_area() gives wrong values for area when the side of polygon crosses a pole #45

Closed
nikizadehgfdl opened this issue Jan 26, 2021 · 0 comments · Fixed by #60
Closed

Comments

@nikizadehgfdl
Copy link
Contributor

Describe the bug
The exchange grid tool uses a function poly_area(), which returns the area of a polygon on globe with given vertices, to calculate the (exchange) grid cell areas. This function gives an unreasonably large values when the side of such polygons crosses a pole. This is because the line inegral formula which the function is based on is not valid when such crossing happens and is bigger than what it should be by pi*R**2 (which explains why the returned area is almost half the area of the Earth).

This pole crossing happens mostly for stretched ATM grids (non-GCA) giving rise to tiling errors for those grids and holes in the Antarctic land_mask.

To Reproduce
Get a version of frenctools with more verbosity for the exchange grid creation tool:

bash
git clone -b nnz_NONGCA_strechedGridIssues https://gitlab.gfdl.noaa.gov/fre/fre-nctools.git fre-nctools_gitlab
cd fre-nctools_gitlab
git checkout adde039  #adds calculated atm_area to land_mask files
export CONFIG_SITE=site-configs/gfdl-ws/config.site 
source site-configs/gfdl-ws/env.sh 
module load gcc/6.2.0
export PATH=.:$PATH
autoreconf -i
./configure 
make

Now create a coupled mosaic with a stretched grid for ATM such as c256r25tlat32.0_om4p25.
Explore the values of area_atm array along the longitude in the tile that contains the south pole (land_mask_tile3.nc) . See figure below.

Expected behavior
area_atm should not give huge values.

System Environment
fre-nctools on PAN

Additional context
See issue #44 for the inaccuracies in poly_area even for non-stretched grids.

Figure below shows the value of area_atm in land_mask_tile3.nc

pathname320='/work/Niki.Zadeh/MOM6-examples_myfork/ice_ocean_SIS2/OM4_025/preprocessing.20201028/mosaic_c256r25tlat32.0_om4p25_githubMaster_Verbose_20210121/'          
land_mask0 = nc.Dataset(pathname320+'land_mask_tile3.nc')
mask320= np.array(land_mask0.variables['mask'])
area_atm320= np.array(land_mask0.variables['area_atm'])
plt.plot(area_atm320[128,:],marker='o')

atm_area_32N

Same as above after a fix to poly_area formulation to take into account the pole crossing for a polygon edge.

at

There is still the discontinuity mentioned in issue #44

@ngs333 ngs333 linked a pull request Mar 15, 2021 that will close this issue
@ngs333 ngs333 closed this as completed Mar 15, 2021
nikizadehgfdl added a commit to nikizadehgfdl/FRE-NCtools that referenced this issue Oct 25, 2022
- Closes issue NOAA-GFDL#180
- The centroid latitude calculation in ploy_ctrlat() needs a small fix similar to the fix in issue NOAA-GFDL#45
  for grid cells staddling the South pole but not including it as a vertex.
- Added/corrected comments in poly_area().
- Cleaned up poly_area() of unneeded code.
nikizadehgfdl added a commit to nikizadehgfdl/FRE-NCtools that referenced this issue Oct 31, 2022
- Closes issue NOAA-GFDL#180
- The centroid latitude calculation in ploy_ctrlat() needs a small fix similar to the fix in issue NOAA-GFDL#45
  for grid cells staddling the South pole but not including it as a vertex.
- Added/corrected comments in poly_area().
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 a pull request may close this issue.

2 participants