{ "cells": [ { "cell_type": "markdown", "id": "13b4e1db-4776-4d84-b7fc-01930387455f", "metadata": {}, "source": [ "# CTD profiles - minimal example\n", "\n", "\n", "📥 Download: [`CTD profiles - minimal example.ipynb`](https://github.com/NPIOcean/kval/raw/master/docs/source/examples/notebooks/CTD_profiles_minimal_example.ipynb?raw=true)\n", "\n", "___\n", "\n", "**In this notebook**\n", "\n", "- Load multiple `.cnv` files containing shipboard profiles from a SeaBird CTD.\n", "- Quick overview and basic plots." ] }, { "cell_type": "code", "execution_count": 1, "id": "44d64f2d-6873-444a-b9f4-bc3c1d6a4308", "metadata": {}, "outputs": [], "source": [ "# Import the ctd module from kval.data\n", "from kval.data import ctd \n", "# Set the plotting backed so we can interact with figures\n", "%matplotlib widget " ] }, { "cell_type": "markdown", "id": "095d1e84-ebd3-47aa-a31a-1d5ffd2dda3e", "metadata": {}, "source": [ "## Load data from `.cnv` files into a single xarray Dataset" ] }, { "cell_type": "markdown", "id": "d1f3bce6-496a-44c7-8a1d-80e1dbf4f6ff", "metadata": {}, "source": [ "**Specify a directory** `cnv_dir` where we have `.cnv` files collected from a SBE CTD.\n", "\n", "\n", "____\n", "\n", "***NOTE:*** *Loading the data in this manner will load* all *the* `.cnv` *files in the directory. Make sure* `cnv_dir/` *only contains the files you want to include.*\n", "\n", "___\n", "\n", "***NOTE:*** *In this case, the* `.cnv` *files contain pressure-gridded data. It is also possible to load ungridded profiles - profiles will then be pressure gridded within kval.*" ] }, { "cell_type": "code", "execution_count": 2, "id": "ebaea9f0-f425-40e9-bfbb-cc729e89a8d9", "metadata": {}, "outputs": [], "source": [ "cnv_dir = ('../../../../tests/test_data/'\n", " 'sbe_files/sbe911plus/atwain_cruise_ctds/')" ] }, { "cell_type": "markdown", "id": "e9c4e38c-71c5-4888-9295-a9635033ad19", "metadata": {}, "source": [ "**Load all** `.cnv` **files** into a single xarray\n", "Dataset - the object we will work with and ultimately export to netCDF." ] }, { "cell_type": "code", "execution_count": 3, "id": "44991190-2a70-45c5-9747-eb5dc6c1b3c7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found 3 .cnv files in \"../../../../tests/test_data/sbe_files/sbe911plus/atwain_cruise_ctds/\".\n", "NOTE: It seems the input data already binned -> using preexisting binning.\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "33b7290a10254854bfea3b831fa109ba", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Joining profiles together: 0%| | 0/3 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ds = ctd.ctds_from_cnv_dir(cnv_dir)" ] }, { "cell_type": "markdown", "id": "013c0ce1-0539-445d-85a2-d0f4a4da58e8", "metadata": {}, "source": [ "The xarray Dataset `ds` should contain 1-D and 2-D fields gridded on pressure (`PRES`) and time (`TIME`). \n", "\n", "When available, metadata such as serial numbers and calibration data have been parsed into variable attributes. The `PROCESSING` variable should include a description of the processing steps and a python script that can be used to reproduce the processing we do here (we add to these fields as we apply methods to the dataset).\n", " " ] }, { "cell_type": "markdown", "id": "66adc37e-6cbd-4134-969d-8d698e320c77", "metadata": {}, "source": [ "## Have a look at the data" ] }, { "cell_type": "markdown", "id": "8db1c377-1ffd-4be3-ba9f-8ca24df2e981", "metadata": {}, "source": [ "\n", "**Take a first look at the dataset**\n", "\n", "\n", "\n", "To have a look around, run `ds` in a cell and browse (if you are running the notebook interactively). Click the ⛃ and 🗎 symbols on the right to display data and metadata. " ] }, { "cell_type": "code", "execution_count": 4, "id": "27f6c7a6-0534-401a-b91b-dd398783213c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 93kB\n",
"Dimensions: (TIME: 3, PRES: 527)\n",
"Coordinates:\n",
" * PRES (PRES) float64 4kB 3.0 4.0 5.0 6.0 ... 527.0 528.0 529.0\n",
" * TIME (TIME) float64 24B 1.743e+04 1.743e+04 1.743e+04\n",
"Data variables:\n",
" TEMP (TIME, PRES) float64 13kB nan 6.362 6.367 ... nan nan nan\n",
" PTEMP (TIME, PRES) float64 13kB nan 6.362 6.367 ... nan nan nan\n",
" CNDC (TIME, PRES) float64 13kB nan 34.68 34.69 ... nan nan nan\n",
" PSAL (TIME, PRES) float64 13kB nan 34.98 34.98 ... nan nan nan\n",
" SIGTH (TIME, PRES) float64 13kB nan 27.49 27.49 ... nan nan nan\n",
" CHLA_fluorescence (TIME, PRES) float64 13kB nan 1.39 1.293 ... nan nan nan\n",
" SBE_FLAG (TIME, PRES) float64 13kB nan 0.0 0.0 0.0 ... nan nan nan\n",
" STATION (TIME) <U5 60B 'AT285' 'AT286' 'AT287'\n",
" LATITUDE (TIME) float64 24B 80.11 80.07 80.04\n",
" LONGITUDE (TIME) float64 24B 9.875 10.38 10.75\n",
" CRUISE <U27 108B '!! CRUISE (Not assigned) !!'\n",
" PROCESSING object 8B None\n",
"Attributes:\n",
" binned: 1 decibars (SBE software)\n",
" source_file: E.g. AT285.HEX, AT285.XMLCON -> AT285.CNV\n",
" history: 2017-09-24 to 2017-09-24: Data collection.\\n2018-07-23...\n",
" instrument_model: Sea-Bird SBE 9\n",
" featureType: profile