-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseLiYF4xls.m
36 lines (36 loc) · 1.49 KB
/
parseLiYF4xls.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Options[ParseLiYF4] = {"Export" -> True};
ParseLiYF4[sheetFname_]:=Module[
{sheetNames, liyf4ExpData, sheetData, header,
expCol, excludeCol, stateLabels, expEnergies,
lastRow, shN},
(
sheetNames = Select[Import[sheetFname, "Sheets"], StringContainsQ[#, "3+"] &];
liyf4ExpData = Table[
(
sheetData = Import[sheetFname, {"Sheets", shN}];
header = sheetData[[1]];
sheetData = sheetData[[2 ;;]];
expCol = Position[header, "Exp (1/cm)"][[1, 1]];
excludeCol = Position[header, "Exp:Excluded"][[1, 1]];
(*first column is always the SLJ coarse label of the state,
keep it*)
sheetData = Transpose[sheetData];
stateLabels = sheetData[[1]];
expEnergies = sheetData[[expCol]];
excludeCol = sheetData[[excludeCol]];
lastRow = Position[stateLabels, ""];
lastRow = If[Length[lastRow] > 0,
lastRow[[1, 1]] - 1,
-1
];
StringTake[shN, {1, 2}] -> Transpose[{expEnergies, stateLabels, excludeCol}][[;; lastRow]]
),
{shN, sheetNames}
];
liyf4ExpData = Association[liyf4ExpData];
If[OptionValue["Export"],
Export[FileNameJoin[{NotebookDirectory[], "data", "LiYF4_exp_data.m"}], liyf4ExpData]
];
Return[liyf4ExpData];
);
]