Modify "to_rgb" loop in mineral.py to use numpy.where
Luner opened this issue · comments
Jonathan Luner commented
This loops through each of the pixels and checks to see if the pixel has data. If it does not, it sets the pixel's value to 0.
#remove no data pixels
for band in [red_band, green_band, blue_band]:
for x in range(band.shape[0]):
for y in range(band.shape[1]):
if numpy.isclose(band[x, y, 0], -0.005) or band[x, y, 0] == -50:
band[x, y] = 0
This takes a large amount of time as running this on the large example file will take around 20 minutes. Changing this loop to a numpy.where operation could significantly reduce runtime.
Lewis John McGibbney commented
+1
Jonathan Luner commented
Currently working in branch: "Issue-187". Currently runs through to_rgb loop in a few seconds instead of 20 minutes for the large example file. Compared results in QGIS and everything appears to work as expected.