101 Commits
Author SHA1 Message Date
bartels-rausch 2ec52b7ee7 Add openBIS sync pipeline; fix nappFileList/nappGenerateSpectra/nappPlot bugs; add importData.m ground script
beamtime/nappFileList.m
- Fix h5 LensMode: translate numeric codes to descriptive text (e.g. 1 ->
  T_HiPPHAXPES) to match what .ibw files already store, applied across all
  three h5read fallback branches, not just the oldest-format one

beamtime/nappGenerateSpectra.m
- Bug fixes

beamtime/nappPlot.m
- Bug fixes

import/importData.m (new)
- Ground script for one beamtime: import (nappFileList,
  nappGenerateSpectra), sample/spot and photon-energy assignment per row
  range, campaign metadata (CustomProperties) and column
  descriptions/units set inline, tidy-up, and export to .csv/.mat/.h5
  (via nappExportH5). Leaves FileList in the workspace for PublishReport.m
  and callOpenbisSync.m to run against afterward.

import/nappExportH5.m (new)
- Export FileList + campaign metadata + raw source files to a
  self-contained HDF5 archive
- Low-level HDF5 API (H5F/H5G/H5D/H5A/H5T/H5S/H5P) to fix
  H5FD_truncate/"too many open files" errors from the top-level
  h5create/h5write functions each reopening the file internally
- Explicit rowIndex attribute per row group, since HDF5 group listing
  order isn't guaranteed to match table row order

openBIS/ (new)
- nappSyncToOpenbis.py, callOpenbisSync.m, testpybis.m, README.md
- openBIS sync pipeline: create-or-update per row matched by $name,
  correct lowercase property codes, timestamp formatting, parent linking,
  raw file upload, plot/photo/video thumbnail embedding, config/engine
  split for maintainability -- see README.md for full details
2026-08-31 14:31:39 +02:00
bartels-rausch 0629ece97c Moved docu to new training repro 2026-08-21 17:10:01 +02:00
bartels-rausch 4d6500ba85 some housekeeping to tidy up 2026-08-21 10:28:44 +02:00
bartels-rausch 5b9c7608d7 Data import now works with 2016 data, too. Data tracking added to md file. 2026-08-21 10:18:39 +02:00
bartels-rausch 9c7a6f4705 bug fixes 2026-07-13 15:30:02 +02:00
bartels-rausch 378d176739 Added import and plot for flow data that is now logged for the MFC 2026-07-10 10:08:07 +02:00
bartels-rausch 3ad96b3890 ISS 2.0 ready 2026-07-03 21:54:47 +02:00
bartels-rausch 9d6d271461 Updated comment to nappBackground to make more clear that pos 2 is always cutoff in linear fit 2026-06-01 13:13:43 +02:00
bartels-rausch caec12ce3d NEW: Option to give upper and lower limit for linear background and Shirley offset 2026-06-01 12:03:28 +02:00
bartels-rausch 2f942c554c Several domains within a spectrum can now be excluded in background fitting 2026-05-11 11:45:46 +02:00
bartels-rausch 55f972f6ae bug fixes 2026-05-11 08:55:02 +02:00
bartels-rausch d12594598e Changed selection rule. Now works not only with numbers, but with any text. Character that the name starts with are used to find matches now. 2026-05-09 11:37:36 +02:00
bartels-rausch 43ac9c00bb small bug fixes. CopyShift now works with any filename, not just numbers as before 2026-05-09 07:31:44 +02:00
bartels-rausch d72e8b4ddc Added a model where Shirley and PV eta are shared for peaks with shared width and relative position. This is usefull for adv. Carbon. 2026-05-08 20:43:17 +02:00
bartels-rausch 2a22d2dbea bug fixes 2026-05-04 19:03:39 +02:00
bartels-rausch 5767a2e26d Added to use max intensity from reference spectra as default. using the peak fit area is now an option. 2026-04-10 08:58:19 +02:00
bartels-rausch e5226802a3 Add project dependency tracking system with yEd and PNG export
- Implement @DEP_IN/OUT/RUN tag standard for MATLAB script metadata
- Add buildDependencyGraph.m for full project mapping and yEd (.tgf) export
- Add plotSingleFileDependencies.m and plotNodeHistory.m for targeted analysis
- Standardize output naming convention to 'Dependency_*' for Finder organization
- Configure high-resolution PNG export as default static fallback
2026-04-02 10:56:28 +02:00
bartels-rausch 873377ce80 Added some helpers and moved the older verions to a specific folder 2026-03-25 12:16:28 +01:00
bartels-rausch f15eadac6d Remove obsolete FileList.mat and nappScale.m. nappScale is replaced by nappNorm.m which does however not yet include the NEXAFS processing. WIP 2026-03-25 12:14:27 +01:00
bartels-rausch 091cf00e77 Refactor energy calibration pipeline, introduce modern arguments blocks, and add universal logging
* Transitioned nappNorm, nappDetermineShift, and nappCopyShift to use modern MATLAB arguments blocks, removing their legacy functionSignatures.json entries.

