|
43 | 43 | photon/ ← raw HDF5 (photon) |
44 | 44 | atomic/ ← raw HDF5 (atomic) |
45 | 45 | mcdc/ |
46 | | - electron/ ← MCDC HDF5 (electron) |
47 | | - photon/ ← MCDC HDF5 (photon) |
48 | | - atomic/ ← MCDC HDF5 (atomic) |
| 46 | + H.h5 ← combined MCDC (electron + photon + atomic) |
| 47 | + He.h5 |
| 48 | + ... |
49 | 49 | """ |
50 | 50 |
|
51 | 51 | from __future__ import annotations |
@@ -189,52 +189,74 @@ def cmd_raw(args): |
189 | 189 |
|
190 | 190 |
|
191 | 191 | def cmd_mcdc(args): |
192 | | - """Create MCDC-format HDF5 files from ENDF sources.""" |
193 | | - from pyepics.converters.hdf5 import create_mcdc_hdf5 |
| 192 | + """Create combined MCDC-format HDF5 files (one per element). |
| 193 | +
|
| 194 | + Each output file contains ``electron_reactions``, |
| 195 | + ``photon_reactions``, and ``atomic_relaxation`` groups — whichever |
| 196 | + ENDF sources are available for that element. |
| 197 | + """ |
| 198 | + from pyepics.converters.hdf5 import create_combined_mcdc_hdf5 |
194 | 199 |
|
195 | 200 | base = Path(args.data_dir) |
196 | | - libraries = args.libraries or list(LIBRARY_CONFIG.keys()) |
197 | 201 | z_min, z_max = args.z_min, args.z_max |
198 | 202 |
|
199 | | - total_ok = 0 |
200 | | - total_fail = 0 |
| 203 | + mcdc_dir = base / "data/mcdc" |
| 204 | + mcdc_dir.mkdir(parents=True, exist_ok=True) |
201 | 205 |
|
202 | | - for lib_name in libraries: |
203 | | - cfg = LIBRARY_CONFIG[lib_name] |
204 | | - endf_dir = base / cfg["endf_dir"] |
205 | | - mcdc_dir = base / cfg["mcdc_dir"] |
206 | | - mcdc_dir.mkdir(parents=True, exist_ok=True) |
| 206 | + # ENDF directories |
| 207 | + eedl_dir = base / LIBRARY_CONFIG["electron"]["endf_dir"] |
| 208 | + epdl_dir = base / LIBRARY_CONFIG["photon"]["endf_dir"] |
| 209 | + eadl_dir = base / LIBRARY_CONFIG["atomic"]["endf_dir"] |
207 | 210 |
|
208 | | - print(f"\n{'=' * 60}") |
209 | | - print(f" Creating MCDC HDF5: {lib_name} ({cfg['dataset_type']})") |
210 | | - print(f" ENDF source: {endf_dir}") |
211 | | - print(f" Output: {mcdc_dir}") |
212 | | - print(f" Z range: {z_min}–{z_max}") |
213 | | - print(f"{'=' * 60}") |
| 211 | + print(f"\n{'=' * 60}") |
| 212 | + print(f" Creating combined MCDC HDF5 files") |
| 213 | + print(f" Output: {mcdc_dir}") |
| 214 | + print(f" Z range: {z_min}–{z_max}") |
| 215 | + print(f"{'=' * 60}") |
214 | 216 |
|
215 | | - for Z in range(z_min, z_max + 1): |
216 | | - sym = _element_symbol(Z) |
217 | | - endf_file = _find_endf_file(endf_dir, cfg["endf_prefix"], Z) |
218 | | - if endf_file is None: |
219 | | - continue |
| 217 | + total_ok = 0 |
| 218 | + total_fail = 0 |
220 | 219 |
|
221 | | - out_path = mcdc_dir / f"{sym}.h5" |
222 | | - print(f" Z={Z:3d} ({sym:>2s}): {endf_file.name} -> {out_path.name}", end=" ... ", flush=True) |
| 220 | + for Z in range(z_min, z_max + 1): |
| 221 | + sym = _element_symbol(Z) |
| 222 | + eedl_file = _find_endf_file(eedl_dir, "EEDL", Z) |
| 223 | + epdl_file = _find_endf_file(epdl_dir, "EPDL", Z) |
| 224 | + eadl_file = _find_endf_file(eadl_dir, "EADL", Z) |
| 225 | + |
| 226 | + if not any([eedl_file, epdl_file, eadl_file]): |
| 227 | + continue |
| 228 | + |
| 229 | + libs = [] |
| 230 | + if eedl_file: |
| 231 | + libs.append("EEDL") |
| 232 | + if epdl_file: |
| 233 | + libs.append("EPDL") |
| 234 | + if eadl_file: |
| 235 | + libs.append("EADL") |
| 236 | + |
| 237 | + out_path = mcdc_dir / f"{sym}.h5" |
| 238 | + print( |
| 239 | + f" Z={Z:3d} ({sym:>2s}): {'+'.join(libs)} -> {out_path.name}", |
| 240 | + end=" ... ", |
| 241 | + flush=True, |
| 242 | + ) |
223 | 243 |
|
224 | | - try: |
225 | | - create_mcdc_hdf5( |
226 | | - cfg["dataset_type"], |
227 | | - endf_file, |
228 | | - out_path, |
229 | | - overwrite=args.overwrite, |
230 | | - ) |
231 | | - print("OK") |
232 | | - total_ok += 1 |
233 | | - except Exception as exc: |
234 | | - print(f"FAIL: {exc}") |
235 | | - total_fail += 1 |
236 | | - if not args.continue_on_error: |
237 | | - return 1 |
| 244 | + try: |
| 245 | + create_combined_mcdc_hdf5( |
| 246 | + Z, |
| 247 | + out_path, |
| 248 | + eedl_path=eedl_file, |
| 249 | + epdl_path=epdl_file, |
| 250 | + eadl_path=eadl_file, |
| 251 | + overwrite=args.overwrite, |
| 252 | + ) |
| 253 | + print("OK") |
| 254 | + total_ok += 1 |
| 255 | + except Exception as exc: |
| 256 | + print(f"FAIL: {exc}") |
| 257 | + total_fail += 1 |
| 258 | + if not args.continue_on_error: |
| 259 | + return 1 |
238 | 260 |
|
239 | 261 | print(f"\nMCDC HDF5: {total_ok} OK, {total_fail} failed") |
240 | 262 | return 0 if total_fail == 0 else 1 |
|
0 commit comments