% Copyright (C) 2012 The HDF Group % % This example code illustrates how to access and visualize GESDISC AIRS Swath % in MATLAB using the OpenDAP Structs Command Line Tool. % http://www.opendap.org/download/ml-structs.html % If you have any questions, suggestions, comments on this example, % please use the HDF-EOS Forum (http://hdfeos.org/forums). % % If you would like to see an example of any other NASA HDF/HDF-EOS % data product that is not listed in the HDF-EOS Comprehensive Examples page % (http://hdfeos.org/zoo), feel free to contact us at % eoshelp@hdfgroup.org or post it at the HDF-EOS Forum (http://hdfeos.org/forums). % Run this script as follows: % % >matlab -nosplash -nodesktop -r AIRS_L2_radiances_channel567_OpenDAP % % Then, you'll get an image file: % % AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425_radiances567_matlab.jpg % % Last update: 10/23/2012 % Tested under: MATALB 2012a clear % Add the path to the Matlab-OpenDAP library installation bin directory addpath /scr/kent/matlab-opendap/dapbin/bin % Open the HDF-EOS2 Swath File via the OpenDAP interface loaddap(['http://eosdap.hdfgroup.uiuc.edu:8080/opendap/data/' ... 'NASAFILES/hdf4/AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425.hdf']); % loaddap creates the structures: % ... % matrix radiances (45 x 30 x 2378) with 3210300 elements. % ... % matrix Latitude (45 x 30) with 1350 elements. % matrix Longitude (45 x 30) with 1350 elements. % ... % This information is also returned as a Matlab structure by attrs=loaddap('-A', ... 'http://eosdap.hdfgroup.uiuc.edu:8080/opendap/data/NASAFILES/hdf4/AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425.hdf'); % Either way, the structure element name must be known in advance to access the % structure element. % The structure element name is the same as the attribute name, which can be % obtained via the OpenDAP web services interface at URL: % http://eosdap.hdfgroup.uiuc.edu:8080/opendap/data/NASAFILES/hdf4/AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425.hdf.das % radiances, Latitude and Longitude are already of type double % Extract 2-D data at level 568 of radiances: 30x2378x45 double data=squeeze(radiances(:,568,:)); % Lat, Long and radiances must have the same dimensions. % -- radiances is transposed dataTranspose = data'; % Replace the fill value with NaN (_FillValue=-9999.000000 from attributes) dataTranspose(dataTranspose==-9999) = NaN; % Plot the data using surfacem and axesm pole=[-90 0 0]; latlim=[floor(min(min(Latitude))),ceil(max(max(Latitude)))]; min_data=floor(min(min(dataTranspose))); max_data=ceil(max(max(dataTranspose))); figure_handle=figure('Name', ... 'AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425_radiances_channel567', ... 'visible','off'); axesm('MapProjection','stereo','MapLatLimit',latlim,... 'Origin',pole,'Frame','on','Grid','on', ... 'MeridianLabel','on','ParallelLabel','on'); coast = load('coast.mat'); % surfacem is faster than contourfm, but produces less desirable graph % surfacem(Latitude,Longitude,dataTranspose); contourfm(Latitude,Longitude,dataTranspose,'LineStyle','none'); colormap('Jet'); caxis([min_data max_data]); cbar_handle=colorbar('YTick', min_data:4:max_data); set (get(cbar_handle, 'title'), 'string', 'mW/m^{2}/cm^{-1}/sr'); plotm(coast.lat,coast.long,'k'); title({'AIRS.2002.12.31.001.L2.CC\_H.v5.0.14.0.G07282131425';'Radiances at channel=567'} ,'FontSize',16,'FontWeight','bold'); scrsz = get(0,'ScreenSize'); if ishghandle(figure_handle) set(figure_handle,'position',scrsz,'PaperPositionMode','auto'); saveas(figure_handle, ... 'AIRS.2002.12.31.001.L2.CC_H.v5.0.14.0.G07282131425_radiances567_matlab.jpg'); end