* Refactored nappNorm to rely on prior peak fitting results (e.g., from nappFitGaussXps) for normalization rather than performing the fitting internally.

* Decoupled energy calibration: nappDetermineShift now solely calculates internal binding energy shifts, and nappCopyShift distributes them using a unified matching engine ('earlier', 'after', 'spectrumNumber').

* Implemented a Universal Logging Block to track data provenance, automatically appending execution timestamps and caller script names to processed rows.

* Updated nappCombineSpectra to output a logDataSource cell array and cleanly name combined spectra.

* Created nappSaveDataTable for automatic, script-named .mat file saving, complete with a Live Editor interceptor.

* Added a publish-mode silencer to nappFitGaussXps to prevent optimizer spam in generated PDFs.

* Updated readme.md to document the new arguments structure, the 3-step calibration workflow, the matching engine, and the new table variables.
2026-03-25 12:07:49 +01:00
bartels-rausch b4cb748cfa updated information on how to copy without loosing file dates 2026-03-22 22:15:59 +01:00
bartels-rausch 2377e3b1f2 Refactor Shirley background to fix kinetic energy scaling and solver convergence
This commit replaces the numerically unstable Shirley background calculation in the peak fitting routine with a continuous, analytical Pseudo-Voigt Cumulative Distribution Function (CDF).

Previously, the solver struggled to converge and pushed peak parameters (area, width) into their absolute bounds due to two critical mathematical bugs in the objective function:

1. The 'flip' and Energy Axis Mutation Bug:
To handle kinetic energy scales (where the background steps up as energy decreases), the code mutated the energy axis (E = max(E)+100-E) inside the peak loop and attempted to use array flipping. This approach fundamentally decoupled the background step from the physical peak position. Array flipping mirrors data based on the length of the plot window, physically moving the Shirley step away from the true peak center. Furthermore, mutating E inside the loop corrupted the X-axis for subsequent peaks in multi-peak fits.

2. The Integration Cutoff ('idxregion') Bug:
The prior implementation used a hard Boolean cutoff (idxregion = (E >= pos)) to restrict the background calculation to only one side of the peak. Because Pseudo-Voigt peaks have long tails, this created a severe mathematical discontinuity (a sharp cliff) exactly at the peak center. Non-linear optimization solvers require smooth, continuous gradients to step correctly. The sharp cutoff destroyed the gradient, causing the solver to panic and lock parameters against their constraints.

The Fix:
- Removed all 'flip()' calls and energy array mutations.
- Replaced the hard cutoff with a continuous analytical CDF evaluated over the entire energy range.
- Handled binding vs. kinetic energy directionality cleanly by toggling between 'integral_fraction' and '(1 - integral_fraction)'.

