import intake
import hvplot.pandas
import hvplot.xarray
import cook_inlet_catalogs as cic
import holoviews as hv
CTD Profiles (Piatt Speckman)¶
CTD Profiles in Cook Inlet
cat = intake.open_catalog(cic.utils.cat_path("ctd_profiles_piatt_speckman_1999"))
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
['10159900',
'10159901',
'10159902',
'10159903',
'10159904',
'10159905',
'10159907',
'10159908',
'10159909',
'10159910',
'10159911',
'10159913',
'10159914',
'10159915',
'10159916',
'9051600',
'9051601',
'9051602',
'9051603',
'9051604',
'9051605',
'9051606',
'9051607',
'9051608',
'9051609',
'9051610',
'9051611',
'9051612',
'9051613',
'9051614',
'9051615',
'9051616',
'9060400',
'9060401',
'9060402',
'9060403',
'9060404',
'9060405',
'9060406',
'9060407',
'9060408',
'9060409',
'9060410',
'9060411',
'9060412',
'9060413',
'9060414',
'9060415',
'9060415b',
'9063000',
'9063001',
'9063002',
'9063003',
'9063004',
'9063005',
'9063006',
'9063007',
'9063008',
'9063009',
'9063010',
'9063011',
'9063012',
'9063013',
'9063014',
'9063015',
'9072201',
'9072202',
'9072203',
'9072204',
'9072205',
'9072206',
'9072207',
'9072208',
'9072209',
'9072210',
'9072211',
'9072212',
'9072213',
'9072214',
'90729a00',
'90729a01',
'90729a02',
'90729a03',
'90729a04',
'90729a05',
'90729a06',
'90729a07',
'90729a08',
'90729a09',
'90729a10',
'90729a11',
'90729a12',
'90729a13',
'90729a14',
'9082101',
'9082102',
'9082103',
'9082104',
'9082106',
'9082107',
'9082108',
'9082109',
'9082110',
'9082111',
'9082112',
'9082113',
'9082114',
'9082115',
'9082116',
'9082117',
'9082118',
'9082119',
'9082120',
'9082121',
'9082122',
'9082123']
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
10159902
| Cruise | Station | Type | Lon | Lat | Bot. Depth | Depth [m] | Temperature [C] | Salinity [psu] | Backscatter | CHL | datetime | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 1 | 11.6772 | 28.5379 | 8.18 | 2.0914 | 1999-08-26 18:12:00 |
| 1 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 2 | 11.5941 | 29.3658 | 9.33 | 1.8945 | 1999-08-26 18:12:00 |
| 2 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 3 | 11.6200 | 29.8945 | 8.80 | 2.2348 | 1999-08-26 18:12:00 |
| 3 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 4 | 11.5591 | 30.0668 | 8.79 | 2.6179 | 1999-08-26 18:12:00 |
| 4 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 5 | 11.4577 | 30.1965 | 8.79 | 9.0560 | 1999-08-26 18:12:00 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 114 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 115 | 9.1183 | 31.3877 | 11.23 | 1.3175 | 1999-08-26 18:12:00 |
| 115 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 116 | 9.1172 | 31.3879 | 11.46 | 1.4129 | 1999-08-26 18:12:00 |
| 116 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 117 | 9.1167 | 31.3878 | 11.48 | 1.4015 | 1999-08-26 18:12:00 |
| 117 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 118 | 9.1174 | 31.3902 | 11.57 | 1.4344 | 1999-08-26 18:12:00 |
| 118 | 1999 | 10159902 | c | -151.348667 | 59.5952 | 120 | 119 | 9.1212 | 31.3903 | 11.19 | 1.3375 | 1999-08-26 18:12:00 |
119 rows × 12 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