diff --git a/ukis_pysat/data.py b/ukis_pysat/data.py
index 5c9f8ca..68a1847 100644
--- a/ukis_pysat/data.py
+++ b/ukis_pysat/data.py
@@ -278,7 +278,7 @@ class Image:
         return [wave_bands[platform][wavelength.lower()] for wavelength in wavelengths]
 
     def get_tiles(self, width=256, height=256, overlap=0):
-        """calculates rasterio.windows.Window, idea from https://stackoverflow.com/a/54525931
+        """Calculates rasterio.windows.Window, idea from https://stackoverflow.com/a/54525931
 
         TODO boundless with 'reflect' padding
 
@@ -306,6 +306,17 @@ class Image:
         # TODO using tukey --> https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.windows.tukey.html
         pass
 
+    def get_subset(self, tile, band=0):
+        """Get slice of array.
+
+        :param tile: rasterio.windows.Window tile from get_tiles().
+        :param band: Band number (default: 0).
+        :return: Sliced numpy array, bounding box of array slice.
+        """
+        # access window bounds
+        bounds = windows.bounds(tile, self.dataset.transform)
+        return self.arr[(band,) + tile.toslices()], bounds  # Shape of array is announced with (bands, height, width)
+
     def get_dask_array(self, chunk_size=(1, 6000, 6000)):
         """ transforms numpy to dask array
 

Build array subset from window tiles
Provide a method to build an array subset from window tiles.
The current workflow is to call the subset window in a for-loop through the [get_tiles](https://github.com/dlr-eoc/ukis-pysat/blob/master/ukis_pysat/data.py#L280) method. Subsetting the array is currently performed by the user by indexing the array with the window properties:
```
for window in data.Image(img_path).get_tiles():
    (row_start, row_stop), (col_start, col_stop) = window_tile.toranges()
    array[0][row_start: row_stop, col_start: col_stop]
```

This can be outsourced to a new method in [ukis_pysat.data](https://github.com/dlr-eoc/ukis-pysat/blob/master/ukis_pysat/data.py):
```
def get_subset(self, window_tile, array, band=0):
    (row_start, row_stop), (col_start, col_stop) = window_tile.toranges()
    return array[band][row_start: row_stop, col_start: col_stop]
```

Performance decreases when requesting the image array for each call:
```
def get_subset(self, window_tile, band=0):
    (row_start, row_stop), (col_start, col_stop) = window_tile.toranges()
    return self.arr[band][row_start: row_stop, col_start: col_stop]
```

This can be solved by handing the array to the new method directly. However, this requires refactoring the [constructor ](https://github.com/dlr-eoc/ukis-pysat/blob/master/ukis_pysat/data.py#L23) of the Image class so that arrays are accepted without handing a dataset as it is currently done [here](https://github.com/dlr-eoc/ukis-pysat/blob/master/ukis_pysat/data.py#L31).

Possible solution:
```
if isinstance(dataset, rasterio.io.DatasetReader) and isinstance(arr, np.ndarray):
    self.dataset = dataset
    self.arr = arr
elif isinstance(arr, np.ndarray):
    self.arr = arr
```

diff --git a/tests/test_data.py b/tests/test_data.py
index a7f7f87..99a36c8 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -93,6 +93,13 @@ class DataTest(unittest.TestCase):
 
         self.assertEqual(idx, 20807)
 
+    def test_get_subset(self):
+        for idx, each in enumerate(img.get_tiles(5, 5, 1)):
+            if idx == 2578:
+                array, bounds = img.get_subset(each)
+                self.assertTrue(np.array_equal(array, np.zeros(shape=(7, 7), dtype=array.dtype)))
+                self.assertEqual(bounds, (11.903960582768779, 51.45624717410995, 11.904589403469808, 51.45687599481152))
+
     def test_get_dask_array(self):
         self.assertIsInstance(img.get_dask_array(chunk_size=(1, 10, 10)), dask.array.core.Array)
 

pip install -e .[complete]
parse_log_pytest
requirements.txt
pytest pytest-cov
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
affine==2.4.0
appdirs==1.4.4
attrs==24.2.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
chardet==3.0.4
click==7.1.2
click-plugins==1.1.1
cligj==0.7.2
coverage==7.2.7
dask==2.14.0
exceptiongroup==1.2.2
Fiona==1.8.22
geographiclib==2.0
geojson==3.2.0
geomet==1.1.0
geopy==2.4.1
html2text==2020.1.16
idna==2.10
importlib-metadata==6.7.0
iniconfig==2.0.0
landsatxplore==0.6
munch==4.0.0
numpy==1.18.5
packaging==24.0
pandas==1.3.5
Pillow==7.1.2
pluggy==1.2.0
pylandsat==0.2
pyparsing==3.1.4
pyproj==2.6.1.post1
pytest==7.4.4
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
pytz==2025.2
rasterio==1.1.8
requests==2.23.0
rio-mucho==1.0.0
rio-toa==0.3.0
sentinelsat==0.14
Shapely==1.7.1
six==1.17.0
snuggs==1.4.7
tomli==2.0.1
toolz==0.12.1
tqdm==4.67.1
typing_extensions==4.7.1
-e git+https://github.com/dlr-eoc/ukis-pysat.git@d43da86c8cef138395c1e0ae5301d859915868e3#egg=ukis_pysat
urllib3==1.25.11
utm==0.5.0
zipp==3.15.0

name: ukis-pysat
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - affine==2.4.0
      - appdirs==1.4.4
      - attrs==24.2.0
      - chardet==3.0.4
      - click==7.1.2
      - click-plugins==1.1.1
      - cligj==0.7.2
      - coverage==7.2.7
      - dask==2.14.0
      - exceptiongroup==1.2.2
      - fiona==1.8.22
      - geographiclib==2.0
      - geojson==3.2.0
      - geomet==1.1.0
      - geopy==2.4.1
      - html2text==2020.1.16
      - idna==2.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - landsatxplore==0.6
      - munch==4.0.0
      - numpy==1.18.5
      - packaging==24.0
      - pandas==1.3.5
      - pillow==7.1.2
      - pluggy==1.2.0
      - pylandsat==0.2
      - pyparsing==3.1.4
      - pyproj==2.6.1.post1
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - rasterio==1.1.8
      - requests==2.23.0
      - rio-mucho==1.0.0
      - rio-toa==0.3.0
      - sentinelsat==0.14
      - setuptools==46.1.3
      - shapely==1.7.1
      - six==1.17.0
      - snuggs==1.4.7
      - tomli==2.0.1
      - toolz==0.12.1
      - tqdm==4.67.1
      - typing-extensions==4.7.1
      - urllib3==1.25.11
      - utm==0.5.0
      - zipp==3.15.0
prefix: /opt/conda/envs/ukis-pysat

tests/test_data.py::DataTest::test_get_subset
tests/test_data.py::DataTest::test__lookup_bands tests/test_data.py::DataTest::test_dn2toa tests/test_data.py::DataTest::test_get_dask_array tests/test_data.py::DataTest::test_get_tiles tests/test_data.py::DataTest::test_get_valid_data_bbox tests/test_data.py::DataTest::test_init tests/test_data.py::DataTest::test_mask_image tests/test_data.py::DataTest::test_warp tests/test_data.py::DataTest::test_write_to_file
ukis_pysat/data.py
ukis_pysat/data.py