Re: PDF calculation for a grid node

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 17 2013 - 06:29:36 MDT

I have not been keeping up with this thread.
I do not have the time to look at this in any detail.
Currently, I am too busy with my own job needs.

===
[1]
re:
> " 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"

I do not have 'script1.ncl' but a simple example.

xxx = pdfx(a, nbin, opt)

parameter 0 is "a"
parameter 1 is "nbin" <===== must be a scalar!!!
parameter 2 is "opt"

The function is prototyped as:

        function pdfx (
                x : numeric, <======= *any* dimensionality
                nbin [1] : integer, <======= scalar
                opt [1] : logical
        )

The error message is telling you that you have set "nbin"
improperly. you have input it as a 3d array.
Use 'printVarSummary(nbin)' prior to your call to pdfx
to see what you are passing in your original script.

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"

   a = random_normal (0,50, (/10,64,128/)) ; a is 3D
   nbin = 25 ; this is the default

   printVarSummary(a) ; 3D
   printVarSummary(nbin) ; scalar

   ap = pdfx(a, nbin, False)

   wks = gsn_open_wks ("x11","pdf_3d")
   res = True
   res@xyLineThicknessF = 2
   res@tiYAxisString = "PDF (%)"
   res@gsnCenterString = "Univariate PDF: Normal"
   plot = gsn_csm_xy (wks, ap@bin_center, ap, res)

+++++++++++++++++++++++++++++++++++++++++++++++
[2] You can look at the pdfx code via

%> less $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
++++++++++++++++++++++++++++++++++++++++++

[3]
The one code segment I saw had the following

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!!! not allowed

     end do
    end do
   end do
  end do

then ws1(kk,nt,nl,ml) is a *scalar* quantity ... one value!
The pdfx documentation states

nbin ...

Number of bins to use. Specifying 0 will result in 25 bins being used.
This must be greater than 2.

A scalar is one value. the code will returne a message and a missing value.

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?
>
>
> Thanks in advance
>
> 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
>
> delete(pdf_gridpt)
>
> end do
> end do
>
>
>
> On 7/16/13 6:36 AM, Ioannis Koletsis wrote:
>> Dear Mary and ncl-users,
>>
>> The point is to calculate the pdf for each grid point, in order to
>> estimate the wind power potential for an area....
>> When I run the script for one grid point (attached script1.ncl) the
>> pdf calculation (as well as windpop calculation) was successfully done....
>> The pdf calculation is depends on the bins number as well as on the
>> maximum value of the wind speed distribution...
>> For this reason, the bins number isn't constant for each grid point
>> and may be varied because of the different wind speed distribution...
>> It should be marked also, that the pdfx function seems to be 1-d...
>>
>> I have already done the following steps, without success:
>>
>> 1. Changing the ws variable dimensions (line 72 of script1.ncl), from
>> one grid point to the desired grid node (line 71 of script1.ncl), the
>> calculation has been completed and returned only one value instead of
>> nlat*nlon values....
>>
>> 2. The script mary2_mods.ncl, which has been modified by Mary using
>> reshape statement, didn't work and an error message has been appeared
>> " warning:Argument 0 of the current function or procedure was coerced
>> to the appropriate type and thus will not change if the function or
>> procedure modifies its value
>> fatal:(-2147483647) has no file extension, can't determine type of
>> file to open fatal:No valid instance of variable time found in file
>> list
>> fatal:Execute: Error occurred at or near line 26 in file mary2_mods.ncl"
>>
>> 3. I believed that at the first script a do loop might be the
>> solution, but it didn't work.....
>>
>> 4. The creation of a new variable wspdf with 4 dimensions including
>> nbins number as the 4th dimension, it didn't work as the number of the
>> bins isn't constant for each grid point....
>>
>> The source files are available at
>> http://ensemblesrt3.dmi.dk/data/A2/C4I/DM/C4IRCA3_A2_ECHAM5_DM_25km_19
>> 61-197
>> 0_wss.nc.gz
>> http://ensemblesrt3.dmi.dk/data/A2/C4I/DM/C4IRCA3_A2_ECHAM5_DM_25km_19
>> 71-198
>> 0_wss.nc.gz
>> http://ensemblesrt3.dmi.dk/data/A2/C4I/DM/C4IRCA3_A2_ECHAM5_DM_25km_19
>> 81-199
>> 0_wss.nc.gz
>> for free download.
>>
>> If anyone has any idea, please share it with me....
>>
>> Any help would be appreciated....
>>
>>
>>
>>
>> -----Original Message-----
>> From: Mary Haley [mailto:haley@ucar.edu]
>> Sent: Tuesday, July 16, 2013 1:01 AM
>> To: Ioannis Koletsis
>> Subject: Re: PDF calculation for a grid node
>>
>> Ioannis,
>>
>> I don't fully understand your script, but I got the reshape part to work.
>>
>> The reshape function is nothing more than this:
>>
>> function reshape(x,dims)
>> begin
>> return(onedtond(ndtooned(x),dims))
>> end
>>
>> I'm not sure exactly what you are trying to bin, but see the attached
>> script and see if this is what you want.
>>
>> Please, if you have further questions on this, post them back to
>> ncl-talk, as I'm not always available.
>>
>> Thanks,
>>
>> --Mary
>>
>> -----
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 2013.0.2904 / Virus Database: 3204/6492 - Release Date:
>> 07/15/13
>>
>>
>>
>> _______________________________________________
>> 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
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2013.0.2904 / Virus Database: 3204/6497 - Release Date: 07/16/13
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 17 06:29:43 2013

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