Strange behavior with basemap.interp() and masked arrays

Goodman, Alexander (398J-Affiliate)

June 24, 2013 6:27 PM

Hi Jeff,

for the quick reply. However I am a little lost with your suggested solution. The issue here is that if datain is a masked array, dataout will not be a masked array when order=3 is used unless masked=True is set, but this just results in none of the elements (besides those outside the domain of xin and yin) being masked. So are you saying to try setting the mask to what it would be after running interp() with order=0? I would appreciate a more concrete example.



After pondering this a bit more, I don’t think you can use order=3 with
masked arrays. Any reason why you can’t using a combo of bilinear and nearest neighbor as I described in my previous email?


I have done something slightly different that works more generally. I am trying to recall it from memory, so some details may be wrong.

Essentially, do the interpolation you want on a filled version of the masked array (filling with a value that makes sense for your data). Then, do the same interpolation on the mask, and cast the mask back as booleans. Finally, build the output masked array by combining the two together with one of the constructors.

Ben Root