converting time variable to actual dates from a regular .nc file from NCEP Reanalysis-2 data

From: A.J. Eiserloh <arthur.eiserloh_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 03 2013 - 15:27:52 MDT

Hi,

I downloaded Reanalysis-2 data and I am just trying to make it convert the
time variable from the .nc file to the real dates (11/26/2012 00Z
--12/05/2012 00Z). This means there are 37 times. The units for the times
are "hours since 1800-1-1 00:00:0.0". I am trying to use the function
calendar_decode2(), but when I print the result, It just gives me back the
dates with the 1800-01-01 date. It seems like it is not using the
actual_range attribute for the time variable. Also, why does the time
variable come with all zeros instead of the actual times from the
actual_range attribute. I am using NCL v6.1.1. Can someone please help me
find a solution to my problem?

Here is my code:

;data source = Reanalysis-2 geopotential height.
;
http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis2.pressure.html
;==============================================================

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/calendar_decode2.ncl"

f = addfile("./hgt.nc","r")

;geopotential height

hgt = short2flt(f->hgt) ; hgt(time,lev,lat,lon)
                                   ; short2flt() function uses scale_factor
and add_offset attribute to convert
time = f->time
lat = f->lat
lon = f->lon
plev = f->level

print(time)
;time@units = "hours since 1800-1-1 00:00:00"
times = calendar_decode2(time,-3)
print(times)

*This is the variable summary for time in my .nc file*:

        double time(time) ;
                time:units = "hours since 1800-1-1 00:00:0.0" ;
                time:long_name = "Time" ;
                time:actual_range = 1866264., 1866480. ;
                time:delta_t = "0000-00-00 06:00:00" ;
                time:standard_name = "time" ;
                time:axis = "T" ;
                time:coordinate_defines = "point"

*This is the output from my code:*

Variable: time
Type: double
Total Size: 296 bytes
            37 values
Number of Dimensions: 1
Dimensions and sizes: [time | 37]
Coordinates:
            time: [ 0.. 0]
Number Of Attributes: 7
  units : hours since 1800-1-1 00:00:0.0
  long_name : Time
  actual_range : ( 1866264, 1866480 )
  delta_t : 0000-00-00 06:00:00
  standard_name : time
  axis : T
  coordinate_defines : point
(0) 0
(1) 0
(2) 0
(3) 0
(4) 0
(5) 0
(6) 0
(7) 0
(8) 0
(9) 0
(10) 0
(11) 0
(12) 0
(13) 0
(14) 0
(15) 0
(16) 0
(17) 0
(18) 0
(19) 0
(20) 0
(21) 0
(22) 0
(23) 0
(24) 0
(25) 0
(26) 0
(27) 0
(28) 0
(29) 0
(30) 0
(31) 0
(32) 0
(33) 0
(34) 0
(35) 0
(36) 0

Variable: times
Type: integer
Total Size: 148 bytes
            37 values
Number of Dimensions: 1
Dimensions and sizes: [37]
Coordinates:
Number Of Attributes: 1
  calendar : standard
(0) 1800010100
(1) 1800010100
(2) 1800010100
(3) 1800010100
(4) 1800010100
(5) 1800010100
(6) 1800010100
(7) 1800010100
(8) 1800010100
(9) 1800010100
(10) 1800010100
(11) 1800010100
(12) 1800010100
(13) 1800010100
(14) 1800010100
(15) 1800010100
(16) 1800010100
(17) 1800010100
(18) 1800010100
(19) 1800010100
(20) 1800010100
(21) 1800010100
(22) 1800010100
(23) 1800010100
(24) 1800010100
(25) 1800010100
(26) 1800010100
(27) 1800010100
(28) 1800010100
(29) 1800010100
(30) 1800010100
(31) 1800010100
(32) 1800010100
(33) 1800010100
(34) 1800010100
(35) 1800010100
(36) 1800010100

Thanks,

-- 
Arthur J. Eiserloh, Jr.
San Jose State University
Graduate Student
Dept. of Meteorology and Climate Science

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 3 15:28:02 2013

This archive was generated by hypermail 2.1.8 : Wed Sep 04 2013 - 10:27:56 MDT