Exercise 1:

1. Using the file in iris.sample_data_path('atlantic_profiles.nc') load the data and print the cube list. Store these cubes in a variable called cubes.


In [1]:
import iris

fname = iris.sample_data_path('atlantic_profiles.nc')
cubes = iris.load(fname)


/Users/dawson/miniconda3/envs/pfcs/lib/python3.5/site-packages/iris/fileformats/cf.py:1140: IrisDeprecation: NetCDF default loading behaviour currently does not expose variables which define reference surfaces for dimensionless vertical coordinates as independent Cubes. This behaviour is deprecated in favour of automatic promotion to Cubes. To switch to the new behaviour, set iris.FUTURE.netcdf_promote to True.
  warn_deprecated(msg)

2. Print a sorted list of unique names for the cubes.


In [2]:
print(sorted([cube.name() for cube in cubes]))


['sea_water_potential_temperature', 'sea_water_practical_salinity']

3. Extract the "sea_water_potential_temperature" cube. Print the minimum, maximum, mean and standard deviation of the cube's data.


In [3]:
cube = cubes.extract('sea_water_potential_temperature')[0]
print(cube)
print('minimum value:', cube.data.min())
print('maximum value:', cube.data.max())
print('standard deviation:', cube.data.std())


sea_water_potential_temperature / (K) (depth: 40; latitude: 6; longitude: 8)
     Dimension coordinates:
          depth                             x             -             -
          latitude                          -             x             -
          longitude                         -             -             x
     Scalar coordinates:
          time: 1984-12-01 00:00:00
     Attributes:
          Conventions: CF-1.5
minimum value: 274.351
maximum value: 300.561
standard deviation: 8.1868473464

4. Print the attributes of the cube.


In [4]:
print(cube.attributes)


{'Conventions': 'CF-1.5'}

5. Print the names of all coordinates on the cube. (Hint: Remember the cube.coords method)


In [5]:
for coord in cube.coords():
    print(coord.name())


depth
latitude
longitude
time

6. Get hold of the "latitude" coordinate on the cube. Identify whether the cube has bounds. Print the minimum and maximum latitude points in this cube.


In [6]:
latitude = cube.coord('latitude')
print(latitude.has_bounds())
print('minimum latitude:', latitude.points.min())
print('maximum latitude:', latitude.points.max())


False
minimum latitude: -9.8338
maximum latitude: -1.50052