@datagrok/compute 1.4.0 → 1.4.2
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/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/exp_data.csv +21601 -0
- package/package.json +2 -2
- package/scripts/default-get-real-data.js +6 -0
- package/scripts/demo-rfv-df-input.js +9 -0
- package/scripts/demo-rfv-simple.js +38 -0
- package/scripts/lorenz-attractor.js +7 -5
- package/src/model-handler.ts +15 -0
- package/scripts/default-complex.js +0 -30
- package/scripts/default-file-script.js +0 -13
- package/scripts/default-immediate.js +0 -36
- package/scripts/default.js +0 -35
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aufar Zakiev",
|
|
7
7
|
"email": "aufar.zakiev@softwarecountry.com"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/Compute"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@datagrok-libraries/compute-utils": "^1.
|
|
16
|
+
"@datagrok-libraries/compute-utils": "^1.5.0",
|
|
17
17
|
"cash-dom": "latest",
|
|
18
18
|
"datagrok-api": "^1.14.0",
|
|
19
19
|
"dayjs": "latest",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//name: Data stats
|
|
2
|
+
//description: Uses Datagrok's built-in viewer to show dataframe stats
|
|
3
|
+
//language: javascript
|
|
4
|
+
//tags: demo
|
|
5
|
+
//input: dataframe inputDf {caption: Input dataframe; viewer: Grid()}
|
|
6
|
+
//output: dataframe outputDf {caption: Output dataframe; viewer: Line chart(block: 50) | Scatter plot(block: 50) | Statistics(block: 100); category: Stats}
|
|
7
|
+
//editor: Compute:RichFunctionViewEditor
|
|
8
|
+
|
|
9
|
+
outputDf = inputDf.clone();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//name: Object cooling
|
|
2
|
+
//description: Uses Newton's law of cooling to simulate object cooling process. Default values are for cube of boiling water in air.
|
|
3
|
+
//language: javascript
|
|
4
|
+
//tags: simulation, demo
|
|
5
|
+
//input: double ambTemp = 22 {caption: Ambient temperature; units: C; category: Environment}
|
|
6
|
+
//input: double initTemp = 100 {caption: Initial temperature; units: C; category: Environment}
|
|
7
|
+
//input: double desiredTemp = 30 {caption: Desired temperature; units: C; category: Environment}
|
|
8
|
+
//input: double area = 0.06 {caption: Surface area; units: m²; category: Object properties}
|
|
9
|
+
//input: double heatCap = 4200 {caption: Heat capacity; units: J/C; category: Object properties}
|
|
10
|
+
//input: double heatTransferCoeff = 8.3 {caption: Heat transfer coefficient; units: W/(m² * C); category: Object properties}
|
|
11
|
+
//input: int simTime = 21600 {caption: Simulation time; units: sec; category: Simulation}
|
|
12
|
+
//output: dataframe simulation {caption: Temp. vs time dependency; category: Output; viewer: Line chart(block: 75) | Grid(block: 25)}
|
|
13
|
+
//output: double timeToCool {caption: Time to cool; units: sec.; category: Output}
|
|
14
|
+
//output: double coolingFactor {caption: Cooling factor; units: 1 / sec.; category: Calculations}
|
|
15
|
+
//output: double tempDiff {caption: Temperature difference; units: C; category: Calculations}
|
|
16
|
+
//editor: Compute:RichFunctionViewEditor
|
|
17
|
+
//meta.uploadMode: true
|
|
18
|
+
|
|
19
|
+
timeToCool = undefined;
|
|
20
|
+
|
|
21
|
+
const tempDiff = initTemp - ambTemp;
|
|
22
|
+
const coolingFactor = heatTransferCoeff * area / heatCap;
|
|
23
|
+
|
|
24
|
+
const timeStamps = new Float32Array(simTime).map((_, idx) => idx);
|
|
25
|
+
const simulatedTemp = timeStamps.map((timeStamp) => {
|
|
26
|
+
const currentTemp = ambTemp + (tempDiff * (Math.E ** -(coolingFactor * timeStamp)));
|
|
27
|
+
|
|
28
|
+
if (!timeToCool && currentTemp < desiredTemp) {
|
|
29
|
+
timeToCool = timeStamp;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return currentTemp;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
simulation = DG.DataFrame.fromColumns([
|
|
36
|
+
DG.Column.fromFloat32Array('Time', timeStamps),
|
|
37
|
+
DG.Column.fromFloat32Array('Temperature', simulatedTemp),
|
|
38
|
+
]);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
//name: Lorenz Attractor
|
|
2
|
-
//tags: simulation
|
|
2
|
+
//tags: simulation, demo
|
|
3
3
|
//meta.domain: Nonlinear dynamics
|
|
4
4
|
//description: Set of chaotic solutions of the system for weather prediction. It illustrates the phenomenon known as the Butterfly effect or (more technically) sensitive dependence on initial conditions
|
|
5
5
|
//language: javascript
|
|
6
|
-
//input: int iterations = 1000
|
|
7
|
-
//input: double dt = 0.01 {caption:
|
|
6
|
+
//input: int iterations = 1000 {caption: Iterations number}
|
|
7
|
+
//input: double dt = 0.01 {caption: Step per iteration}
|
|
8
8
|
//input: double x0 = 0 [Initial conditions for rate of convective motion - i.e. how fast the rolls are rotating]
|
|
9
9
|
//input: double y0 = 1 [Initial conditions for temperature difference between the ascending and descending currents]
|
|
10
10
|
//input: double z0 = 1.05 [Initial conditions for distortion (from linearity) of the vertical temperature profile]
|
|
11
|
-
//output: dataframe df {viewer: 3d Scatter plot(
|
|
11
|
+
//output: dataframe df {caption: Lorenz attractor; viewer: 3d Scatter plot())}
|
|
12
|
+
//editor: Compute:RichFunctionViewEditor
|
|
13
|
+
//meta.runOnInput: true
|
|
12
14
|
|
|
13
15
|
function lorenzEquations(x, y, z, s=10, r=28, b=2.667) {
|
|
14
16
|
return {
|
|
@@ -37,4 +39,4 @@ df = DG.DataFrame.fromColumns([
|
|
|
37
39
|
DG.Column.fromFloat32Array('X', xs),
|
|
38
40
|
DG.Column.fromFloat32Array('Y', ys),
|
|
39
41
|
DG.Column.fromFloat32Array('Z', zs)
|
|
40
|
-
]);
|
|
42
|
+
]);
|
package/src/model-handler.ts
CHANGED
|
@@ -70,6 +70,21 @@ export class ModelHandler extends DG.ObjectHandler {
|
|
|
70
70
|
return markup;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
async renderPreview(x: DG.Func) {
|
|
74
|
+
const editorName = x.options.editor ?? 'Compute:RichFunctionEditor';
|
|
75
|
+
const editor = await grok.functions.find(editorName);
|
|
76
|
+
if (editor !== null && editor instanceof DG.Func) {
|
|
77
|
+
console.log(editor);
|
|
78
|
+
const viewCall = editor.prepare({'call': x.prepare()});
|
|
79
|
+
await viewCall.call(false, undefined, {processed: true});
|
|
80
|
+
const view = viewCall.getOutputParamValue();
|
|
81
|
+
if (view instanceof DG.View)
|
|
82
|
+
return view;
|
|
83
|
+
}
|
|
84
|
+
//@ts-ignore
|
|
85
|
+
return super.renderPreview(x);
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
renderProperties(x: DG.Func) {
|
|
74
89
|
const a = ui.accordion('ComputeModel');
|
|
75
90
|
a.context = x;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//name: Default complex script JS
|
|
2
|
-
//description: Shows that default view works (or not)
|
|
3
|
-
//language: javascript
|
|
4
|
-
//tags: bioreactor
|
|
5
|
-
//input: dataframe test { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) }
|
|
6
|
-
//input: double S1 = 50 {caption: S1; units: ft² * BTU / hr °F}
|
|
7
|
-
//input: double S2 = 12 {caption: Initial scalar; units: L/min}
|
|
8
|
-
//input: double S3 = -2 {caption: Dummy scalar.; units: °C}
|
|
9
|
-
//input: double S4 = 5 {caption: Final S4; units: cells/mL}
|
|
10
|
-
//input: double S5 = 210.5 {caption: Final Volume; units: L}
|
|
11
|
-
//input: double S = 31.1 {caption: Temp.; units: °C}
|
|
12
|
-
//output: dataframe tempOnTime { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate }
|
|
13
|
-
//output: double IC2 {caption: Culture temp.; units: °C; category: Cooling rate}
|
|
14
|
-
//output: dataframe tempOnTime2 { viewer: Line chart(x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 50); category: Cooling rate 2 }
|
|
15
|
-
//output: dataframe tempOnTime3 { viewer: Line chart(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Scatter plot(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
|
|
16
|
-
//output: dataframe tempOnTime4 { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
|
|
17
|
-
//output: dataframe tempOnTime5 { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false); category: Cooling rate 3 }
|
|
18
|
-
//output: double IC3 {caption: Culture temp.; units: °C; category: Cooling rate 3}
|
|
19
|
-
//output: double IC4 {caption: Culture temp.; units: °C; category: Cooling rate 3}
|
|
20
|
-
//editor: Compute:RichFunctionViewEditor
|
|
21
|
-
|
|
22
|
-
tempOnTime = test
|
|
23
|
-
tempOnTime2 = tempOnTime
|
|
24
|
-
tempOnTime3 = tempOnTime
|
|
25
|
-
tempOnTime4 = tempOnTime
|
|
26
|
-
tempOnTime5 = tempOnTime
|
|
27
|
-
|
|
28
|
-
IC2 = S1
|
|
29
|
-
IC3 = S1
|
|
30
|
-
IC4 = S1 * 2
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//name: Default import script
|
|
2
|
-
//description: desc
|
|
3
|
-
//language: javascript
|
|
4
|
-
//input: file uploadedFile
|
|
5
|
-
//output: dataframe df { viewer: Grid(); }
|
|
6
|
-
//editor: Compute:RichFunctionViewEditor
|
|
7
|
-
|
|
8
|
-
const wb = new ExcelJS.Workbook();
|
|
9
|
-
await wb.xlsx.load(await uploadedFile.arrayBuffer());
|
|
10
|
-
|
|
11
|
-
const df_ws = wb.getWorksheet("df");
|
|
12
|
-
let data = await df_ws.workbook.csv.writeBuffer();
|
|
13
|
-
df = grok.data.parseCsv(data.toString());
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//name: Default immediate script JS
|
|
2
|
-
//description: Shows that default view works (or not)
|
|
3
|
-
//language: javascript
|
|
4
|
-
//tags: bioreactor
|
|
5
|
-
//input: double S1 = 1 {caption: S1; units: ft² * BTU / hr °F; category: Category1}
|
|
6
|
-
//input: double S2 = 100 {caption: Initial scalar; units: L/min; category: Category1}
|
|
7
|
-
//input: double S3 = -2 {caption: Dummy scalar.; units: °C; category: Category1}
|
|
8
|
-
//input: double S4 = 5 {caption: Final S4; units: cells/mL; category: Category2}
|
|
9
|
-
//input: double S5 = 210.5 {caption: Final Volume; units: L; category: Category2}
|
|
10
|
-
//input: double S = 31.1 {caption: Temp.; units: °C; category: Category2}
|
|
11
|
-
//output: dataframe tempOnTime { viewer: Line chart(block: 50, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Statistics(block: 50); category: CoolingRate }
|
|
12
|
-
//output: dataframe tempOnTime2 { viewer: Line chart(block: 25, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 75); category: CoolingRate2 }
|
|
13
|
-
//output: double O1 {caption: Temp 1.; units: °C; category: CoolingRate2 }
|
|
14
|
-
//output: dataframe tempOnTime3 { caption: "My lovely caption"; viewer: Line chart(block: 75, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 25); category: CoolingRate2 }
|
|
15
|
-
//output: double O2 {caption: Temp 2.; units: °C; category: CoolingRate3 }
|
|
16
|
-
//output: double O3 {caption: Temp 3.; units: °C; category: CoolingRate3 }
|
|
17
|
-
//output: double O4 {caption: Temp 4.; units: °C; category: CoolingRate3 }
|
|
18
|
-
//output: double O5 {caption: Temp 5.; units: °C; category: CoolingRate3 }
|
|
19
|
-
//editor: Compute:RichFunctionViewEditor
|
|
20
|
-
//meta.runOnInput: true
|
|
21
|
-
|
|
22
|
-
const tt = [...Array(S2).keys()]
|
|
23
|
-
const Sol = [...Array(S2).keys()].map((x) => x*2)
|
|
24
|
-
|
|
25
|
-
tempOnTime = DG.DataFrame.fromColumns([
|
|
26
|
-
DG.Column.float("Time (hours)", S2).init((i) => tt[i]),
|
|
27
|
-
DG.Column.float("Temperature (°C)", S2).init((i) => Sol[i]),
|
|
28
|
-
])
|
|
29
|
-
tempOnTime2 = tempOnTime
|
|
30
|
-
tempOnTime3 = tempOnTime
|
|
31
|
-
|
|
32
|
-
O1 = S2
|
|
33
|
-
O2 = S2
|
|
34
|
-
O3 = S2
|
|
35
|
-
O4 = S2
|
|
36
|
-
O5 = S2
|
package/scripts/default.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//name: Default simple script JS
|
|
2
|
-
//description: Shows that default view works (or not)
|
|
3
|
-
//language: javascript
|
|
4
|
-
//tags: bioreactor
|
|
5
|
-
//input: double S1 = 1 {caption: S1; units: ft² * BTU / hr °F; category: Category1}
|
|
6
|
-
//input: double S2 = 100 {caption: Initial scalar; units: L/min; category: Category1}
|
|
7
|
-
//input: double S3 = -2 {caption: Dummy scalar.; units: °C; category: Category1}
|
|
8
|
-
//input: double S4 = 5 {caption: Final S4; units: cells/mL; category: Category2}
|
|
9
|
-
//input: double S5 = 210.5 {caption: Final Volume; units: L; category: Category2}
|
|
10
|
-
//input: double S = 31.1 {caption: Temp.; units: °C; category: Category2}
|
|
11
|
-
//output: dataframe tempOnTime { viewer: Line chart(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Statistics(block: 50); category: CoolingRate }
|
|
12
|
-
//output: dataframe tempOnTime2 { viewer: Line chart(block: 100, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 75); category: CoolingRate2 }
|
|
13
|
-
//output: double O1 {caption: Temp 1.; units: °C; category: CoolingRate2 }
|
|
14
|
-
//output: dataframe tempOnTime3 { caption: "My lovely caption"; viewer: Line chart(block: 75, x: "Time (hours)", y: "Temperature (°C)", showSplitSelector: false) | Grid(block: 25); category: CoolingRate2 }
|
|
15
|
-
//output: double O2 {caption: Temp 2.; units: °C; category: CoolingRate3 }
|
|
16
|
-
//output: double O3 {caption: Temp 3.; units: °C; category: CoolingRate3 }
|
|
17
|
-
//output: double O4 {caption: Temp 4.; units: °C; category: CoolingRate3 }
|
|
18
|
-
//output: double O5 {caption: Temp 5.; units: °C; category: CoolingRate3 }
|
|
19
|
-
//editor: Compute:RichFunctionViewEditor
|
|
20
|
-
|
|
21
|
-
const tt = [...Array(S2).keys()]
|
|
22
|
-
const Sol = [...Array(S2).keys()].map((x) => x*2)
|
|
23
|
-
|
|
24
|
-
tempOnTime = DG.DataFrame.fromColumns([
|
|
25
|
-
DG.Column.float("Time (hours)", S2).init((i) => tt[i]),
|
|
26
|
-
DG.Column.float("Temperature (°C)", S2).init((i) => Sol[i]),
|
|
27
|
-
])
|
|
28
|
-
tempOnTime2 = tempOnTime
|
|
29
|
-
tempOnTime3 = tempOnTime
|
|
30
|
-
|
|
31
|
-
O1 = S2
|
|
32
|
-
O2 = S2
|
|
33
|
-
O3 = S2
|
|
34
|
-
O4 = S2
|
|
35
|
-
O5 = S2
|