Skip to content

Commit

Permalink
ENH: Use the window argument to subset SAR data during SNAP pre-pro…
Browse files Browse the repository at this point in the history
…cess #186
  • Loading branch information
remi-braun committed Feb 21, 2025
1 parent 7e5a107 commit b4417ba
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- **ENH: Adding the support of WorldView Legion constellation** ([#183](https://github.com/sertit/eoreader/issues/183))
- **ENH: Adding the support of Umbra constellation (only GEC file)** ([#114](https://github.com/sertit/eoreader/issues/114))
- **ENH: Add the ability to open a product with a context manager** ([#133](https://github.com/sertit/eoreader/issues/133))
- **ENH: Use the `window` argument to subset SAR data during SNAP pre-process** ([#186](https://github.com/sertit/eoreader/issues/186))
- **ENH: Add a function computing the centroid of the footprint of the product**
- **ENH: Add a `path` attribute to the bands, corresponding to their path on disk**
- FIX: Fix toa radiance to toa reflectance computation for VHR data
Expand Down
4 changes: 3 additions & 1 deletion ci/weekly/test_all_sat_end_to_end_on_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def _test_core(

with tempfile.TemporaryDirectory() as tmp_dir:
if WRITE_ON_DISK:
tmp_dir = os.path.join("/home/data/ci/e2e_satellites")
tmp_dir = os.path.join(
"/mnt", "ds2_db3", "CI", "eoreader", "e2e_satellites"
)
output = tmp_dir
is_zip = "_ZIP" if prod.is_archived else ""
prod.output = os.path.join(output, f"{prod.condensed_name}{is_zip}")
Expand Down
20 changes: 18 additions & 2 deletions eoreader/data/cplx_no_calib_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@
<file>${file}</file>
</parameters>
</node>

<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Multilook">
<operator>Multilook</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
19 changes: 18 additions & 1 deletion eoreader/data/cplx_s1_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@
<formatName>SENTINEL-1</formatName>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>

<node id="ThermalNoiseRemoval">
<operator>ThermalNoiseRemoval</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<selectedPolarisations/>
Expand Down
19 changes: 18 additions & 1 deletion eoreader/data/cplx_s1_sm_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@
<formatName>SENTINEL-1</formatName>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>

<node id="ThermalNoiseRemoval">
<operator>ThermalNoiseRemoval</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<selectedPolarisations/>
Expand Down
19 changes: 18 additions & 1 deletion eoreader/data/cplx_sar_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
<file>${file}</file>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Calibration">
<operator>Calibration</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
21 changes: 19 additions & 2 deletions eoreader/data/grd_no_calib_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
<file>${file}</file>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Terrain-Correction">
<operator>Terrain-Correction</operator>
<sources>
<sourceProduct refid="LinearToFromdB"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down Expand Up @@ -46,7 +63,7 @@
<node id="LinearToFromdB">
<operator>LinearToFromdB</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Terrain-Correction"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
22 changes: 20 additions & 2 deletions eoreader/data/grd_s1_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${file}</file>
<formatName>SENTINEL-1</formatName>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Apply-Orbit-File">
Expand Down Expand Up @@ -62,7 +80,7 @@
<node id="Terrain-Correction">
<operator>Terrain-Correction</operator>
<sources>
<sourceProduct refid="LinearToFromdB"/>
<sourceProduct refid="Calibration"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down Expand Up @@ -98,7 +116,7 @@
<node id="LinearToFromdB">
<operator>LinearToFromdB</operator>
<sources>
<sourceProduct refid="Calibration"/>
<sourceProduct refid="Terrain-Correction"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
23 changes: 20 additions & 3 deletions eoreader/data/grd_sar_preprocess_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
<file>${file}</file>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Calibration">
<operator>Calibration</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand All @@ -29,7 +46,7 @@
<node id="Terrain-Correction">
<operator>Terrain-Correction</operator>
<sources>
<sourceProduct refid="LinearToFromdB"/>
<sourceProduct refid="Calibration"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down Expand Up @@ -65,7 +82,7 @@
<node id="LinearToFromdB">
<operator>LinearToFromdB</operator>
<sources>
<sourceProduct refid="Calibration"/>
<sourceProduct refid="Terrain-Correction"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
19 changes: 18 additions & 1 deletion eoreader/data/grd_sar_preprocess_fallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
<file>${file}</file>
</parameters>
</node>
<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<tiePointGrids/>
<region/>
<referenceBand/>
<geoRegion>${aoi}</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<copyMetadata>false</copyMetadata>
</parameters>
</node>
<node id="Terrain-Correction">
<operator>Terrain-Correction</operator>
<sources>
<sourceProduct refid="Read"/>
<sourceProduct refid="Subset"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
Expand Down
15 changes: 3 additions & 12 deletions eoreader/products/optical/optical_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import xarray as xr
from rasterio import crs as riocrs
from rasterio.enums import Resampling
from sertit import AnyPath, files, path, rasters
from sertit import AnyPath, path, rasters
from sertit.misc import ListEnum
from sertit.types import AnyPathStrType, AnyPathType

Expand Down Expand Up @@ -678,17 +678,8 @@ def _get_clean_band_path(
rad_proc = "" if kwargs.get(TO_REFLECTANCE, True) else "_as_is"

# Window name
window = kwargs.get("window")

win_suffix = ""
if window is not None:
if path.is_path(window):
win_suffix = path.get_filename(window)
elif isinstance(window, gpd.GeoDataFrame):
win_suffix = window.attrs.get("name")
if not win_suffix:
win_suffix = f"win{files.hash_file_content(str(window))}"

win_suffix = utils.get_window_suffix(kwargs.get("window"))
if win_suffix:
win_suffix += "_"

return self._get_band_folder(writable).joinpath(
Expand Down
Loading

0 comments on commit b4417ba

Please sign in to comment.