I have the foll. numpy masked array:
masked_array(data =
[[-- -- -- ..., -- -- --]
[-- -- -- ..., -- -- --]
[-- -- -- ..., -- -- --]
...,
[-- -- -- ..., -- -- --]
[-- -- -- ..., -- -- --]
[-- -- -- ..., -- -- --]],
mask =
[[ True True True ..., True True True]
[ True True True ..., True True True]
[ True True True ..., True True True]
...,
[ True True True ..., True True True]
[ True True True ..., True True True]
[ True True True ..., True True True]],
fill_value = -9999.0)
I want to replace all the -9999.0 in this masked array with 0.0, but the foll. does not work:
arr.data[arr == -9999.0] = 0.0
The resulting arr still has all the -9999.0 in it. How do I fix it?
--EDIT:
This is what arr.data looks like:
array([[-9999., -9999., -9999., ..., -9999., -9999., -9999.],
[-9999., -9999., -9999., ..., -9999., -9999., -9999.],
[-9999., -9999., -9999., ..., -9999., -9999., -9999.],
...,
[-9999., -9999., -9999., ..., -9999., -9999., -9999.],
[-9999., -9999., -9999., ..., -9999., -9999., -9999.],
[-9999., -9999., -9999., ..., -9999., -9999., -9999.]], dtype=float32)
-9999.0in it, and not some other floats very close to-9999.0?arr.datalooks likearr.filled(0)might be what you want.