react-cheminfo 0.65.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/README.md +33 -17
  2. package/lib/download/ui/FigureDownloadPanel.d.ts +7 -1
  3. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  4. package/lib/download/ui/FigureDownloadPanel.js +2 -2
  5. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  6. package/lib/ecosystem/core/sites.js +3 -3
  7. package/lib/ecosystem/core/sites.js.map +1 -1
  8. package/lib/ecosystem/core/types.d.ts +1 -1
  9. package/lib/ecosystem/core/types.d.ts.map +1 -1
  10. package/lib/ecosystem/ui/glyphs.js +1 -1
  11. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  12. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  13. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  14. package/lib/i18n/core/messageCatalog.d.ts +2 -2
  15. package/lib/i18n/vite/localeCatalog.d.ts +1 -1
  16. package/lib/ir/core/analysisSpectra.d.ts +23 -6
  17. package/lib/ir/core/analysisSpectra.d.ts.map +1 -1
  18. package/lib/ir/core/analysisSpectra.js.map +1 -1
  19. package/lib/ir/core/bandLabelPlan.d.ts.map +1 -1
  20. package/lib/ir/core/bandLabelPlan.js +11 -6
  21. package/lib/ir/core/bandLabelPlan.js.map +1 -1
  22. package/lib/ir/core/index.d.ts +15 -11
  23. package/lib/ir/core/index.d.ts.map +1 -1
  24. package/lib/ir/core/index.js +9 -6
  25. package/lib/ir/core/index.js.map +1 -1
  26. package/lib/ir/core/irBand.d.ts +45 -14
  27. package/lib/ir/core/irBand.d.ts.map +1 -1
  28. package/lib/ir/core/irBand.js +28 -6
  29. package/lib/ir/core/irBand.js.map +1 -1
  30. package/lib/ir/core/irCommands.d.ts +11 -0
  31. package/lib/ir/core/irCommands.d.ts.map +1 -1
  32. package/lib/ir/core/irCommands.js +11 -1
  33. package/lib/ir/core/irCommands.js.map +1 -1
  34. package/lib/ir/core/irDomain.d.ts +4 -3
  35. package/lib/ir/core/irDomain.d.ts.map +1 -1
  36. package/lib/ir/core/irDomain.js +10 -7
  37. package/lib/ir/core/irDomain.js.map +1 -1
  38. package/lib/ir/core/irEditorApi.d.ts +12 -0
  39. package/lib/ir/core/irEditorApi.d.ts.map +1 -1
  40. package/lib/ir/core/irFormat.d.ts +14 -2
  41. package/lib/ir/core/irFormat.d.ts.map +1 -1
  42. package/lib/ir/core/irFormat.js +33 -4
  43. package/lib/ir/core/irFormat.js.map +1 -1
  44. package/lib/ir/core/irMode.d.ts +35 -8
  45. package/lib/ir/core/irMode.d.ts.map +1 -1
  46. package/lib/ir/core/irMode.js +38 -10
  47. package/lib/ir/core/irMode.js.map +1 -1
  48. package/lib/ir/core/irReducer.d.ts +2 -30
  49. package/lib/ir/core/irReducer.d.ts.map +1 -1
  50. package/lib/ir/core/irReducer.js +1 -24
  51. package/lib/ir/core/irReducer.js.map +1 -1
  52. package/lib/ir/core/irSidePanels.d.ts +7 -1
  53. package/lib/ir/core/irSidePanels.d.ts.map +1 -1
  54. package/lib/ir/core/irSpectrum.d.ts +52 -26
  55. package/lib/ir/core/irSpectrum.d.ts.map +1 -1
  56. package/lib/ir/core/irSpectrum.js +21 -15
  57. package/lib/ir/core/irSpectrum.js.map +1 -1
  58. package/lib/ir/core/irState.d.ts +46 -5
  59. package/lib/ir/core/irState.d.ts.map +1 -1
  60. package/lib/ir/core/irState.js +38 -1
  61. package/lib/ir/core/irState.js.map +1 -1
  62. package/lib/ir/core/irTechnique.d.ts +94 -0
  63. package/lib/ir/core/irTechnique.d.ts.map +1 -0
  64. package/lib/ir/core/irTechnique.js +87 -0
  65. package/lib/ir/core/irTechnique.js.map +1 -0
  66. package/lib/ir/core/irTechniqueCommands.d.ts +26 -0
  67. package/lib/ir/core/irTechniqueCommands.d.ts.map +1 -0
  68. package/lib/ir/core/irTechniqueCommands.js +68 -0
  69. package/lib/ir/core/irTechniqueCommands.js.map +1 -0
  70. package/lib/ir/core/pickBands.d.ts +6 -5
  71. package/lib/ir/core/pickBands.d.ts.map +1 -1
  72. package/lib/ir/core/pickBands.js +49 -26
  73. package/lib/ir/core/pickBands.js.map +1 -1
  74. package/lib/ir/core/ramanBands.d.ts +30 -0
  75. package/lib/ir/core/ramanBands.d.ts.map +1 -0
  76. package/lib/ir/core/ramanBands.js +83 -0
  77. package/lib/ir/core/ramanBands.js.map +1 -0
  78. package/lib/ir/core/spectrumJcamp.d.ts +10 -5
  79. package/lib/ir/core/spectrumJcamp.d.ts.map +1 -1
  80. package/lib/ir/core/spectrumJcamp.js +63 -15
  81. package/lib/ir/core/spectrumJcamp.js.map +1 -1
  82. package/lib/ir/core/toIrSpectrum.d.ts.map +1 -1
  83. package/lib/ir/core/toIrSpectrum.js +17 -2
  84. package/lib/ir/core/toIrSpectrum.js.map +1 -1
  85. package/lib/ir/ui/BandRow.d.ts +30 -0
  86. package/lib/ir/ui/BandRow.d.ts.map +1 -0
  87. package/lib/ir/ui/BandRow.js +42 -0
  88. package/lib/ir/ui/BandRow.js.map +1 -0
  89. package/lib/ir/ui/BandsPanel.d.ts +4 -0
  90. package/lib/ir/ui/BandsPanel.d.ts.map +1 -1
  91. package/lib/ir/ui/BandsPanel.js +14 -59
  92. package/lib/ir/ui/BandsPanel.js.map +1 -1
  93. package/lib/ir/ui/IrAboutDialog.d.ts +7 -0
  94. package/lib/ir/ui/IrAboutDialog.d.ts.map +1 -1
  95. package/lib/ir/ui/IrAboutDialog.js +16 -3
  96. package/lib/ir/ui/IrAboutDialog.js.map +1 -1
  97. package/lib/ir/ui/IrCanvas.d.ts +7 -0
  98. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  99. package/lib/ir/ui/IrCanvas.js +9 -4
  100. package/lib/ir/ui/IrCanvas.js.map +1 -1
  101. package/lib/ir/ui/IrChart.d.ts +2 -1
  102. package/lib/ir/ui/IrChart.d.ts.map +1 -1
  103. package/lib/ir/ui/IrChart.js +22 -21
  104. package/lib/ir/ui/IrChart.js.map +1 -1
  105. package/lib/ir/ui/IrCommandProvider.d.ts +7 -0
  106. package/lib/ir/ui/IrCommandProvider.d.ts.map +1 -1
  107. package/lib/ir/ui/IrCommandProvider.js +2 -2
  108. package/lib/ir/ui/IrCommandProvider.js.map +1 -1
  109. package/lib/ir/ui/IrCommandTooltip.d.ts +7 -0
  110. package/lib/ir/ui/IrCommandTooltip.d.ts.map +1 -1
  111. package/lib/ir/ui/IrCommandTooltip.js +3 -2
  112. package/lib/ir/ui/IrCommandTooltip.js.map +1 -1
  113. package/lib/ir/ui/IrDocumentationDialog.d.ts +8 -1
  114. package/lib/ir/ui/IrDocumentationDialog.d.ts.map +1 -1
  115. package/lib/ir/ui/IrDocumentationDialog.js +30 -7
  116. package/lib/ir/ui/IrDocumentationDialog.js.map +1 -1
  117. package/lib/ir/ui/IrEditor.d.ts +25 -5
  118. package/lib/ir/ui/IrEditor.d.ts.map +1 -1
  119. package/lib/ir/ui/IrEditor.js +3 -20
  120. package/lib/ir/ui/IrEditor.js.map +1 -1
  121. package/lib/ir/ui/IrHeader.d.ts.map +1 -1
  122. package/lib/ir/ui/IrHeader.js +5 -1
  123. package/lib/ir/ui/IrHeader.js.map +1 -1
  124. package/lib/ir/ui/IrLogo.d.ts +11 -3
  125. package/lib/ir/ui/IrLogo.d.ts.map +1 -1
  126. package/lib/ir/ui/IrLogo.js +14 -5
  127. package/lib/ir/ui/IrLogo.js.map +1 -1
  128. package/lib/ir/ui/IrShell.d.ts +9 -1
  129. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  130. package/lib/ir/ui/IrShell.js +26 -74
  131. package/lib/ir/ui/IrShell.js.map +1 -1
  132. package/lib/ir/ui/IrSidePanel.d.ts +11 -0
  133. package/lib/ir/ui/IrSidePanel.d.ts.map +1 -1
  134. package/lib/ir/ui/IrSidePanel.js +12 -3
  135. package/lib/ir/ui/IrSidePanel.js.map +1 -1
  136. package/lib/ir/ui/IrStatusBar.d.ts +3 -2
  137. package/lib/ir/ui/IrStatusBar.d.ts.map +1 -1
  138. package/lib/ir/ui/IrStatusBar.js +14 -9
  139. package/lib/ir/ui/IrStatusBar.js.map +1 -1
  140. package/lib/ir/ui/IrToolbar.d.ts +3 -0
  141. package/lib/ir/ui/IrToolbar.d.ts.map +1 -1
  142. package/lib/ir/ui/IrToolbar.js +10 -3
  143. package/lib/ir/ui/IrToolbar.js.map +1 -1
  144. package/lib/ir/ui/IrTraces.d.ts +4 -1
  145. package/lib/ir/ui/IrTraces.d.ts.map +1 -1
  146. package/lib/ir/ui/IrTraces.js +2 -0
  147. package/lib/ir/ui/IrTraces.js.map +1 -1
  148. package/lib/ir/ui/RamanEditor.d.ts +64 -0
  149. package/lib/ir/ui/RamanEditor.d.ts.map +1 -0
  150. package/lib/ir/ui/RamanEditor.js +17 -0
  151. package/lib/ir/ui/RamanEditor.js.map +1 -0
  152. package/lib/ir/ui/SpectraPanel.d.ts.map +1 -1
  153. package/lib/ir/ui/SpectraPanel.js +2 -2
  154. package/lib/ir/ui/SpectraPanel.js.map +1 -1
  155. package/lib/ir/ui/SpectrumRow.d.ts +7 -0
  156. package/lib/ir/ui/SpectrumRow.d.ts.map +1 -1
  157. package/lib/ir/ui/SpectrumRow.js +4 -5
  158. package/lib/ir/ui/SpectrumRow.js.map +1 -1
  159. package/lib/ir/ui/VibrationalEditor.d.ts +62 -0
  160. package/lib/ir/ui/VibrationalEditor.d.ts.map +1 -0
  161. package/lib/ir/ui/VibrationalEditor.js +33 -0
  162. package/lib/ir/ui/VibrationalEditor.js.map +1 -0
  163. package/lib/ir/ui/bandsTsv.d.ts +19 -0
  164. package/lib/ir/ui/bandsTsv.d.ts.map +1 -0
  165. package/lib/ir/ui/bandsTsv.js +38 -0
  166. package/lib/ir/ui/bandsTsv.js.map +1 -0
  167. package/lib/ir/ui/index.d.ts +1 -0
  168. package/lib/ir/ui/index.d.ts.map +1 -1
  169. package/lib/ir/ui/index.js.map +1 -1
  170. package/lib/ir/ui/irActions.d.ts +3 -3
  171. package/lib/ir/ui/irActions.d.ts.map +1 -1
  172. package/lib/ir/ui/irChartProps.d.ts +21 -4
  173. package/lib/ir/ui/irChartProps.d.ts.map +1 -1
  174. package/lib/ir/ui/irChartProps.js +3 -2
  175. package/lib/ir/ui/irChartProps.js.map +1 -1
  176. package/lib/ir/ui/irCommandContext.d.ts +8 -0
  177. package/lib/ir/ui/irCommandContext.d.ts.map +1 -1
  178. package/lib/ir/ui/irCommandContext.js +14 -3
  179. package/lib/ir/ui/irCommandContext.js.map +1 -1
  180. package/lib/ir/ui/irHostPanels.d.ts +53 -0
  181. package/lib/ir/ui/irHostPanels.d.ts.map +1 -0
  182. package/lib/ir/ui/irHostPanels.js +41 -0
  183. package/lib/ir/ui/irHostPanels.js.map +1 -0
  184. package/lib/ir/ui/useIrEditor.d.ts +3 -3
  185. package/lib/ir/ui/useIrEditor.d.ts.map +1 -1
  186. package/lib/ir/ui/useIrEditor.js +13 -4
  187. package/lib/ir/ui/useIrEditor.js.map +1 -1
  188. package/lib/ir/ui/useIrHandle.d.ts +14 -0
  189. package/lib/ir/ui/useIrHandle.d.ts.map +1 -0
  190. package/lib/ir/ui/useIrHandle.js +39 -0
  191. package/lib/ir/ui/useIrHandle.js.map +1 -0
  192. package/lib/ir/ui/useIrSide.d.ts +27 -0
  193. package/lib/ir/ui/useIrSide.d.ts.map +1 -0
  194. package/lib/ir/ui/useIrSide.js +42 -0
  195. package/lib/ir/ui/useIrSide.js.map +1 -0
  196. package/lib/ir/ui/useIrText.d.ts +40 -0
  197. package/lib/ir/ui/useIrText.d.ts.map +1 -0
  198. package/lib/ir/ui/useIrText.js +118 -0
  199. package/lib/ir/ui/useIrText.js.map +1 -0
  200. package/lib/ir/ui/useIrZoom.d.ts +15 -0
  201. package/lib/ir/ui/useIrZoom.d.ts.map +1 -1
  202. package/lib/ir/ui/useIrZoom.js +6 -4
  203. package/lib/ir/ui/useIrZoom.js.map +1 -1
  204. package/lib/ir/ui/useValueAxisZoom.d.ts +20 -0
  205. package/lib/ir/ui/useValueAxisZoom.d.ts.map +1 -0
  206. package/lib/ir/ui/useValueAxisZoom.js +54 -0
  207. package/lib/ir/ui/useValueAxisZoom.js.map +1 -0
  208. package/lib/ir.d.ts +3 -0
  209. package/lib/ir.d.ts.map +1 -1
  210. package/lib/ir.js +3 -0
  211. package/lib/ir.js.map +1 -1
  212. package/lib/locales/de.json +29 -2
  213. package/lib/locales/en.json +29 -2
  214. package/lib/locales/es.json +29 -2
  215. package/lib/locales/fr.json +29 -2
  216. package/lib/locales/it.json +29 -2
  217. package/lib/molecule3d/core/animatedPng.d.ts +25 -0
  218. package/lib/molecule3d/core/animatedPng.d.ts.map +1 -0
  219. package/lib/molecule3d/core/animatedPng.js +59 -0
  220. package/lib/molecule3d/core/animatedPng.js.map +1 -0
  221. package/lib/molecule3d/core/file.d.ts +24 -0
  222. package/lib/molecule3d/core/file.d.ts.map +1 -0
  223. package/lib/molecule3d/core/file.js +2 -0
  224. package/lib/molecule3d/core/file.js.map +1 -0
  225. package/lib/molecule3d/core/index.d.ts +4 -1
  226. package/lib/molecule3d/core/index.d.ts.map +1 -1
  227. package/lib/molecule3d/core/index.js +1 -0
  228. package/lib/molecule3d/core/index.js.map +1 -1
  229. package/lib/molecule3d/core/settings.d.ts +0 -7
  230. package/lib/molecule3d/core/settings.d.ts.map +1 -1
  231. package/lib/molecule3d/core/settings.js.map +1 -1
  232. package/lib/molecule3d/ui/Molecule3DExport.d.ts +10 -2
  233. package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
  234. package/lib/molecule3d/ui/Molecule3DExport.js +15 -2
  235. package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
  236. package/lib/molecule3d/ui/Molecule3DToolbar.js +9 -2
  237. package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
  238. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  239. package/lib/molecule3d/ui/MoleculeCanvas3D.js +23 -41
  240. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  241. package/lib/molecule3d/ui/drawScene.d.ts +2 -1
  242. package/lib/molecule3d/ui/drawScene.d.ts.map +1 -1
  243. package/lib/molecule3d/ui/drawScene.js.map +1 -1
  244. package/lib/molecule3d/ui/exportMoleculeImage.d.ts +15 -1
  245. package/lib/molecule3d/ui/exportMoleculeImage.d.ts.map +1 -1
  246. package/lib/molecule3d/ui/exportMoleculeImage.js +14 -2
  247. package/lib/molecule3d/ui/exportMoleculeImage.js.map +1 -1
  248. package/lib/molecule3d/ui/moleculeFrames.d.ts +47 -0
  249. package/lib/molecule3d/ui/moleculeFrames.d.ts.map +1 -0
  250. package/lib/molecule3d/ui/moleculeFrames.js +65 -0
  251. package/lib/molecule3d/ui/moleculeFrames.js.map +1 -0
  252. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +14 -1
  253. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  254. package/lib/molecule3d/ui/renderMolecule.d.ts +3 -3
  255. package/lib/molecule3d/ui/renderMolecule.d.ts.map +1 -1
  256. package/lib/molecule3d/ui/renderMolecule.js +2 -1
  257. package/lib/molecule3d/ui/renderMolecule.js.map +1 -1
  258. package/lib/molecule3d/ui/sceneDrawer.d.ts +2 -1
  259. package/lib/molecule3d/ui/sceneDrawer.d.ts.map +1 -1
  260. package/lib/molecule3d/ui/sceneDrawer.js +9 -1
  261. package/lib/molecule3d/ui/sceneDrawer.js.map +1 -1
  262. package/lib/molecule3d/ui/useImageExport.d.ts +8 -3
  263. package/lib/molecule3d/ui/useImageExport.d.ts.map +1 -1
  264. package/lib/molecule3d/ui/useImageExport.js +13 -4
  265. package/lib/molecule3d/ui/useImageExport.js.map +1 -1
  266. package/lib/molecule3d/ui/useMoleculeScene.d.ts +2 -1
  267. package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -1
  268. package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -1
  269. package/lib/molecule3d/ui/useMoleculeViewer.d.ts +16 -0
  270. package/lib/molecule3d/ui/useMoleculeViewer.d.ts.map +1 -0
  271. package/lib/molecule3d/ui/useMoleculeViewer.js +37 -0
  272. package/lib/molecule3d/ui/useMoleculeViewer.js.map +1 -0
  273. package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts +3 -3
  274. package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts.map +1 -1
  275. package/lib/molecule3d/ui/usePolarSurfaceArea.js +4 -3
  276. package/lib/molecule3d/ui/usePolarSurfaceArea.js.map +1 -1
  277. package/lib/molecule3d/ui/viewer.d.ts +4 -1
  278. package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
  279. package/lib/molecule3d/ui/viewer.js +21 -19
  280. package/lib/molecule3d/ui/viewer.js.map +1 -1
  281. package/lib/molecule3d/ui/viewerTypes.d.ts +6 -0
  282. package/lib/molecule3d/ui/viewerTypes.d.ts.map +1 -1
  283. package/lib/molstar/core/captureScene.d.ts +19 -1
  284. package/lib/molstar/core/captureScene.d.ts.map +1 -1
  285. package/lib/molstar/core/captureScene.js +57 -2
  286. package/lib/molstar/core/captureScene.js.map +1 -1
  287. package/lib/molstar/core/index.d.ts +5 -2
  288. package/lib/molstar/core/index.d.ts.map +1 -1
  289. package/lib/molstar/core/index.js +4 -2
  290. package/lib/molstar/core/index.js.map +1 -1
  291. package/lib/molstar/core/trajectory.d.ts +56 -0
  292. package/lib/molstar/core/trajectory.d.ts.map +1 -0
  293. package/lib/molstar/core/trajectory.js +96 -0
  294. package/lib/molstar/core/trajectory.js.map +1 -0
  295. package/lib/panel/ui/PanelRail.d.ts.map +1 -1
  296. package/lib/panel/ui/PanelRail.js +1 -1
  297. package/lib/panel/ui/PanelRail.js.map +1 -1
  298. package/lib/raman.d.ts +17 -0
  299. package/lib/raman.d.ts.map +1 -0
  300. package/lib/raman.js +12 -0
  301. package/lib/raman.js.map +1 -0
  302. package/lib/router/core/basePath.d.ts +2 -2
  303. package/lib/router/core/basePath.js +2 -2
  304. package/lib/router/core/siteAddresses.d.ts +1 -1
  305. package/lib/router/core/siteAddresses.js +1 -1
  306. package/lib/seo/core/siteFiles.js +1 -1
  307. package/lib/seo/core/siteFiles.js.map +1 -1
  308. package/lib/server/answerAddresses.d.ts +3 -3
  309. package/lib/server/answerAddresses.js +3 -3
  310. package/lib/structure/core/index.d.ts +2 -0
  311. package/lib/structure/core/index.d.ts.map +1 -1
  312. package/lib/structure/core/index.js +1 -0
  313. package/lib/structure/core/index.js.map +1 -1
  314. package/lib/structure/core/structureTransfer.d.ts +29 -0
  315. package/lib/structure/core/structureTransfer.d.ts.map +1 -0
  316. package/lib/structure/core/structureTransfer.js +26 -0
  317. package/lib/structure/core/structureTransfer.js.map +1 -0
  318. package/lib/structure/ui/EditorImportButton.d.ts +20 -0
  319. package/lib/structure/ui/EditorImportButton.d.ts.map +1 -0
  320. package/lib/structure/ui/EditorImportButton.js +24 -0
  321. package/lib/structure/ui/EditorImportButton.js.map +1 -0
  322. package/lib/structure/ui/EditorImportProblem.d.ts +17 -0
  323. package/lib/structure/ui/EditorImportProblem.d.ts.map +1 -0
  324. package/lib/structure/ui/EditorImportProblem.js +32 -0
  325. package/lib/structure/ui/EditorImportProblem.js.map +1 -0
  326. package/lib/structure/ui/StructureDrop.d.ts +39 -0
  327. package/lib/structure/ui/StructureDrop.d.ts.map +1 -0
  328. package/lib/structure/ui/StructureDrop.js +19 -0
  329. package/lib/structure/ui/StructureDrop.js.map +1 -0
  330. package/lib/structure/ui/StructureDropOverlay.d.ts +16 -0
  331. package/lib/structure/ui/StructureDropOverlay.d.ts.map +1 -0
  332. package/lib/structure/ui/StructureDropOverlay.js +29 -0
  333. package/lib/structure/ui/StructureDropOverlay.js.map +1 -0
  334. package/lib/structure/ui/StructureEditor.d.ts +3 -80
  335. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  336. package/lib/structure/ui/StructureEditor.js +21 -33
  337. package/lib/structure/ui/StructureEditor.js.map +1 -1
  338. package/lib/structure/ui/importedStructure.d.ts +25 -0
  339. package/lib/structure/ui/importedStructure.d.ts.map +1 -0
  340. package/lib/structure/ui/importedStructure.js +74 -0
  341. package/lib/structure/ui/importedStructure.js.map +1 -0
  342. package/lib/structure/ui/index.d.ts +2 -0
  343. package/lib/structure/ui/index.d.ts.map +1 -1
  344. package/lib/structure/ui/index.js +1 -0
  345. package/lib/structure/ui/index.js.map +1 -1
  346. package/lib/structure/ui/structureEditorProps.d.ts +98 -0
  347. package/lib/structure/ui/structureEditorProps.d.ts.map +1 -0
  348. package/lib/structure/ui/structureEditorProps.js +2 -0
  349. package/lib/structure/ui/structureEditorProps.js.map +1 -0
  350. package/lib/structure/ui/useDebouncedChange.d.ts +16 -0
  351. package/lib/structure/ui/useDebouncedChange.d.ts.map +1 -0
  352. package/lib/structure/ui/useDebouncedChange.js +30 -0
  353. package/lib/structure/ui/useDebouncedChange.js.map +1 -0
  354. package/lib/structure/ui/useStructureDrop.d.ts +30 -0
  355. package/lib/structure/ui/useStructureDrop.d.ts.map +1 -0
  356. package/lib/structure/ui/useStructureDrop.js +49 -0
  357. package/lib/structure/ui/useStructureDrop.js.map +1 -0
  358. package/lib/structure/ui/useStructureImport.d.ts +45 -0
  359. package/lib/structure/ui/useStructureImport.d.ts.map +1 -0
  360. package/lib/structure/ui/useStructureImport.js +62 -0
  361. package/lib/structure/ui/useStructureImport.js.map +1 -0
  362. package/package.json +5 -1
  363. package/src/download/ui/FigureDownloadPanel.tsx +9 -2
  364. package/src/ecosystem/core/sites.ts +3 -3
  365. package/src/ecosystem/core/types.ts +1 -1
  366. package/src/ecosystem/ui/glyphs.tsx +1 -1
  367. package/src/i18n/core/messageCatalog.ts +2 -2
  368. package/src/i18n/vite/localeCatalog.ts +1 -1
  369. package/src/ir/core/analysisSpectra.ts +26 -10
  370. package/src/ir/core/bandLabelPlan.ts +21 -10
  371. package/src/ir/core/index.ts +31 -7
  372. package/src/ir/core/irBand.ts +52 -14
  373. package/src/ir/core/irCommands.ts +15 -1
  374. package/src/ir/core/irDomain.ts +9 -7
  375. package/src/ir/core/irEditorApi.ts +13 -0
  376. package/src/ir/core/irFormat.ts +39 -6
  377. package/src/ir/core/irMode.ts +42 -10
  378. package/src/ir/core/irReducer.ts +3 -51
  379. package/src/ir/core/irSidePanels.ts +8 -1
  380. package/src/ir/core/irSpectrum.ts +59 -30
  381. package/src/ir/core/irState.ts +73 -5
  382. package/src/ir/core/irTechnique.ts +115 -0
  383. package/src/ir/core/irTechniqueCommands.ts +82 -0
  384. package/src/ir/core/pickBands.ts +63 -28
  385. package/src/ir/core/ramanBands.ts +105 -0
  386. package/src/ir/core/spectrumJcamp.ts +65 -16
  387. package/src/ir/core/toIrSpectrum.ts +20 -2
  388. package/src/ir/ui/BandRow.tsx +107 -0
  389. package/src/ir/ui/BandsPanel.tsx +32 -125
  390. package/src/ir/ui/IrAboutDialog.tsx +69 -28
  391. package/src/ir/ui/IrCanvas.tsx +29 -3
  392. package/src/ir/ui/IrChart.tsx +31 -24
  393. package/src/ir/ui/IrCommandProvider.tsx +10 -3
  394. package/src/ir/ui/IrCommandTooltip.tsx +11 -2
  395. package/src/ir/ui/IrDocumentationDialog.tsx +99 -55
  396. package/src/ir/ui/IrEditor.tsx +27 -40
  397. package/src/ir/ui/IrHeader.tsx +10 -3
  398. package/src/ir/ui/IrLogo.tsx +28 -9
  399. package/src/ir/ui/IrShell.tsx +47 -96
  400. package/src/ir/ui/IrSidePanel.tsx +36 -10
  401. package/src/ir/ui/IrStatusBar.tsx +17 -12
  402. package/src/ir/ui/IrToolbar.tsx +26 -15
  403. package/src/ir/ui/IrTraces.tsx +5 -1
  404. package/src/ir/ui/RamanEditor.tsx +71 -0
  405. package/src/ir/ui/SpectraPanel.tsx +2 -1
  406. package/src/ir/ui/SpectrumRow.tsx +14 -5
  407. package/src/ir/ui/VibrationalEditor.tsx +113 -0
  408. package/src/ir/ui/bandsTsv.ts +46 -0
  409. package/src/ir/ui/index.ts +1 -0
  410. package/src/ir/ui/irActions.ts +3 -3
  411. package/src/ir/ui/irChartProps.ts +21 -4
  412. package/src/ir/ui/irCommandContext.tsx +18 -3
  413. package/src/ir/ui/irHostPanels.ts +76 -0
  414. package/src/ir/ui/useIrEditor.ts +20 -8
  415. package/src/ir/ui/useIrHandle.ts +51 -0
  416. package/src/ir/ui/useIrSide.ts +60 -0
  417. package/src/ir/ui/useIrText.ts +170 -0
  418. package/src/ir/ui/useIrZoom.ts +22 -3
  419. package/src/ir/ui/useValueAxisZoom.ts +67 -0
  420. package/src/ir.ts +3 -0
  421. package/src/locales/de.json +29 -2
  422. package/src/locales/en.json +29 -2
  423. package/src/locales/es.json +29 -2
  424. package/src/locales/fr.json +29 -2
  425. package/src/locales/it.json +29 -2
  426. package/src/molecule3d/core/animatedPng.ts +79 -0
  427. package/src/molecule3d/core/file.ts +23 -0
  428. package/src/molecule3d/core/index.ts +3 -1
  429. package/src/molecule3d/core/settings.ts +0 -8
  430. package/src/molecule3d/ui/Molecule3DExport.tsx +43 -5
  431. package/src/molecule3d/ui/Molecule3DToolbar.tsx +9 -2
  432. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +24 -38
  433. package/src/molecule3d/ui/drawScene.ts +2 -1
  434. package/src/molecule3d/ui/exportMoleculeImage.ts +28 -3
  435. package/src/molecule3d/ui/moleculeFrames.ts +88 -0
  436. package/src/molecule3d/ui/moleculeViewer3DProps.ts +14 -5
  437. package/src/molecule3d/ui/renderMolecule.ts +5 -3
  438. package/src/molecule3d/ui/sceneDrawer.ts +14 -2
  439. package/src/molecule3d/ui/useImageExport.ts +22 -5
  440. package/src/molecule3d/ui/useMoleculeScene.ts +2 -1
  441. package/src/molecule3d/ui/useMoleculeViewer.ts +46 -0
  442. package/src/molecule3d/ui/usePolarSurfaceArea.ts +6 -4
  443. package/src/molecule3d/ui/viewer.ts +34 -27
  444. package/src/molecule3d/ui/viewerTypes.ts +6 -0
  445. package/src/molstar/core/captureScene.ts +85 -2
  446. package/src/molstar/core/index.ts +13 -2
  447. package/src/molstar/core/trajectory.ts +117 -0
  448. package/src/panel/ui/PanelRail.tsx +3 -0
  449. package/src/raman.ts +20 -0
  450. package/src/router/core/basePath.ts +2 -2
  451. package/src/router/core/siteAddresses.ts +1 -1
  452. package/src/seo/core/siteFiles.ts +1 -1
  453. package/src/server/answerAddresses.ts +3 -3
  454. package/src/structure/core/index.ts +8 -0
  455. package/src/structure/core/structureTransfer.ts +37 -0
  456. package/src/structure/ui/EditorImportButton.tsx +59 -0
  457. package/src/structure/ui/EditorImportProblem.tsx +63 -0
  458. package/src/structure/ui/StructureDrop.tsx +66 -0
  459. package/src/structure/ui/StructureDropOverlay.tsx +50 -0
  460. package/src/structure/ui/StructureEditor.tsx +49 -134
  461. package/src/structure/ui/importedStructure.ts +83 -0
  462. package/src/structure/ui/index.ts +2 -0
  463. package/src/structure/ui/structureEditorProps.ts +103 -0
  464. package/src/structure/ui/useDebouncedChange.ts +41 -0
  465. package/src/structure/ui/useStructureDrop.ts +76 -0
  466. package/src/structure/ui/useStructureImport.ts +122 -0
