On Sun, Mar 3, 2013 at 7:39 AM, Piotr Djaków <span dir="ltr"><<a href="mailto:pdjakow@gmail.com" target="_blank">pdjakow@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello!<div><br></div><div>I'm trying to create maps of percentiles from E-OBS dataset. I'm succefuly run percentiles.py script from pygrads examples, but i'm not very familiar with this.</div>
<div><br></div><div>What i want to do, is make percentiles for given day of a month (i.e. for Jan 1st). Input is E-OBS database in one big netCDF file with values from jan 1st 1950 to 2012. So i want to extract only values for jan 1st 1951,1952,1953,....,2009,2010 and calculate percentiles. </div>
<div><br></div><div>In example we have extracting timeseries:</div><div><br></div><div><div># Extract a timeseries</div><div># --------------------</div><div>ga('set t 1 41') </div>
<div>x = ga.exp('tx')</div><div>g = x.grid</div><div><br></div><div><br></div><div>But how to extract timeseries for January 1st? It's for example t=1, t=366...</div><div><br></div></div></div></blockquote><div>
<br></div><div>Because leap years can be tricky, I'd exract one day at a time and concatenate them</div><div><br></div><div>from numpy import c_</div><div>x = ga.exp('tx(time=1jan1950') # first day in sequence</div>
<div>nx, ny = x.shape</div><div>X = x.ravel() # must flatten array for c_ to work</div><div>for year in range(1951,2013):</div><div> x = ga.exp('tx(time=1jan%d)'%year)</div><div> X = c_[X,x.ravel()] # concatenate arrays</div>
<div>X = X.reshape((nx,ny,-1)) # restore lon/lat dimensions</div><div><br></div><div>This should give you an array with shape (nx,ny,nt) where the "t" dimension has data only for january 1st of each year. Repeat this for other days.</div>
<div><br></div><div> Arlindo</div><div><br></div><div><br></div></div>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu" target="_blank">dasilva@alum.mit.edu</a>