# Extracting S5p SO2 variables

**URL:** https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361
**Category:** HARP
**Created:** [June 22, 2021, 11:46am UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361 "2021-06-22T11:46:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![effie](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/e/58f4c7/32.png) [@effie](https://forum.atmospherictoolbox.org/u/effie)
#### Post date: [June 22, 2021, 11:46am UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361/1 "2021-06-22T11:46:04Z")

</div>

Hi,  
I would like to extract variables from the Sentinel 5p SO2 product using HARP. The variables are listed in different locations: under PRODUCT, under PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS, etc.

I’ve used the following code unsuccessfully:

harpconvert -a ‘latitude \> 1 [degree\_north]; latitude \< 7 [degree\_north]; longitude \> 92 [degree\_east]; longitude \< 98 [degree\_east];bin\_spatial(333,1,0.02,333,93,0.02); derive(latitude {latitude}); derive(longitude {longitude}); keep(PRODUCT/sulfurdioxide\_total\_vertical\_column, PRODUCT/sulfurdioxide\_total\_vertical\_column\_precision, PRODUCT/qa\_value, PRODUCT/SUPPORT\_DATA/INPUT\_DATA/surface\_classification, PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_15km,PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_15km\_precision, PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_1km, PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_1km\_precision, PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_7km, PRODUCT/SUPPORT\_DATA/DETAILED\_RESULTS/sulfurdioxide\_total\_vertical\_column\_7km\_precision, PRODUCT/SUPPORT\_DATA/INPUT\_DATA/aerosol\_index\_340\_380,PRODUCT/SUPPORT\_DATA/INPUT\_DATA/PROCESSOR/surface\_classification,PRODUCT/longitude, PRODUCT/latitude)’ input.nc output.nc

Using just the names of the variables in the keep syntax (e.g. qa\_value instead of PRODUCT/qa\_value) also doesn’t work. If I use only the first part of the code, excluding the keep part, the code works, but the result does not contain all the variables of the initial netcdf file.

Could anyone advise?

Thank you very much,

Effie

---

<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: [June 22, 2021, 6:13pm UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361/2 "2021-06-22T18:13:03Z")

</div>

Please have a look at [About the HARP category - #15 by svniemeijer](https://forum.atmospherictoolbox.org/t/about-the-harp-category/13/15)  
The mapping description for SO2 is provided [here](http://stcorp.github.io/harp/doc/html/ingestions/S5P_L2_SO2.html).

---

<div class="post-metadata">

### Author: ![effie](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/e/58f4c7/32.png) [@effie](https://forum.atmospherictoolbox.org/u/effie)
#### Post date: [June 23, 2021, 10:32am UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361/3 "2021-06-23T10:32:57Z")

</div>

Thank you very much, the mapping link was very helpful!

For other users, the following line worked:  
_harpconvert -o so2\_column=1km -a ‘SO2\_column\_number\_density\_validity\>50;keep(SO2\_column\_number\_density, absorbing\_aerosol\_index, surface\_albedo, surface\_altitude, latitude, longitude); latitude \>= 0 [degree\_north]; latitude \<= 8 [degree\_north]; longitude \>= 92 [degree\_east]; longitude \<= 100 [degree\_east];derive(SO2\_column\_number\_density [DU]); bin\_spatial(444,0,0.02,444,92,0.02); derive(latitude {latitude}); derive(longitude {longitude}); exclude(latitude\_bounds\_weight,longitude\_bounds\_weight,count,weight)’ input.nc output.nc_

Just a clarification: It wasn’t possible to derive _SO2\_column\_number\_density\_validity, SO2\_column\_number\_density\_uncertainty\_random_ . I tried to derive them simultaneously, as in the line below, as well as for each one of them separately. I also experimented with different sequence of operations. The variables were still not included in the output nc.  
_harpconvert -o so2\_column=1km -a ‘keep(SO2\_column\_number\_density,SO2\_column\_number\_density\_validity, SO2\_column\_number\_density\_uncertainty\_random, absorbing\_aerosol\_index, surface\_albedo, surface\_altitude, latitude, longitude); latitude \> 1 [degree\_north]; latitude \< 7 [degree\_north]; longitude \> 92 [degree\_east]; longitude \< 98 [degree\_east];derive(SO2\_column\_number\_density [DU]); derive(SO2\_column\_number\_density\_validity);derive(SO2\_column\_number\_density\_uncertainty\_random);bin\_spatial(333,1,0.02,333,93,0.02); derive(latitude {latitude}); derive(longitude {longitude})’ input.nc output.nc_

Why would this be the case? The processor is new and the options are set correctly, do you think there could be an issue with binning? or the units?

Thanks again,

Effie

---

<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: [June 23, 2021, 11:12am UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361/4 "2021-06-23T11:12:39Z")

</div>

The case for validity was also answered [here](https://forum.atmospherictoolbox.org/t/keep-validity-variable-in-harp-exported-product/266/4). You can’t average validity flags.

For the uncertainty, HARP only propagates the total uncertainty (the variable without \_random or \_systematic postfix). So you would first have to perform a `derive(SO2_column_number_density_uncertainty {time})` and then perform your binning.

---

<div class="post-metadata">

### Author: ![effie](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/e/58f4c7/32.png) [@effie](https://forum.atmospherictoolbox.org/u/effie)
#### Post date: [June 23, 2021, 11:32am UTC](https://forum.atmospherictoolbox.org/t/extracting-s5p-so2-variables/361/5 "2021-06-23T11:32:51Z")

</div>

Top, thank you very much!!