@@ -13,8 +13,10 @@
13
13
  * a stale band is then impossible rather than merely unlikely.
14
14
  */
15
15
 
16
- import type { IrSidePanelId } from './irSidePanels.ts';
16
+ import type { IrPanelId, IrSidePanelId } from './irSidePanels.ts';
17
17
  import type { IrDomain, IrMode, IrSpectrum } from './irSpectrum.ts';
18
+ import type { IrTechnique } from './irTechnique.ts';
19
+ import { defaultIrMode, irModeFor, offersIrMode } from './irTechnique.ts';
18
20
  import type { PickBandsOptions } from './pickBands.ts';
19
21
 
20
22
  /** The document: what a file holds. */
@@ -40,15 +42,23 @@ export interface IrView {
40
42
  domain: IrDomain | null;
41
43
  /** Which tool a drag across the chart is running. */
42
44
  tool: IrTool;
43
- /** The side panels that are open, in the order their icons are stacked. */
44
- openPanelIds: IrSidePanelId[];
45
+ /**
46
+ * The side panels that are open: the viewer's own and any a host added. An id
47
+ * no panel on offer answers to opens nothing.
48
+ */
49
+ openPanelIds: IrPanelId[];
45
50
  /** Why the last action was refused, `null` as soon as one succeeds. */
46
51
  error: string | null;
47
52
  }
