-
Notifications
You must be signed in to change notification settings - Fork 11
fix ease index in ease pfaf tile file and remove pole tiles #1430
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
base: develop
Are you sure you want to change the base?
Changes from all commits
ff1ada1
9f47996
83c0226
f50a92e
51ccb06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -968,12 +968,17 @@ SUBROUTINE supplemental_tile_attributes(nx,ny,regrid,dateline,fnameTil, Rst_id) | |
| real*4, allocatable, target :: q0 (:,:) | ||
| real(REAL64), allocatable :: rTable(:,:) | ||
| integer, allocatable :: iTable(:,:) | ||
| real(REAL64), allocatable :: rTable_keep(:,:) | ||
| integer, allocatable :: iTable_keep(:,:) | ||
| character(len=128) :: gName(2) | ||
| logical, allocatable :: IsOcean(:) | ||
| logical, allocatable :: keep_tile(:) | ||
| ! This is used to adjust EASE grid from 1-based to 0-based indexes | ||
| ! The tile file with only one EASE grid is already 0-based and may not go through this subroutine | ||
| ! This is a special case for river-routing. The ocean grid is also EASE just for convenience | ||
| logical :: two_EASE | ||
| integer :: ip_keep, k | ||
| real(REAL64), parameter :: EASE_LAT_MAX = 85.04459_REAL64 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weiyuan-jiang : The min/max latitudes for the EASE grid depend on the resolution. For consistency, we should probably get this from MAPL_ease_extent() |
||
|
|
||
| ! ----------------------------------------------------- | ||
| ! | ||
|
|
@@ -1222,10 +1227,12 @@ SUBROUTINE supplemental_tile_attributes(nx,ny,regrid,dateline,fnameTil, Rst_id) | |
|
|
||
| if (two_EASE) then | ||
| iTable(:,2) = iTable(:,2) - 1 | ||
| iTable(:,3) = iTable(:,3) - 1 | ||
| !flip to make it consistent with conventional EASE indexing | ||
| iTable(:,3) = JM(1) - iTable(:,3) | ||
|
|
||
| where (iTable(:,0) == 0) | ||
| iTable(:,4) = iTable(:,4) -1 | ||
| iTable(:,5) = iTable(:,5) -1 | ||
| iTable(:,5) = JM(1) - iTable(:,5) | ||
| endwhere | ||
| j = index(gName(2), "-Pfafstetter") | ||
| gName(2) = gName(2)(1:j-1) | ||
|
|
@@ -1247,7 +1254,33 @@ SUBROUTINE supplemental_tile_attributes(nx,ny,regrid,dateline,fnameTil, Rst_id) | |
| endwhere | ||
|
|
||
| fname=trim(fnameTil)//'.nc4' | ||
| call MAPL_WriteTilingNC4(fname, gName(1:n_grid), im(1:n_grid), jm(1:n_grid), nx, ny, iTable, rTable, N_PfafCat=SRTM_maxcat, rc=status) | ||
| if (two_EASE) then | ||
| ! remove tiles outside EASE grid domain | ||
| allocate(keep_tile(ip)) | ||
| keep_tile = (rTable(1:ip,2) <= EASE_LAT_MAX) .and. (rTable(1:ip,2) >= -EASE_LAT_MAX) | ||
| ip_keep = count(keep_tile) | ||
| ASSERT_(ip_keep > 0) | ||
|
|
||
| allocate(iTable_keep(ip_keep,0:7)) | ||
| allocate(rTable_keep(ip_keep,10)) | ||
|
|
||
| k = 0 | ||
| do n = 1, ip | ||
| if (keep_tile(n)) then | ||
| k = k + 1 | ||
| iTable_keep(k,0:7) = iTable(n,0:7) | ||
| rTable_keep(k,1:10) = rTable(n,1:10) | ||
| endif | ||
| enddo | ||
|
|
||
| call MAPL_WriteTilingNC4(fname, gName(1:n_grid), im(1:n_grid), jm(1:n_grid), & | ||
| nx, ny, iTable_keep, rTable_keep, N_PfafCat=SRTM_maxcat, rc=status) | ||
|
|
||
| deallocate(iTable_keep, rTable_keep, keep_tile) | ||
| else | ||
| call MAPL_WriteTilingNC4(fname, gName(1:n_grid), im(1:n_grid), jm(1:n_grid), & | ||
| nx, ny, iTable, rTable, N_PfafCat=SRTM_maxcat, rc=status) | ||
| endif | ||
|
|
||
| deallocate (rTable, iTable) | ||
| deallocate (limits) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ program main | |||
|
|
||||
| use MAPL | ||||
| use river_ncfile_helper | ||||
| use routing_model_constants, only : nc, nlon, nlat, np=>np_tot | ||||
| use routing_model_constants, only : nc, nlon, nlat, np=>np_tot, nlatE | ||||
|
|
||||
| implicit none | ||||
|
|
||||
|
|
@@ -51,7 +51,7 @@ program main | |||
| call read_ncfile_int1d(trim(file_path1),"i_indg",xi_tile,np) | ||||
| xi_tile = xi_tile + 1 | ||||
| call read_ncfile_int1d(trim(file_path1),"j_indg",yi_tile,np) | ||||
| yi_tile = yi_tile + 1 | ||||
| yi_tile = nlatE - yi_tile | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zyj8881357 : I tried to understand why the lat index is flipped here. It looks like Line 32 in ff111ad
It looks like if we don't flip the lat index at all, the processing should work out. But I didn't inspect every little bit of the code and didn't test it. There may be other processing involved that requires the lat index. If my hunch is right, though, we should avoid flipping the lat index twice. |
||||
| call read_ncfile_int1d(trim(file_path1),"pfaf_index",catid_tile,np) | ||||
| call read_ncfile_real1d(trim(file_path1),"area",area_tile,np) | ||||
| area_tile = area_tile * MAPL_RADIUS**2 / 1.e6 !km^2 | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zyj8881357 : Is there a place elsewhere in the code (e.g., in preprocessing) where the orientation of the latitude indices (j_indg) from the EASE-Pfaf file needs to be flipped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. for the file GEOSsurface_GridComp/Utils/Raster/preproc/routing_model/get_num_sub_catchment.f90.
The line 54: yi_tile = yi_tile + 1
should be changed to
yi_tile = nlatE - yi_tile
Also, add nlatE in line 6 as:
use routing_model_constants, only : nc, nlon, nlat, np=>np_tot, nlatE
That is all.