{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A2. Loading sensornet files\n", "This example loads sensornet files. Both single-ended and double-ended measurements are supported." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:18.017157Z", "iopub.status.busy": "2022-04-06T08:12:18.016166Z", "iopub.status.idle": "2022-04-06T08:12:19.818415Z", "shell.execute_reply": "2022-04-06T08:12:19.817618Z" } }, "outputs": [], "source": [ "import os\n", "import glob\n", "\n", "from dtscalibration import read_sensornet_files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The example data files are located in `./python-dts-calibration/tests/data`." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:19.821193Z", "iopub.status.busy": "2022-04-06T08:12:19.820976Z", "iopub.status.idle": "2022-04-06T08:12:19.825091Z", "shell.execute_reply": "2022-04-06T08:12:19.824478Z" } }, "outputs": [], "source": [ "filepath = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"sensornet_oryx_v3.7\")\n", "print(filepath)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:19.862591Z", "iopub.status.busy": "2022-04-06T08:12:19.862218Z", "iopub.status.idle": "2022-04-06T08:12:19.868228Z", "shell.execute_reply": "2022-04-06T08:12:19.867633Z" } }, "outputs": [], "source": [ "filepathlist = sorted(glob.glob(os.path.join(filepath, \"*.ddf\")))\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 sensornet files. As the sensornet files are of low spatial and temporal resolution, reading the data lazily into dask is not supported." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:19.871525Z", "iopub.status.busy": "2022-04-06T08:12:19.871278Z", "iopub.status.idle": "2022-04-06T08:12:20.102791Z", "shell.execute_reply": "2022-04-06T08:12:20.102077Z" } }, "outputs": [], "source": [ "ds = read_sensornet_files(directory=filepath)" ] }, { "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`." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:20.105803Z", "iopub.status.busy": "2022-04-06T08:12:20.105530Z", "iopub.status.idle": "2022-04-06T08:12:20.121624Z", "shell.execute_reply": "2022-04-06T08:12:20.120865Z" } }, "outputs": [], "source": [ "print(ds)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "Double ended sensornet files are also supported. Note the REV-ST and REV-AST data variables." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2022-04-06T08:12:20.124573Z", "iopub.status.busy": "2022-04-06T08:12:20.124284Z", "iopub.status.idle": "2022-04-06T08:12:20.285504Z", "shell.execute_reply": "2022-04-06T08:12:20.284773Z" } }, "outputs": [], "source": [ "filepath = os.path.join(\"..\", \"..\", \"tests\", \"data\", \"sensornet_halo_v1.0\")\n", "ds = read_sensornet_files(directory=filepath)\n", "print(ds)" ] } ], "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 }