import intake
import hvplot.pandas
import hvplot.xarray
import cook_inlet_catalogs as cic
import holoviews as hv

Underway CTD (NOAA PMEL): Towed on ferry

An oceanographic monitoring system aboard the Alaska Marine Highway System ferry Tustumena operated for four years in the Alaska Coastal Current (ACC) with funding from the Exxon Valdez Oil Spill Trustee Council’s Gulf Ecosystem Monitoring Program, the North Pacific Research Board and the National Oceanic and Atmospheric Administration. An electronic public display aboard the ferry educated passengers about the local oceanography and mapped the ferry’s progress. Sampling water at 4 m, the underway system measured: (1) temperature and salinity (used in the present report), and (2) nitrate, (3) chlorophyll fluorescence, (4) colored dissolved organic matter fluorescence, and (5) optical beam transmittance (not used in report).

Nominal 4 meter depth.

NORTH PACIFIC RESEARCH BOARD PROJECT FINAL REPORT Alaskan Ferry Oceanographic Monitoring in the Gulf of Alaska NPRB Project 707 Final Report Edward D. Cokelet and Calvin W. Mordy. https://www.nodc.noaa.gov/archive/arc0031/0070122/1.1/data/0-data/Final_Report_NPRB_0707.pdf

Exxon Valdez Oil Spill Gulf Ecosystem Monitoring and Research Project Final Report Biophysical Observations Aboard Alaska Marine Highway System Ferries Gulf Ecosystem Monitoring and Research Project 040699 Final Report Edward D. Cokelet, Calvin W. Mordy, Antonio J. Jenkins, W. Scott Pegau https://www.nodc.noaa.gov/archive/arc0031/0070122/1.1/data/0-data/Final_Report_GEM_040699.pdf

Archive: https://www.ncei.noaa.gov/metadata/geoportal/rest/metadata/item/gov.noaa.nodc%3A0070122/html

pic

cat = intake.open_catalog(cic.utils.cat_path("ctd_towed_ferry_noaa_pmel"))

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
['2004-10',
 '2004-11',
 '2004-12',
 '2004-9',
 '2005-1',
 '2005-10',
 '2005-11',
 '2005-2',
 '2005-3',
 '2005-4',
 '2005-5',
 '2005-6',
 '2005-7',
 '2005-8',
 '2005-9',
 '2006-10',
 '2006-11',
 '2006-12',
 '2006-5',
 '2006-6',
 '2006-7',
 '2006-8',
 '2006-9',
 '2007-1',
 '2007-10',
 '2007-2',
 '2007-3',
 '2007-4',
 '2007-5',
 '2007-6',
 '2007-7',
 '2007-8',
 '2007-9',
 '2008-10',
 '2008-11',
 '2008-3',
 '2008-4',
 '2008-5',
 '2008-6',
 '2008-7',
 '2008-8',
 '2008-9']

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
2004-12
---------------------------------------------------------------------------
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:1331, in XArrayDatasetReader._read(self, data, open_local, **kw)
   1329         return open_dataset(f, **kw)
   1330     else:
-> 1331         f = fsspec.open(data.url, **(data.storage_options or {})).open()
   1332         return open_dataset(f, **kw)
   1333 return open_dataset(data.url, **kw)

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)