From 52235f819bf9d2824056731c6a728c89649d2e26 Mon Sep 17 00:00:00 2001 From: Luc Patiny Date: Tue, 11 Jun 2024 11:02:20 +0200 Subject: [PATCH] feat: add regions and components annotations --- .../__snapshots__/fromVamas.test.js.snap | 297 ++ .../cellulose_fitted_following_briggs.vms | 2663 +++++++++++++++++ src/from/__tests__/fromVamas.test.js | 14 +- src/from/getNormalizedMeta.js | 2 +- src/from/mapRegions.js | 36 +- src/index.js | 5 +- ...tations.js => getComponentsAnnotations.js} | 6 +- src/jsgraph/getRegionsAnnotations.js | 68 + 8 files changed, 3083 insertions(+), 8 deletions(-) create mode 100644 src/from/__tests__/__snapshots__/fromVamas.test.js.snap create mode 100644 src/from/__tests__/data/cellulose_fitted_following_briggs.vms rename src/jsgraph/{getAnnotations.js => getComponentsAnnotations.js} (89%) create mode 100644 src/jsgraph/getRegionsAnnotations.js diff --git a/src/from/__tests__/__snapshots__/fromVamas.test.js.snap b/src/from/__tests__/__snapshots__/fromVamas.test.js.snap new file mode 100644 index 0000000..4ba9cc5 --- /dev/null +++ b/src/from/__tests__/__snapshots__/fromVamas.test.js.snap @@ -0,0 +1,297 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`fromVamas > Cellulose with CASA information, regions and components 1`] = ` +{ + "analyserMode": "FAT", + "analysisSource": { + "beamWidthX": { + "units": "um", + "value": 6000, + }, + "beamWidthY": { + "units": "um", + "value": 500, + }, + "characteristicEnergy": { + "units": "eV", + "value": 1486.6, + }, + "label": "Al Ka, Monochromated", + }, + "components": [ + { + "area": 4830.0138, + "assignment": "C 1s 1", + "bindingEnergy": { + "units": "eV", + "value": 286.7736, + }, + "kineticEnergy": { + "units": "eV", + "value": 1199.8264, + }, + "shapeParameters": { + "gamma": 1.1057933, + }, + "type": "lorentzianAsymmetric", + }, + { + "area": 989.18682, + "assignment": "C 1s 2", + "bindingEnergy": { + "units": "eV", + "value": 288.1950999999999, + }, + "kineticEnergy": { + "units": "eV", + "value": 1198.4049, + }, + "shapeParameters": { + "gamma": 1.1121055, + }, + "type": "lorentzianAsymmetric", + }, + { + "area": 56.812945, + "assignment": "C 1s degrad", + "bindingEnergy": { + "units": "eV", + "value": 288.8453999999999, + }, + "kineticEnergy": { + "units": "eV", + "value": 1197.7546, + }, + "shapeParameters": { + "gamma": 0.82920074, + }, + "type": "gaussianLorentzianProduct", + }, + { + "area": 100.40835, + "assignment": "C 1s Adv.C", + "bindingEnergy": { + "units": "eV", + "value": 284.8711999999998, + }, + "kineticEnergy": { + "units": "eV", + "value": 1201.7288, + }, + "shapeParameters": { + "gamma": 0.74742285, + }, + "type": "gaussianLorentzianProduct", + }, + ], + "energyType": { + "kind": "binding", + "units": "eV", + }, + "from": 294.16, + "region": { + "auger": { + "element": null, + "transition": null, + }, + "name": "C 1s", + "orbital": { + "angularMomentum": "s", + "element": "C", + "shell": 1, + }, + }, + "regions": [ + { + "background": { + "parameters": { + "averageWidth": 1, + "bindingEnergyEnd": { + "units": "eV", + "value": 283.34839999999986, + }, + "bindingEnergyStart": { + "units": "eV", + "value": 293.2871, + }, + "crossSection": [ + 40.442441, + -450, + 0, + 0, + ], + "endOffset": 0, + "kineticEnergyEnd": { + "units": "eV", + "value": 1203.2516, + }, + "kineticEnergyStart": { + "units": "eV", + "value": 1193.3129, + }, + "relativeSensitivityFactor": 0.278, + "startOffset": 0, + }, + "rawParameters": "1193.3129 1203.2516 0.278 2 0 0 40.442441 -450 0 0", + "type": "Shirley", + }, + "block": { + "atomicMass": 12.011, + "regionBlockID": "C 1s", + "relativeSensitivityFactor": 0.278, + }, + "regionID": "C 1s", + }, + ], + "speciesLabel": "C", + "to": 282.16, +} +`; + +exports[`fromVamas Cellulose with CASA information, regions and components 1`] = ` +{ + "analyserMode": "FAT", + "analysisSource": { + "beamWidthX": { + "units": "um", + "value": 6000, + }, + "beamWidthY": { + "units": "um", + "value": 500, + }, + "characteristicEnergy": { + "units": "eV", + "value": 1486.6, + }, + "label": "Al Ka, Monochromated", + }, + "components": [ + { + "area": 4830.0138, + "assignment": "C 1s 1", + "bindingEnergy": { + "units": "eV", + "value": 286.7736, + }, + "kineticEnergy": { + "units": "eV", + "value": 1199.8264, + }, + "shapeParameters": { + "gamma": 1.1057933, + }, + "type": "lorentzianAsymmetric", + }, + { + "area": 989.18682, + "assignment": "C 1s 2", + "bindingEnergy": { + "units": "eV", + "value": 288.1950999999999, + }, + "kineticEnergy": { + "units": "eV", + "value": 1198.4049, + }, + "shapeParameters": { + "gamma": 1.1121055, + }, + "type": "lorentzianAsymmetric", + }, + { + "area": 56.812945, + "assignment": "C 1s degrad", + "bindingEnergy": { + "units": "eV", + "value": 288.8453999999999, + }, + "kineticEnergy": { + "units": "eV", + "value": 1197.7546, + }, + "shapeParameters": { + "gamma": 0.82920074, + }, + "type": "gaussianLorentzianProduct", + }, + { + "area": 100.40835, + "assignment": "C 1s Adv.C", + "bindingEnergy": { + "units": "eV", + "value": 284.8711999999998, + }, + "kineticEnergy": { + "units": "eV", + "value": 1201.7288, + }, + "shapeParameters": { + "gamma": 0.74742285, + }, + "type": "gaussianLorentzianProduct", + }, + ], + "energyType": { + "kind": "binding", + "units": "eV", + }, + "from": 294.16, + "region": { + "auger": { + "element": null, + "transition": null, + }, + "name": "C 1s", + "orbital": { + "angularMomentum": "s", + "element": "C", + "shell": 1, + }, + }, + "regions": [ + { + "background": { + "parameters": { + "averageWidth": 1, + "bindingEnergyEnd": { + "units": "eV", + "value": 283.34839999999986, + }, + "bindingEnergyStart": { + "units": "eV", + "value": 293.2871, + }, + "crossSection": [ + 40.442441, + -450, + 0, + 0, + ], + "endOffset": 0, + "kineticEnergyEnd": { + "units": "eV", + "value": 1203.2516, + }, + "kineticEnergyStart": { + "units": "eV", + "value": 1193.3129, + }, + "relativeSensitivityFactor": 0.278, + "startOffset": 0, + }, + "rawParameters": "1193.3129 1203.2516 0.278 2 0 0 40.442441 -450 0 0", + "type": "Shirley", + }, + "block": { + "atomicMass": 12.011, + "regionBlockID": "C 1s", + "relativeSensitivityFactor": 0.278, + }, + "regionID": "C 1s", + }, + ], + "speciesLabel": "C", + "to": 282.16, +} +`; diff --git a/src/from/__tests__/data/cellulose_fitted_following_briggs.vms b/src/from/__tests__/data/cellulose_fitted_following_briggs.vms new file mode 100644 index 0000000..de5e6e2 --- /dev/null +++ b/src/from/__tests__/data/cellulose_fitted_following_briggs.vms @@ -0,0 +1,2663 @@ +VAMAS Surface Chemical Analysis Standard Data Transfer Format 1988 May 4 +SurfaceSpectra Ltd. +Scienta ESCA300 +G Beamson +Cellulose +9 +Casa Info Follows CasaXPS Version 2.3.22PR1.0 +2 +C 1s +C 1s +O 1s +O 1s +The XPS of Polymers Database +Copyright (c) 2000 SurfaceSpectra Ltd. +SourceAnalyserAngle: 54.735600 d +NORM +REGULAR +4 +1 +None +d +0 +0 +0 +0 +4 +Survey +Sample Name: Cellulose +2000 +3 +1 +1 +0 +0 +0 +8 +Casa Info Follows +0 +0 +0 +0 +Sample Name: Cellulose +The XPS of Polymers Database +Copyright (c) 2000 SurfaceSpectra Ltd. +XPS +0 +Al Ka, Monochromated +1486.6 +1400 +6000 +500 +45 +315 +FAT +300 +5 +1e+037 +0 +6000 +500 +45 +0 +Survey + +-1 +Binding energy +eV +1153.16 +-1 +1 +Counts +d +pulse counting +0.1 +3 +1e+037 +90 +0 +0 +0 +1151 +27 +8424 +2243 +2261 +2253 +2136 +2216 +2281 +2239 +2131 +2146 +2119 +2148 +2118 +2199 +2170 +2179 +2193 +2206 +2112 +2304 +2304 +2192 +2183 +2160 +2139 +2185 +2157 +2223 +2185 +2215 +2271 +2247 +2073 +2161 +2209 +2228 +2234 +2281 +2180 +2235 +2160 +2099 +2253 +2225 +2176 +2230 +2221 +2213 +2279 +2358 +2294 +2204 +2205 +2236 +2298 +2262 +2275 +2237 +2351 +2289 +2221 +2236 +2264 +2181 +2254 +2238 +2195 +2212 +2218 +2289 +2272 +2224 +2225 +2170 +2280 +2200 +2278 +2276 +2369 +2252 +2144 +2250 +2253 +2407 +2455 +2292 +2200 +2238 +2209 +2242 +2281 +2159 +2178 +2334 +2368 +2194 +2169 +2262 +2206 +2331 +2349 +2287 +2128 +2304 +2285 +2433 +2301 +2263 +2376 +2329 +2231 +2288 +2441 +2359 +2299 +2181 +2312 +2349 +2342 +2376 +2398 +2445 +2532 +2246 +2263 +2426 +2409 +2389 +2415 +2356 +2342 +2368 +2392 +2387 +2357 +2415 +2420 +2404 +2545 +2359 +2399 +2347 +2432 +2462 +2217 +2338 +2388 +2380 +2390 +2416 +2430 +2420 +2542 +2633 +2613 +2612 +2616 +2569 +2677 +2556 +2483 +2356 +2360 +2411 +2334 +2333 +2255 +2203 +2261 +2139 +2297 +2346 +2374 +2592 +2582 +2853 +2829 +2961 +3038 +2905 +2872 +2689 +2551 +2489 +2367 +2248 +2113 +1868 +1791 +1689 +1486 +1438 +1394 +1449 +1410 +1353 +1427 +1380 +1474 +1496 +1465 +1469 +1294 +1443 +1357 +1342 +1318 +1508 +1299 +1410 +1390 +1352 +1363 +1344 +1392 +1416 +1380 +1429 +1374 +1362 +1480 +1344 +1417 +1391 +1419 +1361 +1395 +1424 +1395 +1400 +1360 +1340 +1416 +1378 +1369 +1306 +1434 +1386 +1442 +1367 +1349 +1510 +1401 +1376 +1435 +1392 +1418 +1383 +1390 +1327 +1444 +1331 +1458 +1408 +1432 +1396 +1347 +1404 +1424 +1383 +1435 +1359 +1399 +1278 +1454 +1345 +1447 +1404 +1333 +1335 +1360 +1271 +1358 +1274 +1355 +1321 +1307 +1427 +1349 +1313 +1340 +1309 +1339 +1330 +1302 +1342 +1327 +1329 +1219 +1347 +1351 +1307 +1377 +1241 +1334 +1351 +1337 +1298 +1348 +1328 +1370 +1372 +1331 +1412 +1359 +1256 +1273 +1322 +1289 +1314 +1340 +1426 +1268 +1281 +1303 +1265 +1319 +1248 +1306 +1362 +1316 +1417 +1354 +1282 +1277 +1248 +1340 +1268 +1292 +1310 +1236 +1311 +1330 +1304 +1304 +1300 +1320 +1325 +1266 +1234 +1295 +1246 +1257 +1208 +1337 +1265 +1349 +1249 +1322 +1207 +1299 +1273 +1258 +1296 +1354 +1325 +1373 +1352 +1266 +1288 +1325 +1287 +1312 +1288 +1281 +1367 +1349 +1345 +1344 +1391 +1229 +1347 +1263 +1292 +1353 +1373 +1384 +1289 +1284 +1332 +1243 +1260 +1303 +1343 +1331 +1217 +1260 +1305 +1250 +1283 +1256 +1260 +1309 +1272 +1293 +1378 +1261 +1248 +1287 +1297 +1376 +1280 +1229 +1224 +1336 +1344 +1281 +1250 +1316 +1300 +1279 +1315 +1300 +1282 +1253 +1267 +1359 +1278 +1344 +1369 +1350 +1256 +1278 +1322 +1370 +1241 +1333 +1332 +1272 +1291 +1252 +1257 +1196 +1234 +1248 +1267 +1264 +1263 +1265 +1245 +1310 +1322 +1274 +1255 +1258 +1139 +1225 +1246 +1244 +1259 +1268 +1273 +1172 +1256 +1259 +1254 +1205 +1188 +1230 +1224 +1149 +1237 +1262 +1303 +1224 +1181 +1273 +1208 +1330 +1279 +1183 +1294 +1170 +1243 +1234 +1224 +1183 +1172 +1201 +1293 +1239 +1275 +1194 +1178 +1175 +1253 +1213 +1208 +1142 +1238 +1220 +1292 +1272 +1186 +1287 +1203 +1244 +1257 +1282 +1211 +1337 +1311 +1204 +1223 +1283 +1211 +1265 +1205 +1224 +1280 +1197 +1245 +1163 +1189 +1233 +1232 +1256 +1171 +1231 +1136 +1256 +1152 +1296 +1309 +1276 +1207 +1264 +1286 +1301 +1256 +1312 +1200 +1205 +1245 +1274 +1181 +1358 +1237 +1241 +1203 +1266 +1223 +1233 +1209 +1220 +1204 +1244 +1298 +1248 +1262 +1262 +1389 +1330 +1267 +1218 +1244 +1278 +1301 +1330 +1305 +1229 +1281 +1258 +1278 +1275 +1272 +1220 +1269 +1269 +1188 +1266 +1311 +1332 +1214 +1243 +1287 +1227 +1226 +1238 +1242 +1117 +1296 +1222 +1236 +1269 +1240 +1172 +1199 +1243 +1192 +1266 +1153 +1277 +1264 +1305 +1214 +1291 +1395 +1465 +1311 +1304 +1274 +1349 +1296 +1186 +1238 +1116 +1034 +934 +884 +879 +792 +697 +677 +596 +639 +521 +521 +512 +607 +975 +2687 +8424 +7415 +1541 +609 +460 +469 +433 +423 +424 +405 +441 +415 +422 +437 +391 +413 +406 +453 +393 +364 +423 +423 +385 +399 +445 +423 +410 +441 +422 +412 +416 +444 +423 +409 +436 +369 +424 +394 +411 +466 +403 +424 +421 +463 +406 +438 +394 +410 +421 +410 +451 +392 +405 +436 +418 +382 +389 +443 +411 +403 +408 +437 +446 +432 +437 +400 +431 +432 +448 +390 +405 +399 +367 +414 +419 +451 +414 +433 +440 +447 +460 +438 +435 +427 +359 +405 +382 +360 +386 +395 +433 +411 +438 +453 +504 +412 +452 +418 +435 +480 +447 +394 +421 +435 +404 +416 +442 +433 +438 +424 +461 +453 +406 +384 +451 +406 +417 +396 +404 +481 +450 +405 +382 +455 +446 +414 +435 +446 +392 +417 +399 +482 +440 +430 +436 +396 +448 +395 +400 +478 +463 +411 +406 +475 +382 +404 +438 +388 +450 +459 +455 +394 +387 +428 +435 +397 +434 +391 +409 +439 +389 +491 +492 +510 +398 +402 +514 +440 +459 +462 +460 +414 +456 +441 +490 +460 +447 +409 +422 +468 +426 +454 +419 +438 +486 +467 +475 +428 +469 +454 +474 +450 +436 +479 +412 +420 +475 +445 +419 +436 +431 +456 +455 +441 +395 +446 +491 +483 +483 +469 +430 +479 +457 +453 +452 +467 +487 +501 +464 +491 +502 +522 +499 +477 +531 +432 +449 +446 +408 +428 +328 +348 +342 +317 +284 +304 +262 +234 +204 +150 +115 +141 +208 +271 +579 +1500 +2288 +3224 +853 +263 +116 +112 +100 +91 +88 +92 +121 +84 +93 +91 +71 +98 +114 +119 +106 +71 +82 +100 +63 +78 +89 +92 +76 +87 +87 +80 +91 +102 +88 +79 +76 +87 +91 +91 +80 +104 +99 +96 +108 +84 +82 +115 +92 +94 +84 +116 +87 +81 +72 +110 +83 +90 +80 +74 +74 +84 +72 +85 +78 +88 +106 +91 +94 +90 +95 +89 +90 +87 +68 +88 +72 +84 +75 +64 +78 +72 +81 +81 +94 +72 +89 +85 +109 +110 +72 +86 +54 +71 +104 +79 +69 +99 +89 +71 +89 +75 +61 +78 +112 +90 +85 +88 +95 +82 +86 +82 +92 +67 +84 +90 +94 +72 +104 +78 +81 +87 +85 +107 +82 +83 +70 +95 +87 +90 +92 +71 +104 +118 +79 +77 +81 +73 +53 +55 +78 +105 +102 +80 +76 +64 +80 +85 +83 +95 +76 +105 +74 +93 +83 +82 +91 +85 +84 +81 +85 +70 +72 +70 +92 +83 +110 +109 +99 +75 +83 +95 +86 +67 +72 +80 +91 +92 +97 +80 +68 +91 +80 +85 +82 +81 +63 +76 +96 +88 +80 +75 +72 +100 +81 +74 +72 +73 +67 +45 +72 +73 +64 +68 +81 +83 +85 +71 +86 +83 +66 +95 +65 +89 +77 +91 +67 +54 +95 +93 +62 +63 +57 +68 +73 +75 +88 +69 +91 +77 +91 +71 +70 +68 +75 +85 +67 +66 +66 +84 +72 +72 +77 +91 +81 +54 +52 +66 +73 +67 +57 +50 +58 +72 +61 +53 +70 +65 +56 +75 +94 +110 +193 +171 +121 +92 +54 +50 +62 +60 +64 +65 +52 +52 +64 +52 +35 +33 +39 +48 +60 +41 +62 +52 +27 +29 +C 1s +Sample Name: Cellulose +2000 +3 +1 +1 +0 +0 +0 +13 +Casa Info Follows +0 +0 +1 +CASA region (*C 1s*) (*Shirley*) 1193.3129 1203.2516 0.278 2 0 0 40.442441 -450 0 0 (*C 1s*) 12.011 0 0.278 +4 +CASA comp (*C 1s 1*) (*LA(1.4,1.7,100)*) Area 4830.0138 1e-020 126904.8 -1 1 MFWHM 1.1057933 0.25 6.25 -1 1 Position 1199.8264 1199.7 1199.87 -1 1 RSF 0.278 MASS 12.011 INDEX -1 (*C 1s*) CONST (**) UNCORRECTEDRSF 0.278 +CASA comp (*C 1s 2*) (*LA(1.4,1.6,100)*) Area 989.18682 0 2000 0 0.2048 MFWHM 1.1121055 0.25 6.25 -1 1 Position 1198.4049 1198.34 1198.74 -1 -1.33 RSF 0.278 MASS 12.011 INDEX -1 (*C 1s*) CONST (**) UNCORRECTEDRSF 0.278 +CASA comp (*C 1s degrad*) (*GL(30)*) Area 56.812945 0 243 -1 1 MFWHM 0.82920074 0.25 2 -1 1 Position 1197.7546 1197.3546 1197.7546 -1 1 RSF 0.278 MASS 12.011 INDEX -1 (*C 1s*) CONST (**) UNCORRECTEDRSF 0.278 +CASA comp (*C 1s Adv.C*) (*GL(30)*) Area 100.40835 1e-020 126904.8 -1 1 MFWHM 0.74742285 0.25 6.25 -1 1 Position 1201.7288 1201.4 1201.8 -1 1 RSF 0.278 MASS 12.011 INDEX -1 (*C 1s*) CONST (**) UNCORRECTEDRSF 0.278 +Sample Name: Cellulose +The XPS of Polymers Database +Copyright (c) 2000 SurfaceSpectra Ltd. +XPS +0 +Al Ka, Monochromated +1486.6 +1400 +6000 +500 +45 +315 +FAT +150 +5 +1e+037 +0 +6000 +500 +45 +0 +C +1s +-1 +Binding energy +eV +294.16 +-0.05 +1 +Counts +d +pulse counting +0.1 +25 +1e+037 +90 +0 +0 +1 +PROPAGATION_CONVERGED +d +1 +241 +154 +9350 +234 +210 +228 +238 +269 +269 +250 +254 +244 +235 +219 +217 +196 +188 +225 +219 +216 +214 +218 +218 +211 +219 +231 +233 +234 +234 +220 +212 +222 +224 +227 +215 +240 +255 +244 +226 +225 +235 +246 +248 +267 +254 +237 +235 +255 +233 +245 +253 +275 +255 +258 +241 +250 +251 +249 +260 +262 +248 +244 +286 +260 +267 +258 +257 +255 +267 +257 +269 +298 +303 +275 +280 +276 +260 +267 +286 +287 +310 +309 +319 +336 +351 +359 +382 +385 +384 +364 +408 +421 +421 +459 +460 +481 +505 +523 +560 +612 +664 +729 +759 +787 +894 +990 +1108 +1206 +1237 +1310 +1458 +1605 +1744 +1875 +1980 +2059 +2238 +2342 +2458 +2534 +2692 +2733 +2746 +2772 +2821 +2830 +2859 +2893 +2883 +2918 +3080 +3145 +3284 +3455 +3688 +3874 +4190 +4492 +4914 +5390 +5757 +6245 +6793 +7171 +7564 +8015 +8226 +8464 +8854 +9059 +9350 +9293 +9072 +8981 +8557 +8175 +7859 +7260 +6735 +6191 +5580 +5022 +4489 +3900 +3375 +2907 +2517 +2108 +1790 +1615 +1419 +1257 +1093 +998 +896 +834 +753 +767 +750 +741 +750 +721 +675 +641 +667 +679 +670 +625 +619 +610 +580 +591 +579 +520 +497 +438 +453 +400 +405 +369 +349 +333 +280 +262 +263 +252 +231 +214 +209 +233 +231 +197 +196 +206 +184 +178 +195 +186 +189 +188 +181 +180 +173 +162 +174 +183 +177 +178 +186 +187 +201 +180 +172 +160 +161 +165 +167 +172 +171 +181 +166 +154 +164 +178 +O 1s +Sample Name: Cellulose +2000 +3 +1 +1 +0 +0 +0 +11 +Casa Info Follows +0 +0 +1 +CASA region (*O 1s*) (*Shirley*) 948.94 957.94 0.78 2 0 0 40.442441 -450 0 0 (*O 1s*) 15.9994 0 0.78 +2 +CASA comp (*O 1s 2*) (*LA(1.4,1.7,130)*) Area 5379.2952 1e-020 235531.5 1 0.666666 MFWHM 1.2104919 0.3 7.5 -1 1 Position 953.06563 0 0 1 -0.58 RSF 0.78 MASS 15.9994 INDEX -1 (*O 1s*) CONST (**) UNCORRECTEDRSF 0.78 +CASA comp (*O 1s 1*) (*LA(1.4,1.7,130)*) Area 8068.9509 0 1e+008 -1 0.66666 MFWHM 1.2194156 0.3 7.5 -1 1 Position 953.64563 953.5 953.67 -1 1 RSF 0.78 MASS 15.9994 INDEX -1 (*O 1s*) CONST (**) UNCORRECTEDRSF 0.78 +Sample Name: Cellulose +The XPS of Polymers Database +Copyright (c) 2000 SurfaceSpectra Ltd. +XPS +0 +Al Ka, Monochromated +1486.6 +1400 +6000 +500 +45 +315 +FAT +150 +5 +1e+037 +0 +6000 +500 +45 +0 +O +1s +-1 +Binding energy +eV +538.16 +-0.05 +1 +Counts +d +pulse counting +0.1 +25 +1e+037 +90 +0 +0 +1 +PROPAGATION_CONVERGED +d +1 +201 +795 +21276 +960 +947 +934 +936 +885 +871 +924 +912 +960 +934 +958 +950 +983 +984 +1006 +1035 +985 +978 +987 +1006 +1022 +996 +995 +1002 +1050 +1021 +1034 +1053 +1083 +1084 +1078 +1096 +1079 +1143 +1146 +1126 +1104 +1132 +1180 +1172 +1204 +1212 +1196 +1223 +1181 +1230 +1219 +1267 +1287 +1332 +1333 +1357 +1421 +1455 +1503 +1524 +1598 +1646 +1709 +1797 +1875 +1973 +2061 +2147 +2282 +2354 +2501 +2661 +2854 +3111 +3289 +3591 +3901 +4221 +4676 +5050 +5513 +6066 +6503 +7177 +7786 +8488 +9196 +9976 +10911 +11924 +12663 +13526 +14598 +15511 +16333 +17182 +17824 +18807 +19570 +20050 +20538 +20972 +21276 +21071 +20901 +20788 +20476 +20060 +19637 +19052 +18315 +17304 +16346 +15610 +14519 +13463 +12481 +11337 +10477 +9488 +8531 +7839 +7071 +6444 +5725 +5017 +4471 +4020 +3552 +3268 +2994 +2690 +2479 +2255 +2094 +1857 +1746 +1710 +1641 +1535 +1490 +1428 +1374 +1337 +1270 +1228 +1268 +1248 +1155 +1138 +1129 +1050 +1026 +979 +995 +1001 +993 +1013 +1010 +950 +950 +952 +902 +908 +947 +919 +881 +881 +912 +903 +930 +925 +903 +877 +845 +867 +838 +873 +895 +879 +839 +836 +874 +842 +807 +870 +861 +852 +849 +836 +830 +868 +848 +834 +855 +842 +835 +805 +813 +836 +834 +795 +798 +851 +809 +Valence +Sample Name: Cellulose +2000 +3 +1 +1 +0 +0 +0 +8 +Casa Info Follows +0 +0 +0 +0 +Sample Name: Cellulose +The XPS of Polymers Database +Copyright (c) 2000 SurfaceSpectra Ltd. +XPS +0 +Al Ka, Monochromated +1486.6 +1400 +6000 +500 +45 +315 +FAT +150 +5 +1e+037 +0 +6000 +500 +45 +0 +Valence + +-1 +Binding energy +eV +38.16 +-0.05 +1 +Counts +d +pulse counting +1 +10 +1e+037 +90 +0 +0 +0 +801 +21 +1420 +408 +387 +385 +405 +394 +397 +382 +391 +394 +390 +393 +380 +364 +373 +380 +401 +404 +397 +389 +386 +401 +383 +378 +388 +388 +358 +382 +404 +395 +376 +393 +421 +398 +382 +408 +393 +377 +427 +401 +379 +372 +377 +378 +386 +393 +397 +361 +349 +378 +385 +375 +393 +387 +390 +393 +365 +374 +395 +394 +388 +378 +405 +391 +381 +395 +399 +376 +402 +393 +377 +366 +382 +375 +373 +380 +416 +405 +402 +367 +369 +388 +389 +374 +360 +389 +393 +369 +387 +415 +386 +375 +366 +392 +359 +378 +379 +411 +399 +392 +419 +388 +388 +404 +391 +390 +390 +406 +402 +388 +384 +393 +413 +407 +405 +421 +421 +395 +439 +451 +430 +431 +403 +429 +414 +396 +440 +461 +454 +457 +435 +406 +409 +439 +450 +428 +455 +456 +459 +455 +451 +456 +454 +470 +469 +473 +475 +467 +479 +505 +525 +530 +503 +503 +471 +505 +518 +518 +522 +531 +545 +530 +524 +534 +522 +554 +573 +569 +590 +590 +601 +586 +647 +669 +623 +628 +633 +671 +662 +644 +689 +696 +711 +727 +748 +786 +729 +763 +793 +773 +754 +768 +828 +853 +837 +884 +915 +926 +902 +904 +915 +930 +1006 +1035 +1023 +1027 +1012 +1035 +1067 +1090 +1069 +1068 +1094 +1093 +1136 +1142 +1146 +1129 +1128 +1163 +1164 +1194 +1219 +1243 +1255 +1209 +1244 +1297 +1350 +1308 +1320 +1289 +1319 +1299 +1359 +1323 +1349 +1420 +1378 +1324 +1301 +1291 +1330 +1356 +1302 +1359 +1354 +1326 +1278 +1266 +1243 +1178 +1196 +1187 +1169 +1119 +1101 +1059 +1070 +1033 +989 +983 +979 +924 +893 +865 +887 +807 +775 +817 +800 +754 +704 +683 +652 +657 +643 +598 +586 +574 +580 +589 +546 +502 +479 +470 +472 +429 +404 +432 +420 +421 +388 +378 +405 +378 +366 +379 +347 +335 +344 +354 +340 +345 +344 +302 +283 +305 +299 +303 +311 +298 +279 +284 +296 +268 +241 +266 +282 +258 +267 +242 +270 +270 +242 +233 +238 +253 +261 +253 +270 +253 +251 +253 +240 +252 +268 +261 +287 +279 +249 +273 +271 +280 +269 +278 +306 +303 +311 +321 +347 +351 +349 +354 +358 +331 +336 +342 +365 +402 +417 +382 +400 +399 +426 +426 +459 +464 +443 +439 +471 +478 +468 +476 +497 +512 +504 +493 +522 +499 +505 +499 +485 +474 +492 +539 +528 +490 +464 +451 +478 +474 +484 +476 +465 +438 +427 +427 +404 +396 +397 +394 +346 +355 +358 +363 +344 +322 +331 +323 +313 +325 +343 +359 +343 +328 +359 +345 +379 +399 +372 +371 +393 +402 +396 +390 +402 +414 +438 +415 +402 +421 +410 +405 +377 +377 +404 +370 +388 +416 +415 +394 +365 +380 +369 +398 +386 +368 +366 +384 +399 +369 +417 +431 +423 +395 +417 +446 +449 +449 +431 +453 +470 +456 +480 +465 +467 +491 +503 +479 +476 +451 +487 +490 +479 +448 +436 +442 +388 +370 +392 +396 +381 +349 +351 +350 +336 +308 +278 +265 +283 +276 +276 +255 +246 +256 +240 +249 +255 +224 +217 +236 +226 +228 +252 +275 +274 +280 +281 +277 +300 +259 +268 +263 +297 +287 +284 +319 +305 +311 +310 +296 +303 +302 +292 +286 +299 +311 +336 +319 +306 +321 +301 +307 +324 +340 +335 +324 +295 +305 +318 +319 +293 +297 +312 +309 +305 +292 +300 +307 +337 +321 +306 +327 +319 +316 +310 +286 +297 +302 +303 +301 +309 +312 +290 +302 +314 +330 +327 +304 +311 +322 +334 +335 +346 +316 +334 +319 +333 +348 +381 +361 +345 +328 +320 +342 +365 +328 +341 +361 +326 +333 +337 +361 +382 +368 +343 +353 +402 +356 +358 +377 +371 +363 +411 +399 +396 +377 +399 +385 +403 +400 +401 +388 +397 +414 +414 +402 +393 +397 +382 +380 +382 +389 +377 +366 +389 +356 +371 +392 +382 +389 +384 +368 +372 +362 +355 +370 +335 +341 +365 +381 +381 +387 +367 +357 +337 +326 +333 +352 +377 +352 +341 +347 +336 +303 +306 +310 +320 +309 +327 +315 +309 +303 +298 +291 +296 +274 +271 +286 +259 +236 +233 +234 +227 +213 +227 +198 +209 +206 +199 +166 +163 +150 +136 +145 +125 +107 +105 +100 +93 +81 +77 +59 +62 +55 +57 +61 +56 +49 +36 +33 +34 +46 +37 +39 +43 +36 +33 +29 +31 +29 +26 +33 +29 +22 +31 +31 +36 +29 +29 +33 +26 +30 +38 +34 +24 +26 +33 +38 +25 +30 +27 +24 +37 +27 +27 +30 +29 +33 +33 +25 +33 +34 +34 +29 +28 +28 +32 +27 +24 +30 +30 +22 +21 +28 +29 +36 +37 +29 +36 +40 +33 +29 +31 +39 +31 +27 +29 +32 +33 +29 +27 +30 +34 +38 +36 +26 +28 +23 +25 +34 +28 +25 +25 +27 +33 +28 +21 +27 +31 +31 +23 +23 +27 +31 +36 +32 +32 +28 +27 +26 +end of experiment diff --git a/src/from/__tests__/fromVamas.test.js b/src/from/__tests__/fromVamas.test.js index 25f8a2b..ff1d5b6 100644 --- a/src/from/__tests__/fromVamas.test.js +++ b/src/from/__tests__/fromVamas.test.js @@ -26,11 +26,23 @@ describe('fromVamas', () => { expect(typeof result.meta.cheminfo.meta).toBe('object'); }); - it.only('peg with CASA information', () => { + it('peg with CASA information', () => { const pegText = readFileSync(join(__dirname, './data/pegCASA.vms'), 'utf8'); let result = fromVamas(pegText).spectra[0]; expect(Object.keys(result.variables)).toHaveLength(2); expect(Object.keys(result.meta)).toHaveLength(62); expect(typeof result.meta.cheminfo.meta).toBe('object'); }); + + it.only('Cellulose with CASA information, regions and components', () => { + const text = readFileSync(join(__dirname, './data/cellulose_fitted_following_briggs.vms'), 'utf8'); + const parsed = fromVamas(text); + const c1s = parsed.spectra[1]; + expect(Object.keys(c1s.variables)).toHaveLength(2); + expect(Object.keys(c1s.meta)).toHaveLength(62); + const cheminfoMeta = c1s.meta.cheminfo.meta; + expect(cheminfoMeta.components).toHaveLength(4); + expect(cheminfoMeta.regions).toHaveLength(1); + expect(cheminfoMeta).toMatchSnapshot(); + }); }); diff --git a/src/from/getNormalizedMeta.js b/src/from/getNormalizedMeta.js index 44e4fe2..5f38f4b 100644 --- a/src/from/getNormalizedMeta.js +++ b/src/from/getNormalizedMeta.js @@ -36,7 +36,7 @@ export function getNormalizedMeta(meta = {}) { parsedCASAs, source.characteristicEnergy.value, ); - normalized.regions = mapRegions(parsedCASAs); + normalized.regions = mapRegions(parsedCASAs, source.characteristicEnergy.value); const increment = meta['abscissa increment']; normalized.from = meta['abscissa start']; diff --git a/src/from/mapRegions.js b/src/from/mapRegions.js index 7a6a203..b725d9c 100644 --- a/src/from/mapRegions.js +++ b/src/from/mapRegions.js @@ -1,9 +1,43 @@ export function mapRegions( parsedBlockComment, - sourceEnergy = undefined, + sourceEnergy, energyUnits = 'eV', ) { const regions = []; + + if (parsedBlockComment.regions) { + for (let region of parsedBlockComment.regions) { + + const newRegion = { ...region } + if (newRegion?.background?.parameters?.kineticEnergyStart) { + newRegion.background.parameters.kineticEnergyStart = { + value: newRegion.background.parameters.kineticEnergyStart, + units: energyUnits, + } + newRegion.background.parameters.bindingEnergyStart = { + value: sourceEnergy - newRegion.background.parameters.kineticEnergyStart.value, + units: energyUnits, + } + } + if (newRegion?.background?.parameters?.kineticEnergyEnd) { + newRegion.background.parameters.kineticEnergyEnd = { + value: newRegion.background.parameters.kineticEnergyEnd, + units: energyUnits, + } + newRegion.background.parameters.bindingEnergyEnd = { + value: sourceEnergy - newRegion.background.parameters.kineticEnergyEnd.value, + units: energyUnits, + } + } + + + regions.push(newRegion); + + } + } + + + if (parsedBlockComment.regions) { return parsedBlockComment.regions; } diff --git a/src/index.js b/src/index.js index 2dd194e..fc3c839 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ import { JSGraph as OriginalJSGraph } from 'common-spectrum'; -import { getAnnotations } from './jsgraph/getAnnotations'; +import { getComponentsAnnotations } from './jsgraph/getComponentsAnnotations.js'; +import { getRegionsAnnotations } from './jsgraph/getRegionsAnnotations.js'; export { Analysis, @@ -16,6 +17,6 @@ export { peakPicking } from './peakPicking'; export { references } from './references'; -export const JSGraph = { ...OriginalJSGraph, getAnnotations }; +export const JSGraph = { ...OriginalJSGraph, getRegionsAnnotations, getComponentsAnnotations }; export { predictUsingHoseCodes } from './utilities/prediction/predictUsingHoseCodes'; diff --git a/src/jsgraph/getAnnotations.js b/src/jsgraph/getComponentsAnnotations.js similarity index 89% rename from src/jsgraph/getAnnotations.js rename to src/jsgraph/getComponentsAnnotations.js index d683faa..5da288d 100644 --- a/src/jsgraph/getAnnotations.js +++ b/src/jsgraph/getComponentsAnnotations.js @@ -9,17 +9,17 @@ /** * Creates annotations for jsgraph that allows to display the result of component picking - * @param {array} components + * @param {Array} components * @param {object} [options={}] * @param {string} [options.fillColor='green'] * @param {string} [options.strokeColor='red'] * @param {string} [options.showAssignment=true] Display the assignment - * @param {function} [options.createFct] (annotation, component) => {}: callback allowing to add properties + * @param {Function} [options.creationFct] (annotation, component) => {}: callback allowing to add properties * @param {string} [options.mode='binding'] 'binding' or 'kinetic' * @returns array */ -export function getAnnotations(components, options = {}) { +export function getComponentsAnnotations(components, options = {}) { const { fillColor = 'green', strokeColor = 'red', creationFct } = options; let annotations = components.map((component) => { let annotation = { diff --git a/src/jsgraph/getRegionsAnnotations.js b/src/jsgraph/getRegionsAnnotations.js new file mode 100644 index 0000000..526ab42 --- /dev/null +++ b/src/jsgraph/getRegionsAnnotations.js @@ -0,0 +1,68 @@ + + +/** + * Creates annotations for jsgraph that allows to display the result of component picking + * @param {Array} regions + * @param {object} [options={}] + * @param {string} [options.fillColor='rgba(0,255,255,0.1)'] + * @param {string} [options.strokeColor='red'] + * @param {string} [options.mode='binding'] 'binding' or 'kinetic' + * @returns array + */ + +export function getRegionsAnnotations(regions, options = {}) { + const { fillColor = 'rgba(0,255,255,0.1)', strokeColor = 'red' } = options; + regions = regions.filter(region => region?.background); + const annotations = regions.map((region) => { + let annotation = { + line: 1, + type: 'rect', + strokeColor, + strokeWidth: 0, + fillColor, + }; + return getAnnotation(annotation, region, options); + }); + return annotations; +} + +function getAnnotation(annotation, region, options = {}) { + const { mode = 'binding', showRegionID = true } = options; + let labels = []; + let line = 0; + + const energyStart = mode === 'kinetic' + ? region.background.parameters.kineticEnergyStart.value + : region.background.parameters.bindingEnergyStart.value; + const energyEnd = mode === 'kinetic' + ? region.background.parameters.kineticEnergyEnd.value + : region.background.parameters.bindingEnergyEnd.value; + + if (showRegionID) { + labels.push({ + text: region.regionID, + size: '18px', + anchor: 'middle', + color: 'darkcyan', + position: { + x: (energyStart + energyEnd) / 2, + y: '0px', + dy: `${13 + line * 14}px`, + }, + }); + line++; + } + + annotation.labels = labels; + annotation.position = [ + { + x: energyStart, + y: '0px', + }, + { + x: energyEnd, + y: '1000px', + }, + ]; + return annotation; +}