Calculating Percentiles in GrADS

Arlindo da Silva dasilva at ALUM.MIT.EDU
Tue Apr 29 00:14:40 EDT 2008


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=256758

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20080429/2c330263/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: py_prctiles_50.png
Type: image/png
Size: 226976 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20080429/2c330263/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ga_prctiles_50.png
Type: image/png
Size: 13948 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20080429/2c330263/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: percentile.py
Type: text/x-python-script
Size: 1690 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20080429/2c330263/attachment.bin 


More information about the gradsusr mailing list