Hello, I hope someone can give me a tip to get this working.

I have some data that I have manipulated in to the following format:

x_dim is a 1D array of sample times (in minutes)

array([ 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300,

330, 360, 390, 420, 450, 480, 510, 540, 570, 600, 630,

660, 690, 720, 750, 780, 810, 840, 870, 900, 930, 960,

990, 1020, 1050, 1080, 1110, 1140, 1170, 1200, 1230, 1260, 1290,

1320, 1350, 1380, 1410])

x_dim is often, but not always regularly spaced and will in practice be much much larger.

y_dim is a 1D array of sample depths

array([ 0., -10., -20., -30., -40., -50., -60., -70., -80.,

-90., -100., -110., -120., -130., -140., -150., -160., -170.,

-180., -190., -200., -210.])

y_dim is always regularly spaced and won’t get much bigger than this

z_dim is a dictionary of 2D arrays of data values where:

z_dim[‘salin’][1,:] is an array of salinity data taken at the second sampling (time 30) with one value for every depth in y_dim:

z_dim[‘salin’][1,:] =

array([ NaN, 10.14000034, 10.14333344, 10.1766669 ,

10.22333336, 10.26000023, NaN, 10.21000004,

10.21000004, 10.19999981, 10.15999985, 10.12800007,

10.10333347, 10.09666697, 10.07000001, 10.06333351,

10.05000019, 10.03666655, 10.01666705, 9.99333318,

9.97999954, NaN])

I put in the numpy.nan where I have no data.

I tried to run this through griddata to make sure the times are regular with something like this:

import matplotlib, numpy

xi = arange(0,x_dim[-1] + 30,30)

zi = mlab.griddata(x_dim,y_dim,z_dim[‘salin’],xi,y_dim)

# but it complains that “inputs x,y,z must all be 1D arrays of the same length”

# I can’t find any example of griddata that use arrays rather than functions for z.

# in my exampley_dim IS regular, so I should be able to skip on to plotting.

x_grid,y_grid = meshgrid(x_dim,y_dim)

z_grid = transpose(z_dim[‘salin’])

# x_grid, y_grid, and z_grid now have the same shape

# Now mask out all the NaNs

ma.fix_invalid(z_grid)

# I have previously figured out level_min and level_max for this dataset.

contour_levels = list(linspace(floor(level_min),ceil(level_max),10))

figure = pyplot.figure()

contour_plot = pyplot.contourf(x_grid,y_grid,z_grid,contour_levels)

cbar = pyplot.colorbar()

pyplot.show()

#and that doesn’t look right at all.

Any tips are greatly appreciated.