Top Banner
National Aeronautics and Space Administration Credit: TROPOMI, ESA, Copernicus, KNMI Pawan Gupta and Melanie Follette-Cook Advanced Webinar: High Resolution NO2 Monitoring From Space with TROPOMI, May 2019 Python Tools for Analyzing NO 2 Data
55

National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Aug 01, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

National Aeronautics and Space Administration

Credit: TROPOMI, ESA, Copernicus, KNMI

Pawan Gupta and Melanie Follette-Cook

Advanced Webinar: High Resolution NO2 Monitoring From Space with TROPOMI, May 2019

Python Tools for Analyzing NO2 Data

Page 2: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

2NASA’s Applied Remote Sensing Training Program

Webinar Agenda

Session 1 Session 3Session 2

Remote sensing of NO2, OMI Data Products, and Tools

Introducing TROPOMI - High

Resolution NO2 Observations from Space

Python Tools - TROPOMI

Page 3: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

3NASA’s Applied Remote Sensing Training Program

Session 3

Introduction to Python tools for Tropospheric Monitoring Instrument (TROPOMI) Data

– Read NetCDF file and learn about SDS

– Read and map NO2 data

– Read and extract NO2 data at a location

– Read NetCDF and extract data into ascii format

Page 4: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

4NASA’s Applied Remote Sensing Training Program

Learning Objectives

By the end of this presentation, you will be able to:

• Read, extract and map TROPOMI NO2 data sets

Page 5: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

5NASA’s Applied Remote Sensing Training Program

Data Sets & Tasks

• Data

– OMI NO2 data

– TROPOMI NO2 data

• Tasks

– Read sds (scientific data sets) and list them

– Read and map the data

– Read and extract data over specific location

– Read and output data in a csv file

Page 6: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

6NASA’s Applied Remote Sensing Training Program

Data & Codes Required

• Screenshot of ARSET page once material is posted

Page 7: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

7NASA’s Applied Remote Sensing Training Program

Anaconda & Spyder Editor

Page 8: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

8NASA’s Applied Remote Sensing Training Program

Spyder View

Code Area

ipython Area

Page 9: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

9NASA’s Applied Remote Sensing Training Program

Current Directory View & fileList.txt

• In a text file, create a list of each

netcdf file of interest and name it,

‘fileList.txt’

• The same directory should have

– All the python codes

– All the netcdf (.nc) data files

– A file named ‘fileList.txt’ that contains

a list of each netcdf filename

Page 10: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

10NASA’s Applied Remote Sensing Training Program

Spyder View

Page 11: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

11NASA’s Applied Remote Sensing Training Program

fileList.txt

Page 12: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 12

Python Packages & Test code

Open the test code and run it

If this code runs without any error and

outputs then your python is ready for

the today’s session.

Page 13: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Read a TROPOMI NO2 File (nc) and Print SDS List

Page 14: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 14

Print Scientific Data Sets (SDSs)

read_tropomi_and_list_sds.py

Purpose: read TROPOMI

level 2 data files in netcdf

format and print all the

Scientific Data Sets

(SDS).

In their current form, all of

these codes work for only

level 2 products, not

gridded products. The code

is tested for NO2 data and

may require to modify to

work with other TROPOMI

data sets.

Page 15: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

15NASA’s Applied Remote Sensing Training Program

Running and Output

• Click the green arrow

to run the code

• The code will process

all of the files in

fileList.txt one-by-

one

• Follow the

instructions on the

ipython terminal (i.e.

enter ‘Y’ or ‘N’ when

prompted and hit

enter)

Output

Page 16: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

16NASA’s Applied Remote Sensing Training Program

Editing the CodeChange the name of

fileList.txt to anything

you’d like

The group name in TROPOMI

where data are stored is

called ‘PRODUCT’. There are

other groups in the data file.

Page 17: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

17NASA’s Applied Remote Sensing Training Program

Applications

• TROPOMI Level 2 NO2 and other data are provided in netCDF (.nc) file

• Each nc file contains several geophysical parameters

• Special codes/tools are required to open the nc files

• This code helps users see the names and dimensions of the available SDSs inside an

nc file for further analysis

Page 18: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Map NO2

Page 19: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

19NASA’s Applied Remote Sensing Training Program

Reminders

• Close the earlier code in Spyder

• Restart the ipython kernel

Page 20: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 20

Plot and save a map of TROPOMI AI & NO2

read_and_map_tropomi_no2_ai.py

Page 21: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

21NASA’s Applied Remote Sensing Training Program

Running and Output

Output map

AI/NO2 Statistics

Page 22: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

22NASA’s Applied Remote Sensing Training Program

Editing the Code

Change the color scale Change the SDS to plot

https://matplotlib.org/examples/color/colormaps_reference.html

Page 23: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

23NASA’s Applied Remote Sensing Training Program

Applications

• This is a sample code to read and map the TROPOMI Level 2 NO2 and AI data

• The code can be modified to address various mapping needs

• User can create daily maps of trace gas columns over certain regions and start

analyzing changes over time

• These maps can also help identify regions of high pollution

Page 24: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Extract NO2/AI at a given location

Page 25: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

25NASA’s Applied Remote Sensing Training Program

Extract NO2 Values from TROPOMI Level 2 Data

• Purpose: read a

TROPOMI NO2/AI

level 2 data file

in nc format and

extract values at

a given ground

location

read_tropomi_no2_ai_at_a_location.py

Page 26: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

26NASA’s Applied Remote Sensing Training Program

Running and Output

Type “Y” to process file,

“N” to skip

Outputs

Lat & Lon of station

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

Page 27: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

27NASA’s Applied Remote Sensing Training Program

Editing the Code – Change the SDS

Page 28: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

28NASA’s Applied Remote Sensing Training Program

