Fix bug in get_gridcellarea function in util/coordinates#380
Fix bug in get_gridcellarea function in util/coordinates#380emanuel-schmid merged 2 commits intodevelopfrom
Conversation
| area = (ONE_LAT_KM * resolution)**2 * np.cos(np.deg2rad(lat)) * 1000000 | ||
| else: | ||
| area = (ONE_LAT_KM * resolution)**2 * np.cos(np.deg2rad(lat)) * 100 | ||
| area = (ONE_LAT_KM * resolution)**2 * np.cos(np.deg2rad(lat)) |
There was a problem hiding this comment.
This correction makes sense to me. I have also double checked with some example coordinates using this external tool: https://www.engr.scu.edu/~emaurer/tools/calc_cell_area_cgi.pl and it looks alright.
|
The factor 100 could be for a conversion from km2 to ha. Could it be that somewhere else in Climada this unit is (wrongly) expected? Might be good to check everywhere the function is used before merging, in case you haven’t yet done so |
|
@bguillod thanks a lot for that comment. Thinking about it, probably the crop production data we initially wrote this function for has the unit t/ha. I'll check and add the unit option ha. |
Sounds reasonable, in that case you should check how the funciton is used in teh crop module and if this needs to be aligned |
Actually a quick search on all calls to that function might be worth it, to make sure you don’t miss other cases which might expect units other than km2 or m2. |
|
yeah it looks like it's called once in |
|
Yes, thanks a lot everyone! I changed the default of the function to ha (as it is used in crop production) and added the calculation in km2. |
Hello!
I came across an issue with the unit / order of magnitude of this function.
Assuming that the max grid cell area should be 2500km^2 (50x50km), I am not sure why we had added *100 in the first place - or am I getting mixed up?
Thanks for having a look!
Best, Carmen