flash-sim 0.0.1__py3-none-any.whl

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.
Files changed (143) hide show
  1. flash/__init__.py +157 -0
  2. flash/_bootstrap.py +35 -0
  3. flash/_core/__init__.py +39 -0
  4. flash/_core/credentials/__init__.py +44 -0
  5. flash/_core/credentials/_config.py +191 -0
  6. flash/_core/credentials/_core.py +277 -0
  7. flash/_core/credentials/_flash_entries.py +83 -0
  8. flash/_core/credentials/_minimal.py +73 -0
  9. flash/_core/credentials/api_keys.py +225 -0
  10. flash/_core/credentials/deepseek.py +187 -0
  11. flash/_core/credentials/flash_ssh.py +472 -0
  12. flash/_core/credentials/gitee.py +220 -0
  13. flash/_core/credentials/manage.py +359 -0
  14. flash/_core/credentials/pypi.py +144 -0
  15. flash/_core/credentials.py +1103 -0
  16. flash/_core/interface.py +90 -0
  17. flash/_core/registry.py +35 -0
  18. flash/_core/schema.py +118 -0
  19. flash/config/__init__.py +105 -0
  20. flash/flash_run/PROCESS.md +435 -0
  21. flash/flash_run/README.md +205 -0
  22. flash/flash_run/__init__.py +25 -0
  23. flash/flash_run/env/README.md +272 -0
  24. flash/flash_run/env/__init__.py +12 -0
  25. flash/flash_run/env/env_manager.py +535 -0
  26. flash/flash_run/env/resource_config.py +650 -0
  27. flash/flash_run/remote/README.md +313 -0
  28. flash/flash_run/remote/__init__.py +20 -0
  29. flash/flash_run/remote/remote_check.py +70 -0
  30. flash/flash_run/remote/remote_deploy.py +792 -0
  31. flash/flash_run/remote/remote_workflow.py +142 -0
  32. flash/flash_run/remote/route_tester.py +465 -0
  33. flash/flash_run/remote/ssh_check.py +107 -0
  34. flash/input_gen/README.md +535 -0
  35. flash/input_gen/__init__.py +170 -0
  36. flash/input_gen/gen_Grid_markRefineDerefine/GEN_GRID_GUIDE.md +68 -0
  37. flash/input_gen/gen_Grid_markRefineDerefine/README.md +327 -0
  38. flash/input_gen/gen_Grid_markRefineDerefine/__init__.py +0 -0
  39. flash/input_gen/gen_Grid_markRefineDerefine/generator.py +567 -0
  40. flash/input_gen/gen_checker/GEN_CHECKER_GUIDE.md +148 -0
  41. flash/input_gen/gen_checker/__init__.py +6 -0
  42. flash/input_gen/gen_checker/checker.py +274 -0
  43. flash/input_gen/gen_checker/ploter/__init__.py +13 -0
  44. flash/input_gen/gen_checker/ploter/density_plotter.py +195 -0
  45. flash/input_gen/gen_checker/ploter/pulse_plotter.py +158 -0
  46. flash/input_gen/gen_checker/ploter/ray_plotter.py +277 -0
  47. flash/input_gen/gen_config/GEN_CONFIG_GUIDE.md +534 -0
  48. flash/input_gen/gen_config/__init__.py +9 -0
  49. flash/input_gen/gen_config/generator.py +205 -0
  50. flash/input_gen/gen_eos_op/GEN_EOS_OP_GUIDE.md +224 -0
  51. flash/input_gen/gen_eos_op/__init__.py +10 -0
  52. flash/input_gen/gen_eos_op/generator.py +481 -0
  53. flash/input_gen/gen_f90/__init__.py +0 -0
  54. flash/input_gen/gen_makefile/GEN_MAKEFILE_GUIDE.md +56 -0
  55. flash/input_gen/gen_makefile/__init__.py +9 -0
  56. flash/input_gen/gen_makefile/generator.py +32 -0
  57. flash/input_gen/gen_newpara/README.md +400 -0
  58. flash/input_gen/gen_newpara/RP_Reference.md +639 -0
  59. flash/input_gen/gen_newpara/__init__.py +19 -0
  60. flash/input_gen/gen_newpara/generator.py +643 -0
  61. flash/input_gen/gen_otherf90s/GEN_OTHER_F90S_GUIDE.md +231 -0
  62. flash/input_gen/gen_otherf90s/__init__.py +0 -0
  63. flash/input_gen/gen_par/GEN_PAR_GUIDE.md +657 -0
  64. flash/input_gen/gen_par/__init__.py +18 -0
  65. flash/input_gen/gen_par/defaults.py +510 -0
  66. flash/input_gen/gen_par/generator.py +445 -0
  67. flash/input_gen/gen_par/materials.py +141 -0
  68. flash/input_gen/gen_shell_script/GEN_SHELL_SCRIPT_GUIDE.md +120 -0
  69. flash/input_gen/gen_shell_script/__init__.py +12 -0
  70. flash/input_gen/gen_shell_script/generator.py +850 -0
  71. flash/input_gen/gen_sim_data/GEN_SIM_DATA_GUIDE.md +306 -0
  72. flash/input_gen/gen_sim_data/__init__.py +10 -0
  73. flash/input_gen/gen_sim_data/generator.py +87 -0
  74. flash/input_gen/gen_sim_init/GEN_SIM_INIT_GUIDE.md +216 -0
  75. flash/input_gen/gen_sim_init/__init__.py +9 -0
  76. flash/input_gen/gen_sim_init/generator.py +104 -0
  77. flash/input_gen/gen_sim_initblock/GEN_SIM_INITBLOCK_GUIDE.md +330 -0
  78. flash/input_gen/gen_sim_initblock/__init__.py +17 -0
  79. flash/input_gen/gen_sim_initblock/generator.py +432 -0
  80. flash/input_gen/gen_sim_initblock/grid.py +278 -0
  81. flash/input_gen/gen_sim_initblock/visualizer.py +250 -0
  82. flash/interface.py +398 -0
  83. flash/output_processors/__init__.py +50 -0
  84. flash/output_processors/conftest.py +41 -0
  85. flash/output_processors/docs/api_reference.md +597 -0
  86. flash/output_processors/docs/how_to_add_custom_variables.md +417 -0
  87. flash/output_processors/docs/output_processors_usage.md +596 -0
  88. flash/output_processors/docs/performance_tuning.md +365 -0
  89. flash/output_processors/docs/workflow.md +101 -0
  90. flash/output_processors/hdf5processor/__init__.py +21 -0
  91. flash/output_processors/hdf5processor/flash_hdf5.py +1224 -0
  92. flash/output_processors/loader/__init__.py +7 -0
  93. flash/output_processors/loader/data_loader.py +392 -0
  94. flash/output_processors/parallel.py +580 -0
  95. flash/output_processors/plotter/__init__.py +8 -0
  96. flash/output_processors/plotter/plot_generator.py +471 -0
  97. flash/output_processors/plotter/plot_style.py +240 -0
  98. flash/physics/ele_nonlocal/Knudsen_Nonlocal_Summary.md +576 -0
  99. flash/projects/__init__.py +0 -0
  100. flash/projects/projects_demo/README.md +94 -0
  101. flash/projects/projects_demo/__init__.py +17 -0
  102. flash/projects/projects_demo/ch_center_demo/__init__.py +16 -0
  103. flash/projects/projects_demo/ch_center_demo/plot_compare.py +169 -0
  104. flash/projects/projects_demo/ch_center_demo/run_compare.py +148 -0
  105. flash/scenarios/README.md +669 -0
  106. flash/scenarios/SNBtest/__init__.py +0 -0
  107. flash/scenarios/__init__.py +18 -0
  108. flash/scenarios/base.py +50 -0
  109. flash/scenarios/center_evolution/__init__.py +2 -0
  110. flash/scenarios/center_evolution/ch_center/__init__.py +361 -0
  111. flash/scenarios/center_evolution/ch_center/laserslab1d_local_custom.py +804 -0
  112. flash/scenarios/collision_compression/__init__.py +38 -0
  113. flash/scenarios/flash_demo/__init__.py +0 -0
  114. flash/scenarios/flash_demo/demo_hpc/__init__.py +0 -0
  115. flash/scenarios/flash_demo/demo_hpc/_plot_utils.py +128 -0
  116. flash/scenarios/flash_demo/demo_hpc/laserslab1d_hpc_demo_batch.py +1035 -0
  117. flash/scenarios/flash_demo/demo_hpc/laserslab1d_supercomputer_demo.py +778 -0
  118. flash/scenarios/flash_demo/demo_hpc/remote_analysis.py +428 -0
  119. flash/scenarios/flash_demo/demo_hpc/remote_plot_script.py +444 -0
  120. flash/scenarios/flash_demo/demo_hpc/remote_ssh_helper.py +457 -0
  121. flash/scenarios/flash_demo/demo_local/__init__.py +0 -0
  122. flash/scenarios/flash_demo/demo_local/laserslab1d_local_demo.py +343 -0
  123. flash/scenarios/flash_demo/hello_flash/README.md +447 -0
  124. flash/scenarios/flash_demo/hello_flash/analyze_density.py +416 -0
  125. flash/scenarios/flash_demo/hello_flash/deploy_flash.py +828 -0
  126. flash/scenarios/interpolator.py +286 -0
  127. flash/scenarios/plasma_preparation/__init__.py +1 -0
  128. flash/scenarios/registry.py +61 -0
  129. flash/scenarios/simulator.py +1045 -0
  130. flash/test/__init__.py +1 -0
  131. flash/test/flash_mathtest_custom01.py +413 -0
  132. flash/test/math_test.py +596 -0
  133. flash/utils/__init__.py +9 -0
  134. flash/utils/check_hdf5_time.py +22 -0
  135. flash/utils/convert_pdf_to_md.py +134 -0
  136. flash/utils/convert_text_to_md.py +102 -0
  137. flash/utils/extract_knowledge.py +200 -0
  138. flash_sim-0.0.1.dist-info/METADATA +811 -0
  139. flash_sim-0.0.1.dist-info/RECORD +143 -0
  140. flash_sim-0.0.1.dist-info/WHEEL +4 -0
  141. flash_sim-0.0.1.dist-info/entry_points.txt +3 -0
  142. flash_sim-0.0.1.dist-info/licenses/LICENSE +386 -0
  143. flash_sim-0.0.1.dist-info/licenses/NOTICE +138 -0
