-
Notifications
You must be signed in to change notification settings - Fork 55
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
erroneous mapping involving HDMAlk ROF grid #339
Comments
We also set up smaller regional test case (Pacific Northwest) by subsetting HDMAlk grid (including lake) and HDMA (no lake) and show similar incorrect runoff mapping to global for HDMAlk grid. Larger scale pattern is correct, but there are some random hrus where mapping is not correct. Note: For both ROF grids, we pre-computed ESMF weight file and centroid square mesh (to provide center coordinate of HRUs) as inputs to NOPC to remap CLM runoff to mizuRoute HRUs in the same ways. |
I brought this up with the CSEG group yesterday and we discussed it. The ESMF folks are interested in helping us out, if it looks like it's an ESMF problem. These are the notes from that meeting on this issue... The mapping files are created with an offline tool (not ESMF). It works for Naoki in an offline setup (which doesn't use CMEPS / ESMF), but gives weird patterns when running in CMEPS / ESMF. Bill: Could you try using the check_maps tool to determine if there is a problem in the mapping file itself? Erik will try this, and then if it seems like the mapping file is fine, will reach out to Bob Oehmke for help." I asked about what check_maps does, and it sends several analytic waveforms through and uses the mapping file to remap them. It can then assess what the errors are, since it's an analytic solution.. A couple people asked about looking at the actual mapping files so I'll add those in at some point. |
ESMF mapping file is located: HDMA-lake over Pacific Northwest region (not working) HDMA over Pacific Northwest region (works fine) potential problems
|
In trying check_maps on the above two mapping files it fails with an error as follows. I get a similar error for some of the other mapping files that do work as well. Some of the simpler grids do work however.
|
Of the mapping files we have already created the mapping files that the check_maps will work on are the following (just considering the ROF to LND maps): /glade/p/cesmdata/cseg/inputdata/rof/mizuRoute/gridmaps/map_HDMAmz_5x5_amazon_TO_5x5_amazon_aave.201028.nc /glade/p/cesmdata/cseg/inputdata/rof/mizuRoute/gridmaps/map_HDMAmz_CONUS_TO_0.125nldas2_aave.201104.nc /glade/p/cesmdata/cseg/inputdata/rof/mizuRoute/gridmaps/map_HDMAmz_TO_f19_aave.200901.nc /glade/p/cesmdata/cseg/inputdata/rof/mizuRoute/gridmaps/map_USGS_GFmz_TO_0.125nldas2_aave.201028.nc /glade/p/cesmdata/cseg/inputdata/rof/mizuRoute/gridmaps/map_USGS_GFmz_TO_f19_aave.201002.nc The script does say that some of it's tests fail, but they at least run. |
I haven't used check_maps in a long time, so I'm not sure off-hand what the errors you're getting indicate. As for the failures in the other files, if the failures are due to exceeding tolerances and it doesn't look like the errors are too large, I think that can sometimes be acceptable: If I remember correctly (from conversations with @mnlevy1981) the tolerances were derived from some trial and error, and can sometimes be too tight, e.g., when the source and destination grids have very different resolutions. |
I looked at the mapping files and didn't see anything obviously wrong, but often it's hard to tell that just by inspection. If this is working for another application using these weight files, the problem could just be an inconsistency in how the weight files are being interpreted on both sides. One approach to figuring this out would be to choose one of the "bad" cells and then track it through and figure out why that particular one is bad. E.g. look at the weight file and see what it's saying about that cell, etc. It looks like there are cells that are supposed to be 0.0 in the destination, but aren't. Is that true? Can you tell me the id of one of those cells. I could look at at what the weight file says about that cell and that might give a clue. |
@oehmke thanks for the suggestions. One clarification is that standalone mizuRoute uses mapping files that these mapping files were created from. So they aren't the same files -- but these files were created from the ones that work for standalone mizuRoute. Which means one possibility is there is some error in the conversion process. But, the conversion process works for other cases, so we aren't sure what's different about these cases or why it works there and fails here. And yes there are some cells that should be zero in the destination grid because it's outside of the CTSM domain. @nmizukami can you give out some ID's of a cell that's like that? |
That's right -- the errors should get larger as either grid gets coarser, and the tolerances were basically set with the assumption that the maps CESM used in 2012 when we were developing the tool should all pass... so anything coarser than some of the coarsest maps from that period of time will probably "fail" even if the maps are doing exactly what is advertised. The exception is that the conservation check applied to aave maps should pass regardless of resolution. Also, I don't really know what to expect from |
So the pairs of plots in the initial post were comparing a mizuRoute mapping file and a CESM mapping file generated from that mapping file? Could you make a similar pair of plots using a case where you were happy with the CESM mapping file generated from the mizuRoute file? And have you provided links to the mizuRoute files? Maybe comparing the structure of the mizuRoute file that results in a bad CESM map to the structure of a file the results in a good map would be informative. |
Thank you for the thoughts. Yes, I can identify some ID of HRU and associated grid cells. @mnlevy1981, my initial plots are all from remapped runoff in CESM (CTSM) using ESMF mapping files (which are converted from stand-alone mizuRoute mapping files). I have not posted any stand-alone mizuRoute remapped runoff here. So we have two mizuRoute grid files - one is catchment polygon only (which remap correctly in CESM), and another one is catchments + lake polygons (which does not). All the stand-alone remapped runoff (for both grids) look correct. |
Hi @ekluzek, I just noticed that the mesh file you created (/glade/work/mizukami/mizuRoute_data/ctsm_test/hdma-lake_pnw/ESMF_mesh_14x13pt_PacificNWUS_c230215.nc) is shifted by one grid box in latitude direction from the domain I used to create standalone weight file (/glade/work/mizukami/py_mapping/HDMA/fv0.9x1.25_pnw/fv0.9x1.25_pnw.nc). The Domain I subset (fv0.9x1.25_pnw.nc) and its SW and NE corner looks like this: But the image from mesh file is you can see the great salt lake is at the bottom row in my domain, but in one above from the bottom in the mesh. I don't think this causes the wrong mapping (because runoff from CLM is mapped correctly to HDMA PNW (no lake) grid). |
Could it be that the wrong version of the lake mesh is being used in the code that isn't giving the right results, but the correct mesh is being used for the code that is working? Having the wrong source or destination mesh for a given set of weights could produce strange results. |
Hi Bob, So little complicated to explain this, but... the stand-alone mapping file does not use the grid box coordinates, but just use indices of lat and lon grid (==the domain I created, not domain from Mesh Erik created) to locate which grid box(es) are overlapped. When I convert it to the ESMF mapping file, I took both CLM mesh (this is one row shifted) and HRU mesh (this is correct) to insert center coordinates (so mesh coordinate and mapping coordinates are consistent). So the CLM grid boxes picked by latitude index is one south below. As a result, the remapped runoff looks right, but if you look carefully, it look shifted by one grid box south.
So, looks like all HRUs are overlapped by gridbox at least partially. so I expect all the HRUs have some valid positive values. I still think it is good to track one bad HRU and see which grid boxes are used to computed remapped values. not sure how we can do? Here is one bad HRU: This is a good HRU (located to next to the bad one): |
Hi Naoki,
I ran out of time today, but next week I can take a look at the weight file and see which source 3017306 is coming from (if that would be useful).
Have a good weekend,
- Bob
… On Mar 3, 2023, at 1:34 PM, Naoki Mizukami ***@***.***> wrote:
Hi Bob, So little complicated to explain this, but... the stand-alone mapping file does not use the grid box coordinates, but just use indices of lat and lon grid (==the domain I created, not domain from Mesh Erik created) to locate which grid box(es) are overlapped. When I convert it to the ESMF mapping file, I took both CLM mesh (this is one row shifted) and HRU mesh (this is correct) to insert center coordinates (so mesh coordinate and mapping coordinates are consistent). So the CLM grid boxes picked by latitude index is one south below. As a result, the remapped runoff looks right, but if you look carefully, it look shifted by one grid box south.
It looks like there are cells that are supposed to be 0.0 in the destination, but aren't. Is that true? Can you tell me the id of one of those cells. I could look at at what the weight file says about that cell and that might give a clue.
So, looks like all HRUs are overlapped by gridbox at least partially. so I expect all the HRUs have some valid positive values.
I still think it is good to track one bad HRU and see which grid boxes are used to computed remapped values. not sure how we can do?
Here is one of bad HRUs:
This one is covered by only one grid box (so should be identical to the runoff value at that box)
HRU ID: 3017305.
HRU center coordinate: 241.63747004970298, 49.38593562863172
Source grid box center coordinate: 241.25, 48.53403091430664
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U53EQYKWRNW7OJHOHLW2JIUBANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Thank you Bob, yes, I think that would be helpful. I also put one good HRU (3019378) just located adjacent to the bad one (3017305). Both are supposed to be coming from the same source grid box. have a good weekend too. |
Hi Naoki,
I looked in the weight file: map_fv0.9x1.25_pnw_TO_HDMA-lake_pnw.nc
The weight file doesn’t have a HRU ids in it, but I just looked at the center coordinates:
HRU ID: 3017305.
HRU center coordinate: 241.63747004970298, 49.38593562863172
Is dst id: 641 in the weight file:
241.637470049703, // xc_b(641)
49.3859356286317, // yc_b(641)
Which is row 1013 in the weight matrix:
641, // row(1013)
Which has src id and weight:
123, // col(1013)
1, // S(1013)
Where src id 123 is:
241.25, // xc_a(123)
48.5340309143066, // yc_a(123)
Which from what you said is the correct src:
Source grid box center coordinate: 241.25, 48.53403091430664
Which all looks ok to me. I think the question now is are the ESMF Field and ESMF Mesh on the src and dst side for this in the CESM application ok, or is there something misaligned there compared to your other code. Let me think about a way to diagnose that.
- Bob
… On Mar 3, 2023, at 6:21 PM, Naoki Mizukami ***@***.***> wrote:
Thank you Bob, yes, I think that would be helpful. I also put one good HRU (3019378) just located adjacent to the bad one (3017305). Both are supposed to be coming from the same source grid box. have a good weekend too.
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7UZ7VDNYYBNCK2ZL25TW2KKLFANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Thank you Bob for looking into this. Yes, my question is also how the mapping file (src and dst locations) and mesh interact. As far as I have seen, there is no errors in both. One thing I am always careful about is the order of dest and src coordinate in mapping file is the same as Mesh. |
Hi Naoki,
I thought of a way to debug this a bit further. Someplace where you are applying these weights that are giving this problem there is an ESMF_FieldRegrid(srcField, dstField, ...) call to apply the routehandle representing the weights. Here srcField is the name of the source field and dstField is the destination Field.
Right before that call would you add: ESMF_FieldWriteVTK(srcField, fileName=“srcField”) and right after that call add: ESMF_FieldWriteVTK(dstField, fileName=“dstField”) and then recompile/run the code.
These added calls will write information about the underlying meshes and associated values of the Fields into two sets of files that end in .vtk. These files will give me a better idea of what’s going on with the meshes, etc. as you apply the weights. The values in the fields will be important, so if there’s a particular phase or something where you are seeing this problem make sure to stop with that one so the files don’t get over written.
Thanks and let me know if you have any questions!
- Bob
… On Mar 8, 2023, at 12:03 PM, Naoki Mizukami ***@***.***> wrote:
Thank you Bob for looking into this. Yes, my question is also how the mapping file (src and dst locations) and mesh interact. As far as I have seen, there is no errors in both. One thing I am always careful about is the order of dest and src coordinate in mapping file is the same as Mesh.
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U3Q3BCOQPV46I34PPTW3DJZRANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Hi Bob, thank you for the suggestion. Erik, It does not looks like there are any calls for |
Instead of ESMF_FieldRegrid() it could also be ESMF_FieldSMM() (both apply a routehandle created from mapping weights). However, my goal is actually to just write the source Field and destination Field after applying the weights, so if you just want to add the ESMF_FieldWriteVTK() calls someplace after you know that has happened, that works too. |
@nmizukami these calls are going to be inside of CMEPS. So we need to search inside the CMEPS external under components/cmeps. I'm looking at it to find the specific calls. But, there is a med_map_mod.F90 file that likely has all the remapping encapsulated inside of it. I'm going to try to find the specific call that covers LND to ROF mapping. |
I think this is where the ESMF_FieldRegridCreate gets called from: https://github.com/ESCOMP/CMEPS/blob/main/mediator/med_phases_prep_rof_mod.F90#L169 |
@oehmke we created a branch of CMEPS to do your suggestion. It seems to be having trouble finding ESMF_FieldWriteVTK. And I couldn't find documentation for that subroutine in ESMF documentation. Is it perhaps a different subroutine name you were thinking of? |
Just follow up..... we just added these lines
and got compiling error like:
so we thought the arguments are inconsistent? |
This may be missing the mark, but from your pasted text, there are curly quotes (unicode character) around srcField; could this be responsible for the first error you're getting? |
@billsacks that is definitely a problem. Thanks for noticing that! @nmizukami I committed that change and pushed it to the branch. |
Yes, good eye. I had trouble even seeing it, but when I tried compiling with that version vs. just typing it in, it didn’t work. Strange.
One other thing, you could add rc=rc to ESMF_FieldWriteVTK() and: if (ChkErr(rc,__LINE__,u_FILE_u)) return afterwards, just to be safe.
… On Mar 15, 2023, at 4:46 PM, Erik Kluzek ***@***.***> wrote:
@billsacks <https://github.com/billsacks> that is definitely a problem. Thanks for noticing that!
@nmizukami <https://github.com/nmizukami> I committed that change and pushed it to the branch.
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U57OU4T57GZ7BCVLGLW4JBDXANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
thanks everyone. we did not notice curly quotes... yes, it now compiled. I will run and then post the results. |
Ok, Now I have created vtk files from each PET, but not sure how the content is interpreted... just googling around, cannot find more information on this. any suggestions?? |
I usually look at them using VisIt. However, if you want to point me to where they are (or send them to me), then I can take a look at them with an eye towards what’s happening with that one bad destination location we were looking at before.
… On Mar 16, 2023, at 12:48 PM, Naoki Mizukami ***@***.***> wrote:
Ok, Now I have created vtk files from each PET, but not sure how the content is interpreted... just googling around, cannot find more information on this. any suggestions??
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U3WLFDXL54PWFRHWBTW4NOADANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Hi Bob, thank you! They are under /glade/scratch/mizukami/HDMA-lake_pnw/run |
Thanks! I’ll take a look (but might not be until tomorrow).
… On Mar 16, 2023, at 1:13 PM, Naoki Mizukami ***@***.***> wrote:
Hi Bob, thank you! They are under /glade/scratch/mizukami/HDMA-lake_pnw/run
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U5YEUGICML7JLPPMMTW4NQ5PANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Hi,
Just to let you know, I started looking through these. However, I’m still picking my way through them and don’t really have anything conclusive to report. I should have more early next week.
- Bob
… On Mar 16, 2023, at 3:34 PM, Robert Oehmke ***@***.***> wrote:
Thanks! I’ll take a look (but might not be until tomorrow).
> On Mar 16, 2023, at 1:13 PM, Naoki Mizukami ***@***.*** ***@***.***>> wrote:
>
>
> Hi Bob, thank you! They are under /glade/scratch/mizukami/HDMA-lake_pnw/run
>
> —
> Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U5YEUGICML7JLPPMMTW4NQ5PANCNFSM6AAAAAAUH6UOZE>.
> You are receiving this because you were mentioned.
>
|
Hi Bob, thank you for the update! and also thank you for taking time looking at this. Have a good weekend! |
Hi All,
I took a look a further look at the vtk files you sent. When I look at the values in the Fields corresponding to the “bad” locations that you identified in the weight file I get these:
src value = 8.93301e-07
src weight = 1.0
dst value = 1.15568e-05
It’s strange because the dst value isn’t 0, so I wonder if something is getting scrambled in the correspondence of the coordinates in the weight file and this Field? (Or maybe that dst value is considered bad?) Is any 0 value in this Field considered bad (I wasn’t sure what this field represents)? I did find some other 0 values in the dstField, so I could look at those instead.
Also, since src value * src weight is not equal to dst value, I was wondering if there are other calculations happening after the application of the regridding weights? If so, could we move the ESMF_FieldWriteVTK() closer to the application of the regrid weights (e.g. via ESMF_FieldSMMStore() or ESMF_FieldRegridStore()) to eliminate that as a possibility?
Thanks,
- Bob
… On Mar 17, 2023, at 6:43 PM, Naoki Mizukami ***@***.***> wrote:
Hi Bob, thank you for the update! and also thank you for taking time looking at this. Have a good weekend!
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U2NGEXFMFF74SMGZCDW4UALZANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Thanks Bob, I believe the bad location is one-to-one corresponding at least LND to ROF direction.
I expect the src values should be equal to dst value given the weight is one (so should not be 0?). A hru is 100% covered by one particular grid box? so yes, src value * src weight is supposed to be equal to dst value (and that is not happening). Also the src value is surface runoff (so it can be zero) I believe. |
Hi Naoki,
Ok, let’s focus on the fact that src_value*src_weight != dst_value. One possibility that I’d like to eliminate is that the values in the src or dst Fields are changing before they get written out. I don’t remember, did you put the ESMF_FieldWriteVTK() calls directly before and directly after the call that applies the routeHandle generated from the mapping weights? I.e. right before and after ESMF_FieldRegrid() or ESMF_FieldSMM()?
- Bob
… On Mar 20, 2023, at 4:57 PM, Naoki Mizukami ***@***.***> wrote:
Thanks Bob,
I believe the bad location is one-to-one corresponding at least LND to ROF direction.
It’s strange because the dst value isn’t 0
I expect the src values should be equal to dst value given the weight is one (so should not be 0?). A hru is 100% covered by one particular grid box? so yes, src value * src weight is supposed to be equal to dst value (and that is not happening).
Also the src value is surface runoff (so it can be zero) I believe.
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U6UIAWA63BMHJRUMRDW5DOHPANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Hi Bob, We put ESMF_FieldWriteVKT() here in CMEP (ekluzek/CMEPS@3f22706). There are several LND variables imported to ROF and they are bundled. So we don't see direct call for ESMF_FieldRegrid() nor ESMF_FieldSMM() here, but believed that |
I think that that subroutine probably includes one of FieldSMM() or FieldRegrid() or the FieldBundle versions of them. It would be great if you could look into that med_map_field_packed subroutine and put the FieldWriteVTK() calls right next to those. The subroutine input includes some norm and frac arguments, so it’s possible that the Field data is being modified before it comes out. It would be nice to eliminate that possibility. Thanks!
… On Mar 21, 2023, at 12:12 PM, Naoki Mizukami ***@***.***> wrote:
Hi Bob,
We put ESMF_FieldWriteVKT() here in CMEP ***@***.*** <ekluzek/CMEPS@3f22706>).
There are several LND variables imported to ROF and they are bundled. So we don't see direct call for ESMF_FieldRegrid() nor ESMF_FieldSMM() here, but believed that call med_map_field_packed include either call. might need to trace this subroutine??
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U2IADDXTEQAEVG7PELW5HVRRANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
@oehmke thanks for the hints on tracking this down. @nmizukami and I just went through the driver code to track down what was happening and discovered what is undoubtedly "the issue". It looks like we had set the mapping file in the case, but there is a bug in CMEPS so that file was not used! So it was doing a screwy mapping from the CTSM grid, to our mesh with the little squares around the center points of the HRU's. It shows up as wrong for the lake cases since the center points can be displaced from the center of the lake HRU. It wasn't right in either case, but is more noticeably wrong in the lake case. So I'm going to file some issues and get a bug fix for CMEPS which we'll try out and make sure is working correctly. |
The CMEPS issue is: |
Great! I’m glad that you were able to track that down. Let me know how it goes once you get that issue with the weight file fixed. Thanks.
… On Mar 22, 2023, at 3:08 PM, Erik Kluzek ***@***.***> wrote:
The CMEPS issue is:
ESCOMP/CMEPS#346 <ESCOMP/CMEPS#346>
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U5EAYCPMZSJG2WYQETW5NS4DANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Yes, it was great to find the bug, but one question I just started wondering about is: Bob identified the source and target value for one bad case.
when cmeps use a square box around the centroid to pick up the src value, dst value is supposed to be the same as src value given src weight=1? |
Yep, but I got src weight =1.0 by looking at the mapping file you sent me, so if it’s using some other way of mapping (e.g, another weight file), then that src weight may be something completely different.
… On Mar 23, 2023, at 11:58 AM, Naoki Mizukami ***@***.***> wrote:
Yes, it was great to find the bug, but one question I just started wondering about is:
Bob identified the source and target value for one bad case.
src value = 8.93301e-07
src weight = 1.0
dst value = 1.15568e-05
when cmeps use a square box around the centroid to pick up the src value, dst value is supposed to be the same as src value given src weight=1?
—
Reply to this email directly, view it on GitHub <#339 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6A7U7S2QCMYOBLBGBH7DTW5SFNBANCNFSM6AAAAAAUH6UOZE>.
You are receiving this because you were mentioned.
|
Working now. |
This is only for CTSM-mizuRoute, not applicable to standalone mizuRoute
ROF grid- rHDMAlk (HDMA-lake) cause erroneous runoff mapping. large scale pattern seems to be captured, but lots of speckles.
See examples of remapped runoff (1 month mean runoff) below.
1.0 degree CTSM grid (f09_f09) -> HDMA-lake (rHDMAlk)
1.0 degree CTSM grid (f09_f09) -> HDMA (rHDMA)
2 degree CTSM grid (f19_f19) -> HDMA-lake (rHDMAlk)
2 degree CTSM grid (f19_f19) -> HDMA (rHDMA)
The text was updated successfully, but these errors were encountered: