Recipe: IDL program as OPeNDAP client

From GEOS-5
Jump to: navigation, search

Back to G5NR Data Access Guide.

Problem

By accessing the collection inst01hr_3d_T_Cv via the OPeNDAP server

http://opendap.nccs.nasa.gov/dods/OSSE/G5NR/Ganymed/7km

we want to read the surface temperature data inside the box bound by latitudes 25oN, 50oN and longitudes -130oW, -65oW for 2006/Sep/18, 9z, compute its min/max and plot the data at the surface.

Solution

IDL version 8.2 and later has native openDAP support. The following code has been tested with IDL version 8.3.

The metadata for the collection inst01hr_3d_T_Cv is available at

http://opendap.nccs.nasa.gov/dods/OSSE/G5NR/Ganymed/7km/0.5000_deg/inst/inst01hr_3d_T_Cv.info

Code

This code accesses the collection inst01hr_3d_T_Cv from the OPeNDAP server and reads a subset of the temperature data (all levels inside the bounding box specified above) and computes its max/min. It then plots the data at the surface (level=72).

NOTE:

  1. Instead of reading a downloaded NetCDF-4 file, we read an OPeNDAP URL.
  2. While in the downloaded file, the temperature variable appears in the uppercase (T), on the OPeNDAP server, this variable is in lowercase.
  3. Via the OPeNDAP URL, we now have access to all times for which data exists. The hourly inst files are available starting at 2005/15/15, 2200z. Our desired time, 2006/09/18, 0900z is then the 11772th step.
 1 ; file
 2 url = 'http://opendap.nccs.nasa.gov:80/dods/OSSE/G5NR/Ganymed/7km/0.5000_deg/inst/inst01hr_3d_T_Cv'
 3 
 4 ; read data from file
 5 ncid = ncdf_open(url)
 6 ; bounding box
 7 ;   lons = -130:0.5:-65
 8 ;   lats =   25:0.5:50
 9 imin = round((-130. + 180.)/0.5) - 1
10 imax = round(( -65. + 180.)/0.5) - 1
11 jmin = round((  25 +  90.)/0.5) - 1
12 jmax = round((  50 +  90.)/0.5) - 1
13 ; corresponding array sizes
14 im = imax-imin+1
15 jm = jmax-jmin+1
16 lm = 72 ; read all 72 levels
17 ; start and count vectors
18 offset = [imin, jmin, 0, 11771] ; time level 11771 corresponds to 2006/09/18, 9z
19 count = [im, jm, lm, 1]
20 ncdf_varget, ncid, 't', T, count=count, offset=offset ; var name is 't'
21 ncdf_close, ncid
22 
23 ; max/min of T
24 print, 'max(T):', max(T)
25 print, 'min(T):', min(T)
26 
27 ; plot T at the surface
28 lons = findgen(im)*0.5-130.
29 lats = findgen(jm)*0.5+25.
30 basemap = map('Cylindrical Equal Area', limit=[25., -130., 50., -65.])
31 cntrplot = contour( $
32            T[*,*,71], $ ;; level=71 => surface
33            lons, $
34            lats, $
35            grid_units=2, $ ;; degrees
36            n_levels=20, $
37            rgb_table=34, $
38            ;; /fill, $
39            /overplot, $
40            title='surface air temperature' $
41                   )
42 m1 = mapcontinents(/countries)
43 
44 END

Output

Running this IDL script

IDL> .run g5nr_reader_dap.pro

we get the text output

max(T):      305.605
min(T):      191.696

and the plot

SurfaceAirTempSubsetIDL.png

Discussion

See Also

  1. File Spec: File:G5NR-Ganymed-7km FileSpec-ON6-V1.0.pdf
  2. Recipe: Fortran program to read data from downloaded file

No Warranty

Copyright