@zac-apps/helium 1.3.0-beta.1 → 1.3.0-beta.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/index.js +240 -56
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import React, { useState, createContext, useContext, useEffect } from 'react';
|
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import { useImmer } from 'use-immer';
|
|
6
6
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
7
|
-
import
|
|
7
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
|
8
8
|
import TableBody from '@mui/material/TableBody';
|
|
9
9
|
import TableCell from '@mui/material/TableCell';
|
|
10
10
|
import TableHead from '@mui/material/TableHead';
|
|
@@ -28,10 +28,12 @@ import Checkbox from '@mui/material/Checkbox';
|
|
|
28
28
|
import Button from '@mui/material/Button';
|
|
29
29
|
import moment$1 from 'moment/moment.js';
|
|
30
30
|
import Typography from '@mui/material/Typography';
|
|
31
|
-
import { LineChart, Line, CartesianGrid, XAxis, Label, YAxis, ReferenceLine, ReferenceArea, Tooltip } from 'recharts';
|
|
32
31
|
import Paper from '@mui/material/Paper';
|
|
32
|
+
import { LineChart, Line, CartesianGrid, XAxis, Label, YAxis, ReferenceLine, ReferenceArea, Tooltip } from 'recharts';
|
|
33
33
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
34
34
|
import Switch from '@mui/material/Switch';
|
|
35
|
+
import regression from 'regression';
|
|
36
|
+
import 'next/app.js';
|
|
35
37
|
|
|
36
38
|
function NumField(_ref) {
|
|
37
39
|
var input = _ref.input,
|
|
@@ -242,7 +244,7 @@ function HeliumTable(_ref2) {
|
|
|
242
244
|
// Catch if no data present
|
|
243
245
|
|
|
244
246
|
if (heliumData.helium.length === 0) {
|
|
245
|
-
return /*#__PURE__*/jsx(
|
|
247
|
+
return /*#__PURE__*/jsx(Grid, {
|
|
246
248
|
children: /*#__PURE__*/jsx("em", {
|
|
247
249
|
children: "No Helium data found."
|
|
248
250
|
})
|
|
@@ -376,8 +378,8 @@ function SelectSpecs(_ref) {
|
|
|
376
378
|
});
|
|
377
379
|
}
|
|
378
380
|
|
|
379
|
-
function ownKeys$
|
|
380
|
-
function _objectSpread$
|
|
381
|
+
function ownKeys$5(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$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
381
383
|
|
|
382
384
|
// Admonition colors
|
|
383
385
|
|
|
@@ -440,7 +442,7 @@ function HePrognosisSum(_ref2) {
|
|
|
440
442
|
var boilOff = heliumLookupData.boilOff;
|
|
441
443
|
var boilData = {};
|
|
442
444
|
Object.keys(heliumData).map(function (spec) {
|
|
443
|
-
boilData = _objectSpread$
|
|
445
|
+
boilData = _objectSpread$5(_objectSpread$5({}, boilData), {}, _defineProperty({}, spec, Math.round(heliumData[spec] + days * boilOff[spec])));
|
|
444
446
|
return null;
|
|
445
447
|
});
|
|
446
448
|
var toMaxSum = Object.keys(boilData).reduce(function (total, current) {
|
|
@@ -578,7 +580,7 @@ function AddPrognoEntry(_ref5) {
|
|
|
578
580
|
children: /*#__PURE__*/jsx("strong", {
|
|
579
581
|
children: "Add prediction row"
|
|
580
582
|
})
|
|
581
|
-
}), /*#__PURE__*/jsxs(
|
|
583
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
582
584
|
children: [/*#__PURE__*/jsx(NumField, {
|
|
583
585
|
input: input,
|
|
584
586
|
SetInput: SetInput,
|
|
@@ -609,7 +611,7 @@ function HePrognosis(_ref6) {
|
|
|
609
611
|
var specDefault = {};
|
|
610
612
|
var specList = Object.keys(heliumData.helium);
|
|
611
613
|
specList.map(function (spec) {
|
|
612
|
-
return specDefault = _objectSpread$
|
|
614
|
+
return specDefault = _objectSpread$5(_objectSpread$5({}, specDefault), {}, _defineProperty({}, spec, true));
|
|
613
615
|
});
|
|
614
616
|
var _useImmer = useImmer(specDefault),
|
|
615
617
|
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
@@ -623,33 +625,33 @@ function HePrognosis(_ref6) {
|
|
|
623
625
|
Object.keys(specs).filter(function (spec) {
|
|
624
626
|
return specs[spec];
|
|
625
627
|
}).map(function (spec) {
|
|
626
|
-
return currHeliumData = _objectSpread$
|
|
628
|
+
return currHeliumData = _objectSpread$5(_objectSpread$5({}, currHeliumData), {}, _defineProperty({}, spec, heliumData.helium[spec]));
|
|
627
629
|
});
|
|
628
630
|
var dates = {};
|
|
629
631
|
for (var i in increments) {
|
|
630
632
|
var d = new Date();
|
|
631
633
|
d.setDate(d.getDate() + increments[i]);
|
|
632
|
-
dates = _objectSpread$
|
|
634
|
+
dates = _objectSpread$5(_objectSpread$5({}, dates), {}, _defineProperty({}, increments[i], moment(d).format("ll")));
|
|
633
635
|
}
|
|
634
|
-
return /*#__PURE__*/jsxs(
|
|
636
|
+
return /*#__PURE__*/jsxs(Grid, {
|
|
635
637
|
container: true,
|
|
636
638
|
columns: {
|
|
637
639
|
xs: 6,
|
|
638
640
|
sm: 12
|
|
639
641
|
},
|
|
640
|
-
children: [/*#__PURE__*/jsx(
|
|
642
|
+
children: [/*#__PURE__*/jsx(Grid, {
|
|
641
643
|
xs: 6,
|
|
642
644
|
children: /*#__PURE__*/jsx(SelectSpecs, {
|
|
643
645
|
specs: specs,
|
|
644
646
|
SetSpecs: SetSpecs
|
|
645
647
|
})
|
|
646
|
-
}), /*#__PURE__*/jsx(
|
|
648
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
647
649
|
xs: 6,
|
|
648
650
|
children: /*#__PURE__*/jsx(AddPrognoEntry, {
|
|
649
651
|
increments: increments,
|
|
650
652
|
SetIncrements: SetIncrements
|
|
651
653
|
})
|
|
652
|
-
}), /*#__PURE__*/jsx(
|
|
654
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
653
655
|
xs: 12,
|
|
654
656
|
children: /*#__PURE__*/jsxs(AppTable, {
|
|
655
657
|
children: [/*#__PURE__*/jsxs(TableHead, {
|
|
@@ -679,7 +681,7 @@ function HePrognosis(_ref6) {
|
|
|
679
681
|
})
|
|
680
682
|
})]
|
|
681
683
|
})
|
|
682
|
-
}), /*#__PURE__*/jsxs(
|
|
684
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
683
685
|
xs: 12,
|
|
684
686
|
sx: {
|
|
685
687
|
display: "flex",
|
|
@@ -920,12 +922,12 @@ function FindTriple(_ref2) {
|
|
|
920
922
|
return minTriple;
|
|
921
923
|
}
|
|
922
924
|
|
|
923
|
-
function ownKeys$
|
|
924
|
-
function _objectSpread$
|
|
925
|
+
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; }
|
|
926
|
+
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; }
|
|
925
927
|
function TupleResult(_ref) {
|
|
926
928
|
var children = _ref.children,
|
|
927
929
|
title = _ref.title;
|
|
928
|
-
return /*#__PURE__*/jsx(
|
|
930
|
+
return /*#__PURE__*/jsx(Grid, {
|
|
929
931
|
children: /*#__PURE__*/jsxs(AppTable, {
|
|
930
932
|
children: [/*#__PURE__*/jsx(TableHead, {
|
|
931
933
|
children: /*#__PURE__*/jsx(TableRow, {
|
|
@@ -1006,7 +1008,7 @@ function PairWizard(_ref4) {
|
|
|
1006
1008
|
var boilOff = heliumLookupData.boilOff;
|
|
1007
1009
|
var defaultSpecs = {};
|
|
1008
1010
|
Object.keys(boilOff).map(function (spec) {
|
|
1009
|
-
return defaultSpecs = _objectSpread$
|
|
1011
|
+
return defaultSpecs = _objectSpread$4(_objectSpread$4({}, defaultSpecs), {}, _defineProperty({}, spec, true));
|
|
1010
1012
|
});
|
|
1011
1013
|
var _useImmer = useImmer(defaultSpecs),
|
|
1012
1014
|
_useImmer2 = _slicedToArray(_useImmer, 2),
|
|
@@ -1023,26 +1025,26 @@ function PairWizard(_ref4) {
|
|
|
1023
1025
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1024
1026
|
limit = _useState4[0],
|
|
1025
1027
|
SetLimit = _useState4[1];
|
|
1026
|
-
var minPair = FindPair(_objectSpread$
|
|
1028
|
+
var minPair = FindPair(_objectSpread$4({}, {
|
|
1027
1029
|
currSpecs: currSpecs,
|
|
1028
1030
|
heliumData: heliumData,
|
|
1029
1031
|
boilOff: boilOff,
|
|
1030
1032
|
limit: limit
|
|
1031
1033
|
}));
|
|
1032
|
-
var minTriple = FindTriple(_objectSpread$
|
|
1034
|
+
var minTriple = FindTriple(_objectSpread$4({}, {
|
|
1033
1035
|
currSpecs: currSpecs,
|
|
1034
1036
|
heliumData: heliumData,
|
|
1035
1037
|
boilOff: boilOff,
|
|
1036
1038
|
limit: limit
|
|
1037
1039
|
}));
|
|
1038
1040
|
return /*#__PURE__*/jsx(React.Fragment, {
|
|
1039
|
-
children: /*#__PURE__*/jsxs(
|
|
1041
|
+
children: /*#__PURE__*/jsxs(Grid, {
|
|
1040
1042
|
container: true,
|
|
1041
1043
|
columns: {
|
|
1042
1044
|
xs: 6,
|
|
1043
1045
|
md: 12
|
|
1044
1046
|
},
|
|
1045
|
-
children: [/*#__PURE__*/jsxs(
|
|
1047
|
+
children: [/*#__PURE__*/jsxs(Grid, {
|
|
1046
1048
|
xs: 6,
|
|
1047
1049
|
sx: {
|
|
1048
1050
|
px: 2
|
|
@@ -1052,7 +1054,7 @@ function PairWizard(_ref4) {
|
|
|
1052
1054
|
children: /*#__PURE__*/jsx("strong", {
|
|
1053
1055
|
children: "Find earliest set of spectrometers requiring"
|
|
1054
1056
|
})
|
|
1055
|
-
}), /*#__PURE__*/jsx(
|
|
1057
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1056
1058
|
sx: {
|
|
1057
1059
|
padding: 2,
|
|
1058
1060
|
display: "flex",
|
|
@@ -1067,13 +1069,13 @@ function PairWizard(_ref4) {
|
|
|
1067
1069
|
SetError: SetError
|
|
1068
1070
|
})
|
|
1069
1071
|
})
|
|
1070
|
-
}), /*#__PURE__*/jsx(
|
|
1072
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1071
1073
|
children: /*#__PURE__*/jsx(SelectSpecs, {
|
|
1072
1074
|
specs: specs,
|
|
1073
1075
|
SetSpecs: SetSpecs
|
|
1074
1076
|
})
|
|
1075
1077
|
})]
|
|
1076
|
-
}), /*#__PURE__*/jsxs(
|
|
1078
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
1077
1079
|
xs: 6,
|
|
1078
1080
|
sx: {
|
|
1079
1081
|
px: 2
|
|
@@ -1083,7 +1085,7 @@ function PairWizard(_ref4) {
|
|
|
1083
1085
|
children: /*#__PURE__*/jsx("strong", {
|
|
1084
1086
|
children: "Result"
|
|
1085
1087
|
})
|
|
1086
|
-
}), /*#__PURE__*/jsxs(
|
|
1088
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
1087
1089
|
sx: {
|
|
1088
1090
|
px: 3
|
|
1089
1091
|
},
|
|
@@ -1126,13 +1128,13 @@ function FillTarget(_ref) {
|
|
|
1126
1128
|
spec: spec
|
|
1127
1129
|
});
|
|
1128
1130
|
return /*#__PURE__*/jsx(React.Fragment, {
|
|
1129
|
-
children: /*#__PURE__*/jsxs(
|
|
1131
|
+
children: /*#__PURE__*/jsxs(Grid, {
|
|
1130
1132
|
container: true,
|
|
1131
1133
|
columns: {
|
|
1132
1134
|
xs: 6,
|
|
1133
1135
|
md: 12
|
|
1134
1136
|
},
|
|
1135
|
-
children: [/*#__PURE__*/jsxs(
|
|
1137
|
+
children: [/*#__PURE__*/jsxs(Grid, {
|
|
1136
1138
|
xs: 6,
|
|
1137
1139
|
sx: {
|
|
1138
1140
|
px: 2
|
|
@@ -1142,7 +1144,7 @@ function FillTarget(_ref) {
|
|
|
1142
1144
|
children: /*#__PURE__*/jsx("strong", {
|
|
1143
1145
|
children: "Select Spectrometer"
|
|
1144
1146
|
})
|
|
1145
|
-
}), /*#__PURE__*/jsx(
|
|
1147
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1146
1148
|
sx: {
|
|
1147
1149
|
padding: 2,
|
|
1148
1150
|
display: "flex",
|
|
@@ -1154,7 +1156,7 @@ function FillTarget(_ref) {
|
|
|
1154
1156
|
SetSpec: SetSpec
|
|
1155
1157
|
})
|
|
1156
1158
|
})]
|
|
1157
|
-
}), /*#__PURE__*/jsxs(
|
|
1159
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
1158
1160
|
xs: 6,
|
|
1159
1161
|
sx: {
|
|
1160
1162
|
px: 2
|
|
@@ -1164,7 +1166,7 @@ function FillTarget(_ref) {
|
|
|
1164
1166
|
children: /*#__PURE__*/jsx("strong", {
|
|
1165
1167
|
children: "Current status"
|
|
1166
1168
|
})
|
|
1167
|
-
}), /*#__PURE__*/jsx(
|
|
1169
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1168
1170
|
sx: {
|
|
1169
1171
|
padding: 2,
|
|
1170
1172
|
display: "flex",
|
|
@@ -1175,7 +1177,7 @@ function FillTarget(_ref) {
|
|
|
1175
1177
|
children: [currLevel, " % (", currLiter, " L)"]
|
|
1176
1178
|
})
|
|
1177
1179
|
})]
|
|
1178
|
-
}), /*#__PURE__*/jsxs(
|
|
1180
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
1179
1181
|
xs: 6,
|
|
1180
1182
|
sx: {
|
|
1181
1183
|
px: 2
|
|
@@ -1185,7 +1187,7 @@ function FillTarget(_ref) {
|
|
|
1185
1187
|
children: /*#__PURE__*/jsx("strong", {
|
|
1186
1188
|
children: "Helium fill amount"
|
|
1187
1189
|
})
|
|
1188
|
-
}), /*#__PURE__*/jsx(
|
|
1190
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1189
1191
|
sx: {
|
|
1190
1192
|
padding: 2,
|
|
1191
1193
|
display: "flex",
|
|
@@ -1201,7 +1203,7 @@ function FillTarget(_ref) {
|
|
|
1201
1203
|
})
|
|
1202
1204
|
})
|
|
1203
1205
|
})]
|
|
1204
|
-
}), /*#__PURE__*/jsxs(
|
|
1206
|
+
}), /*#__PURE__*/jsxs(Grid, {
|
|
1205
1207
|
xs: 6,
|
|
1206
1208
|
sx: {
|
|
1207
1209
|
px: 2
|
|
@@ -1211,7 +1213,7 @@ function FillTarget(_ref) {
|
|
|
1211
1213
|
children: /*#__PURE__*/jsx("strong", {
|
|
1212
1214
|
children: "After filling"
|
|
1213
1215
|
})
|
|
1214
|
-
}), /*#__PURE__*/jsx(
|
|
1216
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1215
1217
|
sx: {
|
|
1216
1218
|
padding: 2,
|
|
1217
1219
|
display: "flex",
|
|
@@ -1235,8 +1237,8 @@ function FillTarget(_ref) {
|
|
|
1235
1237
|
});
|
|
1236
1238
|
}
|
|
1237
1239
|
|
|
1238
|
-
function ownKeys$
|
|
1239
|
-
function _objectSpread$
|
|
1240
|
+
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; }
|
|
1241
|
+
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; }
|
|
1240
1242
|
function EstimateConsumption() {
|
|
1241
1243
|
// Get data
|
|
1242
1244
|
|
|
@@ -1262,7 +1264,7 @@ function EstimateConsumption() {
|
|
|
1262
1264
|
// Calculate consumption per day, month, year from values above
|
|
1263
1265
|
|
|
1264
1266
|
specCons = specCons.map(function (spec) {
|
|
1265
|
-
return _objectSpread$
|
|
1267
|
+
return _objectSpread$3(_objectSpread$3({}, spec), {}, {
|
|
1266
1268
|
perDay: spec.liters / spec.days,
|
|
1267
1269
|
perMonth: (spec.liters / spec.days * 30).toFixed(1),
|
|
1268
1270
|
perYear: (spec.liters / spec.days * 365).toFixed(1)
|
|
@@ -1330,6 +1332,125 @@ function EstimateConsumption() {
|
|
|
1330
1332
|
});
|
|
1331
1333
|
}
|
|
1332
1334
|
|
|
1335
|
+
function EstimateSlope(_ref) {
|
|
1336
|
+
var data = _ref.data;
|
|
1337
|
+
// define slope and intercept
|
|
1338
|
+
|
|
1339
|
+
var slope = 0;
|
|
1340
|
+
var intercept = 0;
|
|
1341
|
+
|
|
1342
|
+
// find last time when spectrometer was filled - for this start from last point and go back until a minimum is found
|
|
1343
|
+
|
|
1344
|
+
var lastLevel = Number(data[data.length - 1].level);
|
|
1345
|
+
var minLevel = lastLevel;
|
|
1346
|
+
var minLevelIndex = data.length - 1;
|
|
1347
|
+
for (var i = data.length - 2; i >= 0; i--) {
|
|
1348
|
+
var level = Number(data[i].level);
|
|
1349
|
+
if (level < minLevel) {
|
|
1350
|
+
minLevel = level;
|
|
1351
|
+
minLevelIndex = i;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// stop if level is increases from minimum
|
|
1355
|
+
|
|
1356
|
+
if (level > minLevel + 1) {
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// find previous time when spectrometer was filled - for this start from lastMinimumIndex and go back until a maximum is found or until level reaches 90%
|
|
1362
|
+
|
|
1363
|
+
var maxLevel = Number(data[minLevelIndex].level);
|
|
1364
|
+
var maxLevelIndex = minLevelIndex;
|
|
1365
|
+
for (var _i = minLevelIndex - 1; _i >= 0; _i--) {
|
|
1366
|
+
var _level = Number(data[_i].level);
|
|
1367
|
+
if (_level > maxLevel) {
|
|
1368
|
+
maxLevel = _level;
|
|
1369
|
+
maxLevelIndex = _i;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// stop if level is decreases from maximum or if level is above 90%
|
|
1373
|
+
|
|
1374
|
+
if (_level < maxLevel - 1 || _level >= 90) {
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// Create an array of points between maximum and minimum in the form [[x1, y1], [x2, y2], ...]
|
|
1380
|
+
|
|
1381
|
+
var points = [];
|
|
1382
|
+
for (var _i2 = maxLevelIndex; _i2 <= minLevelIndex; _i2++) {
|
|
1383
|
+
points.push([_i2, Number(data[_i2].level)]);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// Perform linear regression on the points
|
|
1387
|
+
|
|
1388
|
+
var result = regression.linear(points, {
|
|
1389
|
+
precision: 3
|
|
1390
|
+
});
|
|
1391
|
+
slope = result.equation[0];
|
|
1392
|
+
intercept = result.equation[1];
|
|
1393
|
+
return {
|
|
1394
|
+
slope: slope,
|
|
1395
|
+
intercept: intercept
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
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; }
|
|
1400
|
+
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; }
|
|
1401
|
+
function ShowEstimate(_ref) {
|
|
1402
|
+
var data = _ref.data,
|
|
1403
|
+
spec = _ref.spec;
|
|
1404
|
+
var heliumLookupData = useContext(LookupContext);
|
|
1405
|
+
|
|
1406
|
+
// Get estimated data
|
|
1407
|
+
|
|
1408
|
+
var estimateResult = EstimateSlope(_objectSpread$2({}, {
|
|
1409
|
+
data: data,
|
|
1410
|
+
spec: spec
|
|
1411
|
+
}));
|
|
1412
|
+
var estimatedBoiloff = estimateResult.slope.toFixed(3) || "N/A";
|
|
1413
|
+
|
|
1414
|
+
// Get stored data
|
|
1415
|
+
|
|
1416
|
+
var storedBoiloff = heliumLookupData.boilOff[spec].toFixed(3) || "N/A";
|
|
1417
|
+
|
|
1418
|
+
// Warn if values differ
|
|
1419
|
+
|
|
1420
|
+
var renderEstimatedBoiloff = Math.abs(estimatedBoiloff - storedBoiloff) < 0.1 ? estimatedBoiloff : /*#__PURE__*/jsx("strong", {
|
|
1421
|
+
style: {
|
|
1422
|
+
color: AppTheme.palette.primary.main
|
|
1423
|
+
},
|
|
1424
|
+
children: estimatedBoiloff
|
|
1425
|
+
});
|
|
1426
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1427
|
+
children: [/*#__PURE__*/jsx("h4", {
|
|
1428
|
+
children: "Boiloff coefficients (%/day)"
|
|
1429
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1430
|
+
container: true,
|
|
1431
|
+
children: /*#__PURE__*/jsxs(AppTable, {
|
|
1432
|
+
children: [/*#__PURE__*/jsxs(TableHead, {
|
|
1433
|
+
children: [/*#__PURE__*/jsx(TableHeadCell, {
|
|
1434
|
+
children: "Estimated"
|
|
1435
|
+
}), /*#__PURE__*/jsx(TableHeadCell, {
|
|
1436
|
+
children: "Stored"
|
|
1437
|
+
})]
|
|
1438
|
+
}), /*#__PURE__*/jsx(TableBody, {
|
|
1439
|
+
children: /*#__PURE__*/jsxs(TableRow, {
|
|
1440
|
+
children: [/*#__PURE__*/jsx(TableCell, {
|
|
1441
|
+
children: renderEstimatedBoiloff
|
|
1442
|
+
}), /*#__PURE__*/jsx(TableCell, {
|
|
1443
|
+
children: storedBoiloff
|
|
1444
|
+
})]
|
|
1445
|
+
})
|
|
1446
|
+
})]
|
|
1447
|
+
})
|
|
1448
|
+
})]
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
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; }
|
|
1453
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1333
1454
|
function RenderGraph(_ref) {
|
|
1334
1455
|
var data = _ref.data,
|
|
1335
1456
|
height = _ref.height,
|
|
@@ -1339,6 +1460,15 @@ function RenderGraph(_ref) {
|
|
|
1339
1460
|
|
|
1340
1461
|
var heliumLookupData = useContext(LookupContext);
|
|
1341
1462
|
|
|
1463
|
+
// Get estimated data
|
|
1464
|
+
|
|
1465
|
+
var estimateResult = EstimateSlope(_objectSpread$1({}, {
|
|
1466
|
+
data: data,
|
|
1467
|
+
spec: spec
|
|
1468
|
+
}));
|
|
1469
|
+
var estimatedBoiloff = estimateResult.slope;
|
|
1470
|
+
var estimatedIntercept = estimateResult.intercept;
|
|
1471
|
+
|
|
1342
1472
|
// Custom Tooltip for LineChart
|
|
1343
1473
|
|
|
1344
1474
|
var CustomTooltip = function CustomTooltip(_ref2) {
|
|
@@ -1394,6 +1524,10 @@ function RenderGraph(_ref) {
|
|
|
1394
1524
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1395
1525
|
showMinima = _useState4[0],
|
|
1396
1526
|
setShowMinima = _useState4[1];
|
|
1527
|
+
var _useState5 = useState(false),
|
|
1528
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1529
|
+
showEstimate = _useState6[0],
|
|
1530
|
+
setShowEstimate = _useState6[1];
|
|
1397
1531
|
|
|
1398
1532
|
// Add days ago to data
|
|
1399
1533
|
|
|
@@ -1401,9 +1535,27 @@ function RenderGraph(_ref) {
|
|
|
1401
1535
|
item.days = -moment(item.date, "ddd MMM D HH:mm:ss YYYY").diff(moment(), "days");
|
|
1402
1536
|
});
|
|
1403
1537
|
|
|
1538
|
+
// Get chart data from estimate
|
|
1539
|
+
|
|
1540
|
+
showEstimate && (data = data.map(function (item) {
|
|
1541
|
+
var days = item.days;
|
|
1542
|
+
var level = item.level;
|
|
1543
|
+
var estimate = estimatedBoiloff * (data.length - days) + estimatedIntercept;
|
|
1544
|
+
return {
|
|
1545
|
+
date: item.date,
|
|
1546
|
+
days: days,
|
|
1547
|
+
level: level,
|
|
1548
|
+
estimate: estimate
|
|
1549
|
+
};
|
|
1550
|
+
}));
|
|
1551
|
+
|
|
1404
1552
|
// Get last n elements of array
|
|
1405
1553
|
|
|
1406
1554
|
data = data.slice(Math.max(data.length - days, 0));
|
|
1555
|
+
|
|
1556
|
+
// Improve visibility of estimate
|
|
1557
|
+
|
|
1558
|
+
var lineColor = showEstimate ? AppTheme.palette.grey[300] : AppTheme.palette.primary.main;
|
|
1407
1559
|
return /*#__PURE__*/jsxs(React.Fragment, {
|
|
1408
1560
|
children: [/*#__PURE__*/jsxs(LineChart, {
|
|
1409
1561
|
height: height,
|
|
@@ -1417,13 +1569,20 @@ function RenderGraph(_ref) {
|
|
|
1417
1569
|
},
|
|
1418
1570
|
children: [/*#__PURE__*/jsx(Line, {
|
|
1419
1571
|
dataKey: "level",
|
|
1420
|
-
stroke:
|
|
1421
|
-
fill:
|
|
1572
|
+
stroke: lineColor,
|
|
1573
|
+
fill: lineColor,
|
|
1422
1574
|
type: "linear",
|
|
1423
1575
|
dot: {
|
|
1424
1576
|
r: 1.5
|
|
1425
1577
|
}
|
|
1426
|
-
}), /*#__PURE__*/jsx(
|
|
1578
|
+
}), showEstimate ? /*#__PURE__*/jsx(Line, {
|
|
1579
|
+
dataKey: "estimate",
|
|
1580
|
+
stroke: AppTheme.palette.action.main,
|
|
1581
|
+
type: "monotone",
|
|
1582
|
+
strokeDasharray: "5 5",
|
|
1583
|
+
strokeWidth: 2,
|
|
1584
|
+
dot: false
|
|
1585
|
+
}) : null, /*#__PURE__*/jsx(CartesianGrid, {
|
|
1427
1586
|
stroke: AppTheme.palette.divider,
|
|
1428
1587
|
strokeDasharray: "5 5"
|
|
1429
1588
|
}), /*#__PURE__*/jsx(XAxis, {
|
|
@@ -1477,8 +1636,8 @@ function RenderGraph(_ref) {
|
|
|
1477
1636
|
}), /*#__PURE__*/jsx(DayButton, {
|
|
1478
1637
|
value: 365
|
|
1479
1638
|
})]
|
|
1480
|
-
}), /*#__PURE__*/
|
|
1481
|
-
children: /*#__PURE__*/jsx(FormControlLabel, {
|
|
1639
|
+
}), /*#__PURE__*/jsxs(FormGroup, {
|
|
1640
|
+
children: [/*#__PURE__*/jsx(FormControlLabel, {
|
|
1482
1641
|
control: /*#__PURE__*/jsx(Switch, {
|
|
1483
1642
|
label: "Show Minimum",
|
|
1484
1643
|
checked: showMinima,
|
|
@@ -1490,16 +1649,41 @@ function RenderGraph(_ref) {
|
|
|
1490
1649
|
sx: {
|
|
1491
1650
|
justifyContent: "center"
|
|
1492
1651
|
}
|
|
1493
|
-
})
|
|
1652
|
+
}), /*#__PURE__*/jsx(FormControlLabel, {
|
|
1653
|
+
control: /*#__PURE__*/jsx(Switch, {
|
|
1654
|
+
label: "Show Estimate",
|
|
1655
|
+
checked: showEstimate,
|
|
1656
|
+
onChange: function onChange() {
|
|
1657
|
+
return setShowEstimate(!showEstimate);
|
|
1658
|
+
}
|
|
1659
|
+
}),
|
|
1660
|
+
label: "Show Estimate",
|
|
1661
|
+
sx: {
|
|
1662
|
+
justifyContent: "center"
|
|
1663
|
+
}
|
|
1664
|
+
})]
|
|
1665
|
+
}), /*#__PURE__*/jsx(ShowEstimate, {
|
|
1666
|
+
spec: spec,
|
|
1667
|
+
data: data
|
|
1494
1668
|
})]
|
|
1495
1669
|
});
|
|
1496
1670
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1671
|
+
|
|
1672
|
+
function HeliumGraph(_ref) {
|
|
1673
|
+
var graphData = _ref.graphData,
|
|
1674
|
+
graphDataMeta = _ref.graphDataMeta,
|
|
1675
|
+
matches = _ref.matches;
|
|
1501
1676
|
var height = matches ? 250 : 200;
|
|
1502
1677
|
var width = matches ? 300 : 280;
|
|
1678
|
+
var heliumLookupData = useContext(LookupContext);
|
|
1679
|
+
|
|
1680
|
+
// remove spectrometers not existing in heliumLookupData
|
|
1681
|
+
|
|
1682
|
+
Object.keys(graphData).forEach(function (spec) {
|
|
1683
|
+
if (!heliumLookupData.boilOff[spec]) {
|
|
1684
|
+
delete graphData[spec];
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1503
1687
|
|
|
1504
1688
|
// Catch missing data
|
|
1505
1689
|
|
|
@@ -1509,7 +1693,7 @@ function HeliumGraph(_ref4) {
|
|
|
1509
1693
|
children: /*#__PURE__*/jsx("strong", {
|
|
1510
1694
|
children: "Helium level monitoring"
|
|
1511
1695
|
})
|
|
1512
|
-
}), /*#__PURE__*/jsx(
|
|
1696
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1513
1697
|
sx: {
|
|
1514
1698
|
display: "flex",
|
|
1515
1699
|
justifyContent: "center"
|
|
@@ -1530,7 +1714,7 @@ function HeliumGraph(_ref4) {
|
|
|
1530
1714
|
}), " ", /*#__PURE__*/jsxs("em", {
|
|
1531
1715
|
children: ["(updated ", moment(graphDataMeta.date).fromNow(), ")"]
|
|
1532
1716
|
})]
|
|
1533
|
-
}), /*#__PURE__*/jsx(
|
|
1717
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1534
1718
|
container: true,
|
|
1535
1719
|
sx: {
|
|
1536
1720
|
display: "flex",
|
|
@@ -1658,7 +1842,7 @@ function Helium(props) {
|
|
|
1658
1842
|
graphDataMeta: graphDataMeta,
|
|
1659
1843
|
matches: matches
|
|
1660
1844
|
})
|
|
1661
|
-
}) : null, /*#__PURE__*/jsxs(
|
|
1845
|
+
}) : null, /*#__PURE__*/jsxs(Grid, {
|
|
1662
1846
|
sx: {
|
|
1663
1847
|
display: "flex",
|
|
1664
1848
|
flexFlow: "column wrap",
|
|
@@ -1668,7 +1852,7 @@ function Helium(props) {
|
|
|
1668
1852
|
title: "Helium Calculator",
|
|
1669
1853
|
size: cardSize,
|
|
1670
1854
|
collapsed: collapsed,
|
|
1671
|
-
children: [/*#__PURE__*/jsx(
|
|
1855
|
+
children: [/*#__PURE__*/jsx(Grid, {
|
|
1672
1856
|
children: /*#__PURE__*/jsxs(DivTitle, {
|
|
1673
1857
|
children: [/*#__PURE__*/jsx("strong", {
|
|
1674
1858
|
children: "Current levels"
|
|
@@ -1678,7 +1862,7 @@ function Helium(props) {
|
|
|
1678
1862
|
})]
|
|
1679
1863
|
})]
|
|
1680
1864
|
})
|
|
1681
|
-
}), /*#__PURE__*/jsx(
|
|
1865
|
+
}), /*#__PURE__*/jsx(Grid, {
|
|
1682
1866
|
children: /*#__PURE__*/jsx(HeliumTable, {
|
|
1683
1867
|
heliumLookupData: heliumLookupData,
|
|
1684
1868
|
heliumData: heliumData,
|
|
@@ -1690,7 +1874,7 @@ function Helium(props) {
|
|
|
1690
1874
|
title: "Spectrometer Set",
|
|
1691
1875
|
size: cardSize,
|
|
1692
1876
|
collapsed: collapsed,
|
|
1693
|
-
children: /*#__PURE__*/jsx(
|
|
1877
|
+
children: /*#__PURE__*/jsx(Grid, {
|
|
1694
1878
|
children: /*#__PURE__*/jsx(PairWizard, {
|
|
1695
1879
|
heliumData: heliumData
|
|
1696
1880
|
})
|
|
@@ -1699,7 +1883,7 @@ function Helium(props) {
|
|
|
1699
1883
|
title: "Estimated Consumption",
|
|
1700
1884
|
size: cardSize,
|
|
1701
1885
|
collapsed: collapsed,
|
|
1702
|
-
children: /*#__PURE__*/jsx(
|
|
1886
|
+
children: /*#__PURE__*/jsx(Grid, {
|
|
1703
1887
|
children: /*#__PURE__*/jsx(EstimateConsumption, {})
|
|
1704
1888
|
})
|
|
1705
1889
|
}), /*#__PURE__*/jsx(AppCard, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zac-apps/helium",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"rollup": "node_modules/rollup/dist/rollup.js",
|
|
6
6
|
"dev": "next dev",
|
|
@@ -30,9 +30,10 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mui/icons-material": "^5.17.1",
|
|
32
32
|
"@mui/material": "^5.17.1",
|
|
33
|
-
"@zac-apps/commons": "^1
|
|
33
|
+
"@zac-apps/commons": "^1",
|
|
34
34
|
"moment": "^2.30.1",
|
|
35
35
|
"recharts": "^2.15.1",
|
|
36
|
+
"regression": "^2.0.1",
|
|
36
37
|
"use-immer": "^0.11.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
@@ -63,10 +64,10 @@
|
|
|
63
64
|
"storybook": "^8.6.10"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
67
|
+
"@zac-apps/commons": "^1",
|
|
66
68
|
"next": "^14",
|
|
67
69
|
"react": "^18 || ^19",
|
|
68
|
-
"react-dom": "^18 || ^19"
|
|
69
|
-
"@zac-apps/commons": "^1"
|
|
70
|
+
"react-dom": "^18 || ^19"
|
|
70
71
|
},
|
|
71
72
|
"description": "A React component to manage and visualize the helium consumption of a set of NMR spectrometers."
|
|
72
73
|
}
|