# L1B Sentinel 5-P

**URL:** https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201
**Category:** HARP
**Tags:** sentinel-5p, python
**Created:** [August 17, 2020, 11:59am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201 "2020-08-17T11:59:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pherrusa7](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/pherrusa7/32/86_2.png) [@pherrusa7](https://forum.atmospherictoolbox.org/u/pherrusa7)
#### Post date: [August 17, 2020, 11:59am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/1 "2020-08-17T11:59:50Z")

</div>

Hello!

I used Harp basically because I wanted to have images of an area of interest (like Berlin), for the L2 Products. Hence, Harp helped me to create a grid there. However, I found myself checking what names does Harp has for the main variable of interest of each of the L2 products (like `nitrogendioxide_tropospheric_column` of `L2 __NO2___ ` product is called `tropospheric_NO2_column_number_density` in `Harp`).

Now I want to create also the grids for the respective L1B products. The problem is that I can’t find the names that Harp has for each of the 12 channels that this data contains and I want to preserve. Is it possible to this with Harp or I should think about creating the grids with another tool like Satpy ([https://satpy.readthedocs.io/en/latest/](https://satpy.readthedocs.io/en/latest/))?

Thank you so much!  
Pedro Herruzo

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [August 18, 2020, 10:57am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/2 "2020-08-18T10:57:36Z")

</div>

You can do this, since HARP supports reading the L1B products directly. See the [L1B items in the documentation](http://stcorp.github.io/harp/doc/html/ingestions/index.html#sentinel-5p-products) for details.

However, be aware that L1B data provides radiances that have a spectral dimension. I doubt that you are looking for an averaged spectrum.

---

<div class="post-metadata">

### Author: ![pherrusa7](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/pherrusa7/32/86_2.png) [@pherrusa7](https://forum.atmospherictoolbox.org/u/pherrusa7)
#### Post date: [September 16, 2020, 9:53pm UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/3 "2020-09-16T21:53:03Z")

</div>

Thanks! I am not averaging, I will preserve the spectrum. I just want to have grids of L2 and L1B data aligned in space, so I might try to predict the products from the raw data.

However, when I try to use Harp to create grids of L1B data, I find the following problem. If I try to use a similar operation used with L2 products, Harp produces no data at all (tested with file `L1B_RA_BD1/S5P_OFFL_L1B_RA_BD1_20190101T082329_20190101T100459_06313_01_010000_20190101T115548.zip`):

```
derive(datetime_stop {time}); latitude >= 54.506 [degree_north] ; latitude <= 56.942 [degree_north] ; longitude >= 36.357 [degree_east] ; longitude <= 38.854 [degree_east]; bin_spatial(45, 55.506, 0.01, 51, 37.357, 0.01); derive(latitude {latitude}); derive(longitude {longitude}); keep(wavelength, photon_radiance, index, latitude_bounds, longitude_bounds, latitude, longitude, sensor_altitude, sensor_azimuth_angle, sensor_zenith_angle, solar_azimuth_angle, solar_zenith_angle) 

```

By try and error, I saw that an operation that works is the following:

```
latitude >= 54.506 [degree_north] ; latitude <= 56.942 [degree_north] ; longitude >= 36.357 [degree_east] ; longitude <= 38.854 [degree_east]; keep(wavelength, photon_radiance, index, latitude_bounds, longitude_bounds, latitude, longitude, sensor_altitude, sensor_azimuth_angle, sensor_zenith_angle, solar_azimuth_angle, solar_zenith_angle)

```

However, this way doesn’t create the grid I want since I am not using `bin_spatial `. Can you help me to see what I am doing wrong, please?

Thank you so much for your time!

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [September 17, 2020, 7:13am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/4 "2020-09-17T07:13:59Z")

</div>

First, when you are using `bin_spatial` you _are_ averaging. When you regrid data you will be performing a weighted average of your input data. If you want to combine the data from L2 and L1 _without_ averaging you should just use the native satellite grid (i.e. look at the data pixel by pixel) and not perform a `bin_spatial`.

Note that it is perfectly possible to perform a `bin_spatial` on the L1B data:

```
latitude >= 54.506 [degree_north] ; latitude <= 56.942 [degree_north] ; longitude >= 36.357 [degree_east] ; longitude <= 38.854 [degree_east]; bin_spatial(45, 55.506, 0.01, 51, 37.357, 0.01); derive(latitude {latitude}); derive(longitude {longitude}); keep(wavelength, photon_radiance, latitude_bounds, longitude_bounds, latitude, longitude, sensor_altitude, sensor_azimuth_angle, sensor_zenith_angle, solar_azimuth_angle, solar_zenith_angle)

```

However, I am not sure how much sense that would make (since the radiances that you are averaging are not using the same wavelength grid).

---

<div class="post-metadata">

### Author: ![pherrusa7](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/pherrusa7/32/86_2.png) [@pherrusa7](https://forum.atmospherictoolbox.org/u/pherrusa7)
#### Post date: [September 17, 2020, 12:58pm UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/5 "2020-09-17T12:58:07Z")

</div>

Thank you for your answer. First of all, I think there is plenty of things I don’t understand and I apologize for this.

Let me first say that my objective is to have raster objects for L2 data (which I believe I already have) and raster objects for L1B data. This means that when looking at position (x,y) either of L2 raster or L1B raster I want to look to the same spatial coverage on Earth. That is why I am filtering first an area and then binning with each cell coverage of 0.01x0.01 square degrees.

I understand that `bin_spatial ` averages over spatial locations (latitudes and longitudes) and I expect not to average over the spectral dimension. I hope this does make sense, otherwise, I would like to see where my current understanding is wrong, please. I use `bin_spatial ` since L2 products have a different spatial resolution so in this way all products have the same spatial shape. Furthermore, each file in the same product can have different sizes for latitude/longitude:

```
source product = 'S5P_OFFL_L2 __NO2____ 20190101T100459_20190101T114629_06314_01_010202_20190107T120049.zip'

int scan_subindex {time=1460250}
double datetime_start {time=1460250} [seconds since 2010-01-01]
float datetime_length [s]
int orbit_index
long validity {time=1460250}
float latitude {time=1460250} [degree_north]
float longitude {time=1460250} [degree_east]

 source product = 'S5P_OFFL_L2 __NO2____ 20190102T080428_20190102T094558_06327_01_010202_20190108T095255.zip'

int scan_subindex {time=1460700}
double datetime_start {time=1460700} [seconds since 2010-01-01]
float datetime_length [s]
int orbit_index
long validity {time=1460700}
float latitude {time=1460700} [degree_north]
float longitude {time=1460700} [degree_east]

```

So this is also a reason for filtering an area and using `bin_spatial `, otherwise, I wouldn’t know how to compare a certain location for different days using plain NumPy objects for the data. And the same thing happens with L1B data. Maybe there is something else I don’t understand here, sorry for that.

In summary, I want to have a raster L1B tensor with shape (time=1 latitude=44, longitude=50, spectral) that I can compare it with a raster L2 tensor with shape (time=1 latitude=44, longitude=50). Does this make sense or am I mixing up something?

> [@svniemeijer](#):
>
> Note that it is perfectly possible to perform a `bin_spatial` on the L1B data:

Yes, that works! I see that you removed the `index` attribute for the query. How can I preserve the date with L1B data? With L2 data I used `derive(datetime_stop {time}); ` but this doesn’ work here…

Thank you so much!

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [September 29, 2020, 9:09am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/6 "2020-09-29T09:09:48Z")

</div>

> [@pherrusa7](#):
>
> How can I preserve the date with L1B data? With L2 data I used `derive(datetime_stop {time}); ` but this doesn’ work here…

Have a look at the [mapping documentation for this product](http://stcorp.github.io/harp/doc/html/ingestions/S5P_L1B_RA_BD1.html) in the HARP documentation. You will see that there is only a single datetime variable. So just `keep()` that variable.

---

<div class="post-metadata">

### Author: ![pherrusa7](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/pherrusa7/32/86_2.png) [@pherrusa7](https://forum.atmospherictoolbox.org/u/pherrusa7)
#### Post date: [September 29, 2020, 9:49am UTC](https://forum.atmospherictoolbox.org/t/l1b-sentinel-5-p/201/7 "2020-09-29T09:49:31Z")

</div>

Thanks, @svniemeijer! I assume that my explanation above makes sense, otherwise, let me know where I am confused, please.

Thank you so much for your time 🙂
