{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [], "source": [ "import subprocess\n", "import sys\n", "\n", "COLAB = \"google.colab\" in sys.modules\n", "\n", "\n", "def _install(package):\n", " if COLAB:\n", " ans = input(f\"Install { package }? [y/n]:\")\n", " if ans.lower() in [\"y\", \"yes\"]:\n", " subprocess.check_call(\n", " [sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", package]\n", " )\n", " print(f\"{ package } installed!\")\n", "\n", "\n", "def _colab_install_missing_deps(deps):\n", " import importlib\n", "\n", " for dep in deps:\n", " if importlib.util.find_spec(dep) is None:\n", " if dep == \"iris\":\n", " dep = \"scitools-iris\"\n", " _install(dep)\n", "\n", "\n", "deps = [\"bagit\", \"pocean-core\"]\n", "_colab_install_missing_deps(deps)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Using BagIt to tag oceanographic data\n", "\n", "Created: 2017-11-01\n", "\n", "[`BagIt`](https://en.wikipedia.org/wiki/BagIt) is a packaging format that supports storage of arbitrary digital content. The \"bag\" consists of arbitrary content and \"tags,\" the metadata files. `BagIt` packages can be used to facilitate data sharing with federal archive centers - thus ensuring digital preservation of oceanographic datasets within IOOS and its regional associations. NOAA NCEI supports reading from a Web Accessible Folder (WAF) containing bagit archives. For an example please see: http://ncei.axiomdatascience.com/cencoos/\n", "\n", "On this notebook we will use the [python interface](http://libraryofcongress.github.io/bagit-python) for `BagIt` to create a \"bag\" of a time-series profile data. First let us load our data from a comma separated values file (`CSV`)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | time | \n", "lon | \n", "lat | \n", "depth | \n", "station | \n", "humidity | \n", "temperature | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "1990-01-01 00:00:00 | \n", "-76.5 | \n", "37.5 | \n", "0.0 | \n", "Station1 | \n", "89.708794 | \n", "15.698009 | \n", "
1 | \n", "1990-01-01 00:00:00 | \n", "-76.5 | \n", "37.5 | \n", "10.0 | \n", "Station1 | \n", "55.789471 | \n", "10.916656 | \n", "
2 | \n", "1990-01-01 00:00:00 | \n", "-76.5 | \n", "37.5 | \n", "20.0 | \n", "Station1 | \n", "50.176994 | \n", "15.666663 | \n", "
3 | \n", "1990-01-01 00:00:00 | \n", "-76.5 | \n", "37.5 | \n", "30.0 | \n", "Station1 | \n", "36.855045 | \n", "1.158752 | \n", "
4 | \n", "1990-01-01 01:00:00 | \n", "-76.5 | \n", "37.5 | \n", "0.0 | \n", "Station1 | \n", "65.016937 | \n", "31.059647 | \n", "