[Thread Prev][Thread Next][Index]

Re: [ferret_users] pyferret stats



Hi Michael,

You are correct; some of the stats PyEFs were not updated for 6D.  Actually, the functions would  work (at least with 4D arrays, but usually also 6D arrays) if I had not left in those shape checks (for debugging).  I have already fixed these issues for the next release, but because of some other changes I made, the Python code I currently have won't work with the current release.

However, since it is Python code, if you are comfortable editing the script, you can just delete the offending shape test when they show up.  In the $FER_DIR/lib/python2.6/site-packages/pyferret/stats are all the stats *.py functions.  So you would edit stats_probplotvals.py and change the lines that look like:

    sample = inputs[0].reshape(-1)
    expshape = ( len(sample), 3, 1, 1 )
    if result.shape != expshape:
        raise ValueError("Unexpected shape of results array: expected %s; found %s" % \
                         (str(expshape), str(result.shape)))
    badmask = ( numpy.fabs(sample - inpbdfs[0]) < 1.0E-5 )

to:

    sample = inputs[0].reshape(-1)
    badmask = ( numpy.fabs(sample - inpbdfs[0]) < 1.0E-5 )

(Make sure there are exactly four space before each line.)  Then restart PyFerret.  Python will detect that the python source (.py) file is newer than the compiled (.pyc) or optimized (.pyo) byte-code, and create and updated .pyc file.  (You can delete the .pyc and .pyo files to make sure.)

I have also attached a 6D version of stat_probplotvals.py that should work with the current release.

-- Karl


On Thu, Sep 20, 2012 at 3:04 PM, michael hughes <michael.hughes@xxxxxxxxxxxxxxx> wrote:
Dear Ferreters
I'm having problems with stats functions using the pyferret module. After opening a fresh pyferret session, I follow the example on the "New Ferret functionality" page and I get an error when running the second part as follows:

use coads_climatology
let template = sst[X=155W:115W,Y=25N:55N,T=15-MAR]
let testvals = stats_laplace_rvs(template, 12.5, 3.0) + stats_norm_rvs(template, 0.0, 1.0)
let ppvals = stats_probplotvals(testvals, "laplace", {0.0,1.0})
plot /vs /graticule=dash ppvals[j=1], ppvals[j=2]

Bailing out of external function "STATS_PROBPLOTVALS":
Error when calling ferret_compute in pyferret.stats.stats_probplotvals: Unexpected shape of results array: expected (336, 3, 1, 1); found (336, 3, 1, 1, 1, 1)
 **ERROR: error in external function

I'm assuming that when ferret exports the grid to python the array is incorrectly specified. I believe this is because the "E" and "F" dimensions are including in my grids which isn't expected by the external function. Is this a bug or is there something wrong at my end? Is there a way to remove the empty E/F dims? Or am I barking up the wrong tree?

-- 
Michael Hughes
Faculty of Environmental Science
Griffith University
Queensland, Australia




--
Karl M. Smith, Ph.D.
JISAO Univ. Wash. and TMAP/PMEL NOAA
"The contents of this message are mine personally and do
not necessarily reflect any position of the Government
or the National Oceanic and Atmospheric Administration."

Attachment: stats_probplotvals.py
Description: Binary data


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement