Ocean data handling

In this notebook we show how ocean data is handled.

[1]:
# NBVAL_IGNORE_OUTPUT
import traceback
from os.path import join

import numpy as np
import iris
import iris.quickplot as qplt
import matplotlib
import matplotlib.pyplot as plt
from scmdata import ScmRun

from netcdf_scm.iris_cube_wrappers import CMIP6OutputCube
[2]:
# make all logs apper
import logging

root_logger = logging.getLogger()
root_logger.addHandler(logging.StreamHandler())
[3]:
plt.style.use("bmh")
%matplotlib inline
[4]:
DATA_PATH_TEST = join("..", "..", "..", "tests", "test-data")
DATA_PATH_TEST_CMIP6_OUTPUT_ROOT = join(DATA_PATH_TEST, "cmip6output")

Test data

For this notebook’s test data we use CMIP6Output from NCAR’s CESM2 model.

2D data

Some ocean data is 2D. Here we use surface downward heat flux in sea water.

Firstly we use data which has been regridded by the modelling group.

[5]:
hfds_file = join(
    DATA_PATH_TEST,
    "cmip6output",
    "CMIP6",
    "CMIP",
    "NCAR",
    "CESM2",
    "historical",
    "r7i1p1f1",
    "Omon",
    "hfds",
    "gr",
    "v20190311",
    "hfds_Omon_CESM2_historical_r7i1p1f1_gr_195701-195703.nc",
)

We also examine how iris handles data which is provided on the native model grid.

[6]:
hfds_file_gn = hfds_file.replace("gr", "gn")

3D data

Some ocean data is 3D. netCDF-SCM currently supports crunching this to iris cubes but will not convert those cubes to SCM timeseries.

[7]:
thetao_file = join(
    DATA_PATH_TEST,
    "cmip6output",
    "CMIP6",
    "CMIP",
    "NCAR",
    "CESM2",
    "historical",
    "r10i1p1f1",
    "Omon",
    "thetao",
    "gn",
    "v20190313",
    "thetao_Omon_CESM2_historical_r10i1p1f1_gn_195310-195312.nc",
)

2D data handling

