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
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
Cell In[5], line 7
4 dataset_id = dataset_ids[0]
5 print(dataset_id)
----> 7 dd = cat[dataset_id].read()
8 dd
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/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/stable/lib/python3.11/site-packages/intake/readers/convert.py:631, in Pipeline._read(self, discover, **kwargs)
629 data = self._read_stage_n(i, data=data, **kw)
630 else:
--> 631 data = self._read_stage_n(i, discover=discover, **kw)
632 return data
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/intake/readers/convert.py:620, in Pipeline._read_stage_n(self, stage, discover, **kwargs)
618 return func.discover(*arg, **kw2)
619 else:
--> 620 return func.read(*arg, **kw2)
621 else:
622 return func(*arg, **kw2)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/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/stable/lib/python3.11/site-packages/intake/readers/readers.py:176, in FileReader._read(self, data, **kw)
174 if self.storage_options and data.storage_options:
175 kw["storage_options"] = data.storage_options
--> 176 return self._func(**kw)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1026, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
1013 kwds_defaults = _refine_defaults_read(
1014 dialect,
1015 delimiter,
(...) 1022 dtype_backend=dtype_backend,
1023 )
1024 kwds.update(kwds_defaults)
-> 1026 return _read(filepath_or_buffer, kwds)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/parsers/readers.py:620, in _read(filepath_or_buffer, kwds)
617 _validate_names(kwds.get("names", None))
619 # Create the parser.
--> 620 parser = TextFileReader(filepath_or_buffer, **kwds)
622 if chunksize or iterator:
623 return parser
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1620, in TextFileReader.__init__(self, f, engine, **kwds)
1617 self.options["has_index_names"] = kwds["has_index_names"]
1619 self.handles: IOHandles | None = None
-> 1620 self._engine = self._make_engine(f, self.engine)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1880, in TextFileReader._make_engine(self, f, engine)
1878 if "b" not in mode:
1879 mode += "b"
-> 1880 self.handles = get_handle(
1881 f,
1882 mode,
1883 encoding=self.options.get("encoding", None),
1884 compression=self.options.get("compression", None),
1885 memory_map=self.options.get("memory_map", False),
1886 is_text=is_text,
1887 errors=self.options.get("encoding_errors", "strict"),
1888 storage_options=self.options.get("storage_options", None),
1889 )
1890 assert self.handles is not None
1891 f = self.handles.handle
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/common.py:728, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
725 codecs.lookup_error(errors)
727 # open URLs
--> 728 ioargs = _get_filepath_or_buffer(
729 path_or_buf,
730 encoding=encoding,
731 compression=compression,
732 mode=mode,
733 storage_options=storage_options,
734 )
736 handle = ioargs.filepath_or_buffer
737 handles: list[BaseBuffer]
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/pandas/io/common.py:430, in _get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode, storage_options)
427 pass
429 try:
--> 430 file_obj = fsspec.open(
431 filepath_or_buffer, mode=fsspec_mode, **(storage_options or {})
432 ).open()
433 # GH 34626 Reads from Public Buckets without Credentials needs anon=True
434 except tuple(err_types_to_retry_with_anon):
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/core.py:491, in open(urlpath, mode, compression, encoding, errors, protocol, newline, expand, **kwargs)
433 """Given a path or paths, return one ``OpenFile`` object.
434
435 Parameters
(...) 488 https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations
489 """
490 expand = DEFAULT_EXPAND if expand is None else expand
--> 491 out = open_files(
492 urlpath=[urlpath],
493 mode=mode,
494 compression=compression,
495 encoding=encoding,
496 errors=errors,
497 protocol=protocol,
498 newline=newline,
499 expand=expand,
500 **kwargs,
501 )
502 if not out:
503 raise FileNotFoundError(urlpath)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/core.py:295, in open_files(urlpath, mode, compression, encoding, errors, name_function, num, protocol, newline, auto_mkdir, expand, **kwargs)
216 def open_files(
217 urlpath,
218 mode="rb",
(...) 228 **kwargs,
229 ):
230 """Given a path or paths, return a list of ``OpenFile`` objects.
231
232 For writing, a str path must contain the "*" character, which will be filled
(...) 293 https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations
294 """
--> 295 fs, fs_token, paths = get_fs_token_paths(
296 urlpath,
297 mode,
298 num=num,
299 name_function=name_function,
300 storage_options=kwargs,
301 protocol=protocol,
302 expand=expand,
303 )
304 if fs.protocol == "file":
305 fs.auto_mkdir = auto_mkdir
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/core.py:667, in get_fs_token_paths(urlpath, mode, num, name_function, storage_options, protocol, expand)
665 inkwargs["fo"] = urls
666 paths, protocol, _ = chain[0]
--> 667 fs = filesystem(protocol, **inkwargs)
668 if isinstance(urlpath, (list, tuple, set)):
669 pchains = [
670 _un_chain(stringify_path(u), storage_options or {})[0] for u in urlpath
671 ]
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/registry.py:322, in filesystem(protocol, **storage_options)
315 warnings.warn(
316 "The 'arrow_hdfs' protocol has been deprecated and will be "
317 "removed in the future. Specify it as 'hdfs'.",
318 DeprecationWarning,
319 )
321 cls = get_filesystem_class(protocol)
--> 322 return cls(**storage_options)
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/spec.py:81, in _Cached.__call__(cls, *args, **kwargs)
79 return cls._cache[token]
80 else:
---> 81 obj = super().__call__(*args, **kwargs)
82 # Setting _fs_token here causes some static linters to complain.
83 obj._fs_token_ = token
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/implementations/cached.py:762, in SimpleCacheFileSystem.__init__(self, **kwargs)
760 for key in ["cache_check", "expiry_time", "check_files"]:
761 kw[key] = False
--> 762 super().__init__(**kw)
763 for storage in self.storage:
764 if not os.path.exists(storage):
File ~/checkouts/readthedocs.org/user_builds/cook-inlet-catalogs/conda/stable/lib/python3.11/site-packages/fsspec/implementations/cached.py:137, in CachingFileSystem.__init__(self, target_protocol, cache_storage, cache_check, check_files, expiry_time, target_options, fs, same_names, compression, cache_mapper, **kwargs)
135 else:
136 storage = cache_storage
--> 137 os.makedirs(storage[-1], exist_ok=True)
138 self.storage = storage
139 self.kwargs = target_options or {}
File <frozen os>:215, in makedirs(name, mode, exist_ok)
File <frozen os>:215, in makedirs(name, mode, exist_ok)
File <frozen os>:225, in makedirs(name, mode, exist_ok)
PermissionError: [Errno 13] Permission denied: '/home/kristen'
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)