{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A3. Loading AP Sensing files\n", "This example loads AP sensing files. Only single-ended files are currently supported. \n", "\n", "The currently supported AP Sensing N4386B device has two data logging options to log into .xml files and .tra files. Only .xml files contain the stokes and anti-stokes intensities needed for this calibration. Unfortunately, these .xml files are scarce on metadata and do not contain the additionally connected sensors e.g. PT100 from the device. The latter are contained inside the .tra file.\n", "\n", "If you did not connect any additional sensors, you can use .xml files only and add your own logged temperature data to the datastore for calibration. (Hint: The .xml file export is well hidden in your AP Sensing software *DTS Configurator* and not documented in the user manual. Inside your *Configuration* turn *POSC export* on - this will export the .xml file.)\n", "\n", "If you want to additionally use data exported to .tra files (e.g. PT100 data) use the .tra logging make sure to enable *Auto Save Traces* in under *Program Options* and make sure *Create Multitrace files* and *Use Binary Format* are both disabled. Make sure to place the .tra files into the identical directory as the .xml files. Then they will be imported automatically with the *read_apsensing_files* commmand.\n", "\n", "The current implementation of .tra file parsing is limited to in-memory reading only." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:29.520519Z", "iopub.status.busy": "2022-04-06T08:12:29.519679Z", "iopub.status.idle": "2022-04-06T08:12:31.215962Z", "shell.execute_reply": "2022-04-06T08:12:31.215351Z" } }, "outputs": [], "source": [ "import os\n", "import glob\n", "\n", "from dtscalibration import read_apsensing_files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The example data files are located in `./python-dts-calibration/tests/data`." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:31.219744Z", "iopub.status.busy": "2022-04-06T08:12:31.219507Z", "iopub.status.idle": "2022-04-06T08:12:31.225338Z", "shell.execute_reply": "2022-04-06T08:12:31.224123Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "..\\..\\tests\\data\\ap_sensing\n" ] } ], "source": [ "filepath = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"ap_sensing\")\n", "filepath_with_tra = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"ap_sensing_2\", \"CH1_SE\")\n", "print(filepath)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:31.254656Z", "iopub.status.busy": "2022-04-06T08:12:31.254433Z", "iopub.status.idle": "2022-04-06T08:12:31.259760Z", "shell.execute_reply": "2022-04-06T08:12:31.258995Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "_AP Sensing_N4386B_3_20180118201727.xml\n", "_AP Sensing_N4386B_3_20180118202957.xml\n", "_AP Sensing_N4386B_3_20180118205357.xml\n" ] } ], "source": [ "filepathlist = sorted(glob.glob(os.path.join(filepath, \"*.xml\")))\n", "filenamelist = [os.path.basename(path) for path in filepathlist]\n", "\n", "for fn in filenamelist:\n", " print(fn)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will simply load in the .xml files" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:31.262782Z", "iopub.status.busy": "2022-04-06T08:12:31.262491Z", "iopub.status.idle": "2022-04-06T08:12:31.692953Z", "shell.execute_reply": "2022-04-06T08:12:31.692317Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3 files were found, each representing a single timestep\n", "4 recorded vars were found: LAF, TEMP, ST, AST\n", "Recorded at 7101 points along the cable\n", "The measurement is single ended\n", "Reading the data from disk\n", "3 files were found, each representing a single timestep\n", "4 recorded vars were found: LAF, TEMP, ST, AST\n", "Recorded at 1201 points along the cable\n", "The measurement is single ended\n", "Reading the data from disk\n", ".tra files exist and will be read\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\David Lah\\Documents\\dts-data-processing\\extern\\python-dts-calibration\\src\\dtscalibration\\io\\apsensing.py:480: UserWarning: Not all .xml files have a matching .tra file.\n", " Missing are time following timestamps {'20180118202957', '20180118201727', '20180118205357'}. Not loading .tra data.\n", " warnings.warn(msg)\n" ] } ], "source": [ "ds = read_apsensing_files(directory=filepath)\n", "ds_with_tra = read_apsensing_files(directory=filepath_with_tra)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The object tries to gather as much metadata from the measurement files as possible (temporal and spatial coordinates, filenames, temperature probes measurements). All other configuration settings are loaded from the first files and stored as attributes of the `xarray.Dataset`.\n", "y\n", "Calibration follows as usual (see the other notebooks)." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:31.695872Z", "iopub.status.busy": "2022-04-06T08:12:31.695622Z", "iopub.status.idle": "2022-04-06T08:12:31.706049Z", "shell.execute_reply": "2022-04-06T08:12:31.705163Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Size: 569kB\n", "Dimensions: (x: 7101, time: 3)\n", "Coordinates:\n", " * x (x) float64 57kB 0.0 0.5 1.0 ... 3.549e+03 3.55e+03 3.55e+03\n", " filename (time) Size: 24B\n", "array([19.60636, 19.62306, 19.62306])\n", "Coordinates:\n", " filename (time) Size: 97kB\n", "Dimensions: (x: 1201, time: 3)\n", "Coordinates:\n", " * x (x) float64 10kB -50.0 -49.75 -49.5 ... 249.5 249.8 250.0\n", " filename (time)