@@ -0,0 +1,365 @@
1
+ # 性能调优指南
2
+
3
+ > 本指南介绍如何优化 `output_processors` 包的性能。
4
+ > 最后更新: 2026-07-04
5
+
6
+ ---
7
+
8
+ ## 目录
9
+
10
+ 1. [性能瓶颈分析](#1-性能瓶颈分析)
11
+ 2. [优化策略](#2-优化策略)
12
+ 3. [内存优化](#3-内存优化)
13
+ 4. [I/O 优化](#4-io-优化)
14
+ 5. [批量处理优化](#5-批量处理优化)
15
+ 6. [性能基准测试](#6-性能基准测试)
16
+ 7. [常见问题](#7-常见问题)
17
+
18
+ ---
19
+
20
+ ## 1. 性能瓶颈分析
21
+
22
+ ### 1.1 典型耗时分布
23
+
24
+ | 操作 | 耗时占比 | 说明 |
25
+ |------|----------|------|
26
+ | HDF5 文件读取 | 40-60% | `h5py` 读取数据集 |
27
+ | AMR 坐标重建 | 20-30% | 计算块坐标网格 |
28
+ | 派生变量计算 | 5-10% | 执行注册的公式 |
29
+ | 数据复制 | 5-10% | 从 HDF5 到 NumPy 数组 |
30
+
31
+ ### 1.2 性能分析工具
32
+
33
+ ```python
34
+ import time
35
+ from output_processors.loader import FlashDataLoader
36
+
37
+ # 手动计时
38
+ loader = FlashDataLoader("file.h5")
39
+
40
+ t0 = time.time()
41
+ container = loader.load(compute_derived=True)
42
+ t1 = time.time()
43
+
44
+ print(f"加载耗时: {t1 - t0:.3f} s")
45
+ print(f" 数据形状: {container.data['dens'].shape}")
46
+ print(f" 变量数: {len(container.data)}")
47
+ print(f" 派生变量数: {len(container.derived)}")
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 2. 优化策略
53
+
54
+ ### 2.1 策略概览
55
+
56
+ | 策略 | 预期加速 | 适用场景 |
57
+ |------|----------|----------|
58
+ | 仅加载需要的变量 | 2-5x | 只需部分变量时 |
59
+ | 禁用派生变量计算 | 1.1-1.5x | 不需要派生变量时 |
60
+ | 批量加载时模式匹配 | 1.2-2x | 文件夹中有非 HDF5 文件时 |
61
+ | 复用 loader 对象 | 1.1x | 多次加载同一文件时 |
62
+
63
+ ---
64
+
65
+ ## 3. 内存优化
66
+
67
+ ### 3.1 仅加载需要的变量
68
+
69
+ 使用 `load_vars()` 方法仅加载指定变量,减少内存占用和加载时间。
70
+
71
+ ```python
72
+ from output_processors.loader import FlashDataLoader
73
+
74
+ # ❌ 不推荐: 加载所有变量
75
+ loader = FlashDataLoader("file.h5")
76
+ container = loader.load(compute_derived=True) # 加载所有变量
77
+
78
+ # ✅ 推荐: 仅加载需要的变量
79
+ container = loader.load_vars("dens", "tele", compute_derived=True)
80
+ ```
81
+
82
+ **性能对比**:
83
+
84
+ | 变量数 | 加载所有变量 | 仅加载 2 个变量 | 加速比 |
85
+ |---------|--------------|------------------|---------|
86
+ | 1D, 44 变量 | 0.5 s | 0.1 s | 5x |
87
+ | 2D, 9 变量 | 1.0 s | 0.3 s | 3.3x |
88
+
89
+ ### 3.2 禁用派生变量计算
90
+
91
+ 如果不需要派生变量,设置 `compute_derived=False`。
92
+
93
+ ```python
94
+ loader = FlashDataLoader("file.h5")
95
+
96
+ # ❌ 不推荐: 计算所有派生变量
97
+ container = loader.load(compute_derived=True)
98
+
99
+ # ✅ 推荐: 不计算派生变量
100
+ container = loader.load(compute_derived=False)
101
+ ```
102
+
103
+ **性能对比**:
104
+
105
+ | 数据 | 计算派生变量 | 不计算派生变量 | 加速比 |
106
+ |------|--------------|------------------|---------|
107
+ | 1D | 0.5 s | 0.4 s | 1.25x |
108
+ | 2D | 1.0 s | 0.9 s | 1.1x |
109
+
110
+ ### 3.3 及时释放内存
111
+
112
+ ```python
113
+ import gc
114
+ from output_processors.loader import FlashDataLoader
115
+
116
+ # 加载并处理单个文件
117
+ loader = FlashDataLoader("file.h5")
118
+ container = loader.load(compute_derived=True)
119
+
120
+ # 处理数据
121
+ result = process_data(container.data["dens"])
122
+
123
+ # 及时删除大对象
124
+ del container
125
+ gc.collect() # 强制垃圾回收
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 4. I/O 优化
131
+
132
+ ### 4.1 避免频繁打开/关闭 HDF5
133
+
134
+ **❌ 不推荐**:
135
+
136
+ ```python
137
+ # 每次提取都打开/关闭 HDF5(慢)
138
+ for varname in ["dens", "tele", "tion"]:
139
+ loader = FlashDataLoader("file.h5")
140
+ container = loader.load_vars(varname)
141
+ # 处理数据
142
+ ```
143
+
144
+ **✅ 推荐**:
145
+
146
+ ```python
147
+ # 复用 FlashDataLoader 对象(快)
148
+ loader = FlashDataLoader("file.h5")
149
+ container = loader.load(compute_derived=False)
150
+
151
+ # 手动计算需要的变量
152
+ for varname in ["dens", "tele", "tion"]:
153
+ data = container.data[varname]
154
+ # 处理数据
155
+ ```
156
+
157
+ ### 4.2 使用 HDF5 文件缓存
158
+
159
+ ```python
160
+ # HDF5 文件对象会自动缓存最近读取的数据集
161
+ # 第二次读取同一变量时会更快
162
+
163
+ loader = FlashDataLoader("file.h5")
164
+ container1 = loader.load_vars("dens") # 第一次读取
165
+
166
+ # 如果文件未关闭,第二次读取会更快
167
+ container2 = loader.load_vars("dens") # 可能更快(取决于 HDF5 库)
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 5. 批量处理优化
173
+
174
+ ### 5.1 使用模式匹配
175
+
176
+ 批量加载时使用 `pattern` 参数过滤文件,避免加载无关文件。
177
+
178
+ ```python
179
+ from output_processors.loader import FlashDataLoader
180
+
181
+ # ❌ 不推荐: 加载所有文件
182
+ containers = FlashDataLoader.load_folder(
183
+ "output_dir/",
184
+ pattern="*", # 加载所有文件
185
+ compute_derived=True
186
+ )
187
+
188
+ # ✅ 推荐: 仅加载 checkpoint 文件
189
+ containers = FlashDataLoader.load_folder(
190
+ "output_dir/",
191
+ pattern="*chk*", # 仅加载 checkpoint 文件
192
+ compute_derived=True
193
+ )
194
+ ```
195
+
196
+ ### 5.2 按需计算派生变量
197
+
198
+ 批量加载时,如果只需要部分文件的派生变量,可以分批处理。
199
+
200
+ ```python
201
+ # 第一步: 加载所有文件,不计算派生变量
202
+ containers = FlashDataLoader.load_folder(
203
+ "output_dir/",
204
+ pattern="*chk*",
205
+ compute_derived=False # 不计算派生变量
206
+ )
207
+
208
+ # 第二步: 仅对需要的文件计算派生变量
209
+ for container in containers:
210
+ if container.simulation_time > 1e-9: # 仅对特定时间的文件计算
211
+ loader = FlashDataLoader(container.filepath)
212
+ container = loader.load(compute_derived=True)
213
+ ```
214
+
215
+ ### 5.3 并行加载多个文件
216
+
217
+ 使用 `concurrent.futures.ProcessPoolExecutor` 并行加载多个文件。
218
+
219
+ ```python
220
+ from concurrent.futures import ProcessPoolExecutor
221
+ from output_processors.loader import FlashDataLoader
222
+
223
+ def load_single(filepath):
224
+ """加载单个文件"""
225
+ loader = FlashDataLoader(filepath)
226
+ return loader.load(compute_derived=True)
227
+
228
+ # 获取文件列表
229
+ import glob
230
+ filepaths = sorted(glob.glob("output_dir/*chk*.h5"))
231
+
232
+ # 并行加载(使用 ProcessPoolExecutor)
233
+ with ProcessPoolExecutor(max_workers=4) as executor:
234
+ containers = list(executor.map(load_single, filepaths))
235
+
236
+ print(f"加载 {len(containers)} 个文件完成")
237
+ ```
238
+
239
+ **性能对比**:
240
+
241
+ | 文件数 | 串行耗时 | 并行耗时 (4 workers) | 加速比 |
242
+ |---------|------------|---------------------|---------|
243
+ | 10 | 5.0 s | 1.5 s | 3.3x |
244
+ | 50 | 25.0 s | 7.0 s | 3.6x |
245
+
246
+ ---
247
+
248
+ ## 6. 性能基准测试
249
+
250
+ ### 6.1 自动化基准测试
251
+
252
+ 创建测试脚本 `test_benchmark.py`:
253
+
254
+ ```python
255
+ import time
256
+ import sys
257
+ sys.path.insert(0, 'path/to/PhySimX')
258
+
259
+ from output_processors.loader import FlashDataLoader
260
+
261
+ def benchmark_load(filepaths, compute_derived=True):
262
+ """基准测试:加载文件"""
263
+ times = []
264
+
265
+ for filepath in filepaths:
266
+ t0 = time.time()
267
+ loader = FlashDataLoader(filepath)
268
+ container = loader.load(compute_derived=compute_derived)
269
+ t1 = time.time()
270
+
271
+ times.append(t1 - t0)
272
+
273
+ return times
274
+
275
+ # 运行基准测试
276
+ filepaths = ["file1.h5", "file2.h5", ...] # 10 个文件
277
+
278
+ # 测试 1: 计算派生变量
279
+ times_with_derived = benchmark_load(filepaths, compute_derived=True)
280
+ print(f"计算派生变量: 平均 {sum(times_with_derived)/len(times_with_derived):.3f} s")
281
+
282
+ # 测试 2: 不计算派生变量
283
+ times_no_derived = benchmark_load(filepaths, compute_derived=False)
284
+ print(f"不计算派生变量: 平均 {sum(times_no_derived)/len(times_no_derived):.3f} s")
285
+ ```
286
+
287
+ ### 6.2 内存使用基准测试
288
+
289
+ ```python
290
+ import psutil
291
+ import os
292
+ from output_processors.loader import FlashDataLoader
293
+
294
+ def measure_memory():
295
+ """测量当前内存使用"""
296
+ process = psutil.Process(os.getpid())
297
+ return process.memory_info().rss / 1024 / 1024 # MB
298
+
299
+ # 加载前
300
+ mem_before = measure_memory()
301
+
302
+ # 加载文件
303
+ loader = FlashDataLoader("file.h5")
304
+ container = loader.load(compute_derived=True)
305
+
306
+ # 加载后
307
+ mem_after = measure_memory()
308
+
309
+ print(f"内存使用: {mem_after - mem_before:.1f} MB")
310
+ ```
311
+
312
+ ---
313
+
314
+ ## 7. 常见问题
315
+
316
+ ### Q1: 为什么加载很慢?
317
+
318
+ **A**: 可能原因:
319
+ 1. HDF5 文件存储在慢速磁盘(如网络文件系统)
320
+ 2. 加载了所有变量(使用 `load_vars()` 仅加载需要的变量)
321
+ 3. 计算了不需要的派生变量(设置 `compute_derived=False`)
322
+
323
+ **解决方案**:
324
+ - 使用 SSD 存储 HDF5 文件
325
+ - 仅加载需要的变量
326
+ - 禁用派生变量计算
327
+
328
+ ### Q2: 内存占用太多怎么办?
329
+
330
+ **A**:
331
+ - 使用 `load_vars()` 仅加载需要的变量
332
+ - 设置 `compute_derived=False` 禁用派生变量计算
333
+ - 及时删除大对象(`del container; gc.collect()`)
334
+ - 逐文件处理,避免批量加载全部数据
335
+
336
+ ### Q3: 如何进一步加速 3D 数据处理?
337
+
338
+ **A**:
339
+ - 仅加载需要的变量(`load_vars()`)
340
+ - 使用并行加载(`ProcessPoolExecutor`)
341
+ - 考虑使用更高效的存储格式(如 Zarr)
342
+
343
+ ### Q4: 为什么第一次加载很慢?
344
+
345
+ **A**: 第一次需要:
346
+ 1. 读取 HDF5 文件(I/O)
347
+ 2. 探测文件结构(`_probe_shape()`)
348
+ 3. 重建坐标网格(`read_grid()`)
349
+
350
+ **解决方案**:
351
+ - 复用 `FlashDataLoader` 对象
352
+ - 批量加载时一次性加载所有文件
353
+
354
+ ---
355
+
356
+ ## 相关文档
357
+
358
+ - 使用说明: `docs/output_processors_usage.md`
359
+ - 自定义变量教程: `docs/how_to_add_custom_variables.md`
360
+ - API 参考手册: `docs/api_reference.md`
361
+
362
+ ---
363
+
364
+ **维护者**: WorkBuddy AI
365
+ **最后更新**: 2026-07-04
@@ -0,0 +1,101 @@
1
+ # 开发者工作流手册
2
+
3
+ > `flash/output_processors` 包的开发、测试与发布工作流。
4
+ > 最后更新: 2026-07-04
5
+
6
+ ---
7
+
8
+ ## 目录
9
+
10
+ 1. [开发环境设置](#1-开发环境设置)
11
+ 2. [测试工作流](#2-测试工作流)
12
+ 3. [h5py yt 风格提取工作流](#3-h5py-yt-风格提取工作流)
13
+ 4. [发布工作流](#4-发布工作流)
14
+
15
+ ---
16
+
17
+ ## 1. 开发环境设置
18
+
19
+ ```bash
20
+ # 安装依赖
21
+ pip install numpy h5py matplotlib pytest
22
+
23
+ # yt 对比需要(开发用)
24
+ pip install yt
25
+
26
+ # 运行测试
27
+ cd flash/output_processors
28
+ pytest test/ -v
29
+ ```
30
+
31
+ ## 2. 测试工作流
32
+
33
+ ### 运行全部测试
34
+ ```bash
35
+ pytest test/ -v --tb=short
36
+ ```
37
+
38
+ ### 运行单个测试
39
+ ```bash
40
+ pytest test/amr_visualization/d1/test_flash_hdf5_vs_yt.py -v
41
+ ```
42
+
43
+ ### 测试配置
44
+ - 配置文件: `pytest.ini`
45
+ - 排除目录: `test/temp_delete/`(已废弃)
46
+ - 测试文件使用晚时间 FLASH 输出文件(AMR 网格更丰富)
47
+
48
+ ## 3. h5py yt 风格提取工作流
49
+
50
+ ### 3.1 核心 API
51
+
52
+ 参考: `docs/api_reference.md` — `extract_var_yt_style()` 章节
53
+
54
+ ### 3.2 精度验证
55
+
56
+ 验证 h5py 提取结果与 yt 的一致性:
57
+
58
+ ```bash
59
+ # 运行对比脚本
60
+ python test/compare_h5py_vs_yt.py
61
+ ```
62
+
63
+ 输出:
64
+ - `outputfiles/test/comparison_1d_h5py_vs_yt.png`
65
+ - `outputfiles/test/comparison_2d_h5py_vs_yt.png`
66
+ - `outputfiles/test/comparison_3d_h5py_vs_yt.png`
67
+ - 控制台输出差异统计摘要
68
+
69
+ ### 3.3 新增坐标系统
70
+
71
+ 步骤:
72
+ 1. 在 `flash_hdf5.py` 的 `coordinate_system` 属性中添加检测分支
73
+ 2. 在 `coord_labels` 属性中添加对应的坐标标签
74
+ 3. 实现 `_extract_yt_Xd()` 私有方法
75
+ 4. 在 `extract_var_yt_style()` 的 `supported_combos` 字典中注册
76
+ 5. 在 `__init__.py` 和 `docs/api_reference.md` 文档中更新
77
+ 6. 运行对比验证:
78
+ ```bash
79
+ python test/compare_h5py_vs_yt.py
80
+ pytest test/ -v
81
+ ```
82
+
83
+ ### 3.4 测试文件选择
84
+
85
+ 测试脚本自动选择目录中最晚时间的 hdf5 文件:
86
+ - `test_1d_extraction` → `lasslab_hdf5_chk_0039`
87
+ - `test_2d_extraction` → `lasslab_hdf5_plt_cnt_0049`
88
+ - `test_3d_extraction` → `lasslab_hdf5_plt_cnt_0020`
89
+
90
+ ## 4. 发布工作流
91
+
92
+ ### 4.1 版本更新
93
+ - 更新 `__init__.py` 中的 `__version__`
94
+ - 更新 `docs/api_reference.md` 的 "最后更新" 日期
95
+ - 生成对比图检查回归
96
+
97
+ ### 4.2 发布检查清单
98
+ - [ ] `pytest test/ -v` 全部通过(27/27)
99
+ - [ ] 对比图无异常
100
+ - [ ] API 文档已更新
101
+ - [ ] 工作流文档已更新
@@ -0,0 +1,21 @@
1
+ """
2
+ hdf5processor — FLASH HDF5 输出文件的核心 I/O 层
3
+
4
+ 负责:
5
+ - 打开/读取 FLASH 的 HDF5 输出文件(checkpoint 和 plot 文件)
6
+ - 自动检测数据的空间维度(1D/2D/3D)
7
+ - 解析 AMR 块结构、边界框、坐标
8
+ - 仿真时间/激光脉冲参数的提取
9
+ - 变量元数据 data_config 注册表
10
+ - 派生变量 data_calculator 计算
11
+ - 全场统计、切片分析
12
+ - 提供物理坐标网格的重建
13
+ """
14
+
15
+ from .flash_hdf5 import (
16
+ FlashHDF5File,
17
+ DataCalculator,
18
+ DATA_CONFIG,
19
+ VAR_ALIASES,
20
+ NA,
21
+ )