...
 
Commits (2)
......@@ -856,6 +856,10 @@ class GeoArray(object):
NOTE: -> numpy also returns a 2D array in that case
NOTE: if array is indexed with a slice -> keep it a 3D array
"""
# a single value -> return as float/int
if arr.ndim == 2 and arr.size == 1:
arr = arr[0, 0]
# 2D -> 3D
if arr.ndim == 2 and isinstance(getitem_params, (tuple, list)) and len(getitem_params) == 3 and \
isinstance(getitem_params[2], slice):
......@@ -1256,7 +1260,7 @@ class GeoArray(object):
plt.subplots_adjust(left=0.05, right=0.95, top=0.90, bottom=0.05, wspace=0.15, hspace=0.05)
ax = ax if ax is not None else plt.subplot(111)
m = Basemap(projection='tmerc', resolution=None, lon_0=center_lon, lat_0=center_lat,
m = Basemap(projection='tmerc', ellps='WGS84', resolution=None, lon_0=center_lon, lat_0=center_lat,
urcrnrlon=UR_XY[0], urcrnrlat=UR_XY[1], llcrnrlon=LL_XY[0], llcrnrlat=LL_XY[1])
# set color palette
......@@ -1326,7 +1330,7 @@ class GeoArray(object):
print(UL_XY, UR_XY, LR_XY, LL_XY)
# m = Basemap(projection='tmerc', resolution=None, lon_0=center_lon, lat_0=center_lat,
# urcrnrx=UR_XY[0], urcrnry=UR_XY[1], llcrnrx=LL_XY[0], llcrnry=LL_XY[1])
m = Basemap(projection='tmerc', resolution=None, lon_0=center_lon, lat_0=center_lat,
m = Basemap(projection='tmerc', ellps='WGS84', resolution=None, lon_0=center_lon, lat_0=center_lat,
urcrnrlon=UR_XY[0], urcrnrlat=UR_XY[1], llcrnrlon=LL_XY[0], llcrnrlat=LL_XY[1],
k_0=0.9996, rsphere=(6378137.00, 6356752.314245179), suppress_ticks=False)
# m.pcolormesh(Xarr, Yarr, self[:], cmap=plt.cm.jet)
......
__version__ = '0.8.16'
__versionalias__ = '20190429.02'
__version__ = '0.8.17'
__versionalias__ = '20190510.01'
......@@ -346,6 +346,22 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
self.assertEqual(inmem_res.ndim, notinmem_res.ndim)
self.assertEqual(inmem_res.shape, notinmem_res.shape)
def test___getitem__consistency_2d_array(self):
testarr = np.zeros((2, 2))
testarr[:, :] = [[11, 12], [13, 14]]
gA_inmem = GeoArray(testarr)
inmem_res = gA_inmem[0, 0]
with tempfile.TemporaryDirectory() as tf:
gA_inmem.save(os.path.join(tf, 'test.bsq'))
gA_notinmem = GeoArray(os.path.join(tf, 'test.bsq'))
notinmem_res = gA_notinmem[0, 0]
self.assertEqual(inmem_res.ndim, notinmem_res.ndim)
self.assertEqual(inmem_res.shape, notinmem_res.shape)
def test_numpy_array(self):
arr = np.array(self.testtiff)
self.assertIsInstance(arr, np.ndarray)
......