Synthetic data are artificially generated datasets designed to represent physical processes, experimental measurements, or numerical simulations.
They are particularly useful in scientific visualization because they allow us to:
• test visualization algorithms without requiring real experimental data;
• control the spatial and temporal properties of a dataset;
• introduce noise, anomalies, and measurement uncertainty;
• generate structured and unstructured datasets;
• compare different visualization techniques.
In this lecture, we will generate two types of synthetic three-dimensional datasets.
The first dataset represents simulated experimental measurements at randomly distributed spatial locations and randomly selected time values. It includes temperature, pressure, velocity components, energy, experimental groups, measurement noise, and anomaly indicators.
The second dataset represents a structured three-dimensional spatial grid generated for several selected time steps. It contains temperature, pressure, velocity components, velocity magnitude, density, and concentration.
Both datasets will be generated using mathematical functions, stored in Pandas DataFrames, and exported to CSV files for subsequent scientific visualization.
We define the number of simulated measurements:
n_samples = 10000
We define a synthetic temperature distribution using three heat sources, a spatial wave component, and an additional oscillating pattern. The first heat source is time-dependent and moves through the spatial domain:
$$T_1(x,y,z,t) = \exp\left(-\frac{(x-2\sin(t))^2+(y-2\cos(t))^2+(z-\sin(0.5t))^2}{2}\right)$$The position of this source changes over time according to trigonometric functions.
The second heat source is stationary and is located around the point $(-2,1,-1):
$$T_2(x,y,z) = \exp\left(-\frac{(x+2)^2+(y-1)^2+(z+1)^2}{3}\right)$$The third heat source is also stationary and is located around the point $(3,-2,2):
$$T_3(x,y,z) = \exp\left(-\frac{(x-3)^2+(y+2)^2+(z-2)^2}{1.5}\right)$$We also introduce a spherical wave component:
$$T_w(x,y,z,t) = \sin\left(2\sqrt{x^2+y^2+z^2}-1.5t\right)$$An additional spatial and temporal pattern is defined as:
$$T_p(x,y,t) = \sin(1.5x+t)\cos(1.2y-0.5t)$$The complete temperature field is:
$$T(x,y,z,t) = 20 + 55T_1 + 35T_2 + 25T_3 + 8T_w + 5T_p$$The temperature field is implemented as a Python function:
def temperature_field(x, y, z, t):
source_1 = np.exp(-((x - 2 * np.sin(t))**2 + (y - 2 * np.cos(t))**2 + (z - np.sin(0.5 * t))**2) / 2)
source_2 = np.exp(-((x + 2)**2 + (y - 1)**2 + (z + 1)**2) / 3)
source_3 = np.exp(-((x - 3)**2 + (y + 2)**2 + (z - 2)**2) / 1.5)
wave = np.sin(2 * np.sqrt(x**2 + y**2 + z**2) - 1.5 * t)
pattern = np.sin(1.5 * x + t) * np.cos(1.2 * y - 0.5 * t)
return 20 + 55 * source_1 + 35 * source_2 + 25 * source_3 + 8 * wave + 5 * pattern
The function accepts spatial coordinates and time as input arguments. It returns the temperature at the specified position and time.
We next define a synthetic pressure distribution using a wave component, a localized pressure source, and an additional oscillating pattern.
The wave component is:
$$P_w(x,y,t) = \sin(1.5x-t)\cos(1.2y+0.5t)$$A localized pressure source is represented by:
$$P_s(x,y,z,t) = \exp\left(-\frac{(x+\sin(t))^2+(y-2)^2+z^2}{4}\right)$$An additional oscillating component is:
$$P_p(x,y,z,t) = \sin(xy+t)\cos(z-t)$$The complete pressure field is:
$$P(x,y,z,t) = 101325 + 2500P_w + 1800P_s + 700P_p$$The constant 101325 represents the reference atmospheric pressure in pascals.
The pressure field is implemented as:
def pressure_field(x, y, z, t):
wave = np.sin(1.5 * x - t) * np.cos(1.2 * y + 0.5 * t)
source = np.exp(-((x + np.sin(t))**2 + (y - 2)**2 + z**2) / 4)
pattern = np.sin(x * y + t) * np.cos(z - t)
return 101325 + 2500 * wave + 1800 * source + 700 * pattern
The function returns the pressure value at a given spatial position and time.
We define three velocity components representing a synthetic three-dimensional flow field.
Two localized flow sources are introduced:
$$S_1(x,y,z) = \exp\left(-\frac{(x-2)^2+(y+1)^2+z^2}{5}\right)$$ $$S_2(x,y,z) = \exp\left(-\frac{(x+2)^2+(y-2)^2+z^2}{4}\right)$$The first velocity component is:
$$v_x = 0.8\sin(y+0.5t)+0.5\cos(x-t)+1.5S_1-0.8S_2+0.2\sin(xy)$$The second velocity component is:
$$v_y = 0.8\cos(x-0.4t)+0.5\sin(y+t)-1.2S_1+1.5S_2+0.2\cos(xy)$$The third velocity component is:
$$v_z = \sin(x-t)\cos(y+z)+0.5\sin(2z+t)$$Together, these three components describe the velocity vector:
$$\mathbf{v}=(v_x,v_y,v_z)$$The velocity field is implemented as:
def velocity_field(x, y, z, t):
source_1 = np.exp(-((x - 2)**2 + (y + 1)**2 + z**2) / 5)
source_2 = np.exp(-((x + 2)**2 + (y - 2)**2 + z**2) / 4)
vx = (
0.8 * np.sin(y + 0.5 * t)
+ 0.5 * np.cos(x - t)
+ 1.5 * source_1
- 0.8 * source_2
+ 0.2 * np.sin(x * y)
)
vy = (
0.8 * np.cos(x - 0.4 * t)
+ 0.5 * np.sin(y + t)
- 1.2 * source_1
+ 1.5 * source_2
+ 0.2 * np.cos(x * y)
)
vz = (
np.sin(x - t) * np.cos(y + z)
+ 0.5 * np.sin(2 * z + t)
)
return vx, vy, vz
We now generate random spatial positions and time values for the simulated experimental measurements. The computational domain extends from $-5$ to $5$ in each spatial direction. The measurement positions are generated independently using a uniform random distribution.
df_measurements = pd.DataFrame({
"x": np.random.uniform(-5, 5, n_samples),
"y": np.random.uniform(-5, 5, n_samples),
"z": np.random.uniform(-5, 5, n_samples),
"time": np.random.uniform(0, 10, n_samples)
})
Each measurement is associated with four initial variables:
• $x$ – spatial coordinate along the X axis;
• $y$ – spatial coordinate along the Y axis;
• $z$ – spatial coordinate along the Z axis;
• $time$ – time at which the measurement is performed.
Unlike a structured computational grid, the measurement positions are not regularly spaced.
To simulate different experimental conditions, we divide the measurements into three groups:
• Control;
• Experiment A;
• Experiment B.
Each measurement is randomly assigned to one of these groups.
df_measurements["group"] = np.random.choice(
["Control", "Experiment A", "Experiment B"],
n_samples,
p=[0.33, 0.33, 0.34]
)
The probability distribution determines the approximate proportion of measurements assigned to each group.
We introduce different temperature offsets for each experimental group:
group_temperature = df_measurements["group"].map({
"Control": 0,
"Experiment A": 5,
"Experiment B": 10
}).to_numpy()
Similarly, different pressure offsets are assigned:
group_pressure = df_measurements["group"].map({
"Control": 0,
"Experiment A": 500,
"Experiment B": 1000
}).to_numpy()
The Control group represents the reference condition.
Experiment A introduces a temperature increase of 5 units and a pressure increase of 500 Pa.
Experiment B introduces a temperature increase of 10 units and a pressure increase of 1000 Pa.
We extract the spatial coordinates and time values from the DataFrame:
x = df_measurements["x"].to_numpy()
y = df_measurements["y"].to_numpy()
z = df_measurements["z"].to_numpy()
t = df_measurements["time"].to_numpy()
We then evaluate the temperature, pressure, and velocity functions at every measurement position.
temperature = temperature_field(x, y, z, t)
pressure = pressure_field(x, y, z, t)
vx, vy, vz = velocity_field(x, y, z, t)
The calculated values represent the ideal physical quantities before introducing experimental group effects and measurement noise.
Real experimental measurements are rarely exact.Sensor inaccuracies, environmental disturbances, and other sources of uncertainty can introduce differences between the actual physical values and recorded measurements.
The temperature measurements are calculated as:
$$T_m = T(x,y,z,t) + \Delta T_g + \epsilon_T$$where:
• $T$ is the temperature calculated from the mathematical model;
• $\Delta T_g$ is the temperature offset associated with the experimental group;
• $\epsilon_T$ is normally distributed random noise with standard deviation 2.
The pressure measurements are:
$$P_m = P(x,y,z,t) + \Delta P_g + \epsilon_P$$where the pressure noise has a standard deviation of 150 Pa.
The velocity components also contain measurement noise with a standard deviation of 0.08.
The implementation is:
df_measurements["temperature"] = temperature + group_temperature + np.random.normal(0, 2, n_samples)
df_measurements["pressure"] = pressure + group_pressure + np.random.normal(0, 150, n_samples)
df_measurements["velocity_x"] = vx + np.random.normal(0, 0.08, n_samples)
df_measurements["velocity_y"] = vy + np.random.normal(0, 0.08, n_samples)
df_measurements["velocity_z"] = vz + np.random.normal(0, 0.08, n_samples)
The function np.random.normal(mean, standard_deviation, size) generates random values from a normal distribution. The first argument specifies the mean, the second specifies the standard deviation, and the third determines the number of generated values.
We define a synthetic energy combining temperature, pressure, and velocity.
The energy indicator is:
$$E = 0.5T + 0.0001P + 10(v_x^2+v_y^2+v_z^2)$$The temperature and pressure contributions are represented by the first two terms. The final term depends on the squared magnitude of the velocity vector. The implementation is:
df_measurements["energy"] = (
0.5 * df_measurements["temperature"]
+ 0.0001 * df_measurements["pressure"]
+ 10 * (
df_measurements["velocity_x"]**2
+ df_measurements["velocity_y"]**2
+ df_measurements["velocity_z"]**2
)
)
This is a synthetic indicator designed for demonstration purposes rather than a physically complete thermodynamic energy equation. It allows us to combine several physical variables into one scalar quantity that can be used in subsequent analysis and visualization.
We can display the first rows of the generated DataFrame:
pd.set_option("display.max_columns", None)
print(df_measurements.head())
The describe() method provides descriptive statistics for numerical variables, including:
• count – number of available measurements;
• mean – arithmetic mean;
• std – standard deviation;
• min – minimum value;
• max – maximum value;
• 25%, 50%, and 75% – selected percentiles.
print(df_measurements.describe())