Result:
The non-linear solver now receives perfectly smooth, mathematically continuous gradients, leading to rapid convergence. Peak parameters no longer crash into their bounds, and the plotted red fit line now perfectly aligns with the internally calculated solver residuals.
2026-03-22 22:07:55 +01:00
leeman_n 92b5fad252 added instructions on how to clone a git repository 2026-03-13 10:45:34 +01:00
bartels-rausch fffa2fb334 Added info how to copy files without changing the timestamps 2026-03-12 14:12:57 +01:00
bartels-rausch a26847b332 Good to know I'm smarter than google gemini. That code did not run. fixed it. Also fixed a time issue. Start aquisition is now taken from the logged time in the data file or if that is not present the OS creation date. the end aquisition time is the last modification time of the os for that file. 2026-03-12 13:35:27 +01:00
bartels-rausch 938eea27e8 feat: add unified functionSignatures.json for MATLAB auto-complete
Adds native IDE parameter suggestions, name-value pair tracking, and enum choices for all NAPP functions based on their current inputParser configurations.
2026-03-12 10:50:30 +01:00
bartels-rausch d7bc516442 Bug fix. The excitation energy for our offline XPS is wrong in the xy files. Set it to 1253.6 eV during import 2026-03-12 10:26:31 +01:00
bartels-rausch 00d34110db MAJOR UPDATE: Add support for Specs .xy files from offline XPS (Soleil/Luca)
Both Scienta (.ibw) and SpecsLab (.xy) raw files capture multidimensional XPS data but use different terminology to structure it. Scienta uses "Region Iterations" and "Sequence Iterations". SpecsLab organizes data by "Groups" or "Regions" (different elemental energy sweeps), "Scans" (time-resolved repetitions), and "Curves". Scienta Region Iterations are automatically averaged to improve the signal-to-noise ratio, while Scienta Sequence Iterations and SpecsLab Scans are  preserved to keep the time-resolved data. For SpecsLab files specifically, distinct Regions are split into separate table rows. Ultimately, the preserved time-resolved data is saved in the table's image variable as a 2D matrix ([Energy bins × Sequence iterations/Scans]).

File type handling: Added .xy as a recognized XPS format. Currently, the script differentiates data types strictly by file extension (NEXAFS: .h5, XPS: .ibw and .xy). This extension-based differentiation needs to be improved in future updates.

Metadata parsing: Implemented global header scanning for .xy files to correctly extract instrument parameters (Acquisition Mode, Lens Mode, Slit, Workfunction) located before the first region block.

Timezone alignment: Added timestamp conversion for .xy files from UTC to local time (Europe/Zurich) to ensure synchronization with LabView logs.

Region separation: Modified .xy parsing to append a _RegX suffix to filenames. This correctly splits single .xy files that contain multiple elements or energy sweeps into distinct table rows so they can be processed individually.

Import efficiency: Added an originalFileName variable. The script now cross-references the input DataTable and skips files that have already been imported to reduce execution time on re-runs.

Testing status: Processing of .xy data has currently only been tested and debugged with nappGenerateSpectra and nappPlot. Compatibility with other functions in the suite remains untested.
2026-03-12 10:08:47 +01:00
bartels-rausch a4ba161146 When using linear fit, the plot somehow reversed the excluded points. This is fixed now, those data labeled excluded are indeed excluded from the fit. Second, the input is now the same for kinetic and binding energy. 2 salars define the range to be excluded (the central peak), adding additional energies add excluded regions at the edge of the spectra. 2026-03-05 13:04:49 +01:00
bartels-rausch 0e07d2972b Finally, several spectra can be fitted with same constraints again...function now loops through any number of spectra 2026-03-05 11:11:37 +01:00
bartels-rausch 3a7ae3dcbd Added possibility to exlclude peak, plus a range at end of the spectrum. Updated the documentation. Bug fixes. 2026-03-05 07:32:53 +01:00
bartels-rausch d521db8cb8 Now uses helper function to merge data tables with different columns 2026-03-04 17:04:02 +01:00
bartels-rausch 5402439ac9 Adds data origin (that is which spectra are combined) and mean of sample settings 2026-03-04 17:02:45 +01:00
bartels-rausch ad7ac0e6ee Bug fix: Now handles also ibw files, not only h5. 2026-03-03 11:32:47 +01:00
bartels-rausch 5fa8c7fa68 But fixes 2026-03-02 17:40:06 +01:00
bartels-rausch 06927702c7 updated the documentation 2026-03-02 14:28:26 +01:00
bartels-rausch 07e414c3ef Now, the function can also deal with columns that have different numbers of entires (such as from peak fitting results) 2026-03-02 14:27:28 +01:00
bartels-rausch 23e49b4330 Addes a model for gas and condensed 2p spectra (2 doublets). Small improvements and bug fixes 2026-03-02 14:26:05 +01:00
bartels-rausch 67e75cde2e Added video to file list 2026-03-02 14:24:50 +01:00
bartels-rausch 6b3c96ff27 nappFileList now supports image formats of new camera. createBEamtimeFolder is a little helper to create empty folders in the beamtime folder. Folder PShell added for h5 data that are not NEXAFS but XPS aquired with PShell. 2026-02-26 13:08:16 +01:00
bartels-rausch 66a11d47f4 first Jeti plotting function 2026-01-23 09:38:15 +01:00
bartels-rausch 484c84e5f0 Major refactor - generic model architecture with full Shirley background support
BREAKING CHANGES:
- Single-spectrum fitting only (enforces exactly one row selected)
- Gauss fitting now uses FWHM parameter instead of Gaussian width sigma
- Removed multi-row batch processing capability

