Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Unit Conversion

In this notebook, we are going to have a look at the conversion of units. Sentinel-1 data, and most other SAR data, is usually provided in decibels (dB). In this notebook, we will discover the advantages of displaying SAR data in decibels and why we need to convert the data to a linear scale in order to make meaningful calculations. Let’s start with importing some libraries.

logarithmic⟷linear\text{logarithmic} \longleftrightarrow \text{linear}
[dB]⟷[m2⋅m−2][\text{dB}] \longleftrightarrow [\text{m}^2 \cdot \text{m}^{-2}]

Exploring the Data

Let’s start by loading some sample data, in order to demonstrate why this conversion is important. Here we will have a look at some SAR data from the Sentinel-1. The data is provided in decibels (dB). In the following example, we will:

  • load data from Sentinel-1

  • visualize the data in logarithmic scale

  • compare the data with linear scale

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 “Discover and Read SAR Data”.

60 scenes found
Loading...

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 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.

Now plot the data.

<Figure size 1400x800 with 10 Axes>

Figure 1: Visually comparing σ0\sigma^0 on a logarithmic and linear scale (left column). In addition, the benefit of using the robust plotting method is shown (middle column). The robust argument uses the 2^nd^ and 98^th^ percentiles of the data to compute the color limits to eliminate washing out the plot due to data outliers.

In the plot above you can see the difference between the two scales. The values in dB are more evenly distributed and are therefore easier to plot. The values in linear scale are more spread out and are therefore harder to interpret. This is why we use the dB scale for plotting/visualization.

While the logarithmic scale facilitates visual interpretation, it has implications for mathematical operations. In the following, we’ll have a closer look at this. But first, let’s see how we can convert between the linear and the logarithmic domains.

Conversion Formulas

The decibel (dB) is a logarithmic unit used to express the ratio of two values of a physical quantity, often power or intensity. In the case of SAR data, the backscatter coefficient is often expressed in dB to facilitate visualization.

In order to convert the data from dB to linear scale, we use the following formula. Let DD be the original value (dB) and II the converted value (m2m−2m^2m^{-2}). The conversion of units can be expressed as:

D=10⋅log⁡10(I)=10⋅log⁡10(e)⋅ln⁡(I)⟶[dB]D = 10 \cdot \log_{10} (I) = 10 \cdot \log_{10} (e) \cdot \ln (I)\longrightarrow [dB]

Similarly, the conversion back to the original unit can be expressed as:

I=eD10⋅log⁡10(e)=10D10⟶[m2m−2]I = e^{\frac{D}{10\cdot \log_{10}(e)}} = 10^{\frac{D}{10}} \longrightarrow [m^2m^{-2}]

You can find these formulas in the script for Microwave Remote Sensing on page 136 (equation 6.40).

Now let’s implement the conversion in Python.

When performing mathematical operations with SAR data it is important to be aware, that adding values in the logarithmic scale doesn’t work in the same way as adding regular (linear) values. This is because in the logarithmic scale, each unit step represents an equal multiplication. This means that an addition of two values in the logarithmic scale equals a multiplication of the values in the linear scale. Vice versa, a subtraction in a logarithmic scale equals a division in a linear scale. Let’s have a look at an example, where we add two values, once without the conversion to linear scale and once with the conversion to linear scale.

Logarithmic Addition:
Logarithmic values: 	10   , 12    [dB]
Logarithmic sum: 	10 + 12 = 22    [dB]

Linear Addition:
Linear values: 		10.0 , 15.85 [lin]
      			(converted from dB)
Linear sum: 		10.0 +  15.85 =  25.85 [lin]
			=  14.12 [dB]

As you can see, the values in dB and in linear scale differ quite a bit. In the example above, the values differ by a factor of around 6 when looked at in linear scale.

Now that we have some data, we will have a look at some practical examples where we will convert the data to linear scale. When we try to calculate the average σ0\sigma^0 value across the scene, we need to do this by converting the data to linear scale first and then calculating the average and converting it back to dB.

Creating a Monthly Mosaic

So in the beginning we have lazily loaded data for an area across a whole year. We therefore have around 700 images. We will now essentially compress the data of each month into one timestamp. This is done by using the resampling method together with an operation method like mean that includes summation. Since the data is in dB we need to convert it to linear scale first, then we can resample the data and convert it back to dB.

Loading...

The dataset has now only 12 timestamps, one for each month. Next, we want to calculate the average σ0\sigma^0 value across a subset of the scene for one month. We will do this again by converting the data to linear scale first and then calculating the average and converting it back to dB.

Average backscatter value in linear units:  0.114
That value in dB: -9.424

Average backscatter value in dB: -10.392

As you can see in the example, the mean values across the scene are different in dB and linear scale. Therefore, it is important to be aware in which scale the data is stored to perform the correct type of mathematical operation or always convert the data to linear scale before doing any calculations.