Particle quantities over 2D heatmap¶
1from idefix2python import RunContext, Pipeline, Fig, PartQuantity, MapMovie2D
2from pathlib import Path
3import numpy as np
4
5projectPath = Path(__file__).parent / "data_examples"
6task = "multipart_2D"
7configPath = projectPath / "config.json"
8# By default the vtks are expected to be in {projetPath}/{task}/outputs/vtks/
9
10
11fields2D = [
12 MapMovie2D(
13 "RHO",
14 r"$\rho$",
15 plot_coords=[0, 0],
16 title="Density",
17 streamlines=["VX1", "VX2"],
18 uids="all",
19 ),
20 MapMovie2D(
21 "VX1",
22 r"$v_x$",
23 plot_coords=[0, 1],
24 streamlines=["VX1", "VX2"],
25 uids=[10, 15],
26 ),
27]
28fig0 = Fig(fields2D)
29
30
31def z(v):
32 r = v.data["PART_X1"]
33 theta = v.data["PART_X2"]
34 return r * np.cos(theta)
35
36
37parts_quantities = [
38 PartQuantity(
39 "PART_X1",
40 "PART_X1",
41 uids="all",
42 plot_coords=[0, 0],
43 ),
44 PartQuantity(
45 "PART_X2",
46 "PART_X2",
47 uids="all",
48 plot_coords=[0, 1],
49 ),
50 PartQuantity("z", "z", uids="all", plot_coords=[0, 2], compute=z),
51]
52fig1 = Fig(parts_quantities)
53
54
55# Initialize context
56runContext = RunContext(task, projectPath, configPath=configPath)
57
58if __name__ == "__main__":
59 pipeline = Pipeline(runContext, [fig0, fig1])
60 pipeline.run()
multipart_2D_fig0.mp4 |
multipart_2D_fig1.png¶ |