Calculating Percentiles in GrADS - please help
ml
Malgorzata.Liszewska at IMGW.PL
Thu Nov 13 09:32:17 EST 2008
Dear Arlindo,
I really appreciate your advices on computing percentiles using PyGrads, but
unfortunately I have problems. I tried to follow your approach: installed
PyGrads and other modules and make examples using your script but I cannot
export grads variable into Python:
>>> xx=ga.exp('djfslp/100')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/grads/ganum.py", line 80, in exp
return self.expr(expr)
File "/usr/lib/python2.5/site-packages/grads/ganum.py", line 380, in expr
d = self.eval(expr)
File "/usr/lib/python2.5/site-packages/grads/gacore.py", line 668, in eval
got = self.Reader.readline()
KeyboardInterrupt
I haven't used python earlier probably I am doing something wrong ??
I tried also the example with model.ctl file and ts - the result was similar.
any idea what's wrong?
I am working on Kubuntu 7.10.
Regards
Malgorzata Liszewska
On Tuesday 29 April 2008 06:14:40 Arlindo da Silva wrote:
> Stephen,
> This is the kind of problem that can be easily solved in PyGrADS. For
> example, the module Pylab implements several Matlab compatible functions,
> in particular prctile() which computes percentiles. The overall approach
> is:
>
> 1. Open the file
> 2. Export the GrADS variables, say the 3D time/lat/lon array, to Python
> 3. Transpose the array and use prctile() to compute the percentiles in each
> gridpoint, transposing the array back in the end
> 4. At this point you can chose to plot the results in Python (with
> Matplotlib) or in GrADS; see sample plots attached.
>
> I am including a self contained script which does the above calculation on
> the sample "slp_djf.nc" file that is included as test data (either in
> PyGrADS tarball or in the Win32 superpack). Your particular application
> will involve a bit more programming for selecting the timeseries for each
> day of the year, but I hope this script gives you the general idea.
>
> You can download PyGrADS (including the Win32 Superpck version) from
> sf.net:
>
>
> http://sourceforge.net/project/showfiles.php?group_id=161773&package_id=256
>758
>
> You can find some documentation on the Wiki:
>
> http://opengrads.org/wiki/index.php?title=Python_Interface_to_GrADS
>
> Let me know if you have questions,
>
> Good Luck,
>
> Arlindo
>
>
> On Mon, Apr 28, 2008 at 2:34 PM, Stephen R McMillan <
>
> smcmillan at planalytics.com> wrote:
> > I found nothing in the user archives to address this question: Is there a
> > relatively simple way to calculate various percentiles in GrADS? For
> > example:
> >
> > 1. Assume I have a 30-year dataset of daily mean temperature values for
> > an x-y domain, contained in a single 3D (x,y,t) gridded file
> > 2. Desired output: a single 3D gridded file containing 11 variables for
> > each gridpoint, per day of year (excluding Feb 29th): 0th pcntile, 10th
> > pcntile, 20th pcntile...100th pcntile. In other words, there would be 30
> > data values to analyze per grid location (each Jan 1st, each Jan
> > 2nd...each Dec 31st).
> >
> > My alternative would be to evaluate text output in Excel then re-convert
> > to gridded, but I'd prefer to keep in GrADS.
> >
> > I'm using GrADS v1.9.0-rc1 (win32) on Win XP Pro.
> >
> > Stephen Mc
> >
> > ***************************************************
> > The information contained in this e-mail message is intended only for the
> > use of the recipient(s) named above and may contain information that is
> > privileged, confidential, and/or proprietary. If you are not the intended
> > recipient, you may not review, copy or distribute this message. If you
> > have received this communication in error, please notify the sender
> > immediately by e-mail, and delete the original message.
> > ***************************************************
>
> --
> Arlindo da Silva
> dasilva at alum.mit.edu
More information about the gradsusr
mailing list