This is a url from NATO CMRE "grid" format, where glider data are stored as profiles. These follow the GROOM convention, and in contrast the the IOOS Glide DAC 2.0 format, instead of one combined profile for the down and up paths, down and up are split into separate profiles.
In addition to the "grid" files, there are also "raw" and "processed" glider netcdf files:
http://comt.sura.org/thredds/catalog/comt_2_full/testing/glider_cmre/catalog.html
import iris
url = 'http://comt.sura.org/thredds/dodsC/comt_2_full/testing/glider_cmre/GL-20140621-elettra-MEDREP14depl005-grid-R.nc'
# adding coordinates attribute so that Iris can find the coordinates
url = 'http://comt.sura.org/thredds/dodsC/comt_2_full/testing/glider_cmre/foo2.ncml'
cubes = iris.load_raw(url)
print(cubes)
0: sea_water_potential_temperature / (Celsius) (-- : 36; -- : 170) 1: sea_water_temperature / (Celsius) (-- : 36; -- : 170) 2: sea_water_salinity / (1e-3) (-- : 36; -- : 170) 3: sound velocity / (m s-1) (-- : 36; -- : 170) 4: sea_water_potential_density / (unknown) (-- : 36; -- : 170) 5: distance flown since mission start / (km) (-- : 36) 6: Profile ID / (unknown) (-- : 36) 7: sea_water_potential_temperature / (Celsius) (-- : 36; -- : 170) 8: sound velocity / (m s-1) (-- : 36; -- : 170) 9: sea_water_electrical_conductivity / (S m-1) (-- : 36; -- : 170) 10: sea_water_electrical_conductivity / (S m-1) (-- : 36; -- : 170) 11: sea_water_potential_density / (unknown) (-- : 36; -- : 170) 12: water pressure / (bar) (-- : 36; -- : 170) 13: profile direction / (no_unit) (-- : 64) 14: water pressure / (bar) (-- : 36; -- : 170) 15: sea_water_temperature / (Celsius) (-- : 36; -- : 170) 16: sea_water_salinity / (1e-3) (-- : 36; -- : 170) 17: profile direction / (no_unit) (-- : 64) 18: distance flown since mission start / (km) (-- : 36)
cube = cubes.extract('sea_water_salinity')[0] #<- it always returns a list!
print(cube)
sea_water_salinity / (1e-3) (-- : 36; -- : 170) Auxiliary coordinates: latitude x - longitude x - time x - depth - x Attributes: Conventions: CF-1.6 DODS.dimName: ctdProfile DODS.strlen: 36 QC_indicator: 0.0 anomaly: none cdm_data_type: TrajectoryProfile contact: http://www.cmre.nato.int/ cruise: MEDREP14 data_classification: NATO Unclassified data_mode: R data_type: Glider profiles data date_update: 2014-06-23T16:45:18Z disclaimer: The processing software that generated this dataset is under development.... distribution_statement: NATO UNCLASSIFIED releasable to project partner only featureType: TrajectoryProfile format_version: 0.99 geospatial_lat_max: 39.9588181424 geospatial_lat_min: 39.8547639286 geospatial_lon_max: 7.44207619048 geospatial_lon_min: 7.30733570387 geospatial_vertical_max: 173.0 geospatial_vertical_min: 0.0 history: 2014-06-23 16:45:18: File created institution: STO-CMRE institution_reference: http://www.cmre.nato.int/ launch_date: 09-Jun-2014 10:00:00 launch_latitude: 39.9537735847 launch_longitude: 7.34393181681 launch_qc: 0.0 mission: depl005 netcdf_version: 3.6 pi_name: R. Onken platform_code: elettra platform_maker: Teledyne Webb Research Corporation platform_model: WEBB SLOCUM positioning_system: GPS processing: real time product_description: This file contains a glider data product derived from processed data. Trajectory... project_name: MEDREP14 provider: STO-CMRE (NATO Science & Technology Organization - Centre for Maritime... qcCodes: 0: no quality control performed on that value; 1: good value (GPS fix);... qc_manual: http://www.groom.org/data/quality_control_manual.pdf quality_index: 0.0 references: http://geos3.cmre.nato.int/REP14 sensors_ctd_manufacturer: Seabird sensors_ctd_model: Slocum Glider CTD sensors_ctd_name: pumpedCTD sensors_ctd_serial_number: 48.0 source: Glider observation summary: MEDREP14 glider data time_coverage_end: 2014-06-23T09:55:13Z time_coverage_start: 2014-06-21T09:28:56Z title: MEDREP14 trans_system: IRIDIUM type: Glider data file update_interval: hourly
import numpy as np
import numpy.ma as ma
import seawater as sw
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
%matplotlib inline
def plot_glider(cube, mask_topo=False, **kw):
"""Plot glider cube."""
cmap = kw.pop('cmap', plt.cm.rainbow)
lon = cube.coord(axis='X').points.squeeze()
lat = cube.coord(axis='Y').points.squeeze()
z = cube.coord(axis='Z').points.squeeze()
data = cube.data
data = ma.masked_invalid(data,copy=True)
z = ma.masked_invalid(z,copy=True)
t = cube.coord(axis='T')
t = t.units.num2date(t.points)
dist, pha = sw.dist(lat, lon, units='km')
dist = np.r_[0, np.cumsum(dist)]
dist, z = np.broadcast_arrays(dist[..., None], z)
fig, ax = plt.subplots(figsize=(9, 3.75))
cs = ax.pcolor(dist, z, data, cmap=cmap, snap=True, **kw)
plt.colorbar(cs)
if mask_topo:
h = z.max(axis=1)
x = dist[:, 0]
ax.plot(x, h, color='black', linewidth='0.5', zorder=3)
ax.fill_between(x, h, y2=h.max(), color='0.9', zorder=3)
ax.invert_yaxis()
ax.set_title('Glider track from {} to {}'.format(t[0], t[-1]))
fig.tight_layout()
return fig, ax, cs
c = cube[:,:]
fig, ax, cs = plot_glider(c, mask_topo=True)