{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Import all necessary packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2025-09-20T16:34:11.344617Z", "iopub.status.busy": "2025-09-20T16:34:11.344470Z", "iopub.status.idle": "2025-09-20T16:34:12.771988Z", "shell.execute_reply": "2025-09-20T16:34:12.771456Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/runner/work/WBTSdata/WBTSdata/WBTSdata/load_vel_files.py:31: SyntaxWarning: invalid escape sequence '\\s'\n", " vel_list.append(pd.read_csv(os.path.join(vel_dir, vel_file),names=column_names, skiprows=74, sep='\\s+', encoding='utf-8'))\n", "/home/runner/work/WBTSdata/WBTSdata/WBTSdata/load_cal_files.py:34: SyntaxWarning: invalid escape sequence '\\s'\n", " cal_list.append(pd.read_csv(os.path.join(cal_dir, cal_file), names=column_names, skiprows=12, sep='\\s+'))\n" ] } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "import os\n", "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import importlib\n", "import yaml\n", "import glob\n", "import sys\n", "#sys.path.append(os.path.abspath('').split('notebooks')[0])\n", "from WBTSdata import plotters, tools, merge_datasets, config\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note: This assumes you have already installed the package using\n", "``` \n", "pip install -e .\n", "```\n", "\n", "## Demo Configuration\n", "\n", "This demo notebook processes only the first 3 years of data (2001-2003) for demonstration purposes. This prevents memory issues when loading all 27 years of data simultaneously.\n", "\n", "For processing the full dataset, use:\n", "```python\n", "ds_all = merge_datasets.merge_years(output_dir) # Process all files\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load the merged file\n", "\n", "Loads the file created by running the script `load_data.ipynb`" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2025-09-20T16:34:12.800528Z", "iopub.status.busy": "2025-09-20T16:34:12.800216Z", "iopub.status.idle": "2025-09-20T16:34:12.820636Z", "shell.execute_reply": "2025-09-20T16:34:12.820183Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Input directory: ../data/input \n", "Output directory: ../data\n" ] } ], "source": [ "### import basepath from mission_config.yaml\n", "config = tools.get_config()\n", "input_dir = config['input_dir']\n", "output_dir = config['output_dir']\n", "print('Input directory: ',input_dir ,'\\nOutput directory: ',output_dir)\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2025-09-20T16:34:12.822067Z", "iopub.status.busy": "2025-09-20T16:34:12.821918Z", "iopub.status.idle": "2025-09-20T16:34:27.164550Z", "shell.execute_reply": "2025-09-20T16:34:27.163974Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/runner/work/WBTSdata/WBTSdata/WBTSdata/merge_datasets.py:235: FutureWarning: In a future version of xarray the default value for join will change from join='outer' to join='exact'. This change will result in the following ValueError: cannot be aligned with join='exact' because index/labels/sizes are not equal along these coordinates (dimensions): 'DEPTH' ('DEPTH',) The recommendation is to set join explicitly for this case.\n", " concatenated_ds = xr.concat(processed_datasets, dim='DATETIME')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing 3 files for demonstration (limited from 3 total)\n", "Loading WBTS_2001_04_CTD_LADCP.nc...\n", "Loading WBTS_2002_06_CTD_LADCP.nc...\n", "Loading WBTS_2003_02_CTD_LADCP.nc...\n" ] } ], "source": [ "ds_all = merge_datasets.merge_years(output_dir, max_files=3)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2025-09-20T16:34:27.166579Z", "iopub.status.busy": "2025-09-20T16:34:27.166397Z", "iopub.status.idle": "2025-09-20T16:34:27.194472Z", "shell.execute_reply": "2025-09-20T16:34:27.193934Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset> Size: 60MB\n",
       "Dimensions:           (DATETIME: 148, DEPTH: 5595)\n",
       "Coordinates:\n",
       "  * DEPTH             (DEPTH) float64 45kB 1.0 2.0 3.0 ... 5.594e+03 5.595e+03\n",
       "  * DATETIME          (DATETIME) datetime64[ns] 1kB 2001-04-26T17:06:58 ... 2...\n",
       "    LATITUDE          (DATETIME) float64 1kB 26.45 27.02 26.43 ... 26.99 26.99\n",
       "    LONGITUDE         (DATETIME) float64 1kB -79.92 -79.92 ... -79.28 -79.2\n",
       "Data variables:\n",
       "    TEMP              (DATETIME, DEPTH) float64 7MB 26.02 26.02 ... nan nan\n",
       "    THETA             (DATETIME, DEPTH) float64 7MB 26.02 26.02 ... nan nan\n",
       "    PSAL              (DATETIME, DEPTH) float64 7MB 36.23 36.23 ... nan nan\n",
       "    DYN_HEIGHT        (DATETIME, DEPTH) float64 7MB 0.004 0.008 ... nan nan\n",
       "    GA                (DATETIME, DEPTH) float64 7MB 0.993 1.987 2.98 ... nan nan\n",
       "    DOXY              (DATETIME, DEPTH) float64 7MB 214.4 214.5 ... nan nan\n",
       "    TIME_FLAG         (DATETIME) float64 1kB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n",
       "    CAST_NUMBER       (DATETIME) float64 1kB 0.0 1.0 2.0 3.0 ... 52.0 53.0 54.0\n",
       "    GC_STRING         (DATETIME) <U10 6kB 'GC_2001_04' ... 'GC_2003_02'\n",
       "    U_WATER_VELOCITY  (DATETIME, DEPTH) float64 7MB nan nan nan ... nan nan nan\n",
       "    V_WATER_VELOCITY  (DATETIME, DEPTH) float64 7MB nan nan nan ... nan nan nan\n",
       "    ERROR_VELOCITY    (DATETIME, DEPTH) float64 7MB nan nan nan ... nan nan nan\n",
       "Attributes: (12/26)\n",
       "    title:                      CTD and LADCP data of the Abaco Cruise\n",
       "    project:                    Western Boundary Time Series\n",
       "    project_id:                 AB0104 / OC365-9\n",
       "    platform:                   CTD and Lowered Acoustic Doppler Current Prof...\n",
       "    geospatial_lat_min:         26.033\n",
       "    geospatial_lat_max:         27.421\n",
       "    ...                         ...\n",
       "    data_url:                   \n",
       "    web_link:                   https://www.aoml.noaa.gov/phod/wbts/data.php\n",
       "    comment:                    GIT repository: https://github.com/ifmeo-hamb...\n",
       "    date_created:               2024-12-06\n",
       "    featureType:                profile\n",
       "    Conventions:                CF-1.11
" ], "text/plain": [ " Size: 60MB\n", "Dimensions: (DATETIME: 148, DEPTH: 5595)\n", "Coordinates:\n", " * DEPTH (DEPTH) float64 45kB 1.0 2.0 3.0 ... 5.594e+03 5.595e+03\n", " * DATETIME (DATETIME) datetime64[ns] 1kB 2001-04-26T17:06:58 ... 2...\n", " LATITUDE (DATETIME) float64 1kB 26.45 27.02 26.43 ... 26.99 26.99\n", " LONGITUDE (DATETIME) float64 1kB -79.92 -79.92 ... -79.28 -79.2\n", "Data variables:\n", " TEMP (DATETIME, DEPTH) float64 7MB 26.02 26.02 ... nan nan\n", " THETA (DATETIME, DEPTH) float64 7MB 26.02 26.02 ... nan nan\n", " PSAL (DATETIME, DEPTH) float64 7MB 36.23 36.23 ... nan nan\n", " DYN_HEIGHT (DATETIME, DEPTH) float64 7MB 0.004 0.008 ... nan nan\n", " GA (DATETIME, DEPTH) float64 7MB 0.993 1.987 2.98 ... nan nan\n", " DOXY (DATETIME, DEPTH) float64 7MB 214.4 214.5 ... nan nan\n", " TIME_FLAG (DATETIME) float64 1kB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n", " CAST_NUMBER (DATETIME) float64 1kB 0.0 1.0 2.0 3.0 ... 52.0 53.0 54.0\n", " GC_STRING (DATETIME) " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Example usage\n", "fig, ax = plotters.plot_cast_over_time(ds_all)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "venv (3.11.7)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.7" } }, "nbformat": 4, "nbformat_minor": 2 }