{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to create Data objects\n", "\n", "The SciDataTool python module has been created to **ease the handling of scientific data**, and considerately simplify plot commands. It unifies the extraction of relevant data (e.g. slices), whether they are stored in the time/space or in the frequency domain. The call to Fourier Transform functions is **transparent**, although it still can be parameterized through the use of a dictionary.\n", "\n", "This tutorial explains the **structure** of the `Data` classes, then shows **how to create axes and fields objects**.\n", "\n", "The following example demonstrates the syntax to **quickly create a 1D data field** depending on time:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]\n" ] } ], "source": [ "# import SciDataTool objects\n", "from SciDataTool import Data1D, DataLinspace, DataPattern, DataTime, DataFreq, VectorField\n", "\n", "import numpy as np\n", "\n", "time = np.linspace(0,10,10,endpoint=False)\n", "Time = Data1D(\n", " name=\"time\",\n", " unit=\"s\",\n", " values=time,\n", ")\n", "print(Time.get_values())\n", "\n", "field = np.ones(10)\n", "Field = DataTime(\n", " name=\"Example field\",\n", " symbol=\"X\",\n", " unit=\"dimless\",\n", " axes=[Time],\n", " values=field,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Your `Data`objects have been successfully created. Other features of the `SciDataTool` package are also available:\n", "- reduce storage if an axis is regularly spaced\n", "- reduce storage if the field presents a symmetry along one of its axes\n", "- store a field in the frequency domain\n", "- specifiy normalizations\n", "\n", "These functionalities are described in the following sections.\n", "\n", "## 1. Data class structure\n", "The `Data` class is composed of:\n", "- classes describing **axes**: `Data1D`, or `DataLinspace` if the axis is regularly spaced (see [section 2](#How-to-reduce-storage-if-an-axis-is-regularly-spaced))\n", "- classes describing **fields** stored in the time/space domain (`DataTime`) or in the frequential domain (`DataFreq`)\n", "\n", "The following UML summarizes this structure:\n", "\n", "