Lorenzo,<div><br></div><div> Thank you for sending me this patch. Could you try version 1.1.6 from here</div><div><br></div><div> <a href="http://opengrads.org/devel/pygrads/">http://opengrads.org/devel/pygrads/</a></div>
<div><br></div><div> I believe I have already fixed this bug, but have not released a new version on sourceforge yet.</div><div><br></div><div> Arlindo</div><div><br><br><div class="gmail_quote">On Wed, Apr 25, 2012 at 1:07 PM, Lorenzo Mentaschi <span dir="ltr"><<a href="mailto:lorenzo.mentaschi@unige.it" target="_blank">lorenzo.mentaschi@unige.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
I'm not sure this is the right place to post about pygrads.<br>
<br>
I found two problems using galab method sampleXY.<br>
<br>
The first problem is that invoking it, I get the error<br>
"NameError: global name 'lon' is not defined"<br>
<br>
The second problem is that parameter dh is completely ignored.<br>
<br>
I fixed the method in order to make it function for me, and I'm sending<br>
you the patched version.<br>
<br>
I hope it can be useful.<br>
<br>
Lorenzo<br>
<br>
#########################################<br>
#########################################<br>
#########################################<br>
def sampleXY ( self, expr, lons, lats, levs=None, dh=None, **kwopts):<br>
if len(lons.shape)!=1 or len(lats.shape)!=1:<br>
raise GrADSError, "lons, lats, time must be 1D arrays"<br>
<br>
<br>
# Retrieve dimension environment<br>
# ------------------------------<br>
######### I ADDED THE IF ###############<br>
if not dh:<br>
dh = self.query("dims", Quiet=True)<br>
###########################################<br>
<br>
# Loop over time, performing interpolation<br>
# ----------------------------------------<br>
g = GaGrid("sampleXY")<br>
g.time = []<br>
V = ma.masked_array(zeros((len(lons),dh.nt,<a href="http://dh.nz" target="_blank">dh.nz</a>)),dtype=float32)<br>
for t in dh.ti:<br>
n = t - dh.ti[0]<br>
self.cmd('set t %d'%t, Quiet=True)<br>
######### I ADDED dh=dh #############<br>
v, g.lev = self._interpXY ( expr, lons, lats,<br>
levs=levs, dh=dh,<br>
**kwopts)<br>
###########################################<br>
if len(v.shape)==1:<br>
V[:,n,0] = v<br>
else:<br>
V[:,n,:] = v<br>
qh =self.query("time",Quiet=True)<br>
g.time.append(qh.t1)<br>
<br>
g.dims = ['obs',]<br>
if dh.nt>1:<br>
g.dims.append('time')<br>
if <a href="http://dh.nz" target="_blank">dh.nz</a>>1:<br>
g.dims.append('lev')<br>
<br>
######### I GUESS THIS IS THE RIGHT ASSIGNMENT #############<br>
g.lon, g.lat = (lons, lats) # "obs" coordinates<br>
###################################################<br>
g.tyme = array([gat2dt(t) for t in g.time])<br>
<br>
# Restore dimension environment<br>
# -----------------------------<br>
self.setdim(dh)<br>
V = V.squeeze()<br>
return GaField(V.data, name=expr, grid=g,<br>
mask=V.mask, dtype=float32)<br>
# ..................................................................<br>
<br>
#########################################<br>
#########################################<br>
#########################################<br>
<br>
------------------------------------------------------------------------------<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<br>
will include endpoint security, mobile security and the latest in malware<br>
threats. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>
_______________________________________________<br>
Opengrads-devel mailing list<br>
<a href="mailto:Opengrads-devel@lists.sourceforge.net">Opengrads-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/opengrads-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/opengrads-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><font face="'comic sans ms', sans-serif" size="6" color="#006600"><span style="font-family:Helvetica;font-size:12px"></span><span></span><span></span>Arlindo da Silva</font><br>
<font size="4"><i><a href="mailto:dasilva@alum.mit.edu" target="_blank">dasilva@alum.mit.edu</a></i></font><br>
</div>