0

I want to plot cross section along longitude using python Iris module which developed for oceanography and meteorology, I'm using their example: http://scitools.org.uk/iris/docs/v1.4/examples/graphics/cross_section.html I tried to change their code to my example but output of my code is empty.

data: http://data.nodc.noaa.gov/thredds/fileServer/woa/WOA09/NetCDFdata/temperature_annual_1deg.nc

import iris
import iris.plot as iplt
import iris.quickplot as qplt

# Enable a future option, to ensure that the netcdf load works the same way
# as in future Iris versions.
iris.FUTURE.netcdf_promote = True

# Load some test data.
fname = 'temperature_annual_1deg.nc'

theta = iris.load_cube(fname, 'sea_water_temperature')
# Extract a single depth vs longitude cross-section. N.B. This could
# easily be changed to extract a specific slice, or even to loop over *all*
# cross section slices.
cross_section = next(theta.slices(['longitude',
                                   'depth']))

qplt.contourf(cross_section, coords=['longitude', 'depth'],
              cmap='RdBu_r')
iplt.show()

1 Answers1

0

What you need to understand here is that your current cross_section is defined as first member of theta.slices iterator, meaning that it starts from one end of coordinates (which are empty in current case). So you need to iterate to the next members of the iterator until you get some data. If you add these lines to the code, maybe it helps to understand what is going on:

import numpy as np
cs = theta.slices(['longitude', 'depth'])
for i in cs:
    print(np.nanmax(i))

Which should print something like:

--
--
--
-0.8788
-0.9052
kakk11
  • 898
  • 8
  • 21