48
53
 
49
54
  /** The workspace: how every spectrum is drawn, whichever ones are open. */
50
55
  export interface IrSettings {
51
- /** Which value axis the spectra are read in. */
56
+ /**
57
+ * What the spectra were measured with. Chosen when the viewer opens and fixed
58
+ * from then on: a change asking for another is ignored.
59
+ */
60
+ technique: IrTechnique;
61
+ /** Which value axis the spectra are read in, always one the technique offers. */
52
62
  mode: IrMode;
53
63
  /** Whether the bands are picked at all. */
54
64
  pickBands: boolean;
@@ -108,6 +118,7 @@ export const DEFAULT_PICKING: PickBandsOptions = {
108
118
 
109
119
  /** The workspace a fresh viewer starts from. */
110
120
  export const DEFAULT_SETTINGS: IrSettings = {
121
+ technique: 'infrared',
111
122
  mode: 'transmittance',
112
123
  pickBands: true,
113
124
  picking: DEFAULT_PICKING,
@@ -116,6 +127,57 @@ export const DEFAULT_SETTINGS: IrSettings = {
116
127
  assignmentTolerance: 5,
117
128
  };
118
129
 
130
+ /** What a viewer opens on. */
131
+ export interface CreateIrStateOptions {
132
+ /**
133
+ * The spectra to open on.
134
+ * @default []
135
+ */
136
+ spectra?: IrSpectrum[];
137
+ /**
138
+ * The workspace to open in. Its `technique` is fixed for the life of the
139
+ * viewer, and its `mode` falls back to the technique's first when the
140
+ * technique does not offer it.
141
+ * @default DEFAULT_SETTINGS
142
+ */
143
+ settings?: Partial<IrSettings>;
144
+ /**
145
+ * The panels open to begin with, the viewer's own or a host's.
146
+ * @default DEFAULT_SIDE_PANELS
147
+ */
148
+ panelIds?: readonly IrPanelId[];
149
+ }
150
+
151
+ /**
152
+ * The state a viewer opens with.
153
+ *
154
+ * The panel list is spread rather than stored by reference: a caller's array is
155
+ * the caller's to mutate, and a viewer holding it would find its open panels
156
+ * changing under it.
157
+ * @param options - What it opens on.
158
+ * @returns The state.
159
+ */
160
+ export function createIrState(options: CreateIrStateOptions = {}): IrState {
161
+ const { spectra = [], settings, panelIds } = options;
162
+ const technique = settings?.technique ?? DEFAULT_SETTINGS.technique;
163
+ const opened: IrSettings = {
164
+ ...DEFAULT_SETTINGS,
165
+ technique,
166
+ mode: defaultIrMode(technique),
167
+ };
168
+ return {
169
+ data: { spectra: [...spectra] },
170
+ view: {
171
+ selectedId: spectra[0]?.id ?? null,
172
+ domain: null,
173
+ tool: 'read',
174
+ openPanelIds: [...(panelIds ?? DEFAULT_SIDE_PANELS)],
175
+ error: null,
176
+ },
177
+ settings: mergeIrSettings(opened, settings),
178
+ };
179
+ }
180
+
119
181
  /**
120
182
  * Fold a change into the workspace, refusing what no chart survives.
121
183
  *
@@ -123,7 +185,9 @@ export const DEFAULT_SETTINGS: IrSettings = {
123
185
  * not yet a number — a lone minus sign, an empty box — and a limit of `NaN`
124
186
  * silently stops every label being drawn. So each is checked, and the current
125
187
  * value is kept where the new one is unusable rather than the field being
126
- * fought with while it is being typed in.
188
+ * fought with while it is being typed in. The technique is never changed, and a
189
+ * mode it does not offer is refused the same way: a Raman spectrum has no
190
+ * absorbance to draw.
127
191
  * @param current - The workspace in force.
128
192
  * @param change - What to change about it.
129
193
  * @returns The new workspace.
@@ -137,6 +201,10 @@ export function mergeIrSettings(
137
201
  return {
138
202
  ...current,
139
203
  ...change,
204
+ technique: current.technique,
205
+ mode: offersIrMode(current.technique, change.mode)
206
+ ? change.mode
207
+ : irModeFor(current.technique, current.mode),
140
208
  picking: { ...current.picking, ...change.picking },
141
209
  labelLimit: Number.isFinite(asked)
142
210
  ? Math.min(MAXIMUM_LABEL_LIMIT, Math.max(0, Math.round(asked)))
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Everything that differs between an infrared spectrum and a Raman one.
3
+ *
4
+ * Both are vibrational spectra over wavenumbers in cm⁻¹, and the viewer reads
5
+ * them the same way — one chart, one set of panels, one set of gestures — so
6
+ * what is left to differ is a handful of facts: which value axes a spectrum is
7
+ * read on, what the horizontal axis is called and which way it runs, whether the
8
+ * correlation table has anything to say about a band, and what a written file
9
+ * calls itself. They are gathered here for the reason `IR_MODE_RULES` gathers
10
+ * what differs between the value axes: a component that asked which technique
11
+ * it was drawing would be the first of many to ask, and they would come to
12
+ * disagree.
13
+ */
14
+
15
+ import type { IrMode } from './irSpectrum.ts';
16
+
17
+ /** What was measured: the light a sample absorbs, or the light it scatters. */
18
+ export type IrTechnique = 'infrared' | 'raman';
19
+
20
+ /** What is true of one technique. */
21
+ export interface IrTechniqueRules {
22
+ /** How it is written inside a sentence; a sentence opening on it capitalises it. */
23
+ name: string;
24
+ /** The value axes a spectrum is read on, in the order a control offers them. */
25
+ modes: readonly IrMode[];
26
+ /** What the horizontal axis is called. */
27
+ xTitle: string;
28
+ /** Whether the horizontal axis runs from high at the left to low at the right. */
29
+ reverseX: boolean;
30
+ /** Whether the correlation table is asked what a band might be. */
31
+ assignments: boolean;
32
+ /** The `##DATA TYPE=` a written spectrum states when its file stated none. */
33
+ dataType: string;
34
+ }
35
+
36
+ /** The techniques, in the order a control would offer them. */
37
+ export const IR_TECHNIQUES: readonly IrTechnique[] = ['infrared', 'raman'];
38
+
39
+ /** How each technique behaves, every fact in one place. */
40
+ export const IR_TECHNIQUE_RULES = {
41
+ infrared: {
42
+ name: 'infrared',
43
+ modes: ['transmittance', 'absorbance'],
44
+ xTitle: 'wavenumber (cm⁻¹)',
45
+ /**
46
+ * 4000 at the left and 400 at the right, which is how every infrared
47
+ * spectrum has been printed since the instruments scanned that way.
48
+ */
49
+ reverseX: true,
50
+ assignments: true,
51
+ dataType: 'INFRARED SPECTRUM',
52
+ },
53
+ raman: {
54
+ name: 'Raman',
55
+ /** One axis: a Raman spectrum is the light scattered, and nothing else. */
56
+ modes: ['intensity'],
57
+ xTitle: 'Raman shift (cm⁻¹)',
58
+ /** The shift grows away from the laser line, left to right. */
59
+ reverseX: false,
60
+ /**
61
+ * The table holds infrared group frequencies and infrared strengths. A
62
+ * vibration strong in one technique is often weak or silent in the other,
63
+ * so its candidates offered for a Raman band would claim what the table
64
+ * does not know.
65
+ */
66
+ assignments: false,
67
+ dataType: 'RAMAN SPECTRUM',
68
+ },
69
+ } as const satisfies Record<IrTechnique, IrTechniqueRules>;
70
+
71
+ /**
72
+ * The value axis a viewer of a technique opens on.
73
+ * @param technique - What was measured.
74
+ * @returns Its first mode.
75
+ */
76
+ export function defaultIrMode(technique: IrTechnique): IrMode {
77
+ return IR_TECHNIQUE_RULES[technique].modes[0];
78
+ }
79
+
80
+ /**
81
+ * Whether a technique reads its spectra on a value axis.
82
+ * @param technique - What was measured.
83
+ * @param mode - The axis asked about; `undefined` is offered by none.
84
+ * @returns Whether the technique offers it.
85
+ */
86
+ export function offersIrMode(
87
+ technique: IrTechnique,
88
+ mode: IrMode | undefined,
89
+ ): mode is IrMode {
90
+ if (mode === undefined) return false;
91
+ const modes: readonly IrMode[] = IR_TECHNIQUE_RULES[technique].modes;
92
+ return modes.includes(mode);
93
+ }
94
+
95
+ /**
96
+ * The value axis to read a technique's spectra on, given the one asked for.
97
+ * @param technique - What was measured.
98
+ * @param mode - The axis asked for, if any.
99
+ * @returns It when the technique offers it, the technique's first otherwise.
100
+ */
101
+ export function irModeFor(technique: IrTechnique, mode?: IrMode): IrMode {
102
+ return offersIrMode(technique, mode) ? mode : defaultIrMode(technique);
103
+ }
104
+
105
+ /**
106
+ * The technique that reads its spectra on a value axis.
107
+ *
108
+ * Every axis belongs to exactly one technique, so the axis a file was written
109
+ * on says what was measured.
110
+ * @param mode - The value axis.
111
+ * @returns The technique offering it.
112
+ */
113
+ export function irModeTechnique(mode: IrMode): IrTechnique {
114
+ return offersIrMode('raman', mode) ? 'raman' : 'infrared';
115
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The commands each technique's viewer offers.
3
+ *
4
+ * A Raman viewer offers the infrared table less the commands with nothing to
5
+ * act on — one value axis is nothing to toggle, and no assignment is nothing to
6
+ * name — and words the rest without the absorbance and transmittance it does
7
+ * not have. It is built from the infrared table, so a command added there
8
+ * reaches both.
9
+ */
10
+
11
+ import type { IrCommand, IrCommandId, IrCommandTable } from './irCommands.ts';
12
+ import { irCommands } from './irCommands.ts';
13
+ import type { IrTechnique } from './irTechnique.ts';
14
+ import { IR_TECHNIQUE_RULES } from './irTechnique.ts';
15
+
16
+ /**
17
+ * Whether a viewer of a technique offers a command at all.
18
+ * @param technique - What was measured.
19
+ * @param id - Which command.
20
+ * @returns False for the toggle of a technique with one value axis, and for
21
+ * the assignments of one the correlation table says nothing about.
22
+ */
23
+ export function irCommandOffered(
24
+ technique: IrTechnique,
25
+ id: IrCommandId,
26
+ ): boolean {
27
+ const { modes, assignments } = IR_TECHNIQUE_RULES[technique];
28
+ if (id === 'toggleMode') return modes.length > 1;
29
+ if (id === 'toggleAssignments') return assignments;
30
+ return true;
31
+ }
32
+
33
+ /**
34
+ * Everything a viewer of a technique offers, in the order it is reached for.
35
+ * @param technique - What was measured.
36
+ * @returns The table; for infrared, `irCommands` itself.
37
+ */
38
+ export function irCommandsFor(technique: IrTechnique): IrCommandTable {
39
+ return COMMAND_TABLES[technique];
40
+ }
41
+
42
+ /** Where the chart is, for a gesture made anywhere on it. */
43
+ const OVER_THE_CHART = 'Over the chart';
44
+
45
+ /** How a Raman viewer words the commands it shares with infrared. */
46
+ const RAMAN_WORDING: Partial<Record<IrCommandId, Partial<IrCommand>>> = {
47
+ about: { title: 'About the Raman viewer' },
48
+ documentation: {
49
+ description: 'How the bands are read, and every gesture.',
50
+ },
51
+ readTool: {
52
+ description:
53
+ 'A drag narrows the Raman shift axis. Released past the baseline, it takes the intensity axis with it.',
54
+ gestures: [{ title: OVER_THE_CHART, shortcuts: ['Drag'] }],
55
+ },
56
+ boxTool: {
57
+ description:
58
+ 'A drag zooms to exactly the rectangle it sweeps out, both axes at once — for looking into a baseline or a shoulder rather than across the spectrum.',
59
+ },
60
+ zoomIn: {
61
+ description:
62
+ 'Brings the weak bands up, scaling the intensity axis about zero.',
63
+ gestures: [{ title: OVER_THE_CHART, shortcuts: ['Scroll wheel'] }],
64
+ },
65
+ zoomOut: {
66
+ gestures: [{ title: OVER_THE_CHART, shortcuts: ['Scroll wheel'] }],
67
+ },
68
+ togglePicking: {
69
+ description:
70
+ 'Finds the bands of the selected spectrum, marks them on the chart and lists them.',
71
+ },
72
+ };
73
+
74
+ /** The command table of each technique. */
75
+ const COMMAND_TABLES: Record<IrTechnique, IrCommandTable> = {
76
+ infrared: irCommands,
77
+ raman: Object.fromEntries(
78
+ (Object.keys(irCommands) as IrCommandId[])
79
+ .filter((id) => irCommandOffered('raman', id))
80
+ .map((id) => [id, { ...irCommands[id], ...RAMAN_WORDING[id] }]),
81
+ ),
82
+ };
@@ -3,11 +3,12 @@
3
3
  *
4
4
  * Everything here is the two things that call needs and does not have: a
5
5
  * `MeasurementXY` built out of the arrays the viewer holds, and the decision to
6
- * pick on **absorbance** rather than on transmittance. That second one is the
7
- * only judgement in the file and it is not a preference — peak picking finds
8
- * maxima, and a band is a maximum in absorbance but a *minimum* in transmittance,
9
- * so picking on transmittance would return the flat baseline between the bands
10
- * and miss every band there is.
6
+ * pick an infrared spectrum on **absorbance** rather than on transmittance. That
7
+ * second one is the only judgement in the file and it is not a preference — peak
8
+ * picking finds maxima, and a band is a maximum in absorbance but a *minimum* in
9
+ * transmittance, so picking on transmittance would return the flat baseline
10
+ * between the bands and miss every band there is. A Raman spectrum is picked on
11
+ * its intensity, by `ramanBands`, with the same picker.
11
12
  */
12
13
 
13
14
  import type { MeasurementXY } from 'cheminfo-types';
@@ -15,7 +16,10 @@ import { autoPeakPicking } from 'ir-spectrum';
15
16
  import { xMaxValue, xMinValue } from 'ml-spectra-processing';
16
17
 
17
18
  import type { IrBand, IrBandStrength } from './irBand.ts';
19
+ import { bandHeight } from './irBand.ts';
18
20
  import type { IrSpectrum } from './irSpectrum.ts';
21
+ import type { PeakPickingOptions } from './ramanBands.ts';
22
+ import { ramanBands } from './ramanBands.ts';
19
23
 
20
24
  /** How the bands are picked. */
21
25
  export interface PickBandsOptions {
@@ -86,20 +90,50 @@ export function pickBands(
86
90
  } = options;
87
91
  if (spectrum.wavenumber.length < 2) return [];
88
92
 
89
- const picked = autoPeakPicking(measurementOf(spectrum), {
90
- // Absorbance, because a band is a maximum there and a minimum in the other.
91
- yVariable: 'a',
93
+ const picking: PeakPickingOptions = {
92
94
  minMaxRatio: minRelativeHeight,
93
95
  minPeakWidth,
94
96
  ...(from === undefined ? {} : { from }),
95
97
  ...(to === undefined ? {} : { to }),
96
- });
98
+ };
99
+ // A spectrum carrying an intensity is a Raman one; any other is infrared.
100
+ const bands =
101
+ spectrum.intensity === undefined
102
+ ? infraredBands(spectrum, picking)
103
+ : ramanBands(spectrum, spectrum.intensity, picking);
104
+
105
+ const kept =
106
+ limit === undefined || bands.length <= limit
107
+ ? bands
108
+ : bands.toSorted(byDescendingHeight).slice(0, limit);
109
+ return kept.toSorted(byAscendingWavenumber);
110
+ }
111
+
112
+ /**
113
+ * The bands of an infrared spectrum, picked on its absorbance.
114
+ * @param spectrum - The spectrum to pick from.
115
+ * @param picking - Where to pick, and how finely.
116
+ * @returns The bands, in the order they were found; none when the spectrum
117
+ * carries only one of its two axes, since the strength is read off the other.
118
+ */
119
+ function infraredBands(
120
+ spectrum: IrSpectrum,
121
+ picking: PeakPickingOptions,
122
+ ): IrBand[] {
123
+ const { id, wavenumber, absorbance, transmittance } = spectrum;
124
+ if (absorbance === undefined || transmittance === undefined) return [];
125
+
126
+ const picked = autoPeakPicking(
127
+ measurementOf(wavenumber, absorbance, transmittance),
128
+ // Absorbance, because a band is a maximum there and a minimum in the other.
129
+ { yVariable: 'a', ...picking },
130
+ );
97
131
 
98
132
  const bands: IrBand[] = [];
99
133
  for (const peak of picked) {
100
134
  if (!Number.isFinite(peak.wavenumber)) continue;
101
135
  bands.push({
102
- spectrumId: spectrum.id,
136
+ spectrumId: id,
103
137
  wavenumber: peak.wavenumber,
104
138
  absorbance: peak.absorbance,
105
139
  // `ConvertedPeak.transmittance` is a fraction where the spectrum's own
@@ -109,12 +143,7 @@ export function pickBands(
109
143
  strength: peak.kind as IrBandStrength,
110
144
  });
111
145
  }
112
-
113
- const kept =
114
- limit === undefined || bands.length <= limit
115
- ? bands
116
- : bands.toSorted(byDescendingAbsorbance).slice(0, limit);
117
- return kept.toSorted(byAscendingWavenumber);
146
+ return bands;
118
147
  }
119
148
 
120
149
  /**
@@ -124,17 +153,23 @@ export function pickBands(
124
153
  * letter is worked out from: without them the conversion assumes a spectrum
125
154
  * running the full 0 to 100 percent, and every band of a shallow ATR trace that
126
155
  * never leaves the eighties comes back weak.
127
- * @param spectrum - The spectrum the viewer holds.
156
+ * @param wavenumber - The wavenumbers, ascending.
157
+ * @param absorbance - Absorbance at each.
158
+ * @param transmittance - Percent transmittance at each.
128
159
  * @returns A measurement carrying all three variables.
129
160
  */
130
- function measurementOf(spectrum: IrSpectrum): MeasurementXY {
131
- const transmittance = {
161
+ function measurementOf(
162
+ wavenumber: Float64Array,
163
+ absorbance: Float64Array,
164
+ transmittance: Float64Array,
165
+ ): MeasurementXY {
166
+ const percent = {
132
167
  label: 'Transmittance (%)',
133
168
  units: '%',
134
169
  symbol: 't' as const,
135
- data: spectrum.transmittance,
136
- min: xMinValue(spectrum.transmittance),
137
- max: xMaxValue(spectrum.transmittance),
170
+ data: transmittance,
171
+ min: xMinValue(transmittance),
172
+ max: xMaxValue(transmittance),
138
173
  };
139
174
  return {
140
175
  variables: {
@@ -142,20 +177,20 @@ function measurementOf(spectrum: IrSpectrum): MeasurementXY {
142
177
  label: 'Wavenumber',
143
178
  units: '1/cm',
144
179
  symbol: 'x',
145
- data: spectrum.wavenumber,
180
+ data: wavenumber,
146
181
  },
147
182
  // `y` is required of every measurement, and stands for whichever axis was
148
183
  // recorded. Nothing here reads it — the picking is told to use `a` and the
149
184
  // strength letter is read off `t` — so it carries the transmittance rather
150
185
  // than a third copy of anything.
151
- y: transmittance,
186
+ y: percent,
152
187
  a: {
153
188
  label: 'Absorbance',
154
189
  units: '',
155
190
  symbol: 'a',
156
- data: spectrum.absorbance,
191
+ data: absorbance,
157
192
  },
158
- t: transmittance,
193
+ t: percent,
159
194
  },
160
195
  };
161
196
  }
@@ -166,8 +201,8 @@ function measurementOf(spectrum: IrSpectrum): MeasurementXY {
166
201
  * @param second - The other.
167
202
  * @returns The comparison.
168
203
  */
169
- function byDescendingAbsorbance(first: IrBand, second: IrBand): number {
170
- return second.absorbance - first.absorbance;
204
+ function byDescendingHeight(first: IrBand, second: IrBand): number {
205
+ return bandHeight(second) - bandHeight(first);
171
206
  }
172
207
 
173
208
  /**
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Finding the bands of a Raman spectrum, with the picker infrared bands are
3
+ * found with.
4
+ *
5
+ * `autoPeakPicking` from `ir-spectrum` is `common-spectrum`'s, which runs
6
+ * `ml-gsd` over whichever variable it is pointed at — the picker
7
+ * `raman-spectrum` itself exports — and converts each peak to absorbance and
8
+ * transmittance on top. A Raman band is a maximum of intensity, so the picker is
9
+ * pointed at the intensity and only where each peak sits is read back: the
10
+ * conversion speaks two axes a Raman spectrum does not have.
11
+ *
12
+ * The strength letter follows the rule `ir-spectrum` applies to transmittance,
13
+ * applied to intensity: where the band's top sits between the spectrum's own
14
+ * lowest and highest intensity — below a third weak, below two thirds medium,
15
+ * strong above.
16
+ */
17
+
18
+ import type { MeasurementXY } from 'cheminfo-types';
19
+ import { autoPeakPicking } from 'ir-spectrum';
20
+ import { xFindClosestIndex, xMinMaxValues } from 'ml-spectra-processing';
21
+
22
+ import type { IrBand, IrBandStrength } from './irBand.ts';
23
+ import type { IrSpectrum } from './irSpectrum.ts';
24
+
25
+ /** What the picker is asked, whichever technique it picks for. */
26
+ export type PeakPickingOptions = NonNullable<
27
+ Parameters<typeof autoPeakPicking>[1]
28
+ >;
29
+
30
+ /**
31
+ * The bands of a Raman spectrum, picked on its intensity.
32
+ * @param spectrum - The spectrum to pick from.
33
+ * @param intensity - Its intensity, which the bands are maxima of.
34
+ * @param picking - Where to pick, and how finely.
35
+ * @returns The bands, in the order they were found.
36
+ */
37
+ export function ramanBands(
38
+ spectrum: IrSpectrum,
39
+ intensity: Float64Array,
40
+ picking: PeakPickingOptions,
41
+ ): IrBand[] {
42
+ const { id, wavenumber } = spectrum;
43
+ const picked = autoPeakPicking(measurementOf(wavenumber, intensity), {
44
+ ...picking,
45
+ yVariable: 'y',
46
+ });
47
+ const { min, max } = xMinMaxValues(intensity);
48
+
49
+ const bands: IrBand[] = [];
50
+ for (const peak of picked) {
51
+ if (!Number.isFinite(peak.wavenumber)) continue;
52
+ // The peak sits on a sample, so its intensity is read off that sample.
53
+ const value = intensity[xFindClosestIndex(wavenumber, peak.wavenumber)];
54
+ if (value === undefined) continue;
55
+ bands.push({
56
+ spectrumId: id,
57
+ wavenumber: peak.wavenumber,
58
+ intensity: value,
59
+ strength: strengthOf(value, min, max),
60
+ });
61
+ }
62
+ return bands;
63
+ }
64
+
65
+ /**
66
+ * How strong a band is, from where its top sits in the spectrum's range.
67
+ * @param value - The band's intensity.
68
+ * @param lowest - The spectrum's lowest intensity.
69
+ * @param highest - Its highest.
70
+ * @returns The letter a correlation table would use.
71
+ */
72
+ function strengthOf(
73
+ value: number,
74
+ lowest: number,
75
+ highest: number,
76
+ ): IrBandStrength {
77
+ const position = (value - lowest) / (highest - lowest);
78
+ if (position < WEAK_BELOW) return 'w';
79
+ if (position < MEDIUM_BELOW) return 'm';
80
+ return 'S';
81
+ }
82
+
83
+ /** Below this fraction of the spectrum's range a band is weak. */
84
+ const WEAK_BELOW = 0.33;
85
+
86
+ /** Below this one it is medium, and strong from here up. */
87
+ const MEDIUM_BELOW = 0.66;
88
+
89
+ /**
90
+ * The spectrum as `ir-spectrum` wants it: the shifts, and the intensity as `y`.
91
+ * @param shift - The Raman shifts, ascending.
92
+ * @param intensity - The intensity at each.
93
+ * @returns The measurement.
94
+ */
95
+ function measurementOf(
96
+ shift: Float64Array,
97
+ intensity: Float64Array,
98
+ ): MeasurementXY {
99
+ return {
100
+ variables: {
101
+ x: { label: 'Raman shift', units: '1/cm', symbol: 'x', data: shift },
102
+ y: { label: 'Intensity', units: '', symbol: 'y', data: intensity },
103
+ },
104
+ };
105
+ }