You can do it with np.copyto
:
np.copyto(a, b, where = a==-999999)
Sample run:
>>> a = np.random.choice([0,1,-999999], size=[5, 6], p=[0.15, 0.15, 0.7])
>>> b = np.random.choice([0,1, 2], size=[5, 6], p=[0.3, 0.4, 0.3])
>>> a
array([[-999999, -999999, -999999, 1, 1, -999999],
[ 0, -999999, -999999, -999999, -999999, -999999],
[-999999, 1, -999999, -999999, -999999, 0],
[ 0, -999999, -999999, -999999, -999999, -999999],
[ 0, 1, -999999, -999999, 0, -999999]])
>>> b
array([[1, 1, 2, 2, 2, 0],
[0, 0, 2, 1, 1, 0],
[0, 1, 1, 1, 2, 1],
[1, 1, 2, 0, 0, 0],
[0, 2, 0, 2, 2, 2]])
>>> np.copyto(a, b, where = a==-999999)
>>> a
array([[1, 1, 2, 1, 1, 0],
[0, 0, 2, 1, 1, 0],
[0, 1, 1, 1, 2, 0],
[0, 1, 2, 0, 0, 0],
[0, 1, 0, 2, 0, 2]])