@@ -269,24 +269,23 @@ def __init__(self, resolution):
269
269
self ._resolution = resolution
270
270
271
271
def transform_non_affine (self , ll ):
272
- longitude = ll [:, 0 : 1 ]
273
- latitude = ll [:, 1 : 2 ]
272
+ longitude = ll [:, 0 ]
273
+ latitude = ll [:, 1 ]
274
274
275
275
# Pre-compute some values
276
276
half_long = longitude / 2.0
277
277
cos_latitude = np .cos (latitude )
278
278
279
279
alpha = np .arccos (cos_latitude * np .cos (half_long ))
280
- # Mask this array or we'll get divide-by-zero errors
281
- alpha = ma .masked_where (alpha == 0.0 , alpha )
282
- # The numerators also need to be masked so that masked
283
- # division will be invoked.
280
+ # Avoid divide-by-zero errors using same method as NumPy.
281
+ alpha [alpha == 0.0 ] = 1e-20
284
282
# We want unnormalized sinc. numpy.sinc gives us normalized
285
- sinc_alpha = ma .sin (alpha ) / alpha
283
+ sinc_alpha = np .sin (alpha ) / alpha
286
284
287
- x = (cos_latitude * ma .sin (half_long )) / sinc_alpha
288
- y = (ma .sin (latitude ) / sinc_alpha )
289
- return np .concatenate ((x .filled (0 ), y .filled (0 )), 1 )
285
+ xy = np .empty_like (ll , float )
286
+ xy [:, 0 ] = (cos_latitude * np .sin (half_long )) / sinc_alpha
287
+ xy [:, 1 ] = np .sin (latitude ) / sinc_alpha
288
+ return xy
290
289
transform_non_affine .__doc__ = Transform .transform_non_affine .__doc__
291
290
292
291
def transform_path_non_affine (self , path ):
0 commit comments