UMEP-dev / UMEP-processing

GNU General Public License v3.0
7 stars 9 forks source link

Fix calculation of poisxy #58

Closed jlegewie closed 11 months ago

jlegewie commented 11 months ago

I think the poisxy is not calculated correctly in solweig_algorithm.py and is off by 1 in many cases in both the x and y dimension. As a result, the POI calculation uses the wrong cell for the tmrt value and other things are probably off as well.

Currently, the cell number in the x-dimension is calculated like this:

np.round((x - minx) * scale)

However, the rounding leads to wrong cell numbers in some situations.

Take the following raster:

And a point right in the middle at x = 3, y = 3, which should be in cell 1, 1. However, solweig gets the wrong point:

x = 3
minx = 0
scale = 1/2
np.round((x - minx) * scale)

This pull request instead uses the following code to calculate the point location and a similar logic for the y-dimension.

np.ceil((x - minx) * scale) - 1
biglimp commented 11 months ago

Thanks for noticing. Why one Earth do we have that if/else statement one line 747...? It has to do with negative coordinates but there is something strange here...

I checked. I think the if statement can be removed. I will approve this and remove the if/else-statement later.

jlegewie commented 11 months ago

I didn't get the if/else either... and looked 5 times for a difference... 😆 But I also didn't think through negative coordinates...