Dear NCL world,
May I have some help? This is an update my earlier request for help
with getting time displayed in my netcdf file. I updated my code from
earlier suggestions, but I am still getting incorrect time. When I do
"ncdump -h" on the my output netcdf file, I don't get the proper time
that should reflect 3-hourly intervals for 1 day.
(It says time = UNLIMITED ; // (1 currently). it should be time =
UNLIMITED ; // (8 currently)).
I'm reading in a binary file that I'm told is composed of 16 direct
access binary ("big_endian") records, which are 2 variables at
3-hourly ntervals for 1 day, basically 8 pairs.
I searched throughout previous posts about time coordinates before
posting this question ncl-talk. Its not clear whether i need to resort
to making up this variable (i.e. specifically make a variable time =
year*10000 + month*100 + day...etc) or if Its something even more
simple that I am overlooking.
Could I have please have some advice on how to fix this? I have my
screen readouts and ncl code below.
-Erik
My ncdump -h of netcdf file:
ENOBLE_at_ATHENA: /usr/people/enoble> ncdump -h sample.nc
netcdf sample {
dimensions:
time = UNLIMITED ; // (1 currently)
lat = 480 ;
lon = 1440 ;
variables:
float COMB_MW(time, lat, lon) ;
COMB_MW:units = "mm/hr" ;
COMB_MW:long_name = "merged microwave precipitation" ;
float lat(lat) ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:units = "degrees_east" ;
float CMORPH(time, lat, lon) ;
CMORPH:units = "mm/hr" ;
CMORPH:long_name = "CMORPH" ;
// global attributes:
:title = "1 day of daily CMORPH precipitation data" ;
:source =
"ftp://ftp.cpc.ncep.noaa.gov/precip/global_CMORPH/3-hourly_025deg" ;
=======
ncl code
=======
; NCL script that reads in ONE NOAA CMORH precipitation binary file
; 16 direct access binary ("big_endian") records, which are 2
variables at 3-hourly
; intervals for 1 day
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
a = addfile("sample.nc","c") ; write netCDF file
a_at_title = "1 day of daily CMORPH precipitation data"
a@source = "ftp://ftp.cpc.ncep.noaa.gov/precip/global_CMORPH/3-hourly_025deg"
filedimdef(a,"time",-1,True) ; make time an UNLIMITED
dimension, always recommended
;===================
; create time variable
;===================
; time = year*10000 + month*100 + day
; time_at_units = "yyyymmdd"
;=============================
; create lat and long coordinate variables
;============================
nlat = 480
mlon = 1440
lat = 59.875 - ispan(0,nlat-1,1)*0.25
lon = 0.125 + ispan(0,mlon-1,1)*0.25
lat!0 = "lat"
lat&lat = lat
lat_at_units = "degrees_north"
lon!0 = "lon"
lon&lon = lon
lon_at_units = "degrees_east"
setfileoption ("bin", "ReadByteOrder", "BigEndian")
ntime = 1
do i = 0, 14,2 ; CMORPH binary file contains 16
records. NCL starts at counting at 0
cpc_combined_MW = fbindirread
("./20060901_3hr-025deg_cpc+comb",i,(/ntime,480,1440/),"float")
CMORPH = fbindirread
("./20060901_3hr-025deg_cpc+comb",i+1,(/ntime,480,1440/),"float")
;=============================
; name dimensions of variables
;============================
cpc_combined_MW!0 = "time"
cpc_combined_MW!1 = "lat"
cpc_combined_MW!2 = "lon"
; cpc_combined_MW&time = time
cpc_combined_MW&lat = lat
cpc_combined_MW&lon = lon
cpc_combined_MW_at_long_name = "merged microwave precipitation"
cpc_combined_MW_at_units = "mm/hr"
print ("====== Binary Record= "+(i+1) +"/ NCL Record Counter
"+(i)+" ======")
printVarSummary(cpc_combined_MW)
CMORPH!0 = "time"
CMORPH!1 = "lat"
CMORPH!2 = "lon"
CMORPH&lat = lat
CMORPH&lon = lon
CMORPH_at_long_name = "CMORPH"
CMORPH_at_units = "mm/hr"
print ("====== Binary Record= "+(i+2) +"/ NCL Record Counter
"+(i+1)+" ======")
printVarSummary(CMORPH)
a->COMB_MW = cpc_combined_MW
a->CMORPH = CMORPH
end do
end
================================
My screen readout when executing NCL:
================================
ENOBLE_at_ATHENA: /usr/people/enoble> ncl bin3.ncl
Copyright (C) 1995-2007 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 4.3.1
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) ====== Binary Record= 1/ NCL Record Counter 0 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 2/ NCL Record Counter 1 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 3/ NCL Record Counter 2 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 4/ NCL Record Counter 3 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 5/ NCL Record Counter 4 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 6/ NCL Record Counter 5 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 7/ NCL Record Counter 6 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 8/ NCL Record Counter 7 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 9/ NCL Record Counter 8 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 10/ NCL Record Counter 9 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 11/ NCL Record Counter 10 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 12/ NCL Record Counter 11 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 13/ NCL Record Counter 12 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 14/ NCL Record Counter 13 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
(0) ====== Binary Record= 15/ NCL Record Counter 14 ======
Variable: cpc_combined_MW
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : merged microwave precipitation
(0) ====== Binary Record= 16/ NCL Record Counter 15 ======
Variable: CMORPH
Type: float
Total Size: 2764800 bytes
691200 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [lat | 480] x [lon | 1440]
Coordinates:
lat: [59.875..-59.875]
lon: [0.125..359.875]
Number Of Attributes: 2
units : mm/hr
long_name : CMORPH
ENOBLE_at_ATHENA: /usr/people/enoble>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 16 2008 - 09:58:10 MDT
This archive was generated by hypermail 2.2.0 : Fri Jul 18 2008 - 08:51:52 MDT