# Re: PDF calculation for a grid node

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 17 2013 - 08:32:47 MDT

If you note my code, the nbins is calculated at each iteration
(grid point and level). It is a scalar.

If 'nbins' changes, then each result (pdf_gridpt) changes size.
The delete(...) allows NCL to create a new 'pdf_gridpt' the
next iteration. (The default mode of NCL is to not allow
an existing array to be overwritten by another array of
a different size.) The following should work.

I have slightly changed the previous code for clarity.

do kl=0,klvl-1
do nl=0,nlat-1
do ml=0,mlon-1

data = ws(:,kl,nl,ml) ; data(:)

nbins = floattointeger(((max(data)-min(data))/ 0.2)+1)
or, if you want to force 0.0 as a lower limit (ie min(data)=0.0)
nbins = floattointeger((max(data))/ 0.2)+1)

pdf_gridpt = pdfx( data, nbins, opt )
printVarSummary(pdf_gridpt)

; do whatever (eg: plot or write to a file or ???)

delete([/pdf_gridpt, data/])
end do
end do
end do

===
I quickly looked at your pdf.ncl and I am confused.
I am assuming 'itime' is a one dimensional array of size>2

ws2 = ws(itime,:,jStrt:jLast,iStrt:iLast) ; 4D (ntim,nlev,nlat,mlon)
ws1 = 1.2697*ws2 ; 4D

max_ws1 = dim_max_n(ws1,0) ; 3D (nlev,nlat,mlon)
min_ws1 = 0. ; lower boundary

; Here 'nbins' is a 3D array: (nlev,nlat,mlon)

nbins = floattointeger(((max_ws1 - min_ws1) / 0.2)+1) ; 3D
min_ws1 = 0.

; In my opinion, the following is not correct

dimx = dimsizes(ws1) ; ws1 is 4D
nlev = dimx(0)
nlat = dimx(1)
mlon = dimx(2)

I think it should be

dimx = dimsizes(ws1)
ntim = dimx(0)
nlev = dimx(1)
nlat = dimx(2)
mlon = dimx(3)

The following (your code) does not make sense to me.
ws1(kk,nt,nl,ml) is a scalar.
pdfx requires an array of at least 2 elements.
Why are you doing this? ie looping over time (kk).
To me this not right.

do kk = 1, 10957
do nl = 0, nlat-1
do ml = 0, mlon-1
do nt = 0, nlev-1

wspdf=(pdfx(ws1(kk,nt,nl,ml),nbins,opt)) ; <<< scalar
end do
end do
end do
end do

*Further*, even if the ws1 argument were not a scalar, the 'nbins'
argument would have to be referenced as

wspdf=(pdfx(ws1(kk,nt,nl,ml),nbins(nt,nl,ml),opt))

the nbins(nt,nl,ml) is a scalar as required by the function.

=====

On 7/17/13 7:21 AM, Ioannis Koletsis wrote:
[SNIP]

> On 7/17/13 3:02 AM, Ioannis Koletsis wrote:
>> Dear Dennis,
>> I have already tried this, with the following error message
>>
>> " fatal:Number of dimensions in parameter (1) of (pdfx) is (3), (1)
>> dimensions were expected
>> fatal:Execute: Error occurred at or near line 103 in file script1.ncl"
>>
>> Have you got any idea what's going on?
>>
>>
>>
>> Ioannis
>>
>> -----Original Message-----
>> From: ncl-talk-bounces@ucar.edu [mailto:ncl-talk-bounces@ucar.edu] On
>> Behalf Of Dennis Shea
>> Sent: Wednesday, July 17, 2013 7:44 AM
>> To: Ioannis Koletsis
>> Cc: ncl-talk@ucar.edu
>> Subject: Re: PDF calculation for a grid node
>>
>> http://www.ncl.ucar.edu/Document/Functions/Contributed/pdfx.shtml
>>
>> If:
>> ws(time,lev,lat,lon)
>>
>> Then, at each grid point and level, the 'pdfx' over all times is:
>>
>> do kl=0,klvl-1
>> do nl = 0, nlat-1
>> do ml = 0, mlon-1
>>
>> nbins = ...
>> pdf_gridpt = pdfx( ws(:,kl,nl,ml),nbins,opt )
>> printVarSummary(pdf_gridpt)
>>
>> ; do whatever
>>
>> delete(pdf_gridpt)
>>
>> end do
>> end do
>> end do
>>
>> ===
>> For all levels and times
>>
>> do nl = 0, nlat-1
>> do ml = 0, mlon-1
>>
>> nbins = ...
>> pdf_gridpt = pdfx( ws(:,:,nl,ml),nbins,opt )
>> printVarSummary(pdf_gridpt)
>>
>> ; do whatever
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 17 08:32:59 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 19 2013 - 15:39:06 MDT