Re: Problems using month_to_annual() function

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 10 2011 - 16:00:45 MST

Madeline,

Yes, what Dennis said, the purpose of that print statement was to
count the number of missing values in your input array. He just
copied the wrong number; you have 1727760 missing values, which is a
little more than half of all your data. Is this what you expected?

The output from printVarSummary indicates that your input array
fsr_mod1_all is formed correctly. All the dimensions are named, so
that is not the problem. Also, "time" is the leftmost dimension, as
it should be for the month_to_annual function.

I am concerned about the large number of missing values. I checked
inside contributed.ncl for the source code for month_to_annual.
There is an if block that is triggered only when there are missing
values, and the primary error is happening that point, line 8537.
The function source code looks correct; I do not see the problem
beyond there.

If you want to try debugging this yourself, then do the following.
Otherwise, I must defer to the NCL support team for further assistance.

1. Make a copy of contributed.ncl in your local directory.

2. At the top of your program, temporarily change the load
statement to use the local copy of contributed.ncl.

3. Edit the local copy as follows:

3a. Move line 8537 down two more lines, to just above the "end if"
statement:
       xAnnual(nyr,:,:) = ... <------ Move down two lines

3b. Insert these four lines just above the new position of
"xAnnual(nyr,:,:) =":
       printVarSummary (xAnnual(nyr,:,:))
       printVarSummary (nGood)
       print (nmos)
       printVarSummary (nGood.ge.nmos)

4. Run the program and show us the new debugging output. This
should start with "month_to_annual: some points have missing data"
and end with the same error that you got before.

I notice that month_to_annual was subject to a bug fix in NCL
version 5.2.1. I do not know whether this is related to your
problem, but it might be.

--Dave

On 3/10/2011 2:10 PM, Dennis Shea wrote:
> > What does the (0) Number missing statement refer to?
>
> When NCL prints a line, it provides the subscript(s) of the
> values being printed. NCL subscripts begin at 0.
>
> nmsg = num(ismissing(x))
>
> nmsg is a scalar or it can be viewed as
> an array of length 1.
>
> ---
> When you do
>
> print ("Number missing = " + num(ismissing(temp_mod1_all)))
>
> This creates a temporary variable of length 1 and type string. Think
>
> s = "Number missing = " + num(ismissing(temp_mod1_all))
> print(s)
> ---
>
> You have 3,144,960 missing values.
>
>
>
> On 3/10/11 12:14 PM, Madeleine Patterson wrote:
>> Hi Dave,
>>
>> Thanks for your email a couple days ago. I did as you suggested and the
>> output from the print statements was
>>
>> Variable: fsr_mod1_all
>> Type: float
>> Total Size: 12579840 bytes
>> 3144960 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [time | 240] x [lat | 91] x [lon | 144]
>> Coordinates:
>> time: [10981..18250]
>> lat: [-90..90]
>> lon: [ 0..357.5]
>> Number Of Attributes: 5
>> long_name : reflected solar radiation
>> units : watt/m^2
>> cell_method : time: mean
>> _FillValue : 1e+36
>> missing_value : 1e+36
>> (0) Number missing =1727760
>>
>>
>> What does the (0) Number missing statement refer to?
>>
>> The NCL version I'm using is 5.2.0
>>
>> Thanks
>> Madeleine
>>
>>
>> On Tue, Mar 8, 2011 at 4:51 PM, Dave Allured<dave.allured@noaa.gov
>> <mailto:dave.allured@noaa.gov>> wrote:
>>
>> It would help to have a little more information. Please insert the
>> following three commands just above the month_to_annual statement,
>> and show the full output from them:
>>
>> printVarSummary (temp_mod1_all)
>> print ("Number missing = " + num(ismissing(temp_mod1_all)))
>> exit
>>
>> Also, what version of NCL are you using?
>>
>> --Dave
>>
>>
>> On 3/8/2011 8:11 AM, Madeleine Patterson wrote:
>>
>> Hi,
>>
>> I am trying to calculate annual means from monthly data and have
>> struck an error message using the month_to_annual(var,1) function:
>>
>> temp_mod1_annmean = month_to_annual(temp_mod1_all,1)
>>
>> The error message I get is:
>>
>>
>> fatal:mask: dimension sizes of parameter 0 and parameter 1 do
>> not match
>> fatal:Execute: Error occurred at or near line 8537 in file
>> $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>>
>> fatal:Execute: Error occurred at or near line 73 in file
>> Annual_mean_diffmap.ncl
>>
>> I did look at past instances of this error message in archived
>> NCL-talk messages, and but have figured out how to name the
>> dimensions of my variable other than by doing:
>>
>>
>> temp_mod1_all_dims = dimsizes(temp_mod1_all)
>> print(temp_mod1_all_dims)
>>
>> ntim = temp_mod1_all_dims(0)
>> nlat = temp_mod1_all_dims(1)
>> nlon = temp_mod1_all_dims(2)
>>
>>
>> But this is not quite what you'd written to another person who
>> encountered this problem:
>>
>> "From: Mary Haley<haley_at_nyahnyahspammersnyahnyah>
>> Date: Wed May 26 2010 - 10:29:24 MDT
>> ....
>> One requirement is that your dimensions are named. Is this the case?
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> var_raw = random_uniform(0.,2.,(/360,146,196/))
>> var_raw!0 = "time"
>> var_raw!1 = "lat"
>> var_raw!2 = "lon"
>>
>> var = month_to_annual(var_raw, 1) "
>>
>> I'm not sure how to specify my particular variable in the above
>> form.... and hence not sure how to solve this particular error
>> message.
>>
>> Thanks for any help you can give me - this problem has stumped me
>> for a while.
>>
>> Best,
>> Madeleine
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 10 16:00:59 2011

This archive was generated by hypermail 2.1.8 : Thu Mar 10 2011 - 21:44:37 MST