[8]:
# NBVAL_IGNORE_OUTPUT
hfds_cube = CMIP6OutputCube()
hfds_cube.load_data_from_path(hfds_file)
[9]:
print(hfds_cube.cube)
surface_downward_heat_flux_in_sea_water / (W m-2) (time: 3; latitude: 180; longitude: 360)
     Dimension coordinates:
          time                                         x            -               -
          latitude                                     -            x               -
          longitude                                    -            -               x
     Cell Measures:
          cell_area                                    -            x               x
     Attributes:
          CDI: Climate Data Interface version 1.8.2 (http://mpimet.mpg.de/cdi)
          CDO: Climate Data Operators version 1.8.2 (http://mpimet.mpg.de/cdo)
          Conventions: CF-1.7 CMIP-6.2
          activity_id: CMIP
          branch_method: standard
          branch_time_in_child: 674885.0
          branch_time_in_parent: 273750.0
          case_id: 21
          cesm_casename: b.e21.BHIST.f09_g17.CMIP6-historical.007
          comment: Model data on the 1x1 grid includes values in all cells for which ocean...
          contact: cesm_cmip6@ucar.edu
          creation_date: 2019-01-19T03:13:13Z
          data_specs_version: 01.00.29
          description: This is the net flux of heat entering the liquid water column through its...
          experiment: all-forcing simulation of the recent past
          experiment_id: historical
          external_variables: areacello
          frequency: mon
          further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r7i1p1...
          grid: ocean data regridded from native gx1v7 displaced pole grid (384x320 latxlon)...
          grid_label: gr
          history: Sun Aug 18 22:57:15 2019: cdo -selmonth,1/3 tmp.nc hfds_Omon_CESM2_historical_r7i1p1f1_gr_195701-195703.nc
Sun...
          id: hfds
          institution: National Center for Atmospheric Research
          institution_id: NCAR
          license: CMIP6 model data produced by <The National Center for Atmospheric Research>...
          mipTable: Omon
          mip_era: CMIP6
          model_doi_url: https://doi.org/10.5065/D67H1H0V
          nominal_resolution: 1x1 degree
          out_name: hfds
          parent_activity_id: CMIP
          parent_experiment_id: piControl
          parent_mip_era: CMIP6
          parent_source_id: CESM2
          parent_time_units: days since 0001-01-01 00:00:00
          parent_variant_label: r1i1p1f1
          product: model-output
          prov: Omon ((isd.003))
          realm: ocean
          source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192...
          source_id: CESM2
          source_type: AOGCM BGC
          sub_experiment: none
          sub_experiment_id: none
          table_id: Omon
          time: time
          time_label: time-mean
          time_title: Temporal mean
          title: Downward Heat Flux at Sea Water Surface
          tracking_id: hdl:21.14100/18907361-7d4d-4a3c-b355-4450472ab458
          type: real
          variable_id: hfds
          variant_info: CMIP6 20th century experiments (1850-2014) with CAM6, interactive land...
          variant_label: r7i1p1f1
     Cell methods:
          mean where sea: area
          mean: time
[10]:
# NBVAL_IGNORE_OUTPUT
time_mean = hfds_cube.cube.collapsed("time", iris.analysis.MEAN)
qplt.pcolormesh(time_mean)
plt.gca().coastlines();
../_images/usage_ocean-data_16_0.png

Iris’ handling of data on the native model grid is mostly workable, but not yet perfect.

[11]:
# NBVAL_IGNORE_OUTPUT
hfds_cube_gn = CMIP6OutputCube()
hfds_cube_gn.load_data_from_path(hfds_file_gn)

print(hfds_cube_gn.cube)
WARNING: missing_value not used since it
cannot be safely cast to variable data type
surface_downward_heat_flux_in_sea_water / (W m-2) (time: 3; -- : 384; -- : 320)
     Dimension coordinates:
          time                                         x       -         -
     Auxiliary coordinates:
          latitude                                     -       x         x
          longitude                                    -       x         x
     Cell Measures:
          cell_area                                    -       x         x
     Attributes:
          CDI: Climate Data Interface version 1.8.2 (http://mpimet.mpg.de/cdi)
          CDO: Climate Data Operators version 1.8.2 (http://mpimet.mpg.de/cdo)
          Conventions: CF-1.7 CMIP-6.2
          activity_id: CMIP
          branch_method: standard
          branch_time_in_child: 674885.0
          branch_time_in_parent: 273750.0
          case_id: 21
          cesm_casename: b.e21.BHIST.f09_g17.CMIP6-historical.007
          comment: This is the net flux of heat entering the liquid water column through its...
          contact: cesm_cmip6@ucar.edu
          creation_date: 2019-01-19T03:13:13Z
          data_specs_version: 01.00.29
          description: This is the net flux of heat entering the liquid water column through its...
          experiment: all-forcing simulation of the recent past
          experiment_id: historical
          external_variables: areacello
          frequency: mon
          further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r7i1p1...
          grid: native gx1v7 displaced pole grid (384x320 latxlon)
          grid_label: gn
          history: Sun Aug 18 22:57:16 2019: cdo -selmonth,1/3 tmp.nc hfds_Omon_CESM2_historical_r7i1p1f1_gn_195701-195703.nc
Sun...
          id: hfds
          institution: National Center for Atmospheric Research
          institution_id: NCAR
          license: CMIP6 model data produced by <The National Center for Atmospheric Research>...
          mipTable: Omon
          mip_era: CMIP6
          model_doi_url: https://doi.org/10.5065/D67H1H0V
          nominal_resolution: 100 km
          out_name: hfds
          parent_activity_id: CMIP
          parent_experiment_id: piControl
          parent_mip_era: CMIP6
          parent_source_id: CESM2
          parent_time_units: days since 0001-01-01 00:00:00
          parent_variant_label: r1i1p1f1
          product: model-output
          prov: Omon ((isd.003))
          realm: ocean
          source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192...
          source_id: CESM2
          source_type: AOGCM BGC
          sub_experiment: none
          sub_experiment_id: none
          table_id: Omon
          time: time
          time_label: time-mean
          time_title: Temporal mean
          title: Downward Heat Flux at Sea Water Surface
          tracking_id: hdl:21.14100/f92a6db7-e8ea-44f1-882c-076226f8a62b
          type: real
          variable_id: hfds
          variant_info: CMIP6 20th century experiments (1850-2014) with CAM6, interactive land...
          variant_label: r7i1p1f1
     Cell methods:
          mean where sea: area
          mean: time
[12]:
# NBVAL_IGNORE_OUTPUT
time_mean = hfds_cube_gn.cube.collapsed("time", iris.analysis.MEAN)
qplt.pcolormesh(time_mean)
plt.gca().coastlines();
../_images/usage_ocean-data_19_0.png

Getting SCM Timeseries

We cut down to SCM timeseries in the standard way.

[13]:
# NBVAL_IGNORE_OUTPUT
regions_to_get = [
    "World",
    "World|Northern Hemisphere",
    "World|Northern Hemisphere|Ocean",
    "World|Ocean",
    "World|Southern Hemisphere",
    "World|Southern Hemisphere|Ocean",
    "World|North Atlantic Ocean",
    "World|El Nino N3.4",
]
hfds_ts = hfds_cube.get_scm_timeseries(regions=regions_to_get)
hfds_gn_ts = hfds_cube_gn.get_scm_timeseries(regions=regions_to_get)

ax = plt.figure(figsize=(16, 9)).add_subplot(111)
ax = hfds_ts.lineplot(hue="region", style="variable", dashes=[(3, 3)], ax=ax)
hfds_gn_ts.lineplot(
    hue="region", style="variable", dashes=[(10, 30)], ax=ax, legend=False
);
Not calculating land fractions as all required cubes are not available
Performing lazy conversion to datetime for calendar: 365_day. This may cause subtle errors in operations that depend on the length of time between dates
WARNING: missing_value not used since it
cannot be safely cast to variable data type
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
Not calculating land fractions as all required cubes are not available
Performing lazy conversion to datetime for calendar: 365_day. This may cause subtle errors in operations that depend on the length of time between dates
../_images/usage_ocean-data_22_1.png

Comparing the results of collapsing the native grid and the regridded data reveals a small difference (approx 1%), in particular in the small El Nino N3.4 region.

[14]:
ax1, ax2 = plt.figure(figsize=(16, 9)).subplots(nrows=1, ncols=2)

ScmRun(hfds_ts.timeseries() - hfds_gn_ts.timeseries()).line_plot(
    hue="region", ax=ax1, legend=False
)
ax1.set_title("Absolute difference")

ScmRun(
    (
        (hfds_ts.timeseries() - hfds_gn_ts.timeseries()) / hfds_ts.timeseries()
    ).abs()
    * 100
).line_plot(hue="region", ax=ax2)
ax2.set_title("Percentage difference");
../_images/usage_ocean-data_24_0.png

3D Data Handling

[15]:
# NBVAL_IGNORE_OUTPUT
thetao_cube = CMIP6OutputCube()
thetao_cube.load_data_from_path(thetao_file)
WARNING: missing_value not used since it
cannot be safely cast to variable data type
Missing CF-netCDF measure variable 'volcello', referenced by netCDF variable 'thetao'
[16]:
print(thetao_cube.cube)
sea_water_potential_temperature / (degC) (time: 3; generic: 60; -- : 384; -- : 320)
     Dimension coordinates:
          time                                x           -        -         -
          generic                             -           x        -         -
     Auxiliary coordinates:
          latitude                            -           -        x         x
          longitude                           -           -        x         x
     Cell Measures:
          cell_area                           -           -        x         x
     Attributes:
          CDI: Climate Data Interface version 1.8.2 (http://mpimet.mpg.de/cdi)
          CDO: Climate Data Operators version 1.8.2 (http://mpimet.mpg.de/cdo)
          Conventions: CF-1.7 CMIP-6.2
          activity_id: CMIP
          branch_method: standard
          branch_time_in_child: 674885.0
          branch_time_in_parent: 306600.0
          case_id: 24
          cesm_casename: b.e21.BHIST.f09_g17.CMIP6-historical.010
          comment: Diagnostic should be contributed even for models using conservative temperature...
          contact: cesm_cmip6@ucar.edu
          creation_date: 2019-03-12T02:46:53Z
          data_specs_version: 01.00.29
          description: Diagnostic should be contributed even for models using conservative temperature...
          experiment: Simulation of recent past (1850 to 2014). Impose changing conditions (consistent...
          experiment_id: historical
          external_variables: areacello volcello
          frequency: mon
          further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.historical.none.r10i1p...
          grid: native gx1v7 displaced pole grid (384x320 latxlon)
          grid_label: gn
          history: Mon Aug 19 17:25:30 2019: cdo -selmonth,10/12 tmp.nc thetao_Omon_CESM2_historical_r10i1p1f1_gn_195310-195312.nc
Mon...
          id: thetao
          institution: National Center for Atmospheric Research
          institution_id: NCAR
          license: CMIP6 model data produced by <The National Center for Atmospheric Research>...
          mipTable: Omon
          mip_era: CMIP6
          model_doi_url: https://doi.org/10.5065/D67H1H0V
          nominal_resolution: 100 km
          out_name: thetao
          parent_activity_id: CMIP
          parent_experiment_id: piControl
          parent_mip_era: CMIP6
          parent_source_id: CESM2
          parent_time_units: days since 0001-01-01 00:00:00
          parent_variant_label: r1i1p1f1
          product: model-output
          prov: Omon ((isd.003))
          realm: ocean
          source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192...
          source_id: CESM2
          source_type: AOGCM BGC
          sub_experiment: none
          sub_experiment_id: none
          table_id: Omon
          time: time
          time_label: time-mean
          time_title: Temporal mean
          title: Sea Water Potential Temperature
          tracking_id: hdl:21.14100/19f9ed4d-daf4-4a51-8563-fe32b9c2a0cd
          type: real
          variable_id: thetao
          variant_info: CMIP6 20th century experiments (1850-2014) with CAM6, interactive land...
          variant_label: r10i1p1f1
     Cell methods:
          mean where sea: area
          mean: time

If we take a time mean of a cube with 3D spatial data, we end up with a 3D cube, which cannot be plotted on a 2D plot.

[17]:
# NBVAL_IGNORE_OUTPUT
time_mean = thetao_cube.cube.collapsed("time", iris.analysis.MEAN)
try:
    qplt.pcolormesh(time_mean,)
except ValueError as e:
    traceback.print_exc(limit=0, chain=False)
Traceback (most recent call last):
ValueError: Cube must be 2-dimensional. Got 3 dimensions.

If we take e.g. a depth mean too, then we can plot (although as this data is on the model’s native grid iris doesn’t do a great job of plotting it).

[18]:
# NBVAL_IGNORE_OUTPUT
# the depth co-ordinate is labelled as 'generic' for some reason
time_depth_mean = time_mean.collapsed("generic", iris.analysis.MEAN)
qplt.pcolormesh(time_depth_mean);
../_images/usage_ocean-data_31_0.png

We can crunch into SCM timeseries cubes.

[19]:
# NBVAL_IGNORE_OUTPUT
thetao_ts_cubes = thetao_cube.get_scm_timeseries_cubes(regions=regions_to_get)
WARNING: missing_value not used since it
cannot be safely cast to variable data type
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
Not calculating land fractions as all required cubes are not available

These cubes now have dimensions of time and depth (labelled as ‘generic’ here). Hence we can plot them.

[20]:
plt.figure(figsize=(12, 15))

plt.subplot(311)
qplt.pcolormesh(thetao_ts_cubes["World"].cube,)
plt.title("World")

plt.subplot(323)
qplt.pcolormesh(thetao_ts_cubes["World|Northern Hemisphere|Ocean"].cube,)
plt.title("World|Northern Hemisphere|Ocean")

plt.subplot(324)
qplt.pcolormesh(thetao_ts_cubes["World|Southern Hemisphere|Ocean"].cube,)
plt.title("World|Southern Hemisphere|Ocean")

plt.subplot(325)
qplt.pcolormesh(thetao_ts_cubes["World|El Nino N3.4"].cube,)
plt.title("World|El Nino N3.4")

plt.subplot(326)
qplt.pcolormesh(thetao_ts_cubes["World|North Atlantic Ocean"].cube,)
plt.title("World|North Atlantic Ocean")

plt.tight_layout()
../_images/usage_ocean-data_35_0.png

We have also not yet decided on our convention for handling the depth information in ScmRun’s, hence attempting to retrieve SCM timeseries will result in an error.

[21]:
# NBVAL_IGNORE_OUTPUT
try:
    thetao_cube.get_scm_timeseries(regions=regions_to_get)
except NotImplementedError as e:
    traceback.print_exc(limit=0, chain=False)
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/fileformats/netcdf.py:395: UserWarning: WARNING: missing_value not used since it
cannot be safely cast to variable data type
  var = variable[keys]
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'latitude'.
  warnings.warn(msg.format(self.name()))
/Users/znicholls/miniconda3/envs/netcdf-scm/lib/python3.8/site-packages/iris/coords.py:1406: UserWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'longitude'.
  warnings.warn(msg.format(self.name()))
Not calculating land fractions as all required cubes are not available
Traceback (most recent call last):
NotImplementedError: Cannot yet get SCM timeseries for data with dimensions other than time, latitude and longitude