[ncl-talk] error using calculate_monthly_values function

Dennis Shea shea at ucar.edu
Wed Oct 21 12:04:32 MDT 2015


https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml

===
Download:   http://www.cgd.ucar.edu/~shea/contributed.ncl_631

Then: load "./contributed.ncl_631"

See if that works. It has an updated 'calculate_monthly_values'

If it doesn't works ...

ftp ftp.cgd.ucar.edu
anonymous
email
cd incoming
put test.nc
quit

On Wed, Oct 21, 2015 at 11:31 AM,  <mberdahl at envsci.rutgers.edu> wrote:
>
> Hi Mary,
>
> Thanks for the suggestion.  I tried to comment those lines out, and
> receive 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
>
> fatal:Execute: Error occurred at or near line 55 in file plotSF.ncl
>
>
> With those lines, I don't receive the error, which is why they are there
> in the first place.  I think maybe it just has to do with case
> sensitivity, and the function is asking for time, and I have TIME.
>
> Anyhow, by request, here is the variable summary for the variable I am
> passing to calculate_monthly_values:
>
> Variable: sf
> Type: float
> Total Size: 96412800 bytes
>             24103200 values
> Number of Dimensions: 3
> Dimensions and sizes:   [TIME | 3652] x [Y18_127 | 110] x [X10_69 | 60]
> Coordinates:
>             TIME: [499320.03125..586944]
>             Y18_127: [-1200.000091097248..1525.000107494753]
>             X10_69: [-775.0000471284118..700.0000440380242]
> Number Of Attributes: 7
>   lat2d :       <ARRAY of 6600 elements>
>   lon2d :       <ARRAY of 6600 elements>
>   missing_value :       -1e+34
>   _FillValue :  -1e+34
>   long_name :   Snowfall
>   units :       mmWE/day
>   history :     From ICE.j57.1958.01.01-15
>
>
> Thanks very much for any advice,
> Mira
>
>
>
>
>
>
> It looks like you are trying to change the "time" coordinate array, but I
> don't think this is necessary.
>
> When you read SF off the file, it appears to have a correct "time" array
> called "TIME" with a units of "HOURS since 1901-01-15 00:00:00".
>
> Therefore, the following code is unnecessary and should be commented out
> (and removed when/if you verify you don't need it):
>
> time = c->TIME
>
> ; do some finangling with the time variable/attribute
> time!0  = "time"
> time&time = time
> sf!0 = "time"
> sf&time = time
>
> Please post back to ncl-talk if this doesn't fix the problem.  It will be
> helpful if you can include the output from a "printVarSummary" of whatever
> variable you are passing to calculate_monthly_values.
>
> --Mary
>
>
> On Mon, Oct 19, 2015 at 6:04 PM, <mberdahl at envsci.rutgers.edu> wrote:
>
>> 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:
>>
>> warning:ut_calendar: Invalid specification string. Missing values will be
>> returned.
>> fatal:New: The dimension size list contains missing values, can't
>> determine size
>> fatal:Execute: Error occurred at or near line 11754 in file
>> $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>>
>> fatal:Execute: Error occurred at or near line 55 in file plotSF.ncl
>>
>>
>> I'm not sure of what this error means.
>>
>> Below I've copied the ncdump output of the input file test.nc and my
>> script.
>> Thanks in advance for any help or advice!
>> 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
>> ;************************************************
>> ;a = addfile("ICE.ALL.SF.nc","r") ; snow fall only
>> b = addfile("ICE.1984.01-12.f78.nc","r") ; this will give me the lat/lon
>> info
>>
>> c = addfile("test.nc","r")
>> ;************************************************
>> ; read in qonal [u] and meridional [v] winds (July)
>> ;************************************************
>>
>> ;sf = a->SF(:,:,:) ; snow fall
>>
>> sf = c->SF(:,:,:)
>> time = c->TIME
>>
>> ; do some finangling with the time variable/attribute
>> time!0  = "time"
>> time&time = time
>> sf!0 = "time"
>> sf&time = time
>>
>>
>> lat2d = b->LAT
>> lon2d = b->LON
>>
>> sf at lon2d = lon2d
>> sf at lat2d = lat2d
>>
>> printVarSummary(sf)
>>
>> ;  calculate the total snow fall for the entire period.
>> sf_total = dim_sum_n(sf,0)
>>
>> ; calculate the monthly averages
>> sfMonthAvg = calculate_monthly_values(sf,"avg",0,False)
>>
>> printVarSummary(sfMonthAvg)
>>
>> ;; calculate the monthly mean snowfall from daily data
>> ;yrStrt = 1958;
>> ;yrLast = 2012;
>> ;nyrs = yrLast -yrStrt +1
>> ;nmos = 12
>> ;;nlat = 110
>> ;;nlon = 60
>>
>>
>> ;printVarSummary(nlat)
>> ;yyyymmdd = sf&TIME
>> ;yyyymm  = yyyymmdd/100
>> ;yyyy = yyyymm/100
>> ;mm = yyyymm-yyyy*100;
>>
>> ;sf_avg = new((/nyrs,nmos,nlat,nlon/),"float")
>> ;do yr = yrStrt,yrLast
>> ;        nyr = yr - yrStrt
>> ;       do mo = 1,nmos
>> ;               i = ind(yyyy.eq.yr .and. mo.eq.mm)
>> ;               sf_avg(nyr,mo-1,:,:) = dim_avg_n(sf(i,:,:),0)
>> ;               delete(i)
>> ;       end do
>> ;end do
>>
>>
>>
>> sf_total at lon2d = lon2d
>> sf_total at lat2d = lat2d
>> sf_avg at lon2d = lon2d
>> sf_avg at lat2d = lat2d
>>
>>
>> printVarSummary(sf_total)
>>
>> ;  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","MAR_SF_total")                 ; 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,sfMonthAvg,res)
>>
>>
>> end
>>
>>
>> *************************************************************
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151020/b1e8081d/attachment.html
> Previous message: [ncl-talk] error using calculate_monthly_values function
> Next message: [ncl-talk] Need Help
> Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> More information about the ncl-talk m
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk


More information about the ncl-talk mailing list