; This example code illustrates how to access and visualize NSIDC AMSR_E ; Grid file in IDL. This Grid file uses Polar Stereographic projection. ; ; 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). ; Define file name, grid name, and data field. FILE_NAME='AMSR_E_L3_SeaIce12km_V11_20050118.hdf' GRID_NAME='SpPolarGrid12km' DATAFIELD_NAME='SI_12km_SH_36H_DAY' ; See the specification [1]. The file doesn't have unit attribute. UNIT = 'K' ; Open file. file_id = EOS_GD_OPEN(FILE_NAME) ; Attach grid. grid_id = EOS_GD_ATTACH(file_id, GRID_NAME) ; Retrieve data. status = EOS_GD_READFIELD(grid_id, DATAFIELD_NAME, data) ; Read fill value. status = EOS_GD_GETFILLVALUE(grid_id, DATAFIELD_NAME, fillvalue) ; Detach grid. status = EOS_GD_DETACH(grid_id) ; Close file status = EOS_GD_CLOSE(file_id) ; Read fill value from data directly using HDFView. fillvalue = 0 ; Convert data type dataf=float(data) ; Process fill value. idx=where(data eq fillvalue, cnt) if cnt gt 0 then dataf[idx]=!Values.F_NAN ; Multiply scale by 0.1 to get Kelvin according to [1]. dataf = dataf * 0.1 ; Get max and min value of data. datamin = min(dataf, /NAN) datamax = max(dataf, /NAN) ; The file contains Polar Stereographic projection. ; We need to use eosdump to generate 1D lat and lon. ; For information on how to obtain the lat/lon data, check [2]. ; Retrieve dimension sizes of data dimsize=size(data,/dim) numlat=dimsize(0) numlon=dimsize(1) ; Open text dump file that has lat data. openr,1,'lat_AMSR_E_L3_SeaIce12km_V11_20050118_SpPolarGrid12km.output' size=numlat*numlon ValInlat=FltArr(size) READF,1,ValInlat lat=FINDGEN(numlat,numlon) lat=Reform(ValInlat,numlat,numlon) ; Open text dump file that has lon data. openr,2,'lon_AMSR_E_L3_SeaIce12km_V11_20050118_SpPolarGrid12km.output' ValInlon=FltArr(size) READF,2,ValInlon lon=FINDGEN(numlat,numlon) lon=Reform(ValInlon,numlat,numlon) ; Get min/max values for lat and lon. latmin=min(lat) latmax=max(lat) lonmin=min(lon) lonmax=max(lon) ; The following code is prepared for colorbar. ; ; If you require colorbar in your plot, you could download ; "Dr. Fanning's Coyote Library" from [3]. Make a directory named ; coyote somewhere on your machine, and extract the Coyote files into ; it. ; ; If color bar is not not necessary for your plot, you can ignore this ; step and add comment character ';' ahead of coding. ; ; Add the coyote directory you create on your machine to your IDL ; path like below: ; ; !PATH=Expand_Path('[coyote directory on your machine])+':'+!PATH ; Let's assume that you've installed coyote library under the current working ; directory that this code exists. !PATH=Expand_Path('+coyote/')+':'+!PATH ; Generate the plot. levels=254 device,decomposed=0 LoadCT,33, Ncolors=levels, Bottom=1 WINDOW, Title='FIELD:' + DATAFIELD_NAME +' '+'UNIT:K' ; The following 3 routines of MAP_SET are for global view and Polar ; view, you could choose either one depending on you purpose. ; (1) Global Grid view. MAP_SET, /GRID, /CONTINENTS, POSITION=[0.05, 0.05, 0.82, 0.82] ; (2) Stereographic view at lat:0 lon:0. ; MAP_SET, /STEREOGRAPHIC, /ISOTROPIC, /HORIZON, /CONTINENTS,$ ; (3) Polar stereographic view. See "-90,0" below. ; MAP_SET, /STEREOGRAPHIC, -90,0, /ISOTROPIC,/CONTINENTS,XMARGIN=5,YMARGIN=5,$ ; POSITION=[0.05, 0.05, 0.82, 0.82], LIMIT=[latmin, lonmin, latmax,lonmax] ; Do not use /FILL to handle fill values correctly on polar ; stereographic projection. CONTOUR, dataf, lon, lat, /OVERPLOT, $ MAX_VALUE=datamax, MIN_VALUE=datamin, $ C_Colors=Indgen(levels)+3, Background=1, NLEVELS=levels, Color=Black MAP_GRID, /LABEL, COLOR=255 MAP_CONTINENTS, COLOR=255 XYOuts, 0.35, 0.84, /Normal, DATAFIELD_NAME, $ Charsize=1.25, color=black, Alignment=0.0 XYOuts, 0.94, 0.82, /Normal, 'UNIT:' + UNIT, $ Charsize=1.25, Color=black, Alignment=1.0 XYOuts, 0.43, 0.92, /Normal, FILE_NAME, $ Charsize=1.75, Color=black, Alignment=0.5 ; The following code assumes that you've already download and installed ; "Dr. Fanning's Coyote Library" and add the coyote directory above. ; ; If you don't need color bar in your plot, you can ignore this step ; by adding comment character ';' at the beginning of the code. COLORBAR, Range=[datamin, datamax], Ncolors=levels, /Vertical, $ Position=[0.9,0.1,0.94,0.8] ; Reference ; ; [1] http://nsidc.org/data/docs/daac/ae_si12_12km_seaice/data.html ; [2] http://hdfeos.org/zoo/note_non_geographic.php ; [3] http://www.dfanning.com/documents/programs.html