diff --git a/geoarray/baseclasses.py b/geoarray/baseclasses.py index 68afd35ffde746e09bddea857eb643d800fe66e7..1dce8c36921fcfdfdd63e288d92989089b680211 100644 --- a/geoarray/baseclasses.py +++ b/geoarray/baseclasses.py @@ -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) diff --git a/geoarray/version.py b/geoarray/version.py index c1d431eef1eb8ff0538c872955f4c76293eb9751..40c0f8a0b59168e82c1c0694c5162c8d9d21948c 100644 --- a/geoarray/version.py +++ b/geoarray/version.py @@ -1,2 +1,2 @@ -__version__ = '0.8.16' -__versionalias__ = '20190429.02' +__version__ = '0.8.17' +__versionalias__ = '20190510.01' diff --git a/tests/test_geoarray.py b/tests/test_geoarray.py index caa67d6e1e07d49aafa845443b40ecc3ddb3f571..cf369a7791a66e65b135b02d78a83fd0f51d5bd4 100644 --- a/tests/test_geoarray.py +++ b/tests/test_geoarray.py @@ -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)