a matlab tutorial in working with hdf files. overview description of hdf data format programs...

26
A Matlab tutorial in working with HDF files

Upload: tobias-dixon

Post on 27-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

A Matlab tutorial in

working with HDF files

Page 2: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Overview Description of HDF data format Programs available for visualizing and manipulating data Features of HDF view and how/where to download Introduction to case study and tasks for this lab Ordering data Reading HDF files into Matlab Matlab coding exercises Getting familiar with Giovanni (time permitting)

Page 3: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Basics of HDF data format

HDF (Hierarchical Data Format) is a library and multi-object file format for storing and managing data between machines.

Two versions: HDF4 and HDF5. HDF-EOS specifically for EOS satellites (Terra, Aqua and Aura)

Important features: Self-describing; Can store swaths, grids, in-situ data, instrument metadata, and

browse image in a single file; No limits on size or number of data objects; Support parallel I/O, multiple platforms and API with

C/C++/Fortran/Java/Matlab interfaces

Page 4: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Programs for HDF files:

http://www.hdfgroup.org/tools.html

Free* HDF View* IDL Matlab Pomegranate* Igor Pro GrADS* Panpoly*

Page 5: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

HDF View :Screenshot of main window

Tree panel

Data panel

Info panel

Menu and tool bar

Page 6: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Getting HDF View

Free download link for WIN/MAC/LINUX:http://www.hdfgroup.org/hdf-java-html/hdfview/

index.html

User guide:http://www.hdfgroup.org/hdf-java-html/hdfview/

UsersGuide/index.html

Page 7: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Case study for lab: 2009 Eruption of Mt. Redoubt

Page 8: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Tasks1. Working with HDF files from MODIS:

a. Retrieve Terra MODIS Level 2 AOD’s at 550 nm for April 4, 2009 at 2220 UTC. http://ladsweb.nascom.nasa.gov/data/search.html

http://modis.gsfc.nasa.gov/

b. Use Matlab to make a contour plot of AOD, with latitude on the Y-axis and longitude on the X-axis. Be sure to add the coastline to your plot.

c. What are the ranges of AOD in your plot? What is the mean AOD? Based on this information, was the event observed in the satellite data a strong volcanic event?

2. Working with HDF files from OMI (time permitting):

a. Retrieve Aura OMI Level 3 AI (UV aerosol index) for April 4, 2009 from Giovannihttp://disc.sci.gsfc.nasa.gov/giovanni/overview/giovanni-parameters

b. Using Matlab, make a contour plot of AI, with latitude on the Y-axis and longitude on the X-axis. Load the coast.

c. From the plot, which regions of the plume would you expect to be most rich in ash?

Page 9: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Task 1a: Retrieving Terra MODIS Level 2 AOD

Page 10: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 11: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 12: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 13: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 14: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Task 1b: Reading MODIS HDF files into Matlabclear

% reading in file MODIS_ID = hdfsd ('start','filename.hdf', 'read');

% extract info about file description [numdata, numdescr] = hdfsd ('fileinfo', MODIS_ID);

% assigning dataset ID(s) AODid = hdfsd ('select', MODIS_ID, 9); longid = hdfsd ('select', MODIS_ID, 0); latid = hdfsd ('select', MODIS_ID, 1);

% extracting info from dataset [name,numdim,dimvector,type,numdescr] = hdfsd('getinfo', AODid) [name,numdim,dimvector,type,numdescr] = hdfsd('getinfo', longid) [name,numdim,dimvector,type,numdescr] = hdfsd('getinfo', latid)

% Reading HDF datasets and importing into Matlab startvector = [0 0]; endvector = dimvector; stride = [];

AODvar = hdfsd('readdata', AODid, startvector, stride, endvector); longvar = hdfsd('readdata', longid, startvector, stride, endvector); latvar = hdfsd('readdata', latid, startvector, stride, endvector);

Page 15: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Tasks 1b & c: On your own or in groups

Steps and hints to problems:

1c. The plot:• Change AOD fill values (-9999) to not a number (NaN)• Don’t forget to multiply AOD by a scale factor of 0.001• You will need to subtract 360 degrees from all values of

longitude that are greater than 0 to remap on a linear scale.

• Use Matlab help. For example, type: help contourf to gather more information on contourf.

1d. Based on the max/min and mean values of AOD for this event, what might this mean about the strength of the eruption? Hint: Fresh plumes from strong eruptions can have AOD’s as high as those for meteorological clouds, which can be in the 100’s.

Page 16: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

April 4 AOD

Page 17: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Task 2a: Getting OMI AI data from Giovanni

Page 18: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 19: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 20: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 21: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 22: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Task 2b: Reading OMI data into Matlab

clear

% reading in file OMI_ID = hdfsd ('start','filename.hdf, 'read');

% extract info about file description [numdata, numdescr] = hdfsd ('fileinfo', OMI_ID);

% assigning dataset ID(s) AIid = hdfsd ('select', OMI_ID, 0)

% extracting info from dataset [name,numdim,dimvector,type,numdescr] = hdfsd('getinfo', AIid)

% Reading HDF datasets and importing into Matlab startvector = [0 0]; endvector = dimvector; stride = [];

AIvar = hdfsd('readdata', AIid, startvector, stride, endvector);

Page 23: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

Task 2b & c: On your own

Steps and hints to problems:

1c. The plot:• Longitude and latitude are not included in this hdf file.

You will need to calculate your own based on the dimensions of the AI matrix and the long/lat ranges

(-180 to -136 longitude; 67 to 47 latitude)• Remember to remove AI fill values (for this dataset, fill value < -1 X 1030)• You may notice when you plot this data that it needs to

be flipped about the x and/or y-axis to get the correct orientation.

1d. Where would you expect to find the areas most rich in ash? Hint: OMI AI serves as a qualitative indicator of the presence of UV absorbing aerosols, such as ash.

Page 24: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features

April 4 OMI AI

Page 25: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features
Page 26: A Matlab tutorial in working with HDF files. Overview  Description of HDF data format Programs available for visualizing and manipulating data Features