{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. Define calibration sections\n", "The goal of this notebook is to show how you can define calibration sections. That means that we define certain parts of the fiber to a timeseries of temperature measurements. Here, we assume the temperature timeseries is already part of the `xarray.Dataset` object." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:09:08.251322Z", "iopub.status.busy": "2022-04-06T08:09:08.250914Z", "iopub.status.idle": "2022-04-06T08:09:09.852522Z", "shell.execute_reply": "2022-04-06T08:09:09.851877Z" } }, "outputs": [], "source": [ "import os\n", "from dtscalibration import read_silixa_files" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:09:09.855368Z", "iopub.status.busy": "2022-04-06T08:09:09.855138Z", "iopub.status.idle": "2022-04-06T08:09:10.207557Z", "shell.execute_reply": "2022-04-06T08:09:10.204867Z" } }, "outputs": [], "source": [ "filepath = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"double_ended2\")\n", "ds = read_silixa_files(directory=filepath, timezone_netcdf=\"UTC\", file_ext=\"*.xml\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we have a look at which temperature timeseries are available for calibration. Therefore we access `ds.data_vars` and we find `probe1Temperature` and `probe2Temperature` that refer to the temperature measurement timeseries of the two probes attached to the Ultima.\n", "\n", "Alternatively, we can access the `ds.dts.get_timeseries_keys()` function to list all timeseries that can be used for calibration." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:09:10.210852Z", "iopub.status.busy": "2022-04-06T08:09:10.210555Z", "iopub.status.idle": "2022-04-06T08:09:10.276848Z", "shell.execute_reply": "2022-04-06T08:09:10.275933Z" } }, "outputs": [], "source": [ "# The following line introduces the .dts accessor for xarray datasets\n", "import dtscalibration # noqa: E401 # noqa: E401\n", "\n", "print(ds.dts.get_timeseries_keys()) # list the available timeseeries\n", "ds.probe1Temperature.plot(figsize=(12, 8))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A calibration is needed to estimate temperature from Stokes and anti-Stokes measurements. There are three unknowns for a single ended calibration procedure $\\gamma$, $C$, and $\\alpha$. The parameters $\\gamma$ and $\\alpha$ remain constant over time, while $C$ may vary. \n", "\n", "At least two calibration sections of different temperatures are needed to perform a decent calibration procedure.\n", "\n", "This setup has two baths, named 'cold' and 'warm'. Each bath has 2 sections. `probe1Temperature` is the temperature timeseries of the cold bath and `probe2Temperature` is the temperature timeseries of the warm bath." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Name section | Name reference temperature time series | Number of sections | Location of sections (m) |\n", "|--------------|:--------------------------------------:|:------------------:|:------------------------:|\n", "| Cold bath | probe1Temperature | 2 | 7.5-17.0; 70.0-80.0 |\n", "| Warm bath | probe2Temperature | 2 | 24.0-34.0; 85.0-95.0 |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sections are defined in a dictionary with its keywords of the names of the reference temperature time series. Its values are lists of slice objects, where each slice object is a section.\n", "\n", "Note that slice is part of the standard Python library and no import is required." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:09:10.280352Z", "iopub.status.busy": "2022-04-06T08:09:10.280094Z", "iopub.status.idle": "2022-04-06T08:09:10.306041Z", "shell.execute_reply": "2022-04-06T08:09:10.305366Z" } }, "outputs": [], "source": [ "sections = {\n", " \"probe1Temperature\": [slice(7.5, 17.0), slice(70.0, 80.0)], # cold bath\n", " \"probe2Temperature\": [slice(24.0, 34.0), slice(85.0, 95.0)], # warm bath\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NetCDF files do not support reading/writing python dictionaries. Internally the sections dictionary is stored in `ds._sections` as a string encoded with yaml, which can be saved to a netCDF file. Each time the sections dictionary is requested, yaml decodes the string and evaluates it to the Python dictionary. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.10.10" } }, "nbformat": 4, "nbformat_minor": 2 }