[ncl-talk] error using calculate_monthly_values

mberdahl at envsci.rutgers.edu mberdahl at envsci.rutgers.edu
Thu Sep 10 21:23:33 MDT 2015


Hi all,

I'm trying to use a contributed function that calculates monthly means
from daily data (calculate_monthly_values).  However, I run into this
error:

fatal:(time) is not a named dimension in variable (x).
fatal:Execute: Error occurred at or near line 11726 in file
$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

I know that the variable must have named dimensions readable by
cd_calendar.  When I dump the file it seems that the dimensions of SF are
TIME,X,Y.  The units of the TIME variable does seem to be of units "Hours
Since..." which should work with cd_calendar.  Do I have to assign time,
lat and lon to SF as attributes explicity to get this to work?  If so, how
do I do this?  I've copied the ncdump for my file, and the ncl script
below.

Any thoughts are appreciated!
Mira

*******************************************************
ncdump -h test.nc | less
netcdf test {
dimensions:
        Y18_127 = 110 ;
        X10_69 = 60 ;
        TIME = UNLIMITED ; // (3652 currently)
variables:
        float LAT(Y18_127, X10_69) ;
                LAT:units = "degrees" ;
                LAT:long_name = "Latitude" ;
                LAT:history = "From ICE.j57.1958.01.01-15" ;
        float LON(Y18_127, X10_69) ;
                LON:units = "degrees" ;
                LON:long_name = "Longitude" ;
                LON:history = "From ICE.j57.1958.01.01-15" ;
        float SF(TIME, Y18_127, X10_69) ;
                SF:missing_value = -1.e+34f ;
                SF:_FillValue = -1.e+34f ;
                SF:long_name = "Snowfall" ;
                SF:units = "mmWE/day" ;
                SF:history = "From ICE.j57.1958.01.01-15" ;
        double TIME(TIME) ;
                TIME:units = "HOURS since 1901-01-15 00:00:00" ;
                TIME:long_name = "time" ;
                TIME:time_origin = "15-JAN-1901 00:00:00" ;
                TIME:axis = "T" ;
        double X10_69(X10_69) ;
                X10_69:units = "km" ;
                X10_69:long_name = "x" ;
                X10_69:point_spacing = "even" ;
                X10_69:axis = "X" ;
        double Y18_127(Y18_127) ;
                Y18_127:units = "km" ;
                Y18_127:long_name = "y" ;
                Y18_127:point_spacing = "even" ;
                Y18_127:axis = "Y" ;
******************************************************



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/csm/shea_util.ncl"

;************************************************
begin
;************************************************
; read in netCDF file s
;************************************************
c = addfile("test.nc","r")
;************************************************
; read in qonal [u] and meridional [v] winds (July)
;************************************************
sf = c->SF(:,:,:)
printVarSummary(sf)

sfMonthAvg = calculate_monthly_values(sf,"avg",0,False)


;  lat goes from 58.9982 to 84.1492, looks like it is polar stereographic
;  lon goes from -89.9739 to 7.01787
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("ps","test") 		; open a ps file
gsn_define_colormap(wks,"temp1")


;---- set common resources for all plots
res 			= True
res at cnLinesOn 		= False
res at cnFillOn		= True  ; color plot desired
res at cnLineLabelsOn	= False ; turn off contour lines



;****************************************************
; choose a subregion
;****************************************************

res at mpMaxLatF = 84
res at mpMinLatF = 59
res at mpMaxLonF = 373
res at mpMinLonF = 270

map = gsn_csm_contour_map(wks,sf_total,res)


end





More information about the ncl-talk mailing list