Thanks a lot Benjamin,

it did the trick. I have another question, I have ocean section along latitude 0 ( equator) which is sampled at depths.

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?

depth=[0,10,20,30,40,50,60,70,80,90,100,120]

lon=[ 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]

In [20]: data.shape

Out[20]: (12, 14)

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

With best regards,

Sudheer

On Sat, Mar 2, 2013 at 11:35 PM, Sudheer Joseph <sudheer.joseph@yahoo.com> wrote:

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:

ssh_data = ssh[:]

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.

I hope that helps!

Ben Root

Hi Brad,I am not getting the attribute reshape for the array, are you having a different version of numpy than mine?I haveIn [55]: np.__version__Out[55]: '1.7.0'and detail of the shapedetails of variableIn [57]: ssh??Type: NetCDFVariableString Form:<NetCDFVariable object at 0x492d3d8>Namespace: InteractiveLength: 75Docstring: NetCDF Variable

In [58]: ssh.shapeOut[58]: (75, 140, 180)ssh??Type: NetCDFVariableString Form:<NetCDFVariable object at 0x492d3d8>Namespace: InteractiveLength: 75Docstring: NetCDF VariableIn [66]: ssh.shapeOut[66]: (75, 140, 180)In [67]: ssh.reshape(75,140*180)---------------------------------------------------------------------------AttributeError Traceback (most recent call last)/home/sjo/RAMA_20120807/adcp/<ipython-input-67-1a21dae1d18d> in <module>()----> 1 ssh.reshape(75,140*180)AttributeError: reshape

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:

ssh_data = ssh[:]

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.

I hope that helps!

Ben Root

_______________________________________________

NumPy-Discussion mailing list

NumPy-Discussion@scipy.org

http://mail.scipy.org/mailman/listinfo/numpy-discussion