NEW FEATURES:
- Generic model architecture: arbitrary number of peaks (determined by length of FitParameter.peakArea)
- Full Shirley background support for both Gaussian and Pseudo-Voigt peak shapes
- Comprehensive parameter validation system with detailed error messages
- Support for shared vs per-peak Shirley K parameters
- New fitting modes: 'positionShirley', 'widthShirley', 'widthPositionShirley'
- New custom mode: 'TwoSpinOrbitDoubletPseudoVoigtShirley'
- Automatic field name typo correction ('Bond' → 'Bound')
- Enhanced results export: now includes peakEta and peakShirleyK columns

REFACTORING:
- Centralized peak and background equations in helper functions
  - gaussPeak(), lorentzPeak(), pseudoVoigtPeak()
  - linearBackground(), activeShirleyBackgroundFwhm()
  - fwhm2w() conversion utility
- Extracted model generation to genericModelGenerator()
- Modular validation helpers: checkFieldDimension(), checkBoundsPair()
- Standardized parameter vector layouts documented for all mode/background/peak-type combinations
- Improved column resizing logic with resizeColumnHelper()
- Enhanced plotting integration with nappPlot.m and nappAddFitToPlot.m

ARCHITECTURE:
- Unified parameter extraction for all fitting modes in centralized switch-case structure
- Consistent FWHM-based width parameterization across all peak types
- Mode-specific Shirley K sizing (scalar for shared modes, array for per-peak modes)
- Comprehensive inline documentation of parameter vector layouts (50+ combinations)

IMPROVEMENTS:
- Backward compatibility for 'gauss' width mode (auto-converts to FWHM)
- Robust bounds checking with detailed diagnostic messages
- Enhanced figure generation: residuals plot + fit visualization in tiledlayout
- Better error handling for empty/malformed data structures
- NaN-padded result arrays for variable peak counts

FILE SIZE: ~73KB → ~152KB (107% increase due to comprehensive documentation and generic architecture)
2026-01-23 08:02:53 +01:00
bartels-rausch 7d37326785 import and plot function for Jeti spectrometer data and for the pressure logging at ISS. 2025-12-17 23:59:20 +01:00
bartels-rausch bf1eb85f88 added export figure description 2025-12-07 16:09:14 +01:00
bartels-rausch 484648b648 Added a function to export figure data into ascii txt files (and to plot ascii text files to check if export worked) 2025-12-07 16:05:59 +01:00
bartels-rausch 5dcb0a9119 Added list of helper functions in utils subfolder 2025-12-07 12:59:34 +01:00
bartels-rausch 74dbdda5e8 Added a list of all functions and added information on a function to join data tables with differences in column number and type. 2025-12-07 12:41:19 +01:00
bartels-rausch 38a62bf560 Updated the HowDoI: Added how to merge tables with different columns into one. 2025-12-07 11:41:12 +01:00
bartels-rausch bbfab45787 Added Example Matlab script with most common during beamtime processing 2025-12-05 15:35:30 +01:00
bartels-rausch 53dd8c6080 Added links to matlab documentation 2025-12-05 10:42:44 +01:00