# Derivations during harp import product | S5P NO2

**URL:** https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583
**Category:** HARP
**Tags:** sentinel-5p, python
**Created:** [December 13, 2022, 3:01pm UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583 "2022-12-13T15:01:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mariliza](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@mariliza](https://forum.atmospherictoolbox.org/u/mariliza)
#### Post date: [December 13, 2022, 3:01pm UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/1 "2022-12-13T15:01:21Z")

</div>

Dear Sander, dear all,

I seem to have hit a bit of a snag with deriving either altitude or pressure from the S5P NO2 datasets. I tried to derive during the import of the product,

try:  
product = harp.import\_product(infile,operations = ‘tropospheric\_NO2\_column\_number\_density\_validity\>75;point\_distance(40.6335,22.9563,20[km]);\ derive(NO2\_slant\_column\_number\_density[Pmolec/cm2]);derive(NO2\_slant\_column\_number\_density\_uncertainty[Pmolec/cm2]);\ derive(tropospheric\_NO2\_column\_number\_density[Pmolec/cm2]);derive(tropospheric\_NO2\_column\_number\_density\_uncertainty[Pmolec/cm2]);  
derive(pressure[Pa]);  
keep(latitude, longitude, latitude\_bounds,longitude\_bounds,solar\_zenith\_angle,sensor\_zenith\_angle,scan\_subindex,\ pressure\_bounds,surface\_pressure,surface\_meridional\_wind\_velocity,surface\_zonal\_wind\_velocity,  
cloud\_fraction,cloud\_pressure, orbit\_index,datetime\_start,datetime\_length,\ NO2\_slant\_column\_number\_density,NO2\_slant\_column\_number\_density\_uncertainty,\ tropospheric\_NO2\_column\_number\_density\_amf,tropospheric\_NO2\_column\_number\_density\_avk,\ tropospheric\_NO2\_column\_number\_density,tropospheric\_NO2\_column\_number\_density\_uncertainty,  
tropospheric\_NO2\_column\_number\_density\_validity,pressure)’)

But I get nothing in return, even though the pressure from pressure bounds is included in the relevant section as available, [pressure derivations — HARP 1.17 documentation (stcorp.github.io)](http://stcorp.github.io/harp/doc/html/algorithms/derivations/pressure.html)

Needless to say, I do get a product ingested when the pressure-related sections are not there in the ingest command.

To be honest, when I am interested is in the altitude [i.e. in m]. Altitude from pressure derivation exists, so I was thinking of a double-derivation, pressure bounds to pressure and pressure to altitude. The necessary fields exist in the S5P NO2 file, I think, [altitude derivations — HARP 1.17 documentation (stcorp.github.io)](http://stcorp.github.io/harp/doc/html/algorithms/derivations/altitude.html)

Am using Harp 1.16, on python 3.8

Many thanks as always,  
MariLiza

---

<div class="post-metadata">

### Author: ![mariliza](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@mariliza](https://forum.atmospherictoolbox.org/u/mariliza)
#### Post date: [December 13, 2022, 6:17pm UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/2 "2022-12-13T18:17:46Z")

</div>

Apologies, I of course tried,  
derive(altitude {time, vertical} [m]);  
derive(pressure {time, vertical} [Pa]);  
🙂

---

<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: [December 14, 2022, 8:55am UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/3 "2022-12-14T08:55:51Z")

</div>

Deriving pressure is possible, but deriving altitude not. [You will need a total air molar mass and a temperature profile for this](http://stcorp.github.io/harp/doc/html/algorithms/derivations/altitude.html#derivation-altitude-from-pressure).

To allow deriving a pressure profile, you need to make sure that you don’t throw away the pressure\_bounds variable.

You can use `harpdump --list-derivations` to see what derivations are possible.

For instance:

```auto
% harpdump --list-derivations -t altitude S5P_OFFL_L2 __NO2____ 20190908T134839_20190908T153008_09863_01_010302_20190914T163328.nc
altitude {time} [m] (double) from
  sensor_altitude {time} [m] (double)

% harpdump --list-derivations -t pressure -a 'tropospheric_NO2_column_number_density_validity>75' S5P_OFFL_L2 __NO2____ 20190908T134839_20190908T153008_09863_01_010302_20190914T163328.nc
pressure {time,vertical} [Pa] (double) from
  pressure_bounds {time,vertical,independent(2)} [Pa] (double)

% harpdump -a 'derive(pressure {time, vertical} [Pa]);keep(pressure)' S5P_OFFL_L2 __NO2____ 20190908T134839_20190908T153008_09863_01_010302_20190914T163328.nc
dimensions:
    time = 1877400
    vertical = 34

attributes:
    source_product = "S5P_OFFL_L2 __NO2____ 20190908T134839_20190908T153008_09863_01_010302_20190914T163328.nc"
    history = "2022-12-14T08:53:50Z [harp-1.17] harpdump -a 'derive(pressure {time, vertical} [Pa]);keep(pressure)' S5P_OFFL_L2 __NO2____ 20190908T134839_20190908T153008_09863_01_010302_20190914T163328.nc"

variables:
    double pressure {time = 1877400, vertical = 34} [Pa]

```

---

<div class="post-metadata">

### Author: ![mariliza](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@mariliza](https://forum.atmospherictoolbox.org/u/mariliza)
#### Post date: [December 14, 2022, 11:19am UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/4 "2022-12-14T11:19:05Z")

</div>

Indeed, I saw all the number\_densities per species being ingested but didn’t notice that the total number density is not there in the file… let’s say that we can calculate it ad hoc, we would still need the appropriate temperature profile. Which we need in any case, also for the P-to-height conversion. Dear me, that one is tough.

Pressure is getting derived, indeed. Thanks!

I’ll think about it.

MariLiza

---

<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: [December 14, 2022, 11:36am UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/5 "2022-12-14T11:36:55Z")

</div>

You would either need a total air number density profile or a temperature profile, because with the available pressure profile you can [calculate one from the other](http://stcorp.github.io/harp/doc/html/algorithms/derivations/temperature.html#derivation-temperature-from-pressure-and-number-density).

---

<div class="post-metadata">

### Author: ![mariliza](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@mariliza](https://forum.atmospherictoolbox.org/u/mariliza)
#### Post date: [December 14, 2022, 1:40pm UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/6 "2022-12-14T13:40:21Z")

</div>

Yes, true, however for the next step, i.e. the z calculation we need the molar mass, which can be derived from the number density using the density, [molar mass derivations — HARP 1.17 documentation (stcorp.github.io)](http://stcorp.github.io/harp/doc/html/algorithms/derivations/molar_mass.html)

Are you suggested we use a generic density profile?

---

<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: [December 14, 2022, 1:58pm UTC](https://forum.atmospherictoolbox.org/t/derivations-during-harp-import-product-s5p-no2/583/7 "2022-12-14T13:58:05Z")

</div>

You could provide a total air density profile, but what is more commonly done is to provide information on the amount of H2O. The molar mass of dry air is considered fixed, so the only thing that is needed is to scale the dry air molar mass based on the amount of H2O that is in the air.
