MONITORING AIR POLLUTION WITH SATELLITE DATA USING SENTINEL 5-P IN PYTHON

Nirdesh
5 min readMar 1, 2021

--

Nitrogen dioxide is an essential trace gas and is found in the troposphere and stratosphere. NO2 in the atmosphere can be attributed to natural as well as anthropogenic sources. The high concentration of NO2 is mainly from fossil fuels, biomass burning and industry.

The distribution of NO2 in the troposphere is variable because of variable sources and the short lifetime of NO2. Therefore it becomes essential to study the spatiotemporal variation of NO2 for planning and management as it can be used to identify the source of pollution

Remote sensing of NO2 via satellites has become one of the most crucial techniques of observation. Satellite remote sensing provides us with continuous data all around the globe at a reasonable accuracy

TROPOMI or Tropospheric Monitoring Instrument is a sensor onboard Sentinel 5P, a precursor satellite to Sentinel 5. It has a sun-synchronous orbit dedicated to monitoring air quality. It has eight spectral bands in UV, visible, NIR and SWIR. With its bands, it can determine the concentration of O3, NO2, CO, CH4, SO2, HCHO and aerosol properties. The sentinel 5P has a heritage with both OMI and SCIAMACHY and is used in tandem with both to provide a continuous time series of air quality data.

Downloading data from Sci-hub: Sci hub is where sentinel data is stored. Downloading 1 image is easy but for a comprehensive study, we need to get files in large number hence sci-hub provides a script to download data. The script can be found at https://scihub.copernicus.eu/twiki/pub/SciHubUserGuide/BatchScripting/dhusget.sh

  1. Save this script to a folder: lets name that working directory. Open python from jupyter notebook and copy this script.

The first three lines are required if you work on a proxy network. Since dhusget.sh is a shell file you need to run it in python with ! and the location of the file in my case it is contained in the sentinel folder. The -d is the website for downloading, username -u and password -p remain the same as sentinel 5-P does not require any registration. -S and -E denote starting and ending date -F is the extra search parameters we want to add like producttype, processing level -l is the number of articles per page and -c is the lat and long. The above file will download data for India as the location is the bounding coordinated for India -o is if we want to download the product

After downloading the files you need to make sure that an md5 checksum is performed for every file. If that is failed, the file is corrupt and the rest of the code will cause an error. This code is only required if you want to download files. If files are already downloaded skip this snippet of code.

Now for the main part: firstly you will be required to install harp which is used to ingest, process and compare atmospheric satellite data. The tool can be used in Python and MATLAB. With an appropriate HARP command line, satellite data can be pre-processed and correlated such that the final data has the same spatial, temporal and grid format for comparison and manipulation. Sentinel files are single files for one swath and one time. HARP tool can be used to spatially and temporally merge along with pre-processing. Once the existing grids are made, we can merge and create a final averaged map.

Harp is a product of stcorp and can be installed using the command in line 1. Assuming other packages are installed you are ready to visualize and generate sentinel 5-P maps.

Working with a single sentinel file

Sentinel files are provided as nc files. These can be opened by xarray. In order to handle and visualize sentinel 5-P files, we need to understand the structure of sentinel files.

Fname is the path to the file you want to open, then we can open the file using xarray. To visualize we store the lat, on and NO2 in separate variables. The above code is used to plot the NO2 concentration using matplotlib.

Since you are here you don't want to plot one file but generate a mosaic of various sentinel 5-P files. We will use harp tool imported in the first step.

now assuming all files are in the same folder where the script is located we import all sentinel files into the input. Harp tool operations are defined below these are for the Indian subcontinent but can be updated to any location.

The latitude and longitude are used to spatially confine the single orbit files. The tropospheric validity is a quality flag which according to official documentation has to be greater than 75 for values to be without clouds.

bin_spatial is used to map samples into a rectangular grid for all variables. The first number defines the number of pixels, the second the starting latitude, the third defines the resolution. Similarly the second part of bin spatial generates rectangular grids.

The derive operation is done after bin spatial to get intermediate lat/lon as bin spatial only gets the bounding coordinates.

The keep operation keeps only the important data and removes unnecessary data for better handling and fast computing.

The squash option will remove the time dimension from the variable to have a proper georeferenced product for final use.

The above snippet will plot the sentinel file which will look as shown

monthly NO2 concentration

As mentioned you can also see the number of images used to generate the average by using the above code

weight

you can also generate an animation of variation by using gis software to snip the concentration to a given shapefile and saving concentration images in .png format. All the png files are then imported for the animation

That’s all folks if you find this informative and use the code please cite 10.5281/zenodo.4569495

if you face any problem email me at nirdeshthekumar@gmail.com

--

--

Responses (2)