def test_get_data_multi_binary(self): with open(REQUEST_MULTI_JSON, 'r') as fp: request = json.load(fp) sentinel_hub = SentinelHub() # TODO (forman): discuss with Primoz how to effectively do multi-bands request t1 = time.perf_counter() response = sentinel_hub.get_data(request, mime_type='application/octet-stream') t2 = time.perf_counter() print(f"test_get_data_multi_binary: took {t2 - t1} secs") _write_zarr_array(self.RESPONSE_MULTI_ZARR, response.content, 0, (512, 512, 4), '<f4') sentinel_hub.close() zarr_array = zarr.open_array(self.RESPONSE_MULTI_ZARR) self.assertEqual((1, 512, 512, 4), zarr_array.shape) self.assertEqual((1, 512, 512, 4), zarr_array.chunks) np_array = np.array(zarr_array).astype(np.float32) self.assertEqual(np.float32, np_array.dtype) np.testing.assert_almost_equal( np.array([ 0.6425, 0.6676, 0.5922, 0.5822, 0.5735, 0.4921, 0.5902, 0.6518, 0.5825, 0.5321 ], dtype=np.float32), np_array[0, 0, 0:10, 0]) np.testing.assert_almost_equal( np.array([ 0.8605, 0.8528, 0.8495, 0.8378, 0.8143, 0.7959, 0.7816, 0.7407, 0.7182, 0.7326 ], dtype=np.float32), np_array[0, 511, -10:, 0])
def test_get_data_multi(self): with open(REQUEST_MULTI_JSON, 'r') as fp: request = json.load(fp) sentinel_hub = SentinelHub() t1 = time.perf_counter() response = sentinel_hub.get_data(request) t2 = time.perf_counter() print(f"test_get_data_multi: took {t2 - t1} secs") with open(self.RESPONSE_MULTI_TAR, 'wb') as fp: fp.write(response.content) sentinel_hub.close()