Van Zyl 1992 3 components decomposition¶
This notebook shows how to apply the van Zyl 3-component decomposition to a PolSARpro NetCDF dataset.
Import packages and set directories¶
In [2]:
Copied!
import os
from pathlib import Path
import xarray as xr
from polsarpro.io import open_netcdf_beam
from polsarpro.decompositions import vanzyl
# optional import for progress bar
from dask.diagnostics import ProgressBar
# change to your data paths
# original dataset
input_alos_data = Path("/data/psp/test_files/SAN_FRANCISCO_ALOS1_slc.nc")
output_dir = Path("/data/psp/res")
import os
from pathlib import Path
import xarray as xr
from polsarpro.io import open_netcdf_beam
from polsarpro.decompositions import vanzyl
# optional import for progress bar
from dask.diagnostics import ProgressBar
# change to your data paths
# original dataset
input_alos_data = Path("/data/psp/test_files/SAN_FRANCISCO_ALOS1_slc.nc")
output_dir = Path("/data/psp/res")
Load data¶
We load the SNAP NetCDF-BEAM dataset using the open_netcdf_beam function.
To obtain such a dataset, please refer to the "Getting Started" tutorial or the quickstart-tutorial.ipynb notebook.
In [3]:
Copied!
# uncomment to test on S matrix made with SNAP
S = open_netcdf_beam(input_alos_data)
# uncomment to test on S matrix made with SNAP
S = open_netcdf_beam(input_alos_data)
Apply the decomposition¶
Let's apply the decomposition and write the result to a NetCDF file. Optionally we can use a progress bar to monitor the progress of the computation.
In [4]:
Copied!
# change to the name of your liking
file_out = output_dir / "psp_vanzyl.nc"
# netcdf writer cannot overwrite
if os.path.isfile(file_out):
os.remove(file_out)
with ProgressBar():
vanzyl(S, boxcar_size=[7, 7]).to_netcdf(file_out)
# change to the name of your liking
file_out = output_dir / "psp_vanzyl.nc"
# netcdf writer cannot overwrite
if os.path.isfile(file_out):
os.remove(file_out)
with ProgressBar():
vanzyl(S, boxcar_size=[7, 7]).to_netcdf(file_out)
[########################################] | 100% Completed | 16.07 s
Display outputs¶
We open the previously saved dataset:
In [5]:
Copied!
res = xr.open_dataset(file_out)
res = xr.open_dataset(file_out)
Then we may plot individual parameters:
In [6]:
Copied!
# odd bounce / surface component
res.odd.plot.imshow(vmin=0, vmax=1)
# odd bounce / surface component
res.odd.plot.imshow(vmin=0, vmax=1)
Out[6]:
<matplotlib.image.AxesImage at 0x7f9390651250>
In [7]:
Copied!
# double bounce
res.double.plot.imshow(vmin=0, vmax=1)
# double bounce
res.double.plot.imshow(vmin=0, vmax=1)
Out[7]:
<matplotlib.image.AxesImage at 0x7f939062ac00>
In [8]:
Copied!
# volume component
res.volume.plot.imshow(vmin=0, vmax=1)
# volume component
res.volume.plot.imshow(vmin=0, vmax=1)
Out[8]:
<matplotlib.image.AxesImage at 0x7f9391277b60>