omgkit 2.12.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -12
- package/package.json +2 -2
- package/plugin/agents/api-designer.md +5 -0
- package/plugin/agents/architect.md +8 -0
- package/plugin/agents/brainstormer.md +4 -0
- package/plugin/agents/cicd-manager.md +6 -0
- package/plugin/agents/code-reviewer.md +6 -0
- package/plugin/agents/copywriter.md +2 -0
- package/plugin/agents/data-engineer.md +255 -0
- package/plugin/agents/database-admin.md +10 -0
- package/plugin/agents/debugger.md +10 -0
- package/plugin/agents/devsecops.md +314 -0
- package/plugin/agents/docs-manager.md +4 -0
- package/plugin/agents/domain-decomposer.md +181 -0
- package/plugin/agents/embedded-systems.md +397 -0
- package/plugin/agents/fullstack-developer.md +12 -0
- package/plugin/agents/game-systems-designer.md +375 -0
- package/plugin/agents/git-manager.md +10 -0
- package/plugin/agents/journal-writer.md +2 -0
- package/plugin/agents/ml-engineer.md +284 -0
- package/plugin/agents/observability-engineer.md +353 -0
- package/plugin/agents/oracle.md +9 -0
- package/plugin/agents/performance-engineer.md +290 -0
- package/plugin/agents/pipeline-architect.md +6 -0
- package/plugin/agents/planner.md +12 -0
- package/plugin/agents/platform-engineer.md +325 -0
- package/plugin/agents/project-manager.md +3 -0
- package/plugin/agents/researcher.md +5 -0
- package/plugin/agents/scientific-computing.md +426 -0
- package/plugin/agents/scout.md +3 -0
- package/plugin/agents/security-auditor.md +7 -0
- package/plugin/agents/sprint-master.md +17 -0
- package/plugin/agents/tester.md +10 -0
- package/plugin/agents/ui-ux-designer.md +12 -0
- package/plugin/agents/vulnerability-scanner.md +6 -0
- package/plugin/commands/data/pipeline.md +47 -0
- package/plugin/commands/data/quality.md +49 -0
- package/plugin/commands/domain/analyze.md +34 -0
- package/plugin/commands/domain/map.md +41 -0
- package/plugin/commands/game/balance.md +56 -0
- package/plugin/commands/game/optimize.md +62 -0
- package/plugin/commands/iot/provision.md +58 -0
- package/plugin/commands/ml/evaluate.md +47 -0
- package/plugin/commands/ml/train.md +48 -0
- package/plugin/commands/perf/benchmark.md +54 -0
- package/plugin/commands/perf/profile.md +49 -0
- package/plugin/commands/platform/blueprint.md +56 -0
- package/plugin/commands/security/audit.md +54 -0
- package/plugin/commands/security/scan.md +55 -0
- package/plugin/commands/sre/dashboard.md +53 -0
- package/plugin/registry.yaml +711 -0
- package/plugin/skills/ai-ml/experiment-tracking/SKILL.md +338 -0
- package/plugin/skills/ai-ml/feature-stores/SKILL.md +340 -0
- package/plugin/skills/ai-ml/llm-ops/SKILL.md +454 -0
- package/plugin/skills/ai-ml/ml-pipelines/SKILL.md +390 -0
- package/plugin/skills/ai-ml/model-monitoring/SKILL.md +398 -0
- package/plugin/skills/ai-ml/model-serving/SKILL.md +386 -0
- package/plugin/skills/event-driven/cqrs-patterns/SKILL.md +348 -0
- package/plugin/skills/event-driven/event-sourcing/SKILL.md +334 -0
- package/plugin/skills/event-driven/kafka-deep/SKILL.md +252 -0
- package/plugin/skills/event-driven/saga-orchestration/SKILL.md +335 -0
- package/plugin/skills/event-driven/schema-registry/SKILL.md +328 -0
- package/plugin/skills/event-driven/stream-processing/SKILL.md +313 -0
- package/plugin/skills/game/game-audio/SKILL.md +446 -0
- package/plugin/skills/game/game-networking/SKILL.md +490 -0
- package/plugin/skills/game/godot-patterns/SKILL.md +413 -0
- package/plugin/skills/game/shader-programming/SKILL.md +492 -0
- package/plugin/skills/game/unity-patterns/SKILL.md +488 -0
- package/plugin/skills/iot/device-provisioning/SKILL.md +405 -0
- package/plugin/skills/iot/edge-computing/SKILL.md +369 -0
- package/plugin/skills/iot/industrial-protocols/SKILL.md +438 -0
- package/plugin/skills/iot/mqtt-deep/SKILL.md +418 -0
- package/plugin/skills/iot/ota-updates/SKILL.md +426 -0
- package/plugin/skills/microservices/api-gateway-patterns/SKILL.md +201 -0
- package/plugin/skills/microservices/circuit-breaker-patterns/SKILL.md +246 -0
- package/plugin/skills/microservices/contract-testing/SKILL.md +284 -0
- package/plugin/skills/microservices/distributed-tracing/SKILL.md +246 -0
- package/plugin/skills/microservices/service-discovery/SKILL.md +304 -0
- package/plugin/skills/microservices/service-mesh/SKILL.md +181 -0
- package/plugin/skills/mobile-advanced/mobile-ci-cd/SKILL.md +407 -0
- package/plugin/skills/mobile-advanced/mobile-security/SKILL.md +403 -0
- package/plugin/skills/mobile-advanced/offline-first/SKILL.md +473 -0
- package/plugin/skills/mobile-advanced/push-notifications/SKILL.md +494 -0
- package/plugin/skills/mobile-advanced/react-native-deep/SKILL.md +374 -0
- package/plugin/skills/simulation/numerical-methods/SKILL.md +434 -0
- package/plugin/skills/simulation/parallel-computing/SKILL.md +382 -0
- package/plugin/skills/simulation/physics-engines/SKILL.md +377 -0
- package/plugin/skills/simulation/validation-verification/SKILL.md +479 -0
- package/plugin/skills/simulation/visualization-scientific/SKILL.md +365 -0
- package/plugin/templates/autonomous/archetypes/event-driven-app.yaml +460 -0
- package/plugin/templates/autonomous/archetypes/microservices-app.yaml +431 -0
- package/plugin/templates/autonomous/state-schema.yaml +1 -1
- package/plugin/workflows/ai-engineering/agent-development.md +3 -3
- package/plugin/workflows/ai-engineering/fine-tuning.md +3 -3
- package/plugin/workflows/ai-engineering/model-evaluation.md +3 -3
- package/plugin/workflows/ai-engineering/prompt-engineering.md +2 -2
- package/plugin/workflows/ai-engineering/rag-development.md +4 -4
- package/plugin/workflows/ai-ml/data-pipeline.md +188 -0
- package/plugin/workflows/ai-ml/experiment-cycle.md +203 -0
- package/plugin/workflows/ai-ml/feature-engineering.md +208 -0
- package/plugin/workflows/ai-ml/model-deployment.md +199 -0
- package/plugin/workflows/ai-ml/monitoring-setup.md +227 -0
- package/plugin/workflows/api/api-design.md +1 -1
- package/plugin/workflows/api/api-testing.md +2 -2
- package/plugin/workflows/content/technical-docs.md +1 -1
- package/plugin/workflows/database/migration.md +1 -1
- package/plugin/workflows/database/optimization.md +1 -1
- package/plugin/workflows/database/schema-design.md +3 -3
- package/plugin/workflows/development/bug-fix.md +3 -3
- package/plugin/workflows/development/code-review.md +2 -1
- package/plugin/workflows/development/feature.md +3 -3
- package/plugin/workflows/development/refactor.md +2 -2
- package/plugin/workflows/event-driven/consumer-groups.md +190 -0
- package/plugin/workflows/event-driven/event-storming.md +172 -0
- package/plugin/workflows/event-driven/replay-testing.md +186 -0
- package/plugin/workflows/event-driven/saga-implementation.md +206 -0
- package/plugin/workflows/event-driven/schema-evolution.md +173 -0
- package/plugin/workflows/fullstack/authentication.md +4 -4
- package/plugin/workflows/fullstack/full-feature.md +4 -4
- package/plugin/workflows/game-dev/content-pipeline.md +218 -0
- package/plugin/workflows/game-dev/platform-submission.md +263 -0
- package/plugin/workflows/game-dev/playtesting.md +237 -0
- package/plugin/workflows/game-dev/prototype-to-production.md +205 -0
- package/plugin/workflows/microservices/contract-first.md +151 -0
- package/plugin/workflows/microservices/distributed-tracing.md +166 -0
- package/plugin/workflows/microservices/domain-decomposition.md +123 -0
- package/plugin/workflows/microservices/integration-testing.md +149 -0
- package/plugin/workflows/microservices/service-mesh-setup.md +153 -0
- package/plugin/workflows/microservices/service-scaffolding.md +151 -0
- package/plugin/workflows/omega/1000x-innovation.md +2 -2
- package/plugin/workflows/omega/100x-architecture.md +2 -2
- package/plugin/workflows/omega/10x-improvement.md +2 -2
- package/plugin/workflows/quality/performance-optimization.md +2 -2
- package/plugin/workflows/research/best-practices.md +1 -1
- package/plugin/workflows/research/technology-research.md +1 -1
- package/plugin/workflows/security/penetration-testing.md +3 -3
- package/plugin/workflows/security/security-audit.md +3 -3
- package/plugin/workflows/sprint/sprint-execution.md +2 -2
- package/plugin/workflows/sprint/sprint-retrospective.md +1 -1
- package/plugin/workflows/sprint/sprint-setup.md +1 -1
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# Scientific Visualization
|
|
2
|
+
|
|
3
|
+
Data visualization for scientific computing including 2D/3D plotting, volume rendering, and interactive visualization.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Scientific visualization transforms complex numerical data into visual representations for analysis, understanding, and communication.
|
|
8
|
+
|
|
9
|
+
## Core Concepts
|
|
10
|
+
|
|
11
|
+
### Visualization Types
|
|
12
|
+
- **Scalar Fields**: Contours, heatmaps, isosurfaces
|
|
13
|
+
- **Vector Fields**: Streamlines, quiver plots, glyphs
|
|
14
|
+
- **Volume Data**: Volume rendering, slicing
|
|
15
|
+
- **Time Series**: Animation, temporal plots
|
|
16
|
+
|
|
17
|
+
### Visualization Pipeline
|
|
18
|
+
```
|
|
19
|
+
Data → Filter → Map → Render → Display
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Matplotlib (2D)
|
|
23
|
+
|
|
24
|
+
### Publication-Quality Plots
|
|
25
|
+
```python
|
|
26
|
+
import matplotlib.pyplot as plt
|
|
27
|
+
import numpy as np
|
|
28
|
+
from matplotlib.colors import Normalize
|
|
29
|
+
from matplotlib.cm import ScalarMappable
|
|
30
|
+
|
|
31
|
+
def setup_publication_style():
|
|
32
|
+
"""Configure matplotlib for publication"""
|
|
33
|
+
plt.rcParams.update({
|
|
34
|
+
'font.family': 'serif',
|
|
35
|
+
'font.serif': ['Times New Roman'],
|
|
36
|
+
'font.size': 10,
|
|
37
|
+
'axes.labelsize': 12,
|
|
38
|
+
'axes.titlesize': 12,
|
|
39
|
+
'xtick.labelsize': 10,
|
|
40
|
+
'ytick.labelsize': 10,
|
|
41
|
+
'legend.fontsize': 10,
|
|
42
|
+
'figure.figsize': (6.4, 4.8),
|
|
43
|
+
'figure.dpi': 300,
|
|
44
|
+
'savefig.dpi': 300,
|
|
45
|
+
'savefig.bbox': 'tight',
|
|
46
|
+
'axes.grid': True,
|
|
47
|
+
'grid.alpha': 0.3,
|
|
48
|
+
'lines.linewidth': 1.5,
|
|
49
|
+
'axes.linewidth': 0.8
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
def create_multi_panel_figure():
|
|
53
|
+
"""Create publication multi-panel figure"""
|
|
54
|
+
fig, axes = plt.subplots(2, 2, figsize=(10, 8))
|
|
55
|
+
|
|
56
|
+
# Panel labels
|
|
57
|
+
labels = ['(a)', '(b)', '(c)', '(d)']
|
|
58
|
+
|
|
59
|
+
for ax, label in zip(axes.flat, labels):
|
|
60
|
+
ax.text(-0.1, 1.05, label, transform=ax.transAxes,
|
|
61
|
+
fontsize=14, fontweight='bold', va='top')
|
|
62
|
+
|
|
63
|
+
plt.tight_layout()
|
|
64
|
+
return fig, axes
|
|
65
|
+
|
|
66
|
+
def plot_with_uncertainty(ax, x, y, y_err, label='Data'):
|
|
67
|
+
"""Plot with shaded uncertainty region"""
|
|
68
|
+
line, = ax.plot(x, y, label=label)
|
|
69
|
+
ax.fill_between(x, y - y_err, y + y_err, alpha=0.3, color=line.get_color())
|
|
70
|
+
return line
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Contour and Heatmaps
|
|
74
|
+
```python
|
|
75
|
+
def plot_scalar_field(data, x, y, title='Scalar Field'):
|
|
76
|
+
"""Plot 2D scalar field with contours"""
|
|
77
|
+
fig, ax = plt.subplots(figsize=(8, 6))
|
|
78
|
+
|
|
79
|
+
# Filled contours
|
|
80
|
+
levels = np.linspace(data.min(), data.max(), 20)
|
|
81
|
+
cf = ax.contourf(x, y, data, levels=levels, cmap='viridis')
|
|
82
|
+
|
|
83
|
+
# Contour lines
|
|
84
|
+
cs = ax.contour(x, y, data, levels=levels[::2], colors='white',
|
|
85
|
+
linewidths=0.5, alpha=0.5)
|
|
86
|
+
ax.clabel(cs, inline=True, fontsize=8, fmt='%.2f')
|
|
87
|
+
|
|
88
|
+
# Colorbar
|
|
89
|
+
cbar = plt.colorbar(cf, ax=ax, label='Value', shrink=0.8)
|
|
90
|
+
|
|
91
|
+
ax.set_xlabel('X')
|
|
92
|
+
ax.set_ylabel('Y')
|
|
93
|
+
ax.set_title(title)
|
|
94
|
+
ax.set_aspect('equal')
|
|
95
|
+
|
|
96
|
+
return fig
|
|
97
|
+
|
|
98
|
+
def plot_vector_field(ax, x, y, u, v, skip=5):
|
|
99
|
+
"""Plot 2D vector field"""
|
|
100
|
+
# Downsample for clarity
|
|
101
|
+
magnitude = np.sqrt(u**2 + v**2)
|
|
102
|
+
|
|
103
|
+
# Quiver plot
|
|
104
|
+
q = ax.quiver(x[::skip, ::skip], y[::skip, ::skip],
|
|
105
|
+
u[::skip, ::skip], v[::skip, ::skip],
|
|
106
|
+
magnitude[::skip, ::skip],
|
|
107
|
+
cmap='coolwarm', scale=50)
|
|
108
|
+
|
|
109
|
+
plt.colorbar(q, ax=ax, label='Magnitude')
|
|
110
|
+
|
|
111
|
+
# Streamlines
|
|
112
|
+
ax.streamplot(x, y, u, v, density=1.5, color='gray',
|
|
113
|
+
linewidth=0.5, arrowsize=0.5)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## PyVista (3D)
|
|
117
|
+
|
|
118
|
+
### 3D Surface and Volume
|
|
119
|
+
```python
|
|
120
|
+
import pyvista as pv
|
|
121
|
+
import numpy as np
|
|
122
|
+
|
|
123
|
+
def plot_3d_surface(data, x, y, z):
|
|
124
|
+
"""Plot 3D surface"""
|
|
125
|
+
# Create structured grid
|
|
126
|
+
grid = pv.StructuredGrid(x, y, z)
|
|
127
|
+
grid['values'] = data.flatten(order='F')
|
|
128
|
+
|
|
129
|
+
# Create plotter
|
|
130
|
+
plotter = pv.Plotter()
|
|
131
|
+
plotter.add_mesh(grid, scalars='values', cmap='viridis',
|
|
132
|
+
show_edges=False, opacity=0.8)
|
|
133
|
+
plotter.add_scalar_bar('Value')
|
|
134
|
+
plotter.show_axes()
|
|
135
|
+
|
|
136
|
+
return plotter
|
|
137
|
+
|
|
138
|
+
def plot_isosurface(data, spacing=(1, 1, 1), isovalues=None):
|
|
139
|
+
"""Plot isosurfaces from volume data"""
|
|
140
|
+
# Create uniform grid
|
|
141
|
+
grid = pv.UniformGrid()
|
|
142
|
+
grid.dimensions = np.array(data.shape) + 1
|
|
143
|
+
grid.spacing = spacing
|
|
144
|
+
grid.cell_data['values'] = data.flatten(order='F')
|
|
145
|
+
|
|
146
|
+
# Generate isosurfaces
|
|
147
|
+
if isovalues is None:
|
|
148
|
+
isovalues = np.linspace(data.min(), data.max(), 5)[1:-1]
|
|
149
|
+
|
|
150
|
+
plotter = pv.Plotter()
|
|
151
|
+
|
|
152
|
+
for i, iso in enumerate(isovalues):
|
|
153
|
+
contour = grid.contour([iso])
|
|
154
|
+
opacity = 0.3 + 0.4 * (i / len(isovalues))
|
|
155
|
+
plotter.add_mesh(contour, opacity=opacity, label=f'iso={iso:.2f}')
|
|
156
|
+
|
|
157
|
+
plotter.add_legend()
|
|
158
|
+
return plotter
|
|
159
|
+
|
|
160
|
+
def volume_rendering(data, spacing=(1, 1, 1)):
|
|
161
|
+
"""Direct volume rendering"""
|
|
162
|
+
grid = pv.UniformGrid()
|
|
163
|
+
grid.dimensions = np.array(data.shape) + 1
|
|
164
|
+
grid.spacing = spacing
|
|
165
|
+
grid.cell_data['values'] = data.flatten(order='F')
|
|
166
|
+
|
|
167
|
+
plotter = pv.Plotter()
|
|
168
|
+
plotter.add_volume(grid, scalars='values', cmap='viridis',
|
|
169
|
+
opacity='sigmoid', shade=True)
|
|
170
|
+
|
|
171
|
+
return plotter
|
|
172
|
+
|
|
173
|
+
def plot_streamlines_3d(velocity_field, seed_points):
|
|
174
|
+
"""3D streamline visualization"""
|
|
175
|
+
# Create vector field grid
|
|
176
|
+
grid = pv.RectilinearGrid(x, y, z)
|
|
177
|
+
grid['velocity'] = np.column_stack([
|
|
178
|
+
velocity_field[0].flatten(order='F'),
|
|
179
|
+
velocity_field[1].flatten(order='F'),
|
|
180
|
+
velocity_field[2].flatten(order='F')
|
|
181
|
+
])
|
|
182
|
+
|
|
183
|
+
# Generate streamlines
|
|
184
|
+
streamlines = grid.streamlines(
|
|
185
|
+
vectors='velocity',
|
|
186
|
+
source_center=seed_points.mean(axis=0),
|
|
187
|
+
source_radius=1.0,
|
|
188
|
+
n_points=100,
|
|
189
|
+
max_time=100
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
plotter = pv.Plotter()
|
|
193
|
+
plotter.add_mesh(streamlines.tube(radius=0.05), cmap='rainbow')
|
|
194
|
+
plotter.add_mesh(grid.outline(), color='black')
|
|
195
|
+
|
|
196
|
+
return plotter
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Plotly (Interactive)
|
|
200
|
+
|
|
201
|
+
### Interactive 3D Plots
|
|
202
|
+
```python
|
|
203
|
+
import plotly.graph_objects as go
|
|
204
|
+
import plotly.express as px
|
|
205
|
+
import numpy as np
|
|
206
|
+
|
|
207
|
+
def interactive_surface(x, y, z):
|
|
208
|
+
"""Create interactive 3D surface"""
|
|
209
|
+
fig = go.Figure(data=[go.Surface(
|
|
210
|
+
x=x, y=y, z=z,
|
|
211
|
+
colorscale='Viridis',
|
|
212
|
+
colorbar=dict(title='Value')
|
|
213
|
+
)])
|
|
214
|
+
|
|
215
|
+
fig.update_layout(
|
|
216
|
+
title='Interactive Surface',
|
|
217
|
+
scene=dict(
|
|
218
|
+
xaxis_title='X',
|
|
219
|
+
yaxis_title='Y',
|
|
220
|
+
zaxis_title='Z'
|
|
221
|
+
),
|
|
222
|
+
width=800,
|
|
223
|
+
height=600
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
return fig
|
|
227
|
+
|
|
228
|
+
def animated_time_series(data_sequence, times):
|
|
229
|
+
"""Create animated visualization of time-evolving data"""
|
|
230
|
+
frames = []
|
|
231
|
+
|
|
232
|
+
for i, (data, t) in enumerate(zip(data_sequence, times)):
|
|
233
|
+
frames.append(go.Frame(
|
|
234
|
+
data=[go.Heatmap(z=data, colorscale='Viridis')],
|
|
235
|
+
name=str(i),
|
|
236
|
+
layout=go.Layout(title=f't = {t:.2f}')
|
|
237
|
+
))
|
|
238
|
+
|
|
239
|
+
fig = go.Figure(
|
|
240
|
+
data=[go.Heatmap(z=data_sequence[0], colorscale='Viridis')],
|
|
241
|
+
frames=frames
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
fig.update_layout(
|
|
245
|
+
updatemenus=[{
|
|
246
|
+
'type': 'buttons',
|
|
247
|
+
'showactive': False,
|
|
248
|
+
'buttons': [
|
|
249
|
+
{'label': 'Play', 'method': 'animate',
|
|
250
|
+
'args': [None, {'frame': {'duration': 100}}]},
|
|
251
|
+
{'label': 'Pause', 'method': 'animate',
|
|
252
|
+
'args': [[None], {'frame': {'duration': 0}, 'mode': 'immediate'}]}
|
|
253
|
+
]
|
|
254
|
+
}],
|
|
255
|
+
sliders=[{
|
|
256
|
+
'currentvalue': {'prefix': 'Frame: '},
|
|
257
|
+
'steps': [{'args': [[f.name], {'frame': {'duration': 0}}],
|
|
258
|
+
'label': str(i), 'method': 'animate'}
|
|
259
|
+
for i, f in enumerate(frames)]
|
|
260
|
+
}]
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
return fig
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## VTK (Advanced)
|
|
267
|
+
|
|
268
|
+
### Custom VTK Pipeline
|
|
269
|
+
```python
|
|
270
|
+
import vtk
|
|
271
|
+
import numpy as np
|
|
272
|
+
|
|
273
|
+
def create_vtk_visualization(data, spacing=(1, 1, 1)):
|
|
274
|
+
"""Create VTK visualization pipeline"""
|
|
275
|
+
# Create image data
|
|
276
|
+
image_data = vtk.vtkImageData()
|
|
277
|
+
image_data.SetDimensions(*data.shape)
|
|
278
|
+
image_data.SetSpacing(*spacing)
|
|
279
|
+
|
|
280
|
+
# Convert numpy to VTK
|
|
281
|
+
vtk_array = vtk.vtkFloatArray()
|
|
282
|
+
vtk_array.SetNumberOfComponents(1)
|
|
283
|
+
vtk_array.SetName('values')
|
|
284
|
+
vtk_array.SetArray(data.flatten(order='F'), data.size, True)
|
|
285
|
+
image_data.GetPointData().SetScalars(vtk_array)
|
|
286
|
+
|
|
287
|
+
# Volume mapper
|
|
288
|
+
volume_mapper = vtk.vtkSmartVolumeMapper()
|
|
289
|
+
volume_mapper.SetInputData(image_data)
|
|
290
|
+
|
|
291
|
+
# Transfer functions
|
|
292
|
+
color_func = vtk.vtkColorTransferFunction()
|
|
293
|
+
color_func.AddRGBPoint(data.min(), 0.0, 0.0, 1.0)
|
|
294
|
+
color_func.AddRGBPoint(data.mean(), 0.0, 1.0, 0.0)
|
|
295
|
+
color_func.AddRGBPoint(data.max(), 1.0, 0.0, 0.0)
|
|
296
|
+
|
|
297
|
+
opacity_func = vtk.vtkPiecewiseFunction()
|
|
298
|
+
opacity_func.AddPoint(data.min(), 0.0)
|
|
299
|
+
opacity_func.AddPoint(data.max(), 1.0)
|
|
300
|
+
|
|
301
|
+
# Volume property
|
|
302
|
+
volume_property = vtk.vtkVolumeProperty()
|
|
303
|
+
volume_property.SetColor(color_func)
|
|
304
|
+
volume_property.SetScalarOpacity(opacity_func)
|
|
305
|
+
volume_property.SetInterpolationTypeToLinear()
|
|
306
|
+
volume_property.ShadeOn()
|
|
307
|
+
|
|
308
|
+
# Volume actor
|
|
309
|
+
volume = vtk.vtkVolume()
|
|
310
|
+
volume.SetMapper(volume_mapper)
|
|
311
|
+
volume.SetProperty(volume_property)
|
|
312
|
+
|
|
313
|
+
# Renderer
|
|
314
|
+
renderer = vtk.vtkRenderer()
|
|
315
|
+
renderer.AddVolume(volume)
|
|
316
|
+
renderer.SetBackground(0.1, 0.1, 0.1)
|
|
317
|
+
|
|
318
|
+
# Render window
|
|
319
|
+
render_window = vtk.vtkRenderWindow()
|
|
320
|
+
render_window.AddRenderer(renderer)
|
|
321
|
+
render_window.SetSize(800, 600)
|
|
322
|
+
|
|
323
|
+
return render_window
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Best Practices
|
|
327
|
+
|
|
328
|
+
1. **Choose Appropriate Colormap**: Sequential, diverging, categorical
|
|
329
|
+
2. **Label Everything**: Axes, colorbars, units
|
|
330
|
+
3. **Maintain Aspect Ratio**: For physical data
|
|
331
|
+
4. **Use Perceptually Uniform Colormaps**: viridis, plasma
|
|
332
|
+
5. **Export Vector Graphics**: PDF, SVG for publications
|
|
333
|
+
|
|
334
|
+
## Visualization Selection Guide
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
2D Scalar: Heatmap, Contour
|
|
338
|
+
2D Vector: Quiver, Streamlines
|
|
339
|
+
3D Scalar: Isosurface, Volume Render
|
|
340
|
+
3D Vector: 3D Streamlines, Glyphs
|
|
341
|
+
Time Series: Animation, Small Multiples
|
|
342
|
+
Large Data: Downsampling, LOD
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Anti-Patterns
|
|
346
|
+
|
|
347
|
+
- Rainbow colormaps for sequential data
|
|
348
|
+
- Missing labels/units
|
|
349
|
+
- Overcrowded plots
|
|
350
|
+
- Poor color contrast
|
|
351
|
+
- Ignoring colorblind accessibility
|
|
352
|
+
|
|
353
|
+
## When to Use
|
|
354
|
+
|
|
355
|
+
- Data analysis
|
|
356
|
+
- Publication figures
|
|
357
|
+
- Presentations
|
|
358
|
+
- Interactive exploration
|
|
359
|
+
- Result validation
|
|
360
|
+
|
|
361
|
+
## When NOT to Use
|
|
362
|
+
|
|
363
|
+
- Simple tables sufficient
|
|
364
|
+
- Extremely large datasets (specialize)
|
|
365
|
+
- Real-time requirements (use game engines)
|