matterviz 0.3.1 → 0.3.3
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.
- package/dist/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { ELEM_SYMBOLS } from '../../labels';
|
|
2
|
+
import * as math from '../../math';
|
|
3
|
+
import { coerce_element_symbol, create_trajectory_frame } from '../helpers';
|
|
4
|
+
// Parse LAMMPS box bounds → lattice matrix. Handles orthogonal and triclinic boxes.
|
|
5
|
+
// Triclinic: converts bounding box to actual dims per https://docs.lammps.org/Howto_triclinic.html
|
|
6
|
+
// Lattice vectors: a=(lx,0,0), b=(xy,ly,0), c=(xz,yz,lz)
|
|
7
|
+
export function parse_lammps_box(box_lines, is_triclinic) {
|
|
8
|
+
if (box_lines.length !== 3)
|
|
9
|
+
return null;
|
|
10
|
+
const bounds = box_lines.map((line) => line.split(/\s+/).map(Number));
|
|
11
|
+
const min_cols = is_triclinic ? 3 : 2;
|
|
12
|
+
if (bounds.some((row) => row.length < min_cols || row.slice(0, min_cols).some(isNaN))) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (!is_triclinic) {
|
|
16
|
+
// Orthogonal: bounds = [lo, hi] per dimension
|
|
17
|
+
const [[lo_x, hi_x], [lo_y, hi_y], [lo_z, hi_z]] = bounds;
|
|
18
|
+
return [
|
|
19
|
+
[hi_x - lo_x, 0, 0],
|
|
20
|
+
[0, hi_y - lo_y, 0],
|
|
21
|
+
[0, 0, hi_z - lo_z],
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
// Triclinic: bounds = [lo_bound, hi_bound, tilt] with tilts xy, xz, yz
|
|
25
|
+
const [[xlo_b, xhi_b, xy], [ylo_b, yhi_b, xz], [zlo_b, zhi_b, yz]] = bounds;
|
|
26
|
+
const lx = xhi_b - Math.max(0, xy, xz, xy + xz) - (xlo_b - Math.min(0, xy, xz, xy + xz));
|
|
27
|
+
const ly = yhi_b - Math.max(0, yz) - (ylo_b - Math.min(0, yz));
|
|
28
|
+
const lz = zhi_b - zlo_b;
|
|
29
|
+
return [
|
|
30
|
+
[lx, 0, 0],
|
|
31
|
+
[xy, ly, 0],
|
|
32
|
+
[xz, yz, lz],
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
// Parse LAMMPS trajectory (.lammpstrj). Atom types mapped to elements via atom_type_mapping
|
|
36
|
+
// or by default: 1→H, 2→He, etc. Supports orthogonal and triclinic simulation boxes.
|
|
37
|
+
export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
38
|
+
const lines = content.trim().split(/\r?\n/);
|
|
39
|
+
const frames = [];
|
|
40
|
+
const atom_types_found = new Set();
|
|
41
|
+
let id_fallback_warning_emitted = false;
|
|
42
|
+
let idx = 0;
|
|
43
|
+
const read_line = () => lines[idx++]?.trim() ?? ``;
|
|
44
|
+
const peek_line = () => lines[idx]?.trim() ?? ``;
|
|
45
|
+
const skip_to = (prefix) => {
|
|
46
|
+
while (idx < lines.length && !peek_line().startsWith(prefix))
|
|
47
|
+
idx++;
|
|
48
|
+
return idx < lines.length;
|
|
49
|
+
};
|
|
50
|
+
// Helper to map atom type to element symbol
|
|
51
|
+
const get_element = (atom_type) => {
|
|
52
|
+
if (atom_type_mapping?.[atom_type])
|
|
53
|
+
return atom_type_mapping[atom_type];
|
|
54
|
+
return ELEM_SYMBOLS[Math.max(0, atom_type - 1) % ELEM_SYMBOLS.length];
|
|
55
|
+
};
|
|
56
|
+
while (idx < lines.length) {
|
|
57
|
+
if (!skip_to(`ITEM: TIMESTEP`))
|
|
58
|
+
break;
|
|
59
|
+
idx++;
|
|
60
|
+
const timestep = parseInt(read_line(), 10) || 0;
|
|
61
|
+
if (!skip_to(`ITEM: NUMBER OF ATOMS`))
|
|
62
|
+
break;
|
|
63
|
+
idx++;
|
|
64
|
+
const num_atoms = parseInt(read_line(), 10);
|
|
65
|
+
if (!num_atoms || num_atoms <= 0)
|
|
66
|
+
continue;
|
|
67
|
+
// BOX BOUNDS: orthogonal="pp pp pp", triclinic="xy xz yz pp pp pp"
|
|
68
|
+
if (!skip_to(`ITEM: BOX BOUNDS`))
|
|
69
|
+
break;
|
|
70
|
+
const box_header = read_line();
|
|
71
|
+
const is_triclinic = /BOX BOUNDS\s+xy\s+xz\s+yz/i.test(box_header);
|
|
72
|
+
const tokens = box_header.replace(`ITEM: BOX BOUNDS`, ``).trim().split(/\s+/).slice(-3);
|
|
73
|
+
const is_periodic = (tok) => tok.toLowerCase().startsWith(`p`);
|
|
74
|
+
const pbc = tokens.length === 3
|
|
75
|
+
? [is_periodic(tokens[0]), is_periodic(tokens[1]), is_periodic(tokens[2])]
|
|
76
|
+
: [true, true, true];
|
|
77
|
+
const lattice_matrix = parse_lammps_box([read_line(), read_line(), read_line()], is_triclinic);
|
|
78
|
+
if (!lattice_matrix)
|
|
79
|
+
continue;
|
|
80
|
+
// Find ITEM: ATOMS and parse column headers
|
|
81
|
+
if (!skip_to(`ITEM: ATOMS`))
|
|
82
|
+
break;
|
|
83
|
+
const cols = read_line().replace(`ITEM: ATOMS`, ``).trim().toLowerCase().split(/\s+/);
|
|
84
|
+
const col = Object.fromEntries(cols.map((name, col_idx) => [name, col_idx]));
|
|
85
|
+
// Determine position columns: prefer unwrapped (xu/yu/zu) > scaled (xs/ys/zs) > regular (x/y/z)
|
|
86
|
+
const pos_keys = [`xu`, `yu`, `zu`].every((key) => key in col)
|
|
87
|
+
? [`xu`, `yu`, `zu`]
|
|
88
|
+
: [`xs`, `ys`, `zs`].every((key) => key in col)
|
|
89
|
+
? [`xs`, `ys`, `zs`]
|
|
90
|
+
: [`x`, `y`, `z`];
|
|
91
|
+
const pos_cols = pos_keys.map((key) => col[key]);
|
|
92
|
+
// Atom identity: prefer numeric type, else explicit element symbol.
|
|
93
|
+
// Fallback to ID-based mapping only for legacy dumps; this can be inaccurate
|
|
94
|
+
// for large or non-element-like IDs, so prefer TYPE column when available.
|
|
95
|
+
const type_col = col.type;
|
|
96
|
+
const element_col = col.element;
|
|
97
|
+
const id_col = col.id;
|
|
98
|
+
const use_scaled = pos_keys[0] === `xs`;
|
|
99
|
+
const max_col_idx = Math.max(...pos_cols, type_col ?? -1, element_col ?? -1, id_col ?? -1);
|
|
100
|
+
if (pos_cols.some((col_idx) => col_idx === undefined))
|
|
101
|
+
continue;
|
|
102
|
+
if (type_col === undefined && element_col === undefined && id_col === undefined) {
|
|
103
|
+
console.warn(`Skipping LAMMPS frame at timestep ${timestep}: missing type/element/id column`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Parse atom data
|
|
107
|
+
const positions = [];
|
|
108
|
+
const elements = [];
|
|
109
|
+
const frac_to_cart = use_scaled ? math.create_frac_to_cart(lattice_matrix) : null;
|
|
110
|
+
for (let atom = 0; atom < num_atoms && idx < lines.length; atom++) {
|
|
111
|
+
const parts = read_line().split(/\s+/);
|
|
112
|
+
const coords = pos_cols.map((col_idx) => parseFloat(parts[col_idx]));
|
|
113
|
+
if (coords.some(isNaN) || parts.length <= max_col_idx)
|
|
114
|
+
continue;
|
|
115
|
+
// Convert scaled coordinates to Cartesian if needed
|
|
116
|
+
const xyz = frac_to_cart ? frac_to_cart(coords) : coords;
|
|
117
|
+
let element_symbol;
|
|
118
|
+
if (type_col !== undefined) {
|
|
119
|
+
// Map atom type to element using custom mapping or default (type 1 -> H, etc.)
|
|
120
|
+
const atom_type = parseInt(parts[type_col], 10) || 1;
|
|
121
|
+
atom_types_found.add(atom_type);
|
|
122
|
+
element_symbol = get_element(atom_type);
|
|
123
|
+
}
|
|
124
|
+
else if (element_col !== undefined) {
|
|
125
|
+
const raw_symbol = parts[element_col];
|
|
126
|
+
if (!raw_symbol)
|
|
127
|
+
continue;
|
|
128
|
+
element_symbol = coerce_element_symbol(raw_symbol);
|
|
129
|
+
if (!element_symbol) {
|
|
130
|
+
console.warn(`Skipping LAMMPS atom with unknown element symbol "${raw_symbol}" at timestep ${timestep}`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (id_col !== undefined) {
|
|
135
|
+
const atom_id = parseInt(parts[id_col], 10) || 1;
|
|
136
|
+
atom_types_found.add(atom_id);
|
|
137
|
+
if (!id_fallback_warning_emitted) {
|
|
138
|
+
console.warn(`LAMMPS parser fallback: mapping atom IDs to elements from ID column; this may be incorrect for large or sequential IDs. Prefer a TYPE column when available.`);
|
|
139
|
+
id_fallback_warning_emitted = true;
|
|
140
|
+
}
|
|
141
|
+
element_symbol = get_element(atom_id);
|
|
142
|
+
}
|
|
143
|
+
if (!element_symbol)
|
|
144
|
+
continue;
|
|
145
|
+
positions.push(xyz);
|
|
146
|
+
elements.push(element_symbol);
|
|
147
|
+
}
|
|
148
|
+
if (positions.length === elements.length && positions.length === num_atoms) {
|
|
149
|
+
const { volume } = math.calc_lattice_params(lattice_matrix);
|
|
150
|
+
frames.push(create_trajectory_frame(positions, elements, lattice_matrix, pbc, timestep, {
|
|
151
|
+
volume,
|
|
152
|
+
timestep,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (frames.length === 0) {
|
|
157
|
+
throw new Error(`No valid frames found in LAMMPS trajectory`);
|
|
158
|
+
}
|
|
159
|
+
const first_frame = frames[0];
|
|
160
|
+
const element_counts = first_frame.structure.sites.reduce((counts, site) => {
|
|
161
|
+
const elem = site.species[0].element;
|
|
162
|
+
counts[elem] = (counts[elem] || 0) + 1;
|
|
163
|
+
return counts;
|
|
164
|
+
}, {});
|
|
165
|
+
return {
|
|
166
|
+
frames,
|
|
167
|
+
metadata: {
|
|
168
|
+
filename,
|
|
169
|
+
source_format: `lammps_trajectory`,
|
|
170
|
+
frame_count: frames.length,
|
|
171
|
+
total_atoms: first_frame.structure.sites.length,
|
|
172
|
+
periodic_boundary_conditions: `lattice` in first_frame.structure
|
|
173
|
+
? first_frame.structure.lattice.pbc
|
|
174
|
+
: [true, true, true],
|
|
175
|
+
atom_types: Array.from(atom_types_found).sort((a, b) => a - b),
|
|
176
|
+
element_counts,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as math from '../../math';
|
|
2
|
+
import { create_trajectory_frame, is_valid_element_symbol, validate_3x3_matrix, } from '../helpers';
|
|
3
|
+
export function parse_vasp_xdatcar(content, filename) {
|
|
4
|
+
const lines = content.trim().split(/\r?\n/);
|
|
5
|
+
if (lines.length < 10)
|
|
6
|
+
throw new Error(`XDATCAR file too short`);
|
|
7
|
+
const scale = parseFloat(lines[1]);
|
|
8
|
+
if (isNaN(scale))
|
|
9
|
+
throw new Error(`Invalid scale factor`);
|
|
10
|
+
const lattice_matrix = validate_3x3_matrix(lines.slice(2, 5).map((line) => line
|
|
11
|
+
.trim()
|
|
12
|
+
.split(/\s+/)
|
|
13
|
+
.map((x) => parseFloat(x) * scale)));
|
|
14
|
+
const element_names = lines[5].trim().split(/\s+/);
|
|
15
|
+
const element_counts = lines[6].trim().split(/\s+/).map(Number);
|
|
16
|
+
if (element_names.length !== element_counts.length) {
|
|
17
|
+
throw new Error(`XDATCAR element names/counts mismatch: names=${element_names.length}, counts=${element_counts.length}`);
|
|
18
|
+
}
|
|
19
|
+
if (element_counts.some((count) => !Number.isFinite(count) || !Number.isInteger(count) || count <= 0)) {
|
|
20
|
+
throw new Error(`XDATCAR contains invalid element counts: expected finite positive integers`);
|
|
21
|
+
}
|
|
22
|
+
const validated_element_names = element_names.map((name) => {
|
|
23
|
+
if (!is_valid_element_symbol(name)) {
|
|
24
|
+
throw new Error(`Invalid element symbol in XDATCAR: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
return name;
|
|
27
|
+
});
|
|
28
|
+
const elements = validated_element_names.flatMap((name, idx) => Array(element_counts[idx]).fill(name));
|
|
29
|
+
const frames = [];
|
|
30
|
+
let line_idx = 7;
|
|
31
|
+
const frac_to_cart = math.create_frac_to_cart(lattice_matrix);
|
|
32
|
+
while (line_idx < lines.length) {
|
|
33
|
+
const config_idx = lines.findIndex((line, idx) => idx >= line_idx && line.includes(`Direct configuration=`));
|
|
34
|
+
if (config_idx === -1)
|
|
35
|
+
break;
|
|
36
|
+
const config_line = lines[config_idx];
|
|
37
|
+
line_idx = config_idx + 1;
|
|
38
|
+
const step_match = /configuration=\s*(\d+)/.exec(config_line);
|
|
39
|
+
const step = step_match ? parseInt(step_match[1]) : frames.length + 1;
|
|
40
|
+
const positions = [];
|
|
41
|
+
for (let idx = 0; idx < elements.length && line_idx < lines.length; idx++) {
|
|
42
|
+
const coords = lines[line_idx].trim().split(/\s+/).slice(0, 3).map(Number);
|
|
43
|
+
if (coords.length === 3 && !coords.some(isNaN)) {
|
|
44
|
+
positions.push(frac_to_cart(coords));
|
|
45
|
+
}
|
|
46
|
+
line_idx++;
|
|
47
|
+
}
|
|
48
|
+
if (positions.length === elements.length) {
|
|
49
|
+
const pbc = [true, true, true];
|
|
50
|
+
const { volume } = math.calc_lattice_params(lattice_matrix);
|
|
51
|
+
frames.push(create_trajectory_frame(positions, elements, lattice_matrix, pbc, step, {
|
|
52
|
+
volume,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
frames,
|
|
58
|
+
metadata: {
|
|
59
|
+
filename,
|
|
60
|
+
source_format: `vasp_xdatcar`,
|
|
61
|
+
frame_count: frames.length,
|
|
62
|
+
total_atoms: elements.length,
|
|
63
|
+
periodic_boundary_conditions: [true, true, true],
|
|
64
|
+
elements: element_names,
|
|
65
|
+
element_counts,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as math from '../../math';
|
|
2
|
+
import { coerce_element_symbol, create_trajectory_frame } from '../helpers';
|
|
3
|
+
export function parse_xyz_trajectory(content) {
|
|
4
|
+
const lines = content.trim().split(/\r?\n/);
|
|
5
|
+
const frames = [];
|
|
6
|
+
let line_idx = 0;
|
|
7
|
+
while (line_idx < lines.length) {
|
|
8
|
+
if (!lines[line_idx]?.trim()) {
|
|
9
|
+
line_idx++;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const num_atoms = parseInt(lines[line_idx].trim(), 10);
|
|
13
|
+
if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 1 >= lines.length) {
|
|
14
|
+
line_idx++;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const comment = lines[++line_idx] || ``;
|
|
18
|
+
const metadata = {};
|
|
19
|
+
// Extract properties efficiently
|
|
20
|
+
const extractors = {
|
|
21
|
+
step: /(?:step|frame|ionic_step)\s*[=:]?\s*(\d+)/i,
|
|
22
|
+
energy: /(?:energy|E|etot|total_energy)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
23
|
+
volume: /(?:volume|vol|V)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
24
|
+
pressure: /(?:pressure|press|P)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
25
|
+
temperature: /(?:temperature|temp|T)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
26
|
+
force_max: /(?:max_force|force_max|fmax)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
27
|
+
bandgap: /(?:bandgap|E_gap|gap)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
28
|
+
};
|
|
29
|
+
const step_match = extractors.step.exec(comment);
|
|
30
|
+
const step = step_match?.[1] ? parseInt(step_match[1]) : frames.length;
|
|
31
|
+
Object.entries(extractors).forEach(([key, pattern]) => {
|
|
32
|
+
if (key === `step`)
|
|
33
|
+
return;
|
|
34
|
+
const match = pattern.exec(comment);
|
|
35
|
+
if (match)
|
|
36
|
+
metadata[key] = parseFloat(match[1]);
|
|
37
|
+
});
|
|
38
|
+
// Extract lattice matrix
|
|
39
|
+
const lattice_match = /Lattice\s*=\s*"([^"]+)"/i.exec(comment);
|
|
40
|
+
let lattice_matrix;
|
|
41
|
+
if (lattice_match) {
|
|
42
|
+
const values = lattice_match[1].split(/\s+/).map(Number);
|
|
43
|
+
if (values.length === 9 && values.every((value) => Number.isFinite(value))) {
|
|
44
|
+
lattice_matrix = [
|
|
45
|
+
[values[0], values[1], values[2]],
|
|
46
|
+
[values[3], values[4], values[5]],
|
|
47
|
+
[values[6], values[7], values[8]],
|
|
48
|
+
];
|
|
49
|
+
metadata.volume = math.calc_lattice_params(lattice_matrix).volume;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Parse atoms
|
|
53
|
+
const positions = [];
|
|
54
|
+
const elements = [];
|
|
55
|
+
const forces = [];
|
|
56
|
+
const has_forces = comment.includes(`forces:R:3`);
|
|
57
|
+
for (let idx = 0; idx < num_atoms; idx++) {
|
|
58
|
+
line_idx++;
|
|
59
|
+
if (line_idx >= lines.length)
|
|
60
|
+
break;
|
|
61
|
+
const parts = lines[line_idx].trim().split(/\s+/);
|
|
62
|
+
if (parts.length >= 4) {
|
|
63
|
+
const x_coord = parseFloat(parts[1]);
|
|
64
|
+
const y_coord = parseFloat(parts[2]);
|
|
65
|
+
const z_coord = parseFloat(parts[3]);
|
|
66
|
+
if (!Number.isFinite(x_coord) ||
|
|
67
|
+
!Number.isFinite(y_coord) ||
|
|
68
|
+
!Number.isFinite(z_coord)) {
|
|
69
|
+
console.warn(`Skipping XYZ atom with invalid coordinates in frame ${frames.length} at line ${line_idx + 1}`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const raw_symbol = parts[0];
|
|
73
|
+
const element_symbol = coerce_element_symbol(raw_symbol);
|
|
74
|
+
if (!element_symbol) {
|
|
75
|
+
console.warn(`Skipping XYZ atom with unknown element symbol "${raw_symbol}" in frame ${frames.length}`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
elements.push(element_symbol);
|
|
79
|
+
positions.push([x_coord, y_coord, z_coord]);
|
|
80
|
+
if (has_forces && parts.length >= 7) {
|
|
81
|
+
const force_x = parseFloat(parts[4]);
|
|
82
|
+
const force_y = parseFloat(parts[5]);
|
|
83
|
+
const force_z = parseFloat(parts[6]);
|
|
84
|
+
if (Number.isFinite(force_x) &&
|
|
85
|
+
Number.isFinite(force_y) &&
|
|
86
|
+
Number.isFinite(force_z)) {
|
|
87
|
+
forces.push([force_x, force_y, force_z]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (forces.length > 0) {
|
|
93
|
+
metadata.forces = forces;
|
|
94
|
+
const magnitudes = forces.map((force) => Math.hypot(...force));
|
|
95
|
+
metadata.force_max = Math.max(...magnitudes);
|
|
96
|
+
// Calculate RMS (root mean square) of force magnitudes
|
|
97
|
+
metadata.force_norm = Math.sqrt(magnitudes.reduce((sum, mag) => sum + mag ** 2, 0) / magnitudes.length);
|
|
98
|
+
}
|
|
99
|
+
frames.push(create_trajectory_frame(positions, elements, lattice_matrix, lattice_matrix ? [true, true, true] : undefined, step, metadata));
|
|
100
|
+
line_idx++;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
frames,
|
|
104
|
+
metadata: {
|
|
105
|
+
source_format: `xyz_trajectory`,
|
|
106
|
+
frame_count: frames.length,
|
|
107
|
+
total_atoms: frames[0]?.structure.sites.length || 0,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -107,7 +107,8 @@ function group_and_assign_series(series, default_visible_properties) {
|
|
|
107
107
|
unit_map.set(unit, group);
|
|
108
108
|
}
|
|
109
109
|
// Create unit groups with priority and visibility
|
|
110
|
-
const groups = Array.from(unit_map.entries())
|
|
110
|
+
const groups = Array.from(unit_map.entries())
|
|
111
|
+
.map(([unit, group_series]) => {
|
|
111
112
|
const priority = calculate_priority(unit, group_series);
|
|
112
113
|
const has_default_visible = group_series.some((srs) => {
|
|
113
114
|
const metadata = Array.isArray(srs.metadata) ? srs.metadata[0] : srs.metadata;
|
|
@@ -115,7 +116,8 @@ function group_and_assign_series(series, default_visible_properties) {
|
|
|
115
116
|
return is_default_visible(property_key, default_visible_properties);
|
|
116
117
|
});
|
|
117
118
|
return { unit, series: group_series, priority, is_visible: has_default_visible };
|
|
118
|
-
})
|
|
119
|
+
})
|
|
120
|
+
.sort((a, b) => a.priority - b.priority);
|
|
119
121
|
// Apply 2-group visibility limit
|
|
120
122
|
const visible_groups = groups.filter((g) => g.is_visible);
|
|
121
123
|
if (visible_groups.length > 2) {
|
|
@@ -183,7 +185,11 @@ function calculate_priority(unit, group_series) {
|
|
|
183
185
|
}
|
|
184
186
|
// Normalize property keys for robust matching (handles case, underscores, and common aliases)
|
|
185
187
|
const normalize_property_key = (key) => {
|
|
186
|
-
const normalized = key
|
|
188
|
+
const normalized = key
|
|
189
|
+
.toLowerCase()
|
|
190
|
+
.replace(/<[^>]*>/g, ``)
|
|
191
|
+
.replace(/_/g, ` `)
|
|
192
|
+
.trim();
|
|
187
193
|
// Map common force property aliases to canonical form
|
|
188
194
|
return [`fmax`, `f`, `force maximum`].includes(normalized) ? `force max` : normalized;
|
|
189
195
|
};
|
|
@@ -213,7 +219,8 @@ export function toggle_series_visibility(series, target_series_idx) {
|
|
|
213
219
|
const visible_groups = unit_groups.filter((group) => group.is_visible);
|
|
214
220
|
if (visible_groups.length >= 2) {
|
|
215
221
|
// Hide lowest priority group (highest priority number)
|
|
216
|
-
const lowest_priority_group = visible_groups
|
|
222
|
+
const lowest_priority_group = visible_groups
|
|
223
|
+
.sort((g1, g2) => g1.priority - g2.priority)
|
|
217
224
|
.pop(); // Get the last (lowest priority) group
|
|
218
225
|
if (lowest_priority_group) {
|
|
219
226
|
lowest_priority_group.is_visible = false;
|
|
@@ -358,8 +365,7 @@ export function generate_streaming_plot_series(metadata_list, options = {}) {
|
|
|
358
365
|
if (!is_energy && !has_significant_variation(data_points.map((p) => p.y)))
|
|
359
366
|
continue;
|
|
360
367
|
const { clean_label, unit } = extract_label_and_unit(property_key, property_config);
|
|
361
|
-
const is_visible = is_default_visible(property_key, default_visible_properties) ||
|
|
362
|
-
color_idx < 2;
|
|
368
|
+
const is_visible = is_default_visible(property_key, default_visible_properties) || color_idx < 2;
|
|
363
369
|
const color = colors[color_idx % colors.length];
|
|
364
370
|
if (is_visible)
|
|
365
371
|
visible_props.push({ property: property_key, unit });
|
|
@@ -411,8 +417,7 @@ function determine_axis_from_groups(property, unit, visible_properties) {
|
|
|
411
417
|
}));
|
|
412
418
|
const groups = group_and_assign_series(mock_series, new Set([property]));
|
|
413
419
|
const target_group = groups.find((group) => group.series.some((srs) => srs.label === property && srs.unit === unit));
|
|
414
|
-
return target_group &&
|
|
415
|
-
groups.filter((group) => group.is_visible).indexOf(target_group) === 1
|
|
420
|
+
return target_group && groups.filter((group) => group.is_visible).indexOf(target_group) === 1
|
|
416
421
|
? `y2`
|
|
417
422
|
: `y1`;
|
|
418
423
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
2
|
+
export type AtomTypeMapping = Record<number, ElementSymbol>;
|
|
3
|
+
export interface LoadingOptions {
|
|
4
|
+
use_indexing?: boolean;
|
|
5
|
+
buffer_size?: number;
|
|
6
|
+
index_sample_rate?: number;
|
|
7
|
+
extract_plot_metadata?: boolean;
|
|
8
|
+
bin_file_threshold?: number;
|
|
9
|
+
text_file_threshold?: number;
|
|
10
|
+
atom_type_mapping?: AtomTypeMapping;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare function merge_nested<T extends Record<string, unknown>>(obj1: T, obj2?: Partial<T>): T;
|
|
2
2
|
export declare const escape_html: (unsafe_string: string) => string;
|
|
3
|
+
export declare const normalize_unicode_minus: (value: string) => string;
|
|
4
|
+
export declare const normalize_scientific_notation: (value: string) => string;
|
|
5
|
+
export declare function decode_url_safe_base64(encoded: string): string | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -17,3 +17,20 @@ export const escape_html = (unsafe_string) => unsafe_string
|
|
|
17
17
|
.replaceAll(`>`, `>`)
|
|
18
18
|
.replaceAll(`"`, `"`)
|
|
19
19
|
.replaceAll(`'`, `'`);
|
|
20
|
+
// Normalize unicode minus (U+2212) to ASCII hyphen-minus.
|
|
21
|
+
export const normalize_unicode_minus = (value) => value.replace(/−/g, `-`);
|
|
22
|
+
// Normalize scientific notation variants (d/D exponent, Mathematica *^).
|
|
23
|
+
export const normalize_scientific_notation = (value) => normalize_unicode_minus(value).toLowerCase().replace(/d/g, `e`).replace(/\*\^/g, `e`);
|
|
24
|
+
// Decode a URL-safe base64 string (RFC 4648 §5) to its original text.
|
|
25
|
+
// Converts `-` → `+`, `_` → `/`, restores padding, then decodes.
|
|
26
|
+
// Returns undefined if decoding fails.
|
|
27
|
+
export function decode_url_safe_base64(encoded) {
|
|
28
|
+
const std_b64 = encoded.replace(/-/g, `+`).replace(/_/g, `/`);
|
|
29
|
+
const padded = std_b64 + `=`.repeat((4 - (std_b64.length % 4)) % 4);
|
|
30
|
+
try {
|
|
31
|
+
return atob(padded);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|