for c, v in enumerate(vars): if v is not 'indices': if defs.has_key(v): desc = defs[v] else: desc = 'No data available from BODC on this variable' # I know I shouldn't be using eval, but I see no way of # creating a dict from a list of variable names without # doing something unpythonic. So unpythonic it is. eval("nc['variables'].update({'" + v + "':{'data':out[:, :, c], \ 'dimensions':['time', 'level'], \ 'attributes':{'long_name':'" + desc + "'}}})") ncwrite.ncdfWrite(nc, ncout, Quiet=False) if drawFig: import matplotlib.pyplot as plt # Create an appropriately sized array of depth values. This is because # for pcolormesh, the y array has to be n + 1 values long. What I'm # doing here is using the first and last depth values and adding those # to the midpoint of the depths inbetween. z = -data[k]['ADEPZZ01'] Z = np.hstack((z[0], (np.diff(z) / 2) + z[:-1], z[-1])) plt.figure() plt.subplot(2, 1, 1) plt.pcolormesh(