Numpy.ma not always necessary

I just discovered that there is an easier way to do this (e.g. from tutorial06): import numpy.ma as ma mask = ma.masked_where(countries[‘ISO’] != iso, countries[‘ISO’]) country = ma.array(countries[‘country’],mask=mask.mask).compressed()[0] by using the built-in numpy.where method: import numpy as np index = np.where(countries[‘ISO’] == iso) country = countries[‘country’][index][0] Yeah, that’s fun ! The numpy.where method takes two…

Matplotlib Basemap tutorial 03 : Masked arrays & Zoom

Here, we will focus on adding a “zoom box” on the top left corner of the plot. But before that, we will mask a part of the earthquakes, in order to have a “cleaner” map ! This is achieved by using the numpy.ma module : import numpy.ma as ma Mlon = ma.masked_outside(lon, 5.6, 7.5) #…