<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"></div><div style="font-family: 'times new roman', 'new york', times, serif;"><div style="font-family: 'times new roman', 'new york', times, serif;"><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2" face="Arial"><span>Thanks a lot  Benjamin, </span></font></div><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2" face="Arial"><span><span> it did the trick. I have another question, I have  ocean section along latitude 0 ( equator) which is sampled at depths.</span></span></font></div><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2"
 face="Arial"><span><span><br></span></span></font></div><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2" face="Arial"><span><span>size of the array is 12x14 but this is just the index of the array I need to make a plot which shows depth value as one axis and longitude values as another axis. Is there a quick way to rescale the data to lat depth section by adding a new axis?</span></span></font></div><div dir="ltr"><span style="font-family: Arial; font-size: 13px;">depth=[0,10,20,30,40,50,60,70,80,90,100,120]</span></div><div dir="ltr"><font size="2" face="Arial"><span><span>lon=[ 40,  45,  50,  55,  60,  65,  70,  75,  80,  85,  90,  95, 100, 105]<br></span></span></font></div><div dir="ltr"><font size="2" face="Arial"><span><span><div dir="ltr">In [20]: data.shape</div><div dir="ltr">Out[20]: (12, 14)</div><div dir="ltr">can you please
 advice me on what is the best way to re-scale the data to depth lat dimensions from the indices 1-12 and 1-14</div><div dir="ltr">With best regards,</div><div dir="ltr">Sudheer</div><div style="font-weight: bold; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><br></div></span></span></font></div><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2" face="Arial"><b><span style="font-weight:bold;"><br></span></b></font></div><div dir="ltr" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><font size="2" face="Arial">  <b><span style="font-weight:bold;">From:</span></b> Benjamin Root <ben.root@ou.edu><br> <b><span style="font-weight: bold;">To:</span></b> Discussion of Numerical Python <numpy-discussion@scipy.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, 4 March 2013 7:40 PM<br> <b><span
 style="font-weight: bold;">Subject:</span></b> Re: [Numpy-discussion] reshaping arrays<br> </font> </div> <br><div id="yiv1920243668" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><br><br><div class="yiv1920243668gmail_quote">On Sat, Mar 2, 2013 at 11:35 PM, Sudheer Joseph <span dir="ltr"><<a rel="nofollow" ymailto="mailto:sudheer.joseph@yahoo.com" target="_blank" href="mailto:sudheer.joseph@yahoo.com">sudheer.joseph@yahoo.com</a>></span> wrote:<br><blockquote class="yiv1920243668gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif;"><div style="font-size:12pt;">Hi Brad,</div><div style="font-size:12pt;">

                I am not getting the attribute reshape for the array, are you having a different version of numpy than mine?</div><div style="font-size:12pt;">

<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;"><div style="font-style:normal;font-size:16px;">

<font size="1">I have </font></div><div><font size="1">In [55]: np.__version__</font></div><div style="font-style:normal;font-size:16px;"><font size="1">Out[55]: '1.7.0'</font></div>

<div style="font-style:normal;font-size:12pt;">and detail of the shape</div><div style="font-style:normal;font-size:12pt;">

<br></div><div style="font-style:normal;font-size:12pt;">details of variable </div><div style="font-style:normal;font-size:12pt;">

<br></div><div><div style="font-style:normal;font-size:16px;"><font size="1">In [57]: ssh??</font></div><div style="font-style:normal;font-size:16px;">

<font size="1">Type:       NetCDFVariable</font></div><div style="font-style:normal;font-size:16px;"><font size="1">String Form:<NetCDFVariable object at 0x492d3d8></font></div>

<div style="font-style:normal;font-size:16px;"><font size="1">Namespace:  Interactive</font></div><div style="font-style:normal;font-size:16px;">

<font size="1">Length:     75</font></div><div><font size="1">Docstring:  NetCDF Variable</font></div><div style="font-style:normal;font-size:16px;"><font size="1"><br>

</font></div><div style="font-style:normal;font-size:16px;"><font size="1">In [58]: ssh.shape</font></div><div style="font-style:normal;font-size:16px;">

<font size="1">Out[58]: (75, 140, 180)</font></div><div style="font-style:normal;font-size:12pt;"><br></div><div><div><font size="1">ssh??</font></div><div>

<font size="1">Type:       NetCDFVariable</font></div><div><font size="1">String Form:<NetCDFVariable object
 at 0x492d3d8></font></div><div><font size="1">Namespace:  Interactive</font></div><div><font size="1">Length:     75</font></div><div><font size="1">Docstring:  NetCDF Variable</font></div><div><font size="1"><br></font></div>

<div><font size="1">In [66]: ssh.shape</font></div><div><font size="1">Out[66]: (75, 140, 180)</font></div><div><font size="1"><br></font></div><div><font size="1">In [67]: ssh.reshape(75,140*180)</font></div><div><font size="1">---------------------------------------------------------------------------</font></div>

<div><font size="1">AttributeError                            Traceback (most recent call last)</font></div><div><font size="1">/home/sjo/RAMA_20120807/adcp/<ipython-input-67-1a21dae1d18d> in <module>()</font></div>

<div><font size="1">----> 1 ssh.reshape(75,140*180)</font></div><div><font size="1"><br></font></div><div><font size="1">AttributeError: reshape</font></div><div style="font-style:normal;font-size:12pt;">

<br><br></div></div></div></div></div></div></blockquote><div><br>Ah, you have a NetCDF variable, which in many ways purposefully looks like a NumPy array, but isn't.  Just keep in mind that a NetCDF variable is merely a way to have the data available without actually reading it in until you need it.  If you do:<br>

<br>ssh_data = ssh[:]<br><br>Then the NetCDF variable will read all the data in the file and return it as a numpy array that can be manipulated as you wish.<br><br>I hope that helps!<br>Ben Root<br><br></div></div>
</div><br><span style="font-size: 12pt;">_______________________________________________</span><br><span style="font-size: 12pt;">NumPy-Discussion mailing list</span><br><a ymailto="mailto:NumPy-Discussion@scipy.org" href="mailto:NumPy-Discussion@scipy.org" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">NumPy-Discussion@scipy.org</a><br><a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br><br><br> </div> </div>  </div></body></html>