import intake
import hvplot.pandas
import hvplot.xarray
import cook_inlet_catalogs as cic
import holoviews as hv
CTD Profiles (Kachemak Kuletz 2005-2007)¶
CTD Profiles in Cook Inlet
cat = intake.open_catalog(cic.utils.cat_path("ctd_profiles_kachemack_kuletz_2005_2007"))
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
['1.0',
'1.1',
'10.0',
'10000.0',
'10001.0',
'10002.0',
'10003.0',
'10004.0',
'10005.0',
'10006.0',
'10007.0',
'10008.0',
'10009.0',
'10010.0',
'10011.0',
'10012.0',
'10013.0',
'10014.0',
'10015.0',
'10016.0',
'10017.0',
'101.0',
'103.0',
'104.0',
'105.0',
'107.0',
'109.0',
'11.0',
'111.0',
'12.1',
'12.2',
'12.3',
'12.4',
'12.5',
'2.0',
'2.02',
'2.03',
'2.2',
'2.3',
'202.0',
'203.0',
'204.0',
'205.0',
'206.0',
'207.0',
'209.0',
'211.0',
'3.0',
'3.01',
'3.02',
'3.1',
'3.2',
'302.0',
'304.0',
'305.0',
'306.0',
'309.0',
'311.0',
'4.0',
'4.1',
'5.0',
'6.0',
'7.0',
'8.0',
'9.0']
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
10.0
| date_time | Depth [m] | Cruise | Station | Type | Lon | Lat | Bot. Depth [m] | Temperature [C] | Salinity [psu] | Obs [v] | Conductivity | Turbidity | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2005-06-21 15:38:00 | 0.495 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 9.5138 | 31.1911 | 0.0089 | NaN | NaN |
| 1 | 2005-06-21 15:38:00 | 0.990 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 9.4587 | 31.3181 | 0.0099 | NaN | NaN |
| 2 | 2005-06-21 15:38:00 | 1.486 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 9.4529 | 31.3052 | 0.0086 | NaN | NaN |
| 3 | 2005-06-21 15:38:00 | 1.981 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 9.4385 | 31.3095 | 0.0092 | NaN | NaN |
| 4 | 2005-06-21 15:38:00 | 2.476 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 9.4238 | 31.3133 | 0.0099 | NaN | NaN |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 130 | 2005-06-21 15:38:00 | 68.341 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 7.0198 | 31.3576 | 0.0110 | NaN | NaN |
| 131 | 2005-06-21 15:38:00 | 68.836 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 7.0195 | 31.3534 | 0.0116 | NaN | NaN |
| 132 | 2005-06-21 15:38:00 | 69.331 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 7.0189 | 31.3564 | 0.0116 | NaN | NaN |
| 133 | 2005-06-21 15:38:00 | 69.826 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 7.0237 | 31.3549 | 0.0108 | NaN | NaN |
| 134 | 2005-06-21 15:38:00 | 70.321 | 1 | 10.0 | c | -151.67 | 59.555 | 71 | 7.0240 | 31.3580 | 0.0116 | NaN | NaN |
135 rows × 13 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