Skip to content

Plottable mccode.dat in NeXus scan case - #2619

Open
willend wants to merge 9 commits into
mainfrom
plottable-mccode.dat-in-NeXus
Open

Plottable mccode.dat in NeXus scan case#2619
willend wants to merge 9 commits into
mainfrom
plottable-mccode.dat-in-NeXus

Conversation

@willend

@willend willend commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Free-form text area

Please describe what your PR is adding in terms of features or bugfixes:

  • Generate mccode.dat by fallback parsing of stdout in NeXus mode.
  • Allow plotting mccode.dat without access to any mccode.sim.

Result: Overall behaviour of scan is available in mccode.dat also
in case of single-output mccode.h5 / NeXus.

(All in all a follow-up / extension of #2618)

  • Further added mechanism to skip scan-points in case of rumtime failure, functional both in cases where the sim folder is not created (init-time issues) and when a mccode.sim is written but monitor data not.

  • Cleaned out references to mcstas.sim (McStas 2.x output)

  • Let mcplot (pyqtgraph/matplotlib) spawn both overview plot and NeXus tool if in NeXus + scan mode


Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Furter, please describe how / where and for what the tools were used:

Claude-assisted:

Prompt1:
When running with the standard 'McCode' output format, the mccode.dat file generated in a scan is populated via reading the underlying 0/ 1/ 2/ ... subfolder datasets.

In NeXus output format however, the underlying data are (intentionally) written to a single HDF5 file instead.

In the NeXus case, please parse the Detector: output from underlying simulations directly from stdout of the simulations instead ( + a copy-pasted stdout output from one step within an mcrun scan)

(Rendered result contained both a mccode.sim and mccode.dat in supplement to mccode.h5 - yet not actually functional with mcplot.)

Prompt 2:
Now look at mcplot - and input file parsing for 'scan' data. It would be nice if there was a fallback-mechanism to plot the content of a mccode.dat without access to mccode.sim and all of the underlying detector files. Could you further finally make an adjustment to NOT create mccode.sim (but still mccode.dat) in the case of a 'NeXus' format scan?


Development OS / boundary conditions

Please describe what OS you developed and tested your additions on, and if any special dependencies are required:


PR Checklist for contributing to McStas/McXtrace

For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:

  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist

Allow plotting mccode.dat without access to any mccode.sim.

Result: Overall behaviour of scan is available in mccode.dat also
in case of single-output mccode.h5 / NeXus.
@willend
willend requested a review from farhi August 30, 2026 12:50
@willend

willend commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Test dataset for skip-mechanism (scan "all" cif,lau,laz - some lead to failure)

mcrun -c PSI_DMC.instr --mpi=auto -L -n1e7 --format=NeXus -d Laz_Lau_Cif_scan_NeXus filename=adrenaline.lau,Ag.laz,Al.lau,Al.laz,Al2O3_sapphire.lau,Al2O3_sapphire.laz,alpha_Fe.laz,aspirin.lau,Au.laz,B4C.lau,B4C.laz,Ba.laz,Be.laz,BeO.lau,BeO.laz,Bi.laz,C_diamond.lau,C_graphite.lau,C_graphite.laz,C60.lau,CaF2.lau,Cd.laz,cementite_300K.laz,Cr.laz,Cs.laz,Cu.laz,Cu2MnAl.laz,Fe_Gamma.laz,Fe.laz,Fe2O3.cif,Fe2O3.laz,Fe3O4_mp-19306_computed.cif,Fe3O4_mp-19306_computed.laz,Fe3O4_mp-19306_conventional_standard.cif,Fe3O4.cif,FeOOH.cif,FeOOH.laz,Ga.laz,Gd.laz,Ge.lau,Ge.laz,H2O_ice_1h.laz,He4_hcp.laz,Hg.laz,I2.laz,In.lau,K.laz,leucine.lau,Li.laz,LiF.laz,LiFePO4.lau,Mo.laz,Na2Ca3Al2F14.laz,Nb.laz,Ni.laz,Pb.laz,Pd.laz,Pt.laz,Rb.laz,Se_alpha.laz,Se_beta.laz,Si.laz,SiO2_cristobalite.lau,SiO2_quartza.lau,SiO2_quartza.laz,SiO2_quartzb.lau,SiO2_quartzb.laz,Sn_alpha.laz,Sn_beta.laz,Ti.laz,TiO2_rutile.lau,Tl.laz,UO2.laz,V.lau,V.laz,Y2O3.laz,Y3Fe5O12_YIG.laz,YBaCuO.lau,Zn.laz,Zr.laz

...

Finally [PSI_DMC: Laz_Lau_Cif_scan_NeXus]. Time: 1 [s] 
INFO: Finish running step, get detectors from stdout
INFO: Got detectors
INFO: Write step detectors line into Laz_Lau_Cif_scan_NeXus/mccode.dat
WARNING: 5 of 80 scan point(s) failed or produced no data and were skipped (step indices: 29, 31, 33, 34, 35). Laz_Lau_Cif_scan_NeXus/mccode.dat contains only the 75 successful point(s).
INFO: Placing instr file copy PSI_DMC.instr in dataset Laz_Lau_Cif_scan_NeXus
INFO: Placing generated c-code copy PSI_DMC.c in dataset Laz_Lau_Cif_scan_NeXus
Screenshot 2026-08-30 at 16 42 54 Screenshot 2026-08-30 at 16 42 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant