@zac-apps/helium 1.3.0-beta.5 → 1.3.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.
- package/dist/index.js +102 -70
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { LineChart, Line, CartesianGrid, XAxis, Label, YAxis, ReferenceLine, Ref
|
|
|
33
33
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
34
34
|
import Switch from '@mui/material/Switch';
|
|
35
35
|
import regression from 'regression';
|
|
36
|
+
import { mean, sqrt, sum } from 'mathjs';
|
|
36
37
|
|
|
37
38
|
function NumField(_ref) {
|
|
38
39
|
var input = _ref.input,
|
|
@@ -377,8 +378,8 @@ function SelectSpecs(_ref) {
|
|
|
377
378
|
});
|
|
378
379
|
}
|
|
379
380
|
|
|
380
|
-
function ownKeys$
|
|
381
|
-
function _objectSpread$
|
|
381
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
382
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
382
383
|
|
|
383
384
|
// Admonition colors
|
|
384
385
|
|
|
@@ -441,7 +442,7 @@ function HePrognosisSum(_ref2) {
|
|
|
441
442
|
var boilOff = heliumLookupData.boilOff;
|
|
442
443
|
var boilData = {};
|
|
443
444
|
Object.keys(heliumData).map(function (spec) {
|
|
444
|
-
boilData = _objectSpread$
|
|
445
|
+
boilData = _objectSpread$4(_objectSpread$4({}, boilData), {}, _defineProperty({}, spec, Math.round(heliumData[spec] + days * boilOff[spec])));
|
|
445
446
|
return null;
|
|
446
447
|
});
|
|
447
448
|
var toMaxSum = Object.keys(boilData).reduce(function (total, current) {
|
|
@@ -610,7 +611,7 @@ function HePrognosis(_ref6) {
|
|
|
610
611
|
var specDefault = {};
|
|
611
612
|
var specList = Object.keys(heliumData.helium);
|
|
612
613
|
specList.map(function (spec) {
|
|
613
|
-
return specDefault = _objectSpread$
|
|
614
|
+
return specDefault = _objectSpread$4(_objectSpread$4({}, specDefault), {}, _defineProperty({}, spec, true));
|
|
614
615
|
});
|
|
615
616
|
var _useImmer = useImmer(specDefault),
|
|
616
617
|
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
@@ -624,13 +625,13 @@ function HePrognosis(_ref6) {
|
|
|
624
625
|
Object.keys(specs).filter(function (spec) {
|
|
625
626
|
return specs[spec];
|
|
626
627
|
}).map(function (spec) {
|
|
627
|
-
return currHeliumData = _objectSpread$
|
|
628
|
+
return currHeliumData = _objectSpread$4(_objectSpread$4({}, currHeliumData), {}, _defineProperty({}, spec, heliumData.helium[spec]));
|
|
628
629
|
});
|
|
629
630
|
var dates = {};
|
|
630
631
|
for (var i in increments) {
|
|
631
632
|
var d = new Date();
|
|
632
633
|
d.setDate(d.getDate() + increments[i]);
|
|
633
|
-
dates = _objectSpread$
|
|
634
|
+
dates = _objectSpread$4(_objectSpread$4({}, dates), {}, _defineProperty({}, increments[i], moment(d).format("ll")));
|
|
634
635
|
}
|
|
635
636
|
return /*#__PURE__*/jsxs(Grid, {
|
|
636
637
|
container: true,
|
|
@@ -921,8 +922,8 @@ function FindTriple(_ref2) {
|
|
|
921
922
|
return minTriple;
|
|
922
923
|
}
|
|
923
924
|
|
|
924
|
-
function ownKeys$
|
|
925
|
-
function _objectSpread$
|
|
925
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
926
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
926
927
|
function TupleResult(_ref) {
|
|
927
928
|
var children = _ref.children,
|
|
928
929
|
title = _ref.title;
|
|
@@ -1007,7 +1008,7 @@ function PairWizard(_ref4) {
|
|
|
1007
1008
|
var boilOff = heliumLookupData.boilOff;
|
|
1008
1009
|
var defaultSpecs = {};
|
|
1009
1010
|
Object.keys(boilOff).map(function (spec) {
|
|
1010
|
-
return defaultSpecs = _objectSpread$
|
|
1011
|
+
return defaultSpecs = _objectSpread$3(_objectSpread$3({}, defaultSpecs), {}, _defineProperty({}, spec, true));
|
|
1011
1012
|
});
|
|
1012
1013
|
var _useImmer = useImmer(defaultSpecs),
|
|
1013
1014
|
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
@@ -1024,13 +1025,13 @@ function PairWizard(_ref4) {
|
|
|
1024
1025
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1025
1026
|
limit = _useState4[0],
|
|
1026
1027
|
SetLimit = _useState4[1];
|
|
1027
|
-
var minPair = FindPair(_objectSpread$
|
|
1028
|
+
var minPair = FindPair(_objectSpread$3({}, {
|
|
1028
1029
|
currSpecs: currSpecs,
|
|
1029
1030
|
heliumData: heliumData,
|
|
1030
1031
|
boilOff: boilOff,
|
|
1031
1032
|
limit: limit
|
|
1032
1033
|
}));
|
|
1033
|
-
var minTriple = FindTriple(_objectSpread$
|
|
1034
|
+
var minTriple = FindTriple(_objectSpread$3({}, {
|
|
1034
1035
|
currSpecs: currSpecs,
|
|
1035
1036
|
heliumData: heliumData,
|
|
1036
1037
|
boilOff: boilOff,
|
|
@@ -1236,8 +1237,8 @@ function FillTarget(_ref) {
|
|
|
1236
1237
|
});
|
|
1237
1238
|
}
|
|
1238
1239
|
|
|
1239
|
-
function ownKeys$
|
|
1240
|
-
function _objectSpread$
|
|
1240
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1241
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1241
1242
|
function EstimateConsumption() {
|
|
1242
1243
|
// Get data
|
|
1243
1244
|
|
|
@@ -1263,7 +1264,7 @@ function EstimateConsumption() {
|
|
|
1263
1264
|
// Calculate consumption per day, month, year from values above
|
|
1264
1265
|
|
|
1265
1266
|
specCons = specCons.map(function (spec) {
|
|
1266
|
-
return _objectSpread$
|
|
1267
|
+
return _objectSpread$2(_objectSpread$2({}, spec), {}, {
|
|
1267
1268
|
perDay: spec.liters / spec.days,
|
|
1268
1269
|
perMonth: (spec.liters / spec.days * 30).toFixed(1),
|
|
1269
1270
|
perYear: (spec.liters / spec.days * 365).toFixed(1)
|
|
@@ -1331,6 +1332,62 @@ function EstimateConsumption() {
|
|
|
1331
1332
|
});
|
|
1332
1333
|
}
|
|
1333
1334
|
|
|
1335
|
+
function ShowEstimate(_ref) {
|
|
1336
|
+
var spec = _ref.spec,
|
|
1337
|
+
estimatedBoiloff = _ref.estimatedBoiloff,
|
|
1338
|
+
estimatedError = _ref.estimatedError;
|
|
1339
|
+
var heliumLookupData = useContext(LookupContext);
|
|
1340
|
+
|
|
1341
|
+
// Get stored data
|
|
1342
|
+
|
|
1343
|
+
var storedBoiloff = heliumLookupData.boilOff[spec].toFixed(3) || "N/A";
|
|
1344
|
+
|
|
1345
|
+
// Round values from props
|
|
1346
|
+
|
|
1347
|
+
estimatedBoiloff = estimatedBoiloff.toFixed(3) || "N/A";
|
|
1348
|
+
estimatedError = estimatedError.toFixed(3) || "N/A";
|
|
1349
|
+
|
|
1350
|
+
// Warn if values differ
|
|
1351
|
+
|
|
1352
|
+
var renderEstimatedBoiloff = Math.abs(estimatedBoiloff - storedBoiloff) < 0.01 ? estimatedBoiloff : /*#__PURE__*/jsx("strong", {
|
|
1353
|
+
style: {
|
|
1354
|
+
color: AppTheme.palette.primary.main
|
|
1355
|
+
},
|
|
1356
|
+
children: estimatedBoiloff
|
|
1357
|
+
});
|
|
1358
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1359
|
+
children: [/*#__PURE__*/jsx("h4", {
|
|
1360
|
+
children: "Boiloff coefficients (%/day)"
|
|
1361
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1362
|
+
container: true,
|
|
1363
|
+
children: /*#__PURE__*/jsxs(AppTable, {
|
|
1364
|
+
children: [/*#__PURE__*/jsx(TableHead, {
|
|
1365
|
+
children: /*#__PURE__*/jsxs(TableRow, {
|
|
1366
|
+
children: [/*#__PURE__*/jsx(TableHeadCell, {
|
|
1367
|
+
children: "Estimated"
|
|
1368
|
+
}), /*#__PURE__*/jsx(TableHeadCell, {
|
|
1369
|
+
children: "Stored"
|
|
1370
|
+
})]
|
|
1371
|
+
})
|
|
1372
|
+
}), /*#__PURE__*/jsx(TableBody, {
|
|
1373
|
+
children: /*#__PURE__*/jsxs(TableRow, {
|
|
1374
|
+
children: [/*#__PURE__*/jsxs(TableCell, {
|
|
1375
|
+
children: [renderEstimatedBoiloff, " ", /*#__PURE__*/jsxs("em", {
|
|
1376
|
+
style: {
|
|
1377
|
+
color: AppTheme.palette.secondary.main
|
|
1378
|
+
},
|
|
1379
|
+
children: ["(\xB1", estimatedError, ")"]
|
|
1380
|
+
})]
|
|
1381
|
+
}), /*#__PURE__*/jsx(TableCell, {
|
|
1382
|
+
children: storedBoiloff
|
|
1383
|
+
})]
|
|
1384
|
+
})
|
|
1385
|
+
})]
|
|
1386
|
+
})
|
|
1387
|
+
})]
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1334
1391
|
function EstimateSlope(_ref) {
|
|
1335
1392
|
var data = _ref.data;
|
|
1336
1393
|
_ref.spec;
|
|
@@ -1402,69 +1459,36 @@ function EstimateSlope(_ref) {
|
|
|
1402
1459
|
// Perform linear regression on the points
|
|
1403
1460
|
|
|
1404
1461
|
var result = regression.linear(points, {
|
|
1405
|
-
precision:
|
|
1462
|
+
precision: 6
|
|
1406
1463
|
});
|
|
1407
1464
|
slope = result.equation[0];
|
|
1408
1465
|
intercept = result.equation[1];
|
|
1409
|
-
return {
|
|
1410
|
-
slope: slope,
|
|
1411
|
-
intercept: intercept
|
|
1412
|
-
};
|
|
1413
|
-
}
|
|
1414
1466
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
var
|
|
1419
|
-
|
|
1420
|
-
|
|
1467
|
+
// Determine slope uncertainty based on regression result
|
|
1468
|
+
// For that, create an array of control values
|
|
1469
|
+
var control = [];
|
|
1470
|
+
for (var _i3 = maxLevelIndex; _i3 <= minLevelIndex; _i3++) {
|
|
1471
|
+
control.push([_i3, _i3 * slope + intercept]);
|
|
1472
|
+
}
|
|
1421
1473
|
|
|
1422
|
-
//
|
|
1474
|
+
// Calculate mean x value
|
|
1423
1475
|
|
|
1424
|
-
var
|
|
1425
|
-
|
|
1426
|
-
spec: spec
|
|
1476
|
+
var meanX = mean(points.map(function (point) {
|
|
1477
|
+
return point[0];
|
|
1427
1478
|
}));
|
|
1428
|
-
var estimatedBoiloff = estimateResult.slope.toFixed(3) || "N/A";
|
|
1429
1479
|
|
|
1430
|
-
//
|
|
1431
|
-
|
|
1432
|
-
var storedBoiloff = heliumLookupData.boilOff[spec].toFixed(3) || "N/A";
|
|
1480
|
+
// Calculate standard slope error
|
|
1433
1481
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
children: "Boiloff coefficients (%/day)"
|
|
1445
|
-
}), /*#__PURE__*/jsx(Grid, {
|
|
1446
|
-
container: true,
|
|
1447
|
-
children: /*#__PURE__*/jsxs(AppTable, {
|
|
1448
|
-
children: [/*#__PURE__*/jsx(TableHead, {
|
|
1449
|
-
children: /*#__PURE__*/jsxs(TableRow, {
|
|
1450
|
-
children: [/*#__PURE__*/jsx(TableHeadCell, {
|
|
1451
|
-
children: "Estimated"
|
|
1452
|
-
}), /*#__PURE__*/jsx(TableHeadCell, {
|
|
1453
|
-
children: "Stored"
|
|
1454
|
-
})]
|
|
1455
|
-
})
|
|
1456
|
-
}), /*#__PURE__*/jsx(TableBody, {
|
|
1457
|
-
children: /*#__PURE__*/jsxs(TableRow, {
|
|
1458
|
-
children: [/*#__PURE__*/jsx(TableCell, {
|
|
1459
|
-
children: renderEstimatedBoiloff
|
|
1460
|
-
}), /*#__PURE__*/jsx(TableCell, {
|
|
1461
|
-
children: storedBoiloff
|
|
1462
|
-
})]
|
|
1463
|
-
})
|
|
1464
|
-
})]
|
|
1465
|
-
})
|
|
1466
|
-
})]
|
|
1467
|
-
});
|
|
1482
|
+
var slopeError = sqrt(1 / (control.length - 2) * sum(points.map(function (point, i) {
|
|
1483
|
+
return Math.pow(point[1] - control[i][1], 2);
|
|
1484
|
+
})) / sum(points.map(function (point, i) {
|
|
1485
|
+
return Math.pow(point[0] - meanX, 2);
|
|
1486
|
+
})));
|
|
1487
|
+
return {
|
|
1488
|
+
slope: slope,
|
|
1489
|
+
intercept: intercept,
|
|
1490
|
+
slopeError: slopeError
|
|
1491
|
+
};
|
|
1468
1492
|
}
|
|
1469
1493
|
|
|
1470
1494
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -1486,6 +1510,7 @@ function RenderGraph(_ref) {
|
|
|
1486
1510
|
}));
|
|
1487
1511
|
var estimatedBoiloff = estimateResult.slope;
|
|
1488
1512
|
var estimatedIntercept = estimateResult.intercept;
|
|
1513
|
+
var estimatedError = estimateResult.slopeError;
|
|
1489
1514
|
|
|
1490
1515
|
// Custom Tooltip for LineChart
|
|
1491
1516
|
|
|
@@ -1555,10 +1580,16 @@ function RenderGraph(_ref) {
|
|
|
1555
1580
|
|
|
1556
1581
|
// Get chart data from estimate
|
|
1557
1582
|
|
|
1583
|
+
// First, get difference between today and last data point
|
|
1584
|
+
|
|
1585
|
+
var daysSinceUpate = moment().diff(moment(data[data.length - 1].date, "ddd MMM D HH:mm:ss YYYY"), "days");
|
|
1586
|
+
|
|
1587
|
+
// Then calculate estimated data points
|
|
1588
|
+
|
|
1558
1589
|
showEstimate && (data = data.map(function (item) {
|
|
1559
1590
|
var days = item.days;
|
|
1560
1591
|
var level = item.level;
|
|
1561
|
-
var estimate = estimatedBoiloff * (data.length - days) + estimatedIntercept;
|
|
1592
|
+
var estimate = estimatedBoiloff * (data.length - days + daysSinceUpate) + estimatedIntercept;
|
|
1562
1593
|
return {
|
|
1563
1594
|
date: item.date,
|
|
1564
1595
|
days: days,
|
|
@@ -1682,7 +1713,8 @@ function RenderGraph(_ref) {
|
|
|
1682
1713
|
})]
|
|
1683
1714
|
}), /*#__PURE__*/jsx(ShowEstimate, {
|
|
1684
1715
|
spec: spec,
|
|
1685
|
-
|
|
1716
|
+
estimatedBoiloff: estimatedBoiloff,
|
|
1717
|
+
estimatedError: estimatedError
|
|
1686
1718
|
})]
|
|
1687
1719
|
});
|
|
1688
1720
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zac-apps/helium",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"rollup": "node_modules/rollup/dist/rollup.js",
|
|
6
6
|
"dev": "next dev",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mui/icons-material": "^5.17.1",
|
|
32
32
|
"@mui/material": "^5.17.1",
|
|
33
|
-
"
|
|
33
|
+
"mathjs": "^14.4.0",
|
|
34
34
|
"moment": "^2.30.1",
|
|
35
|
-
"recharts": "^2.15.
|
|
35
|
+
"recharts": "^2.15.3",
|
|
36
36
|
"regression": "^2.0.1",
|
|
37
37
|
"use-immer": "^0.11.0"
|
|
38
38
|
},
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
"@storybook/test": "^8.6.12",
|
|
58
58
|
"babel-loader": "^10.0.0",
|
|
59
59
|
"eslint": "^9",
|
|
60
|
-
"eslint-config-next": "15.3.
|
|
60
|
+
"eslint-config-next": "15.3.1",
|
|
61
61
|
"eslint-plugin-storybook": "^0.12.0",
|
|
62
|
+
"next": "^14",
|
|
62
63
|
"rollup": "^4.40.0",
|
|
63
64
|
"semantic-release": "^24.2.3",
|
|
64
65
|
"storybook": "^8.6.12"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
|
67
68
|
"@zac-apps/commons": "^1",
|
|
68
|
-
"next": "^14",
|
|
69
69
|
"react": "^18 || ^19",
|
|
70
70
|
"react-dom": "^18 || ^19"
|
|
71
71
|
},
|