{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 10. Align double ended measurements" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The cable length was initially configured during the DTS measurement. For double ended\n", "measurements it is important to enter the correct length so that the forward channel and the\n", "backward channel are aligned.\n", "\n", "This notebook shows how to better align the forward and the backward measurements. Do this before the calibration steps." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:41.504994Z", "iopub.status.busy": "2022-04-06T08:10:41.504482Z", "iopub.status.idle": "2022-04-06T08:10:42.970309Z", "shell.execute_reply": "2022-04-06T08:10:42.969681Z" } }, "outputs": [], "source": [ "import os\n", "from dtscalibration import read_silixa_files\n", "from dtscalibration.dts_accessor_utils import (\n", " suggest_cable_shift_double_ended,\n", " shift_double_ended,\n", ")\n", "import numpy as np\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:42.972706Z", "iopub.status.busy": "2022-04-06T08:10:42.972519Z", "iopub.status.idle": "2022-04-06T08:10:43.009664Z", "shell.execute_reply": "2022-04-06T08:10:43.009175Z" } }, "outputs": [], "source": [ "?suggest_cable_shift_double_ended" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:43.011841Z", "iopub.status.busy": "2022-04-06T08:10:43.011645Z", "iopub.status.idle": "2022-04-06T08:10:43.349302Z", "shell.execute_reply": "2022-04-06T08:10:43.348715Z" } }, "outputs": [], "source": [ "filepath = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"double_ended2\")\n", "\n", "ds_aligned = read_silixa_files(\n", " directory=filepath, timezone_netcdf=\"UTC\", file_ext=\"*.xml\"\n", ") # this one is already correctly aligned" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because our loaded files were already nicely aligned, we are purposely offsetting the forward and backward channel by 3 `spacial indices'." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:43.351853Z", "iopub.status.busy": "2022-04-06T08:10:43.351637Z", "iopub.status.idle": "2022-04-06T08:10:43.365345Z", "shell.execute_reply": "2022-04-06T08:10:43.364693Z" } }, "outputs": [], "source": [ "ds_notaligned = shift_double_ended(ds_aligned, 3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The device-calibrated temperature doesnot have a valid meaning anymore and is dropped" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:43.367697Z", "iopub.status.busy": "2022-04-06T08:10:43.367530Z", "iopub.status.idle": "2022-04-06T08:10:43.946995Z", "shell.execute_reply": "2022-04-06T08:10:43.946514Z" } }, "outputs": [], "source": [ "suggested_shift = suggest_cable_shift_double_ended(\n", " ds_notaligned, np.arange(-5, 5), plot_result=True, figsize=(12, 8)\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The two approaches suggest a shift of -3 and -4. It is up to the user which suggestion to follow. Usually the two suggested shift are close" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:43.949227Z", "iopub.status.busy": "2022-04-06T08:10:43.949032Z", "iopub.status.idle": "2022-04-06T08:10:43.959590Z", "shell.execute_reply": "2022-04-06T08:10:43.959129Z" } }, "outputs": [], "source": [ "ds_restored = shift_double_ended(ds_notaligned, suggested_shift[0])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:10:43.961718Z", "iopub.status.busy": "2022-04-06T08:10:43.961520Z", "iopub.status.idle": "2022-04-06T08:10:43.967547Z", "shell.execute_reply": "2022-04-06T08:10:43.967128Z" } }, "outputs": [], "source": [ "print(ds_aligned.x, 3 * \"\\n\", ds_restored.x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that our fiber has become shorter by 2*3 spatial indices" ] } ], "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.9.11" } }, "nbformat": 4, "nbformat_minor": 2 }