diff options
Diffstat (limited to 'tutorials/module_4/4.1 Introduction to Data and Scientific Datasets.md')
| -rw-r--r-- | tutorials/module_4/4.1 Introduction to Data and Scientific Datasets.md | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tutorials/module_4/4.1 Introduction to Data and Scientific Datasets.md b/tutorials/module_4/4.1 Introduction to Data and Scientific Datasets.md new file mode 100644 index 0000000..8327006 --- /dev/null +++ b/tutorials/module_4/4.1 Introduction to Data and Scientific Datasets.md @@ -0,0 +1,65 @@ +# Introduction to Data and Scientific Datasets + +**Learning objectives:** + +- Understand what makes data “scientific” (units, precision, metadata) +- Recognize types of data: time-series, experimental, simulation, and imaging data +- Identify challenges in data processing (missing data, noise, outliers) +- Overview of the data-analysis workflow +--- +### What is scientific data? +Scientific data refers to **measured or simulated information** that describes a physical phenomenon in a quantitative and reproducible way. Scientific data is rooted in physical laws and carries information about the system’s behavior, boundary conditions, and measurement uncertainty whether this is collected experimentally or predicted with a model. + +We may collect this in the following ways: +- **Experiments** – temperature readings from thermocouples, strain or force from sensors, vibration accelerations, or flow velocities. +- **Simulations** – outputs from finite-element or CFD models such as pressure, stress, or temperature distributions. +- **Instrumentation and sensors** – digital or analog signals from transducers, encoders, or DAQ systems. + +### Introduction to pandas +`pandas` (**Pan**el **Da**ta) is a Python library designed for **data analysis and manipulation**, widely used in engineering, science, and data analytics. It provides two core data structures: the **Series** and the **DataFrame**. + +A `Series` represents a single column or one-dimensional labeled array, while a `DataFrame` is a two-dimensional table of data, similar to a spreadsheet table, where each column is a `Series` and each row has a labeled index. + +DataFrames can be created from dictionaries, lists, NumPy arrays, or imported from external files such as CSV or Excel. Once data is loaded, you can **view and explore** it using methods like `head()`, `tail()`, and `describe()`. Data can be **selected by label** or **by position**. These indexing systems make it easy to slice, filter, and reorganize datasets efficiently. + + +### Problem 1: Import a text file +```python +import pandas as pd + +file_path = "force_displacement_data.txt" + +df_txt = pd.read_csv( + file_path, + delim_whitespace=True, + comment="#", + skiprows=0, + header=0 +) + +print("\n=== Basic Statistics ===") +print(df_txt.describe()) + +if "Force_N" in df_txt.columns: + print("\nFirst five Force readings:") + print(df_txt["Force_N"].head()) + +try: + import matplotlib.pyplot as plt + + plt.plot(df_txt.iloc[:, 0], df_txt.iloc[:, 1]) + plt.xlabel(df_txt.columns[0]) + plt.ylabel(df_txt.columns[1]) + plt.title("Loaded Data from Text File") + plt.grid(True) + plt.show() + +except ImportError: + print("\nmatplotlib not installed — skipping plot.") + +``` + + +**Activities & Examples:** +- Load small CSV datasets using `numpy.loadtxt()` and `pandas.read_csv()` +- Discuss real ME examples: strain gauge data, thermocouple readings, pressure transducers
\ No newline at end of file |
