import intake
import hvplot.pandas
import hvplot.xarray
import cook_inlet_catalogs as cic
import holoviews as hv
CTD Profiles (KB small mesh 2006)¶
CTD Profiles in Cook Inlet
cat = intake.open_catalog(cic.utils.cat_path("ctd_profiles_kb_small_mesh_2006"))
Plot all datasets in catalog¶
dd, ddlabels = cic.utils.combine_datasets_for_map(cat)
dd.hvplot(**cat.metadata["map"]) * ddlabels.hvplot(**cat.metadata["maplabels"])
List available datasets in the catalog¶
dataset_ids = list(cat)
dataset_ids
['1001',
'1002',
'1003',
'1004',
'1005',
'1006',
'1007',
'1008',
'1009',
'1010',
'1011',
'1012',
'1013',
'1014',
'1015',
'1017',
'1018',
'1019',
'1020',
'1021',
'1022',
'1023',
'1024',
'1025',
'1026',
'1027',
'1028']
Select one dataset to investigate¶
try:
dataset_id = dataset_ids[2]
except:
dataset_id = dataset_ids[0]
print(dataset_id)
dd = cat[dataset_id].read()
dd
1003
| Cruise | Station | Type | Lon | Lat | Bot. Depth [m] | Temperature [C] | fluor [v] | tran [v] | sbeoxv | PAR | Depth [m] | Salinity [psu] | oxconc | oxper [%] | datetime | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 5.9344 | 1.1227 | 3.2514 | 4.6071 | 166.0000 | 0.991 | 31.1245 | 14.09357 | 138.69495 | 2006-05-10 21:18:00 |
| 1 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 5.6764 | 2.5044 | 3.1537 | 4.6094 | 92.2000 | 1.981 | 31.1077 | 14.18977 | 138.76513 | 2006-05-10 21:18:00 |
| 2 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 5.5176 | 2.5830 | 2.9565 | 4.6179 | 54.5000 | 2.972 | 31.1349 | 14.27151 | 139.05973 | 2006-05-10 21:18:00 |
| 3 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 5.4910 | 3.2210 | 2.9007 | 4.5718 | 32.0000 | 3.962 | 31.1641 | 14.11564 | 137.47962 | 2006-05-10 21:18:00 |
| 4 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 5.3430 | 3.5141 | 2.8276 | 4.4540 | 18.4000 | 4.953 | 31.2130 | 13.74198 | 133.40766 | 2006-05-10 21:18:00 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 60 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 4.6591 | 0.2871 | 3.4765 | 3.4431 | 0.0410 | 60.418 | 31.6686 | 10.35033 | 99.12239 | 2006-05-10 21:18:00 |
| 61 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 4.6592 | 0.2999 | 3.5080 | 3.4421 | 0.0413 | 61.409 | 31.6684 | 10.34787 | 99.09878 | 2006-05-10 21:18:00 |
| 62 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 4.6593 | 0.2797 | 3.4866 | 3.4397 | 0.0403 | 62.399 | 31.6685 | 10.34080 | 99.03145 | 2006-05-10 21:18:00 |
| 63 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 4.6594 | 0.2912 | 3.3880 | 3.4359 | 0.0395 | 63.389 | 31.6703 | 10.32812 | 98.91156 | 2006-05-10 21:18:00 |
| 64 | 2006 | 1003 | c | -151.265667 | 59.636 | 68.0 | 4.6596 | 0.2733 | 3.3182 | 3.4344 | 0.0408 | 64.379 | 31.6707 | 10.32397 | 98.87251 | 2006-05-10 21:18:00 |
65 rows × 16 columns
Plot one dataset¶
keys = list(cat[dataset_id].metadata["plots"].keys())
print(keys)
plots = []
for key in keys:
plot_kwargs = cat[dataset_id].metadata["plots"][key]
if "clim" in plot_kwargs and isinstance(plot_kwargs["clim"], list):
plot_kwargs["clim"] = tuple(plot_kwargs["clim"])
if "dynamic" in plot_kwargs:
plot_kwargs["dynamic"] = False
plots.append(cat[dataset_id].ToHvPlot(**plot_kwargs).read())
hv.Layout(plots).cols(1)
['data']
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[6], line 11
9 if "dynamic" in plot_kwargs:
10 plot_kwargs["dynamic"] = False
---> 11 plots.append(cat[dataset_id].ToHvPlot(**plot_kwargs).read())
12 hv.Layout(plots).cols(1)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/readers.py:121, in BaseReader.read(self, *args, **kwargs)
119 kw.update(kwargs)
120 args = kw.pop("args", ()) or args
--> 121 return self._read(*args, **kw)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/convert.py:629, in Pipeline._read(self, discover, **kwargs)
627 kw = kwargs if i == len(self.steps) else {}
628 if i:
--> 629 data = self._read_stage_n(i, data=data, **kw)
630 else:
631 data = self._read_stage_n(i, discover=discover, **kw)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/convert.py:615, in Pipeline._read_stage_n(self, stage, discover, **kwargs)
613 return func(metadata=self.metadata).discover(*arg, **kw2)
614 else:
--> 615 return func(metadata=self.metadata).read(*arg, **kw2)
616 elif isinstance(func, BaseReader):
617 if discover:
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/readers.py:121, in BaseReader.read(self, *args, **kwargs)
119 kw.update(kwargs)
120 args = kw.pop("args", ()) or args
--> 121 return self._read(*args, **kw)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/convert.py:62, in BaseConverter._read(self, data, *args, **kwargs)
60 if isinstance(data, BaseReader):
61 data = data.read()
---> 62 return self.run(data, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/intake/readers/convert.py:192, in ToHvPlot.run(self, data, explorer, **kw)
189 if explorer:
190 # this is actually a hvplot.ui:hvPlotExplorer and only allows tabular data
191 return hvplot.explorer(data, **kw)
--> 192 return hvplot.hvPlot(data, **kw)()
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/hvplot/plotting/core.py:95, in hvPlotBase.__call__(self, x, y, kind, **kwds)
92 plot = self._get_converter(x, y, kind, **kwds)(kind, x, y)
93 return pn.panel(plot, **panel_dict)
---> 95 return self._get_converter(x, y, kind, **kwds)(kind, x, y)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/hvplot/converter.py:2066, in HoloViewsConverter.__call__(self, kind, x, y)
2063 dataset = Dataset(data)
2064 dataset = redim_(dataset, **self._redim)
-> 2066 obj = method(x, y)
2067 obj._dataset = dataset
2069 if self.crs and self.project:
2070 # Apply projection before rasterizing
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/hvplot/converter.py:2601, in HoloViewsConverter.line(self, x, y, data)
2599 def line(self, x=None, y=None, data=None):
2600 self._error_if_unavailable('line')
-> 2601 return self.chart(Curve, x, y, data)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/hvplot/converter.py:2588, in HoloViewsConverter.chart(self, element, x, y, data)
2586 charts = []
2587 for c in y:
-> 2588 ydim = hv.Dimension(c, label=self.value_label)
2589 kdims, vdims = self._get_dimensions([x], [ydim])
2590 chart = element(data, kdims, vdims)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/latest/lib/python3.11/site-packages/holoviews/core/dimension.py:285, in Dimension.__init__(self, spec, **params)
283 raise ValueError('Dimension name cannot be empty')
284 if not all_params['label']:
--> 285 raise ValueError('Dimension label cannot be empty')
287 values = params.get('values', [])
288 if isinstance(values, str) and values == 'initial':
ValueError: Dimension label cannot be empty