<jupyter_start><jupyter_text>10. Align double ended measurements The cable length was initially configured during the DTS measurement. For double endedmeasurements it is important to enter the correct length so that the forward channel and thebackward channel are aligned.This notebook shows how to better align the forward and the backward measurements. Do this before the calibration steps.<jupyter_code>import os
from dtscalibration import read_silixa_files
from dtscalibration.datastore_utils import suggest_cable_shift_double_ended, shift_double_ended
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
suggest_cable_shift_double_ended?
filepath = os.path.join('..', '..', 'tests', 'data', 'double_ended2')

ds_aligned = read_silixa_files(
    directory=filepath,
    timezone_netcdf='UTC',
    file_ext='*.xml')  # this one is already correctly aligned<jupyter_output>6 files were found, each representing a single timestep
6 recorded vars were found: LAF, ST, AST, REV-ST, REV-AST, TMP
Recorded at 1693 points along the cable
The measurement is double ended
Reading the data from disk<jupyter_text>Because our loaded files were already nicely aligned, we are purposely offsetting the forward and backward channel by 3 `spacial indices'.<jupyter_code>ds_notaligned = shift_double_ended(ds_aligned, 3)<jupyter_output>I dont know what to do with the following data ['TMP']<jupyter_text>The device-calibrated temperature doesnot have a valid meaning anymore and is dropped<jupyter_code>suggested_shift = suggest_cable_shift_double_ended(
    ds_notaligned, 
    np.arange(-5, 5), 
    plot_result=True, 
    figsize=(12,8))<jupyter_output>/Users/bfdestombe/Projects/dts-calibration/python-dts-calibration-dev/src/dtscalibration/datastore_utils.py:306: RuntimeWarning: invalid value encountered in log
  i_f = np.log(st / ast)
/Users/bfdestombe/Projects/dts-calibration/python-dts-calibration-dev/src/dtscalibration/datastore_utils.py:307: RuntimeWarning: invalid value encountered in log
  i_b = np.log(rst / rast)<jupyter_text>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<jupyter_code>ds_restored = shift_double_ended(ds_notaligned, suggested_shift[0])
print(ds_aligned.x, 3*'\n', ds_restored.x)<jupyter_output><xarray.DataArray 'x' (x: 1693)>
array([-80.5043, -80.3772, -80.2501, ..., 134.294 , 134.421 , 134.548 ])
Coordinates:
  * x        (x) float64 -80.5 -80.38 -80.25 -80.12 ... 134.2 134.3 134.4 134.5
Attributes:
    name:              distance
    description:       Length along fiber
    long_description:  Starting at connector of forward channel
    units:             m 


 <xarray.DataArray 'x' (x: 1687)>
array([-80.123 , -79.9959, -79.8688, ..., 133.913 , 134.04  , 134.167 ])
Coordinates:
  * x        (x) float64 -80.12 -80.0 -79.87 -79.74 ... 133.8 133.9 134.0 134.2
Attributes:
    name:              distance
    description:       Length along fiber
    long_description:  Starting at connector of forward channel
    units:             m
{'fraction_non_alphanumeric': 0.09155844155844156, 'fraction_numerical': 0.05519480519480519, 'mean_word_length': 4.186868686868687, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '161210', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1091, 'n_tokens_neox': 968, 'n_words': 301, 'path': 'examples/notebooks/10Align_double_ended_measurements.ipynb', 'repo_name': 'bvdscheer/python-dts-calibration', 'size': '3080'}