[ncl-talk] Unable to read level1 compressed netcdf-files

Heiko Klein Heiko.Klein at met.no
Fri Mar 20 11:53:06 MDT 2015


Hi,

for our type of data, it is most efficient to use netcdf level-1 
compression when writing files. ncl seems to have problems with those 
files and cannot read the variables:

   Copyright (C) 1995-2015 - All Rights Reserved
   University Corporation for Atmospheric Research
   NCAR Command Language Version 6.3.0
   The use of this software is governed by a License Agreement.
   See http://www.ncl.ucar.edu/ for more details.
fatal:["Execute.c":132]:variable (conc.instant_Cs137) is not in file 
(mean.nc)
fatal:["Execute.c":6316]:variable (conc.instant_Cs137) is not in file (f1)
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in 
file Cs137_dep_ps.ncl



Using the same data-file, but with level-3 compression, my scripts works 
without problems. I tried it with ncl 6.3.0 and 6.2.1 on linux (ubuntu 
trusty, using debian 7 opendap enabled precompiled binaries).

A working file with compression level 3 can be created by

nccopy -k 4 -d 3 mean.nc mean_3.nc

I've linked 1 file to this email:
* mean.nc (28.8 MB) hosted on Dropbox: https://db.tt/wCI02aQX


Best regards,

Heiko

-------------- next part --------------
;****************************************************
; native_2.ncl
;
; Concepts illustrated:
;   - Drawing filled contours over a mercator map
;   - Overlaying contours on a map without having lat,lon coordinates
;   - Drawing a map using the medium resolution map outlines
;   - Turning on map tickmark labels with degree symbols
;   - Selecting a different color map
;   - Turning off the addition of a longitude cyclic point
;   - Zooming in on a particular area on a mercator map
;   - Adding a color to an existing color map
;
;*****************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;*****************************************************
begin
 f1 = addfile("mean.nc","r")
; fsd= f1->$"137Cesium_concentration"$(100,1,:,:)
 ;fsd2 = f1->$"accum.wet.dep_Cs137"$
 fsd = f1->$"conc.instant_Cs137"$(0,:,:)

 lat  = f1->latitude
 lon  = f1->longitude

 nlat = dimsizes(f1->latitude)
 nlon = dimsizes(f1->longitude)

;**************************************
;   Create plot
;***************************************
 wks  = gsn_open_wks("ps", "animate")
 gsn_define_colormap(wks,"radar"); matlab_jet")         ; choose color map
;
; This will not be necessary in V6.1.0 and later. Named colors can
; be used without having to first add them to the color map.
;
; i = NhlNewColor(wks,0.7,0.7,0.7)                   ; add gray to colormap


 res                             = True             ; plot mods desired

 res at cnFillOn                    = True             ; turn on color 
 res at cnLinesOn                   = False            ; no contour lines

 res at cnLevelSelectionMode        = "ManualLevels"   ; set manual contour levels
 res at cnMinLevelValF              = 0                ; set min contour level
 res at cnMaxLevelValF              = 70               ; set max contour level
 res at cnLevelSpacingF             = 5                ; contour spacing


 res at gsnSpreadColors             = True             ; use full color map
 res at gsnSpreadColorEnd           = -8               ; don't use added gray
 res at lbOrientation               ="horizontal"        ; vertical label bar

 res at mpDataBaseVersion           = "HighRes";"Ncarg4_1"       ; use finer database
 res at pmTickMarkDisplayMode       = "Always"         ; turn on tickmarks
 
 res at gsnAddCyclic                = False            ; regional data, don't add pt

 res at mpOutlineOn           = True 
 res at mpOutlineBoundarySets = (/"National"/)
 res at mpFillAreaSpecifiers        = (/"Land","Water"/)
 res at mpSpecifiedFillColors       = (/"beige", "lightblue"/)
 res at mpProjection                = "Stereographic"       ; projection
 res at mpGridLatSpacingF           = 5
 res at mpGridLonSpacingF           = 5
 res at mpGridAndLimbOn             = True
 res at mpLimitMode                 = "Corners"        ; method to zoom
 res at mpLeftCornerLatF            = 29
 res at mpLeftCornerLonF            = 131.8
 res at mpRightCornerLatF           = 45
 res at mpRightCornerLonF           = 151.8
  res at mpRelativeCenterLon         = True                 ; set a center lon
  res at mpCenterLonF                = 140        ; center lon
  res at mpRelativeCenterLat         = True                        ; set a center lat
  res at mpCenterLatF                = 90.                  ; center lat

; res at mpLeftCornerLatF            = min(lat)
; res at mpLeftCornerLonF            = min(lon)
; res at mpRightCornerLatF           = max(lat)       
; res at mpRightCornerLonF           = max(lon)

; res at tfDoNDCOverlay              = True             ; do not transform data
 res at cnLevelSelectionMode  = "ExplicitLevels"   ; set explicit contour levels
; res at cnLevels              = (/ 0.001,0.003,0.01000,0.03,0.10000,0.30000,1,3,10,30,100,300,1000/)
  res at cnLevels              = (/0.001,0.01,0.1,1,10,100,1000/)
; res at cnLevels              = (/0.01,0.03,0.1,0.3,1,3,10,30/)
; res at cnFillColors         = (/2,3,4,5,6,7,8,9,10,11,12,13,14,15/)
 res at cnFillColors          = (/4,3,2,6,7,8,9,10,11/)
 res at tiMainString                =""
; data = fsd(0,:,:) + fsd2(0,:,:)
; data = fsd(0,:,:,:)
; data at lon2d = lon
; data at lat2d = lat

;
 ; Convert to UTC time.
 ;
   utc_date = cd_calendar(f1->time, 0)
 ;
 ; Store return information into more meaningful variables.
 ;
   year   = tointeger(utc_date(:,0))    ; Convert to integer for
   month  = tointeger(utc_date(:,1))    ; use sprinti 
   day    = tointeger(utc_date(:,2))
   hour   = tointeger(utc_date(:,3))
   minute = tointeger(utc_date(:,4))
   second = utc_date(:,5)
 ;
 ; Write out strings in the format "hhZ dd mmm yyyy".
 ;
  month_abbr = (/"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep", \
                    "Oct","Nov","Dec"/)
  date_str = sprinti("%0.2i ", day) + \
             month_abbr(month) + " "  + sprinti("%0.4i  ", year) + \
             sprinti("%0.2iZ", hour)


  ntimes = dimsizes(f1->time(:))
  print(ntimes)
  do i=0,ntimes-1
   print(i)
   print(sprinti("%04d", (/i/)))
   wks  = gsn_open_wks("png", "animate" + sprinti("%04d", (/ i /)))
   gsn_define_colormap(wks,"radar")         ; choose color map

   fsd= f1->$"conc.instant_Cs137"$(i,:,:)
   fsd at units = "Bq/m3"
   fsd at long_name = "137Cs inst conc     " + date_str(i)
   fsd = where(fsd.lt.0.001, fsd at _FillValue, fsd)
   fsd at lon2d = lon
   fsd at lat2d = lat
   plot = gsn_csm_contour_map (wks,fsd,res)    ; create plot
  end do

end 



More information about the ncl-talk mailing list