Applications

Satellite Validation

OMI V2

OMI V3

Observations

Source: Krotkov et al. (2017)AQS (Surface)

OMI (Satellite)

Column vs. Surface

Relationship and Trends

Source: Lamsal, L.N. et al. (2016)

Page 29: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Output nc variables to CSV

Page 30: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

30NASA’s Applied Remote Sensing Training Program

Output TROPOMI NO2/AI nc variables to a CSV file

• Purpose: read

a TROPOMI

level 2 NO2 or

AI data file in

netCDF

format and

write certain

SDSs into a

csv (text) file

read_tropomi_no2_ai_and_dump_ascii.py

Page 31: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

31NASA’s Applied Remote Sensing Training Program

Output

This code saves a .csv

file, which can be opened

by excel, a text editor, or

other codes or software

Page 32: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

32NASA’s Applied Remote Sensing Training Program

Editing the Code

Change the SDS

SDS to be written

as output

NOTE: This code

will only work when

all the variables

listed are the same

dimension. Use

the “list SDS” code

to view the variable

dimensions

Page 33: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Transition to OMI Data

Page 34: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Read an OMI NO2 File (he5) and Print SDS List

Page 35: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 35

Print Scientific Data Sets (SDSs)

read_omi_no2_so2_and_list_sds.py

Purpose: read OMI NO2 or

SO2 level 2 data files in hdf

format and print all the

Scientific Data Sets

(SDS).

In their current form, all of

these codes work for only

level 2 products, not

gridded products.

The ‘_geo.py’ code lists all

of the geolocation fields

read_omi_no2_so2_and_list_sds_geo.py

Page 36: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

36NASA’s Applied Remote Sensing Training Program

Running and Output

• Click the green arrow

to run the code

• The code will process

all of the files in

fileList.txt one-by-

one

• Follow the

instructions on the

ipython terminal (i.e.

enter ‘Y’ or ‘N’ when

prompted and hit

enter)

Output

Page 37: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

37NASA’s Applied Remote Sensing Training Program

Editing the CodeChange the name of

fileList.txt to anything you’d

like

By changing the location of

dataFields to geolocation

(found in other codes) this

can also list the available

geolocation variables

Page 38: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

38NASA’s Applied Remote Sensing Training Program

Applications

• OMI Level 2 NO2 and SO2 data are provided in hdf file

• Each HDF file contains several geophysical parameters

• Special codes/tools are required to open the hdf files

• This code helps users see the names and dimensions of the available SDSs inside an

hdf file for further analysis

Page 39: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Map NO2 or SO2

Page 40: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 40

Plot and save a map of OMI NO2 or SO2

read_and_map_omi_so2_no2.py

Page 41: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

41NASA’s Applied Remote Sensing Training Program

Running and Output

Output map

NO2/SO2 Statistics

Page 42: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

42NASA’s Applied Remote Sensing Training Program

Editing the Code

Change the color scale Change the SDS to plot

https://matplotlib.org/examples/color/colormaps_reference.html

Page 43: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

43NASA’s Applied Remote Sensing Training Program

Applications

• This is a sample code to read and map the OMI Level 2 NO2 and SO2 data

• The code can be modified to address various mapping needs

• User can create daily maps of trace gas columns over certain regions and start

analyzing changes over time

• These maps can also help identify regions of high pollution

Page 44: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Extract NO2/SO2 at a given location

Page 45: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 45

Extract AOD Values from MODIS Aerosol Level 2 Data

read_mod_aerosol_and_list_sds.py

• Purpose: read an OMI

NO2/SO2 level 2 data

file in HDF format and

extract values at a

given ground location

Page 46: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

46NASA’s Applied Remote Sensing Training Program

Running and Output

Type “Y” to process file,

“N” to skip

Outputs

Lat & Lon of station

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

X XX X XXX

Page 47: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

47NASA’s Applied Remote Sensing Training Program

Editing the Code – Change the SDS

Page 48: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

48NASA’s Applied Remote Sensing Training Program

Applications

Satellite AOD Validation Time Series AnalysisAOD-PM2.5 Relationship

Page 49: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

49NASA’s Applied Remote Sensing Training Program

Applications

Satellite Validation

OMI V2

OMI V3

Observations

Source: Krotkov et al. (2017)AQS (Surface)

OMI (Satellite)

Column vs. Surface

Relationship and Trends

Source: Lamsal, L.N. et al. (2016)

Page 50: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Output HDF variables to CSV

Page 51: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

NASA’s Applied Remote Sensing Training Program 51

Output OMI NO2/SO2 HDF variables to a CSV file

read_omi_no2_so2_and_dump_ascii.py

• Purpose: read an OMI

level 2 NO2 or SO2

data file in HDF format

and write certain SDSs

into a csv (text) file

Page 52: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

52NASA’s Applied Remote Sensing Training Program

Output

This code saves a .csv

file, which can be opened

by excel, a text editor, or

other codes or software

Page 53: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

53NASA’s Applied Remote Sensing Training Program

Editing the Code

Change the SDS

SDS to be written

as output

NOTE: This code

will only work when

all the variables

listed are the same

dimension. Use

the “list SDS” code

to view the variable

dimensions

Page 54: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

54NASA’s Applied Remote Sensing Training Program

Applications

• This is a sample code to read and extract OMI Level 2 NO2 and SO2 data

• The code can be modified to extract varying SDSs into a single .csv file

• The code be easily modified to extract data over a certain region

• The output file can be opened in excel, or any other data analysis tool

Page 55: National Aeronautics and Space Administration · •This is a sample code to read and extract OMI Level 2 NO 2 and SO 2 data •The code can be modified to extract varying SDSs into

Credit: TROPOMI, ESA, Copernicus, KNMI

Question & Answers