Recipe: IDL program as OPeNDAP client: Difference between revisions
Created page with "Back to G5NR Data Access Guide. == Problem == By accessing the collection <code>inst01hr_3d_T_Cv</code> via the OPeNDAP server http://opendap.nccs.nasa.gov/dods/OSSE/G5..." |
Move from http to https |
||
Line 4: | Line 4: | ||
By accessing the collection <code>inst01hr_3d_T_Cv</code> via the OPeNDAP server | By accessing the collection <code>inst01hr_3d_T_Cv</code> via the OPeNDAP server | ||
https://opendap.nccs.nasa.gov/dods/OSSE/G5NR/Ganymed/7km | |||
we want to read the surface temperature data inside the box bound by latitudes 25<sup>o</sup>N, 50<sup>o</sup>N and longitudes -130<sup>o</sup>W, -65<sup>o</sup>W for 2006/Sep/18, 9z, compute its min/max and plot the data at the surface. | we want to read the surface temperature data inside the box bound by latitudes 25<sup>o</sup>N, 50<sup>o</sup>N and longitudes -130<sup>o</sup>W, -65<sup>o</sup>W for 2006/Sep/18, 9z, compute its min/max and plot the data at the surface. | ||
Line 12: | Line 12: | ||
The metadata for the collection <code>inst01hr_3d_T_Cv</code> is available at | The metadata for the collection <code>inst01hr_3d_T_Cv</code> is available at | ||
https://opendap.nccs.nasa.gov/dods/OSSE/G5NR/Ganymed/7km/0.5000_deg/inst/inst01hr_3d_T_Cv.info | |||
==== Code ==== | ==== Code ==== | ||
Line 24: | Line 24: | ||
<syntaxhighlight lang="idl" line> | <syntaxhighlight lang="idl" line> | ||
; file | ; file | ||
url = ' | url = 'https://opendap.nccs.nasa.gov:80/dods/OSSE/G5NR/Ganymed/7km/0.5000_deg/inst/inst01hr_3d_T_Cv' | ||
; read data from file | ; read data from file |
Latest revision as of 10:25, 9 April 2019
Back to G5NR Data Access Guide.
Problem
By accessing the collection inst01hr_3d_T_Cv
via the OPeNDAP server
https://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
https://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:
- Instead of reading a downloaded NetCDF-4 file, we read an OPeNDAP URL.
- While in the downloaded file, the temperature variable appears in the uppercase (T), on the OPeNDAP server, this variable is in lowercase.
- 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.
; file
url = 'https://opendap.nccs.nasa.gov:80/dods/OSSE/G5NR/Ganymed/7km/0.5000_deg/inst/inst01hr_3d_T_Cv'
; read data from file
ncid = ncdf_open(url)
; bounding box
; lons = -130:0.5:-65
; lats = 25:0.5:50
imin = round((-130. + 180.)/0.5) - 1
imax = round(( -65. + 180.)/0.5) - 1
jmin = round(( 25 + 90.)/0.5) - 1
jmax = round(( 50 + 90.)/0.5) - 1
; corresponding array sizes
im = imax-imin+1
jm = jmax-jmin+1
lm = 72 ; read all 72 levels
; start and count vectors
offset = [imin, jmin, 0, 11771] ; time level 11771 corresponds to 2006/09/18, 9z
count = [im, jm, lm, 1]
ncdf_varget, ncid, 't', T, count=count, offset=offset ; var name is 't'
ncdf_close, ncid
; max/min of T
print, 'max(T):', max(T)
print, 'min(T):', min(T)
; plot T at the surface
lons = findgen(im)*0.5-130.
lats = findgen(jm)*0.5+25.
basemap = map('Cylindrical Equal Area', limit=[25., -130., 50., -65.])
cntrplot = contour( $
T[*,*,71], $ ;; level=71 => surface
lons, $
lats, $
grid_units=2, $ ;; degrees
n_levels=20, $
rgb_table=34, $
;; /fill, $
/overplot, $
title='surface air temperature' $
)
m1 = mapcontinents(/countries)
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
Discussion
See Also
- File Spec: File:G5NR-Ganymed-7km FileSpec-ON6-V1.0.pdf
- Recipe: Fortran program to read data from downloaded file