dmask = ( sstdata == sstbadflag )&gt;&gt;&gt; sstbadflag[0] = 1.0E20
&gt;&gt;&gt; sstdata[badmask] = sstbadflag&gt;&gt;&gt; sstlons = sstdict["axis_coords"][pyferret.X_AXIS]&gt;&gt;&gt; m10r7lons = ( sstlons % 10.0 == 7.0 )&gt;&gt;&gt; sstlats = sstdict["axis_coords"][pyferret.Y_AXIS]&gt;&gt;&gt; import numpy&gt;&gt;&gt; midlats = numpy.logical_and(-3.0 &lt;= sstlats, sstlats &lt;= 3.0)&gt;&gt;&gt; tweakit = numpy.outer(m10r7lons, midlats)&gt;&gt;&gt; sstdata[tweakit,:,:,:,:] = 5&gt;&gt;&gt; sstdict["name"]