Thank you for the answer. I decided to give np.where a go. I tried the following:
import os
import rasterio
import numpy as np
workspace = '.../tests'
A = os.path.join (workspace, "inRaster1.tif")
B = os.path.join (workspace, "inRaster2.tif")
with rasterio.open(A) as srcA:
array_inA = srcA.read()
profile = srcA.profile
with rasterio.open(B) as srcB:
array_inB = srcB.read()
array_out= np.copy(array_inA)
array_out[np.where(array_inA > 0.5),array_inB ,array_inA]
result = os.path.join (workspace, "result.tif")
with rasterio.open(result, 'w', **profile) as dst:
dst.write(array_out)
crs = srcA.crs
But I'm getting this error.
line 29, in <module> array_out[np.where(array_inA< 0.5),array_inB ,array_inA]
IndexError: arrays used as indices must be of integer (or boolean) type