polsarpro.io
This code is part of the Python PolSARpro software:
"A re-implementation of selected PolSARPro functions in Python, following the scientific recommendations of PolInSAR 2021"
developed within an ESA funded project with SATIM.
Author: Olivier D'Hondt, 2025. Scientific advisors: Armando Marino and Eric Pottier.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Description: module containing read / write functions
get_incidence_angle_netcdf_beam(file_in, interpolation_method='linear')
Extract the incidence angle raster from a SNAP NetCDF-BEAM file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_in
|
str | Path
|
NetCDF-BEAM file produced with SNAP. |
required |
interpolation_method
|
str
|
interpolation method passed to xarray.Dataset.interp. |
'linear'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xarray.Dataset: incidence angle interpolated to the raster grid. |
Note
This is a helper function that interpolates incidence angle from the tie point grid to the raster grid in SLC products. For geocoded products this function is not relevant since various incidence angles can be directly computed with SNAP Range Doppler Terrain Correction.
open_netcdf_beam(file_path)
Open data in the NetCDF-BEAM format exported by SNAP and create a valid python PolSARpro Dataset. Also works for complex matrix datasets written with polmat_to_netcdf.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
path of the input file. |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
xarray.Dataset: output dataset with python PolSARpro specific metadata. |
Note
Only polarimetric data is allowed. Supported polarimetric types are 'S' scattering matrix, 'C3' and 'C4' covariance matrices, 'T3' and 'T4' coherency matrices as well as 'C2' dual-polarimetric covariance matrix.
polmat_to_netcdf(ds, file_path)
Writes complex polarimetric matrices to a nectdf file. Due to the lack of complex number support in netcdf files, real and imaginary parts are stored separately. Variable names follow the netcdf-beam convention used by SNAP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
input dataset with polarimetric matrix elements. |
required |
file_path
|
str | Path
|
output file path. |
required |