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

mkscripgrid.ncl generates corners in CW rather than CCW order #938

Closed
billsacks opened this issue Mar 9, 2020 · 6 comments · Fixed by #823 or #1079
Closed

mkscripgrid.ncl generates corners in CW rather than CCW order #938

billsacks opened this issue Mar 9, 2020 · 6 comments · Fixed by #823 or #1079
Assignees
Labels
bug something is working incorrectly

Comments

@billsacks
Copy link
Member

Brief summary of bug

It looks like https://github.com/ESCOMP/CTSM/blob/master/tools/mkmapgrids/mkscripgrid.ncl generates corners in clockwise rather than counter-clockwise order. According to ESMF documentation it is a requirement that corners be in counter-clockwise order.

General bug information

CTSM version you are using: master

Does this bug cause significantly incorrect results in the model's science? Probably not

Configurations affected: N/A

Details of bug

Both from examining the code and from running NCL's scrip_check_input on a generated grid, it appears that corners are in the wrong order. I'm not sure whether this actually causes problems with the generated mapping files.

@billsacks billsacks added the bug something is working incorrectly label Mar 9, 2020
@slevis-lmwg
Copy link
Contributor

Shall I link this issue to #823 and resolve from there, or do you prefer that I open a new PR?

@billsacks
Copy link
Member Author

Whichever is easier for you.

@ekluzek
Copy link
Collaborator

ekluzek commented May 12, 2020

From talking with Ufuk one resolution for this might be to remove the setting of corner coordinates. There was a problem in NCL in the past where they had to be set by hand. NCL probably does it correctly now so we could remove the manual setting of corners.

@ekluzek
Copy link
Collaborator

ekluzek commented May 20, 2020

The 5x5_amazon grid is in CCW order, so the original version must have been this way. The current version goes back to 2013 though.

Applying the following difference I can reproduce the 5x5_amazon grid (with only a roundoff difference in center lat and lon).

--- a/tools/mkmapgrids/mkscripgrid.ncl
+++ b/tools/mkmapgrids/mkscripgrid.ncl
@@ -124,16 +124,16 @@ end
   do i = 0, nx-1
     lat(:,i)          =  latCenters;
     latCorners(:,i,0) =  latCenters - delY/2.d0;
-    latCorners(:,i,1) =  latCenters + delY/2.d0;
+    latCorners(:,i,1) =  latCenters - delY/2.d0;
     latCorners(:,i,2) =  latCenters + delY/2.d0;
-    latCorners(:,i,3) =  latCenters - delY/2.d0;
+    latCorners(:,i,3) =  latCenters + delY/2.d0;
   end do
   do j = 0, ny-1
     lon(j,:)          =  lonCenters;
     lonCorners(j,:,0) =  lonCenters - delX/2.d0;
-    lonCorners(j,:,1) =  lonCenters - delX/2.d0;
+    lonCorners(j,:,1) =  lonCenters + delX/2.d0;
     lonCorners(j,:,2) =  lonCenters + delX/2.d0;
-    lonCorners(j,:,3) =  lonCenters + delX/2.d0;
+    lonCorners(j,:,3) =  lonCenters - delX/2.d0;
   end do
 
   ; for some reason, "No_FillValue" isn't working in the case where imask=1

Here's the command to use to reconstruct it...

./mknoocnmap.pl -p -9.5,295. -name 5x5_amazon -nx 5 -ny 5 -dx 17.5 -dy 11 -verbose

@ekluzek
Copy link
Collaborator

ekluzek commented May 20, 2020

Note, that if I let NCL set the corners, I also reproduce the 5x5_amazon grid, except only the corner latitudes are off by roundoff. So we might as well take out the calculation of the corners.

@ekluzek
Copy link
Collaborator

ekluzek commented May 20, 2020

The one thing about removing the calculation of the corners, is that it then doesn't work for a single point grid (or a grid with a single latitude or longitude).

ekluzek added a commit to ekluzek/CTSM that referenced this issue Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is working incorrectly
Projects
None yet
3 participants