import intake
import hvplot.pandas
import hvplot.xarray
import cook_inlet_catalogs as cic
import holoviews as hv
Underway CTD (GWA): Towed, temperature only¶
Temperature only: Environmental Drivers: Continuous Plankton Recorders, Gulf Watch Alaska.
This project is a component of the integrated Long-term Monitoring of Marine Conditions and Injured Resources and Services submitted by McCammon et. al. Many important species, including herring, forage outside of Prince William Sound for at least some of their life history (salmon, birds and marine mammals for example) so an understanding of the productivity of these shelf and offshore areas is important to understanding and predicting fluctuations in resource abundance. The Continuous Plankton Recorder (CPR) has sampled a continuous transect extending from the inner part of Cook Inlet, onto the open continental shelf and across the shelf break into the open Gulf of Alaska monthly through spring and summer since 2004. There are also data from 2000-2003 from a previous transect. The current transect intersects with the outer part of the Seward Line and provides complementary large scale data to compare with the more local, finer scale plankton sampling on the shelf and in PWS. Resulting data will enable us to identify where the incidences of high or low plankton are, which components of the community are influenced, and whether the whole region is responding in a similar way to meteorological variability. Evidence from CPR sampling over the past decade suggests that the regions are not synchronous in their response to ocean climate forcing. The data can also be used to try to explain how the interannual variation in ocean food sources creates interannual variability in PWS zooplankton, and when changes in ocean zooplankton are to be seen inside PWS. The CPR survey is a cost-effective, ship-of-opportunity based sampling program supported in the past by the EVOS TC that includes local involvement and has a proven track record.
Nominal 7m depth, 2011-2016.
Project overview: https://gulf-of-alaska.portal.aoos.org/#metadata/87f56b09-2c7d-4373-944e-94de748b6d4b/project
cat = intake.open_catalog(cic.utils.cat_path("ctd_towed_gwa_temp"))
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
['2011-06-20',
'2011-07-23',
'2011-08-22',
'2012-04-09',
'2012-05-13',
'2012-06-11',
'2012-09-16',
'2012-10-16',
'2013-04-14',
'2013-05-13',
'2013-06-15',
'2013-07-15',
'2013-08-17',
'2014-04-27',
'2014-05-27',
'2014-06-29',
'2014-07-29',
'2014-08-31',
'2015-08-23',
'2015-09-01',
'2016-04-17',
'2016-05-16',
'2016-06-19',
'2016-07-19',
'2016-08-29',
'2016-10-02']
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
2011-08-22
---------------------------------------------------------------------------
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)