Skip to content

Commit

Permalink
Merge pull request #38 from TUW-GEO/dev
Browse files Browse the repository at this point in the history
Fix text and caching paths
  • Loading branch information
MartinSchobben authored Jan 9, 2025
2 parents 95a4794 + 4b6be64 commit 64351aa
Show file tree
Hide file tree
Showing 26 changed files with 363 additions and 264 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-pythia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:
path: |
~/.local/share/jupyter/kernels
~/.cache/pip
/usr/share/miniconda/envs
./chapters/courses/.jupyter_cache
./chapters/courses/microwave-remote-sensing/.jupyter_cache
./chapters/templates/.jupyter_cache
./chapters/tutorials/.jupyter_cache
key: ${{ runner.os }}-env-${{ hashFiles('./environment.yml', './notebooks/**/*.yml') }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-quarto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ jobs:
path: |
~/.local/share/jupyter/kernels
~/.cache/pip
/usr/share/miniconda/envs
./chapters/courses/.jupyter_cache
./chapters/courses/microwave-remote-sensing/.jupyter_cache
./chapters/templates/.jupyter_cache
./chapters/tutorials/.jupyter_cache
key: ${{ runner.os }}-env-${{ hashFiles('./environment.yml', './notebooks/**/*.yml') }}
Expand Down
6 changes: 5 additions & 1 deletion chapters/courses/microwave-remote-sensing.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ jupyter:
display_name: "microwave-remote-sensing"
---

This course ...
This course at the TU Wien teaches course, students are able to read, visualize and analyze Synthetic Aperture Radar (SAR) data. This will aid interpretation of SAR data based upon a physical understanding of sensing principles and the interaction of microwaves with natural objects.

::: {.callout-note}
These notebooks contain interactive elements. The full interactive elements can only be viewed on Binder by clicking on the Binder badge or 🚀 button.
:::
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Discover and Read Sentinel 1 Data
title: Discover and Read SAR Data
jupyter:
kernelspec:
name: "microwave-remote-sensing"
Expand All @@ -8,7 +8,7 @@ jupyter:
---


This notebook demonstrates how to access radar data in a SpatioTemporal Asset Catalog (STAC) Catalogue using the pystac library. In this example, we use Sentinel-1 data from the EODC (earth observation data and high performance computing service provider based in Vienna) STAC catalog. In the further process, we will learn how to query a STAC catalog, select specific items, and display the metadata and the actual image.
This notebook demonstrates how to access radar data in a SpatioTemporal Asset Catalog (STAC) Catalogue using the `pystac` library. In this example, we use Sentinel-1 data from the EODC (earth observation data and high performance computing service provider based in Vienna) STAC catalog. In the further process, we will learn how to query a STAC catalog, select specific items, and display the metadata and the actual image.


```{python}
Expand Down Expand Up @@ -66,7 +66,7 @@ lonmin, lonmax = 13.8, 17.8 # West to East
bounding_box = [lonmin, latmin, lonmax, latmax]
```

If the region of interest is not rectengular, we can also define a polygon:
If the region of interest is not rectangular, we can also define a polygon:

```{python}
# GEOJSON can be created on geojson.io
Expand All @@ -88,7 +88,7 @@ area_of_interest = {
}
```

Using our previously loaded STAC catalog, we can now search for items fullfilling our query. In this example we are using the bounding box. If we want to use an area of interest specified in the geojson format - one hast to use the intersects parameter as documented in the comment below.
Using our previously loaded STAC catalog, we can now search for items full-filling our query. In this example we are using the bounding box. If we want to use an area of interest specified in the geojson format - one hast to use the intersects parameter as documented in the comment below.

```{python}
search = eodc_catalog.search(
Expand Down Expand Up @@ -158,7 +158,7 @@ map

STAC can also be a useful tool for the discovery of data, however it only loads metadata. This saves memory, but if one would like to do further analysis, the data has to be loaded into memory or downloaded on disk.

In the following, we will demonstrate this with the library `odc-stac`. Here we can define what data will loaded as `bands`; in this case VV sigma naught. Moreover we can resample the data by providing any coordinate reference system (CRS) and resolution as well as a method for resampling of continuos data (e.g. bilinear resampling). In the example below we use the EQUI7 Grid of Europe and a 20 meter sampling. This is the native format of sigma naught stored at EODC, so there will be no actual resampling. Note, also, that resampling is not advisable for this data, as it is provided on a logarithmic scale. More about this in notebook 2.
In the following, we will demonstrate this with the library `odc-stac`. Here we can define what data will loaded as `bands`; in this case VV sigma naught. Moreover we can resample the data by providing any coordinate reference system (CRS) and resolution as well as a method for resampling of continuos data (e.g. bilinear resampling). In the example below we use the EQUI7 Grid of Europe and a 20 meter sampling. This is the native format of sigma naught stored at EODC, so there will be no actual resampling. Note, also, that resampling is not advisable for this data, as it is provided on a logarithmic scale. More about this in the notebook "Backscattering Coefficients".

*The chunks argument is an advancement method for performing parallel computations on the data. We will not cover this in further detail.*

Expand All @@ -184,7 +184,7 @@ Let's have a look at the VV polarized band of the dataset.
sig0_dc.VV
```

As we can see, the data is stored as a `xarray` DataArray. `Xarray` is a convenient package for multidimensional labeled arrays, like temperature, humidity, pressure, different bands of satellite imagery, and so on. [The link](https://docs.xarray.dev/en/stable/index.html) provides detailed documentation. In a later notebook we will explore some more of the functionality of `xarray`. As we can see in the coordinates, the data here consists of 21 time steps.
As we can see, the data is stored as a `xarray` DataArray. Xarray is a convenient package for multidimensional labeled arrays, like temperature, humidity, pressure, different bands of satellite imagery, and so on. [The link](https://docs.xarray.dev/en/stable/index.html) provides detailed documentation. In a later notebook we will explore some more of the functionality of `xarray`. As we can see in the coordinates, the data here consists of 21 time steps.

In general, data from STAC is "lazily" loaded, which means that the structure of the DataArray is constructed, but the data is not loaded yet. It is loaded only at instance when it is needed, for example, for plotting, computations, and so on.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In the following example, we will:

## Search for some Data

Now, we start by loading data from Sentinel-1 from the `EODC` STAC Catalogue. We do this in the same way as in the previous notebook 1.
Now, we start by loading data from Sentinel-1 from the EODC STAC Catalogue. We do this in the same way as in the previous notebook "Discover and Read SAR Data".

```{python}
latmin, latmax = 48, 48.5
Expand Down Expand Up @@ -82,7 +82,7 @@ sig0_dc

## Comparison of the Data in dB and Linear Scale

In the next two cells we will select a subset of the data. This is done to reduce the amount of data we are working with. The precice workflow is not important for now, since the theory is explained after the cells. They are just here to show the data we are working with.
In the next two cells we will select a subset of the data. This is done to reduce the amount of data we are working with. The precise workflow is not important for now, since the theory is explained after the cells. They are just here to show the data we are working with.

```{python}
subset = sig0_dc.sel(time=slice("2022-07-01", "2022-07-07"))
Expand Down Expand Up @@ -265,7 +265,7 @@ As you can see in the example, the mean values across the scene are different in

## Save Mean Mosaic as Tif File

Often we want to store the output of a computation permanently on a file system. The most common file format for this is a GeoTIFF (TIF file with additional information on the georeference). The following cell indicates how this can be easily done with Xarray. When we want to store the data as a GeoTIFF we need to make sure to provide a spatial reference to geolocate the data. The best way to check whether the Xarray has a coordinate reference system (CRS) is by using the rioxarray `rio.crs` accessor. More about this in notebook 4.
Often we want to store the output of a computation permanently on a file system. The most common file format for this is a GeoTIFF (TIF file with additional information on the georeference). The following cell indicates how this can be easily done with Xarray. When we want to store the data as a GeoTIFF we need to make sure to provide a spatial reference to geolocate the data. The best way to check whether the Xarray has a coordinate reference system (CRS) is by using the rioxarray `rio.crs` accessor. More about this in notebook "Datacubes".

```{python}
# Select some data which we want to save
Expand All @@ -274,7 +274,7 @@ data_2_save.rio.crs
```

In this case, the spatial reference is the EPSG Code `EPSG:27704`, which is the `Equi7Grid Europe`.
As the output dataarray already has a spatial reference we now save it as a raster file
As the output data array already has a spatial reference we now save it as a raster file

```{python}
# Save the data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To get the same projection, resolution, and region we have to resample one (or m

*Figure 1: Stacking of arrays to form datacubes (source: https://eox.at)*.

In this notebook we will study two different SAR products. SAR data from the Advanced Land Observing Satellite (ALOS-2), which is a Japanese platform with an L-band sensor from the Japan Aerospace Exploration Agency (JAXA), and C-band data from the Copernicus Sentinel-1 mission. It is our goal to compare C- with L-band, so we need to somehow stack these arrays.
In this notebook we will study two different SAR products. SAR data from the Advanced Land Observing Satellite (Alos-2), which is a Japanese platform with an L-band sensor from the Japan Aerospace Exploration Agency (JAXA), and C-band data from the Copernicus Sentinel-1 mission. It is our goal to compare C- with L-band, so we need to somehow stack these arrays.


```{python}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: SAR Wavelength and Polarization
title: Wavelength and Polarization
jupyter:
kernelspec:
name: "microwave-remote-sensing"
Expand All @@ -13,7 +13,7 @@ In this notebook, we aim to demonstrate how C-band (4–8 GHz, wavelengths of ap
+ Sentinel-1 (C-band)
+ VV
+ VH
+ ALOS-2 (L-band):
+ Alos-2 (L-band):
+ HH
+ HV

Expand All @@ -30,7 +30,7 @@ import holoviews as hv

## Data Loading

We load the data again with the help of `intake`
We load the data again with the help of `intake`.

```{python}
url = "https://huggingface.co/datasets/martinschobben/microwave-remote-sensing/resolve/main/microwave-remote-sensing.yml"
Expand Down Expand Up @@ -80,7 +80,7 @@ plt.tight_layout()

Now we can see that areas with high mean LAI values (Figure 1) show a drop-off to values as low as those for areas with low mean LAI during the autumn months (Figure 2 ; right panel). Hence we might deduce that we deal with deciduous forest that becomes less green during autumn, as can be expected for the study area.

Remember that longer wavelengths like L-bands are more likely to penetrate through a forest canopy and would interact more readily with larger object like tree trunks and the forest floor. In turn, C-band microwaves are more likely to interact with sparse and shrub vegetation. The polarization of the emitted and received microwaves is on the other hand dependent on the type of backscattering with co-polarization (HH and VV) happening more frequently with direct backscatter or double bounce scattering. Whereas volume scattering occurs when the radar signal is subject to multiple reflections within 3-dimensional matter, as the orientation of the main scatterers is random, the polarisation of the backscattered signal is also random. Volume scattering can therefore cause an increase of cross-polarized intensity.
Remember that longer wavelengths like L-bands are more likely to penetrate through a forest canopy and would interact more readily with larger object like tree trunks and the forest floor. In turn, C-band microwaves are more likely to interact with sparse and shrub vegetation. The polarization of the emitted and received microwaves is on the other hand dependent on the type of backscattering with co-polarization (HH and VV) happening more frequently with direct backscatter or double bounce scattering. Whereas volume scattering occurs when the radar signal is subject to multiple reflections within 3-dimensional matter, as the orientation of the main scatterers is random, the polarization of the backscattered signal is also random. Volume scattering can therefore cause an increase of cross-polarized intensity.

Let's put this to the test by checking the microwave backscatter signatures over forested and sparsely vegetated areas as well as water bodies (Lake Garda). Let's first look at the different sensor readings for the beginning of summer and autumn.

Expand All @@ -102,9 +102,9 @@ t2 = fused_ds.gam0.\
t1 + t2
```

*Figure 3: Maps of Sentinel-1 and ALOS-2 $\gamma^0_T \,[dB]$ for the beginning of summer (left) and autumn (right).*
*Figure 3: Maps of Sentinel-1 and Alos-2 $\gamma^0_T \,[dB]$ for the beginning of summer (left) and autumn (right).*

The most notable difference is the lower energy received for cross-polarized than for co-polarized microwaves for both Sentinel-1 and ALOS-2. The latter differences are independent of the time of year. However, one can also note small changes in the received energy for the same satellite dependent on the time of year. To get a better feel for these changes over time we generate the following interactive plot. On the following plot one can select areas of a certain mean LAI (by clicking on the map) and see the associated timeseries of $\gamma^0_T$ for each of the sensors.
The most notable difference is the lower energy received for cross-polarized than for co-polarized microwaves for both Sentinel-1 and Alos-2. The latter differences are independent of the time of year. However, one can also note small changes in the received energy for the same satellite dependent on the time of year. To get a better feel for these changes over time we generate the following interactive plot. On the following plot one can select areas of a certain mean LAI (by clicking on the map) and see the associated timeseries of $\gamma^0_T$ for each of the sensors.

```{python}
LAI_image = LAI_mean.hvplot.\
Expand Down Expand Up @@ -149,9 +149,9 @@ time_series = hv.DynamicMap(get_timeseries, streams=[point_stream])
LAI_image + time_series
```

*Figure 4: Map of MEAN LAI around Lake Garda. The pixel values can be seen by hovering your mouse over the pixels. Clicking on the pixel will generate the timeseries for the associated mean LAI on the right hand-side. (Right) Timeseries of for Sentinel-1 and ALOS-2 $\gamma^0_T [dB]$.*
*Figure 4: Map of MEAN LAI around Lake Garda. The pixel values can be seen by hovering your mouse over the pixels. Clicking on the pixel will generate the timeseries for the associated mean LAI on the right hand-side. (Right) Timeseries of for Sentinel-1 and Alos-2 $\gamma^0_T [dB]$.*

Can you see some patterns when analysing the different wavelengths and polarizations?
Can you see some patterns when analyzing the different wavelengths and polarizations?

Remember again that we deal with a logarithmic scale. A measurement of 10 dB is 10 times brighter than the intensity measured at 0 dB, and 100 times brighter at 20 dB. The most notable difference is that the offset between cross- and co-polarised signals becomes larger at low LAI and lower at higher LAI. This might indicate the effect of volume scattering in forested areas where co- and cross-polarisation render backscattering values more equal. You will study the differences among cross- and co-polarized backscattering in more detail in the homework exercise.
Remember again that we deal with a logarithmic scale. A measurement of 10 dB is 10 times brighter than the intensity measured at 0 dB, and 100 times brighter at 20 dB. The most notable difference is that the offset between cross- and co-polarised signals becomes larger at low LAI and lower at higher LAI. This might indicate the effect of volume scattering in forested areas where co- and cross-polarization render backscattering values more equal. You will study the differences among cross- and co-polarized backscattering in more detail in the homework exercise.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Dielectric Properties of Natural Media
title: Dielectric Properties
jupyter:
kernelspec:
name: "microwave-remote-sensing"
Expand Down Expand Up @@ -33,7 +33,7 @@ hv.extension("bokeh")

## Load Sentinel-1 Data

For our analysis we are using sigma naught backscatering data from Sentinel-1. The images we are analyzing cover the region south of Vienna and west of Neusiedlersee Lake. We load the data and and apply again a preprocessing function. Here we extract the scaling factor and the date the image was taken from the metadata. We will focus our attention to a smaller area containing a part of the Neusiedlersee Lake and its surrounding land. The obtained`xarray` dataset and is then converted to an array, because we only have one variable, the VV backscatter values.
For our analysis we are using sigma naught backscatering data from Sentinel-1. The images we are analyzing cover the region south of Vienna and west of Lake Neusiedl. We load the data and and apply again a preprocessing function. Here we extract the scaling factor and the date the image was taken from the metadata. We will focus our attention to a smaller area containing a part of the Lake Neusiedl Lake and its surrounding land. The obtained`xarray` dataset and is then converted to an array, because we only have one variable, the VV backscatter values.

```{python}
url = "https://huggingface.co/datasets/martinschobben/microwave-remote-sensing/resolve/main/microwave-remote-sensing.yml"
Expand Down
Loading

0 comments on commit 64351aa

Please sign in to comment.