I would like to perform this raster calculation where when ras@1 >0 gives me 1 as pixel value of the output raster, while when ras@1 <0 the values are given by the other formula ras@1/(1-2.71828^(ras@2)), but it doesn't work because it gives me in any case the result of the other formula, even when ras@1 is higher than zero. Can someone give me some suggestion?
import qgis
import gdal
from qgis.analysis import QgsRasterCalculator, QgsRasterCalculatorEntry
from qgis.core import QgsRasterLayer
inputpath = '/Users/macbook/Desktop/TESI/PROGETTO/sigm/sigmath90.tif'
inputpath2 = '/Users/macbook/Desktop/TESI/PROGETTO/lambdamin/lambminth90.tif'
outputpath = '/Users/macbook/Desktop/TESI/PROGETTO/alfamax/alphamaxth90.tif'
entries = []
inputrasterfile = QgsRasterLayer(inputpath)
ras = QgsRasterCalculatorEntry()
ras.ref = 'ras@1'
ras.raster = inputrasterfile
ras.bandNumber = 1
entries.append( ras )
inputrasterfile2 = QgsRasterLayer(inputpath2)
ras2 = QgsRasterCalculatorEntry()
ras2.ref = 'ras@2'
ras2.raster = inputrasterfile2
ras2.bandNumber = 1
entries.append( ras2 )
alpha_max='(ras@1 < 1)* ras@1 / (1-2.71828^(ras@2)) + (ras@1 >>1)*1'
new_path = outputpath
alfamax= QgsRasterCalculator(alpha_max, new_path, 'GTiff', inputrasterfile.extent(), inputrasterfile.width(), inputrasterfile.height(), entries )
alfamax.processCalculation()
iface.addRasterLayer(new_path)