Thank you sir: thank you....very much for ur time and consideration..................<br><br><div class="gmail_quote">On Fri, Apr 29, 2011 at 9:11 PM, Christopher Barker <span dir="ltr"><<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 4/29/11 12:31 AM, pratik wrote:<br>
> On Friday 29 April 2011 12:56 PM, dileep kunjaai wrote:<br>
>> Dear sir,<br>
>> I am trying to make an array of varies from -60 to 90 with difference<br>
>> 0.25. I tried the following command ...<br>
<br>
>> >>import numpy as N<br>
>> lat=N.array(xrange(-6000, 9000, 25), dtype=float)<br>
>> print lat/100<br>
<br>
</div>xrange() (or range(), or np.arange()) is almost never the right solution<br>
for floating point ranges, due to the intricacies of floating point<br>
precision.<br>
<div class="im"><br>
> lat =numpy.mgrid[-60:90:.25]<br>
<br>
</div>or np.linspace:<br>
<br>
np.linspace(-60,90,((60.+90.)*4. + 1))<br>
<br>
((60.+90.)*4. + 1) is the number of points you want -- the +1 because<br>
you want both end points.<br>
<br>
mgrid is usually used for 2-d (or higher) grids, though it looks like it<br>
makes sense for this use, too, though note that it doesn't give you both<br>
endpoints in this case. From the docs:<br>
<br>
"""If the step length is not a<br>
     complex number, then the stop is not inclusive.<br>
"""<br>
<br>
and an example:<br>
<br>
In [15]: np.mgrid[-1:3:.25]<br>
Out[15]:<br>
array([-1.  , -0.75, -0.5 , -0.25,  0.  ,  0.25,  0.5 ,  0.75,  1.  ,<br>
         1.25,  1.5 ,  1.75,  2.  ,  2.25,  2.5 ,  2.75])<br>
<br>
I think this is too bad, actually, because we're back to range()-type<br>
tricks to get the end point:<br>
<br>
In [20]: np.mgrid[-1:3.25:.25]<br>
Out[20]:<br>
array([-1.  , -0.75, -0.5 , -0.25,  0.  ,  0.25,  0.5 ,  0.75,  1.  ,<br>
         1.25,  1.5 ,  1.75,  2.  ,  2.25,  2.5 ,  2.75,  3.  ])<br>
<br>
<br>
-Chris<br>
<br>
<br>
<br>
--<br>
Christopher Barker, Ph.D.<br>
Oceanographer<br>
<br>
Emergency Response Division<br>
NOAA/NOS/OR&R            (206) 526-6959   voice<br>
7600 Sand Point Way NE   (206) 526-6329   fax<br>
Seattle, WA  98115       (206) 526-6317   main reception<br>
<br>
<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a><br>
<div><div></div><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>DILEEPKUMAR. R<br>J R F, IIT DELHI<br><div style="display: inline;"></div><br>