first Jeti plotting function
This commit is contained in:
1 parent
484c84e5f0
commit
66a11d47f4
2 files changed
+29
-53
No files matched your search
@@ -1,42 +0,0 @@
|
||||
feat: 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)
|
||||
+29
-11
@@ -1,14 +1,14 @@
|
||||
function dataTable = importJeti(filename)
|
||||
%IMPORTFILE Import JETI SPECBOS irradiance data (CSV or TXT format)
|
||||
% DATATABLE = IMPORTFILE(FILENAME) reads data from text file FILENAME.
|
||||
%IMPORTJETI Import JETI SPECBOS irradiance data (CSV or TXT format)
|
||||
% DATATABLE = IMPORTJETI(FILENAME) reads data from text file FILENAME.
|
||||
%
|
||||
% Supports two formats:
|
||||
% Supports:
|
||||
% 1. CSV: Semicolon-separated with header metadata
|
||||
% 2. isd: txt-style format with [sections] and tab-separated data
|
||||
%
|
||||
% Example:
|
||||
% table = importfile("20251212_1606_Jeti.csv");
|
||||
% table = importfile("spectrum_#2.isd");
|
||||
% table = importJeti("20251212_1606_Jeti.csv");
|
||||
% table = importJeti("spectrum_#2.isd");
|
||||
|
||||
%% Determine file type and route accordingly
|
||||
[~, ~, ext] = fileparts(filename);
|
||||
@@ -47,8 +47,8 @@ while true
|
||||
end
|
||||
lineIdx = lineIdx + 1;
|
||||
|
||||
% Detect start of data
|
||||
if contains(thisLine, 'Wavelength [nm];Spectral Irradiance [W/(sqm*nm)]')
|
||||
% Detect start of data header line
|
||||
if contains(thisLine, 'Wavelength [nm]')
|
||||
dataHeaderLineIdx = lineIdx;
|
||||
break
|
||||
end
|
||||
@@ -89,10 +89,27 @@ end
|
||||
firstDataLineInFile = dataHeaderLineIdx + 1;
|
||||
fclose(fid);
|
||||
|
||||
% Derive number of columns
|
||||
if isnan(metadata.numDatasets)
|
||||
error('Number of datasets not found in header.');
|
||||
% Derive number of columns:
|
||||
% If 'Number of datasets' is present: use it.
|
||||
% Otherwise infer from the header line (new Spec1/Spec2 format).[file:1]
|
||||
fid = fopen(filename, 'r');
|
||||
if fid == -1
|
||||
error('Cannot reopen file: %s', filename);
|
||||
end
|
||||
headerLine = '';
|
||||
for k = 1:dataHeaderLineIdx
|
||||
headerLine = fgetl(fid);
|
||||
end
|
||||
fclose(fid);
|
||||
|
||||
headerParts = strsplit(headerLine, ';');
|
||||
nHeaderCols = numel(headerParts);
|
||||
|
||||
if isnan(metadata.numDatasets)
|
||||
% New format: first column is wavelength, remaining are datasets
|
||||
metadata.numDatasets = nHeaderCols - 1;
|
||||
end
|
||||
|
||||
numCols = 1 + metadata.numDatasets;
|
||||
|
||||
% Build dataLines
|
||||
@@ -119,8 +136,9 @@ if ~isempty(metadata.Date) && ~isempty(metadata.Time)
|
||||
tstr = strtrim(metadata.Time{k});
|
||||
|
||||
try
|
||||
% JETI CSV: e.g. 12/18/2025 and 10:40:14 for 12h clock.[file:1]
|
||||
dt = datetime([dstr ' ' tstr], ...
|
||||
'InputFormat', 'MM/dd/yyyy hh:mm:ssa');
|
||||
'InputFormat', 'MM/dd/yyyy HH:mm:ss');
|
||||
timestr = datestr(dt, 'yyyymmdd_HHMMss');
|
||||
catch
|
||||
timestr = sprintf('dataset%02d', k);
|
||||
|
||||
Reference in new issue
Block a user