w-geo 1.1.21 → 1.1.23
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/README.md +1 -1
- package/dist/w-geo.umd.js +3 -3
- package/dist/w-geo.umd.js.map +1 -1
- package/docs/-_class.mjs.html +1 -1
- package/docs/calcDepthByDepthStartEnd.mjs.html +1 -1
- package/docs/calcDepthStartEndByConnect.mjs.html +1 -1
- package/docs/calcDepthStartEndByDepth.mjs.html +1 -1
- package/docs/calcDepthStartEndByGroup.mjs.html +1 -1
- package/docs/calcLiquefaction.mjs.html +1 -1
- package/docs/calcVerticalStress.mjs.html +1 -1
- package/docs/checkDepth.mjs.html +1 -1
- package/docs/checkDepthStartEnd.mjs.html +1 -1
- package/docs/complementDepthData.mjs.html +1 -1
- package/docs/groupByDepthStartEnd.mjs.html +1 -1
- package/docs/index.html +1 -1
- package/docs/mergeByDepthStartEnd.mjs.html +1 -1
- package/docs/relaPlasticityParams.mjs.html +1 -1
- package/docs/relaPorousParams.mjs.html +1 -1
- package/docs/sepDepthStartEndByDepth.mjs.html +1 -1
- package/docs/smoothDepthByKey.mjs.html +1 -1
- package/docs/w-geo.html +1 -1
- package/{g_5_4-getDepthMaxMin.mjs → g_4_5-calcDepthMaxMin.mjs} +7 -7
- package/g_5_4-buildInterpFun.mjs +46 -0
- package/g_8_1-dtIntrpPsdBySize.mjs +1 -1
- package/g_8_1-dtIntrpPsdContentIso.mjs +31 -0
- package/package.json +1 -1
- package/src/WGeo.mjs +3 -1
- package/src/buildInterpFun.mjs +104 -0
- package/src/{getDepthMaxMin.mjs → calcDepthMaxMin.mjs} +28 -28
- package/src/dtIntrpPsdContentIso.mjs +109 -0
- package/test/buildInterpFun.test.mjs +65 -0
- package/test/calcDepthMaxMin.test.mjs +29 -0
- package/test/dtIntrpPsdContentIso.test.mjs +30 -0
- package/test/getDepthMaxMin.test.mjs +0 -29
- /package/test/{getDepthMaxMin-rowsIn1.json → calcDepthMaxMin-rowsIn1.json} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import get from 'lodash-es/get.js'
|
|
2
|
+
import find from 'lodash-es/find.js'
|
|
3
|
+
import round from 'lodash-es/round.js'
|
|
4
|
+
import size from 'lodash-es/size.js'
|
|
5
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
6
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
7
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
8
|
+
import dtIntrpPsdBySize from './dtIntrpPsdBySize.mjs'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function dtIntrpPsdContentIso(dt, opt = {}) {
|
|
12
|
+
|
|
13
|
+
//keySize
|
|
14
|
+
let keySize = get(opt, 'keySize', '')
|
|
15
|
+
if (!isestr(keySize)) {
|
|
16
|
+
keySize = 'size'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//keyFraction
|
|
20
|
+
let keyFraction = get(opt, 'keyFraction', '')
|
|
21
|
+
if (!isestr(keyFraction)) {
|
|
22
|
+
keyFraction = 'fraction'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//dtIntrpPsdBySize
|
|
26
|
+
let psizes = [
|
|
27
|
+
630,
|
|
28
|
+
200,
|
|
29
|
+
63,
|
|
30
|
+
20,
|
|
31
|
+
6.3,
|
|
32
|
+
2,
|
|
33
|
+
0.63,
|
|
34
|
+
0.2,
|
|
35
|
+
0.063,
|
|
36
|
+
0.02,
|
|
37
|
+
0.0063,
|
|
38
|
+
0.002,
|
|
39
|
+
]
|
|
40
|
+
let psds = dtIntrpPsdBySize(dt, psizes, { keySize, keyFraction })
|
|
41
|
+
// console.log('psds', psds)
|
|
42
|
+
|
|
43
|
+
//check
|
|
44
|
+
if (size(psds) === 0) {
|
|
45
|
+
console.log('dt', dt)
|
|
46
|
+
console.log('psizes', psizes)
|
|
47
|
+
console.log('keySize', keySize)
|
|
48
|
+
console.log('keyFraction', keyFraction)
|
|
49
|
+
throw new Error('invalid PSD')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//1e20->2: 礫石
|
|
53
|
+
//2->0.063: 砂
|
|
54
|
+
//0.063->0.02: 粉土
|
|
55
|
+
//0.02->0: 黏土
|
|
56
|
+
let p2 = find(psds, { size: 2 })
|
|
57
|
+
let p0063 = find(psds, { size: 0.063 })
|
|
58
|
+
// let p0005 = find(psds, { size: 0.005 })
|
|
59
|
+
let p0002 = find(psds, { size: 0.002 })
|
|
60
|
+
let f2 = get(p2, 'fraction')
|
|
61
|
+
let f0063 = get(p0063, 'fraction')
|
|
62
|
+
// let f0005 = get(p0005, 'fraction')
|
|
63
|
+
let f0002 = get(p0002, 'fraction')
|
|
64
|
+
// console.log('p2', p2, 'p0063', p0063, 'p0002', p0002)
|
|
65
|
+
// console.log('f2', f2, 'f0063', f0063, 'f0002', f0002)
|
|
66
|
+
|
|
67
|
+
//check
|
|
68
|
+
if (!isnum(f2)) {
|
|
69
|
+
throw new Error('invalid PSD in 2mm')
|
|
70
|
+
}
|
|
71
|
+
if (!isnum(f0063)) {
|
|
72
|
+
throw new Error('invalid PSD in 0.063mm')
|
|
73
|
+
}
|
|
74
|
+
if (!isnum(f0002)) {
|
|
75
|
+
throw new Error('invalid PSD in 0.002mm')
|
|
76
|
+
}
|
|
77
|
+
f2 = cdbl(f2)
|
|
78
|
+
f0063 = cdbl(f0063)
|
|
79
|
+
f0002 = cdbl(f0002)
|
|
80
|
+
// console.log('f2', f2, 'f0063', f0063, 'f0002', f0002)
|
|
81
|
+
|
|
82
|
+
//ctGravelISO, ctSandISO, ctFineISO, ctClayISO, 四捨五入可能會導致4項總和非100%
|
|
83
|
+
let ctGravelISO = 100 - f2
|
|
84
|
+
ctGravelISO = round(ctGravelISO)
|
|
85
|
+
let ctSandISO = f2 - f0063
|
|
86
|
+
ctSandISO = round(ctSandISO)
|
|
87
|
+
let ctSiltISO = f0063 - f0002
|
|
88
|
+
ctSiltISO = round(ctSiltISO)
|
|
89
|
+
let ctClayISO = f0002
|
|
90
|
+
ctClayISO = round(ctClayISO)
|
|
91
|
+
// console.log('ctGravelISO', ctGravelISO, 'ctSandISO', ctSandISO, 'ctSiltISO', ctSiltISO, 'ctClayISO', ctClayISO)
|
|
92
|
+
|
|
93
|
+
//add prop.
|
|
94
|
+
dt.ctCoarseISO = ctGravelISO + ctSandISO
|
|
95
|
+
dt.ctGravelISO = ctGravelISO
|
|
96
|
+
dt.ctSandISO = ctSandISO
|
|
97
|
+
dt.ctFineISO = ctSiltISO + ctClayISO
|
|
98
|
+
dt.ctSiltISO = ctSiltISO
|
|
99
|
+
dt.ctClayISO = ctClayISO
|
|
100
|
+
// console.log('ctGravel Ori', dt.ctGravel, 'New', ctGravelISO)
|
|
101
|
+
// console.log('ctSand Ori', dt.ctSand, 'New', ctSandISO)
|
|
102
|
+
// console.log('ctFine Ori', (cdbl(dt.ctSilt) + cdbl(dt.ctClay)), 'New', ctFineISO)
|
|
103
|
+
// console.log('ctClay Ori', dt.ctClay, 'New', ctClayISO)
|
|
104
|
+
|
|
105
|
+
return dt
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
export default dtIntrpPsdContentIso
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import _ from 'lodash-es'
|
|
3
|
+
import w from 'wsemi'
|
|
4
|
+
import buildInterpFun from '../src/buildInterpFun.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe(`buildInterpFun`, function() {
|
|
8
|
+
|
|
9
|
+
let rows = [
|
|
10
|
+
{
|
|
11
|
+
depth: 0,
|
|
12
|
+
value: 1,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
depth: 1,
|
|
16
|
+
value: 2,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
depth: 3,
|
|
20
|
+
value: 3,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
depth: 10,
|
|
24
|
+
value: 4,
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
let fun1 = buildInterpFun(rows, 'depth', 'value')
|
|
29
|
+
|
|
30
|
+
let x1 = 0.5
|
|
31
|
+
// let y1 = fun1(x1)
|
|
32
|
+
// console.log(y1)
|
|
33
|
+
let y1 = 1
|
|
34
|
+
|
|
35
|
+
let xs1 = [0.5, 1, 1.9, 2, 2.1]
|
|
36
|
+
// let ys1 = fun1(xs1)
|
|
37
|
+
// console.log(ys1)
|
|
38
|
+
let ys1 = [1, 2, 2, 2, 3]
|
|
39
|
+
|
|
40
|
+
let fun2 = buildInterpFun(rows, 'depth', 'value', { mode: 'linear' })
|
|
41
|
+
|
|
42
|
+
let xs2 = [0.5, 1, 1.9, 2, 2.1]
|
|
43
|
+
// let ys2 = fun2(xs2)
|
|
44
|
+
// console.log(ys2)
|
|
45
|
+
let ys2 = [1.5, 2, 2.45, 2.5, 2.55]
|
|
46
|
+
|
|
47
|
+
it(`should return ${y1} when fun1(${x1}) by buildInterpFun(rows, 'depth', 'value')`, function() {
|
|
48
|
+
let r = fun1(x1)
|
|
49
|
+
let rr = y1
|
|
50
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it(`should return ${ys1} when fun1(${xs1}) by buildInterpFun(rows, 'depth', 'value')`, function() {
|
|
54
|
+
let r = fun1(xs1)
|
|
55
|
+
let rr = ys1
|
|
56
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it(`should return ${ys2} when fun1(${xs2}) by buildInterpFun(rows, 'depth', 'value', { mode: 'linear' })`, function() {
|
|
60
|
+
let r = fun2(xs2)
|
|
61
|
+
let rr = ys2
|
|
62
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { calcDepthMaxMin } from '../src/calcDepthMaxMin.mjs'
|
|
3
|
+
import rowsIn1 from './calcDepthMaxMin-rowsIn1.json' assert { type: "json" }
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe(`calcDepthMaxMin`, function() {
|
|
7
|
+
|
|
8
|
+
let ropt = {
|
|
9
|
+
1: { approximate: false },
|
|
10
|
+
2: { approximate: true },
|
|
11
|
+
}
|
|
12
|
+
let rout = {
|
|
13
|
+
1: { depthMax: 99.98, depthMin: 0 },
|
|
14
|
+
2: { depthMax: 100, depthMin: 0 },
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
it(`should return ${JSON.stringify(rout[1])} when calcDepthMaxMin(rowsIn1, ${JSON.stringify(ropt[1])})`, function() {
|
|
18
|
+
let r = calcDepthMaxMin(rowsIn1, ropt[1])
|
|
19
|
+
let rr = rout[1]
|
|
20
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it(`should return ${JSON.stringify(rout[2])} when calcDepthMaxMin(rowsIn1, ${JSON.stringify(ropt[2])})`, function() {
|
|
24
|
+
let r = calcDepthMaxMin(rowsIn1, ropt[2])
|
|
25
|
+
let rr = rout[2]
|
|
26
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import _ from 'lodash-es'
|
|
3
|
+
import w from 'wsemi'
|
|
4
|
+
import dtIntrpPsdContentIso from '../src/dtIntrpPsdContentIso.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe(`dtIntrpPsdContentIso`, function() {
|
|
8
|
+
|
|
9
|
+
let dt = {
|
|
10
|
+
GSD: `[101.6, 76.2, 50.8, 25.4, 19.0, 9.5, 4.75, 2.0, 0.85, 0.425, 0.25, 0.15, 0.106, 0.075, 0.027, 0.018, 0.011, 0.008, 0.006, 0.003, 0.001, 0.0, 0.0, 0.0]`,
|
|
11
|
+
GSP: `[100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, -1.0, 100.0, 99.0, 96.0, 86.0, 74.0, 61.0, 51.0, 32.0, 16.0, 0.0, 0.0, 0.0]`,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let out1 = {
|
|
15
|
+
GSD: '[101.6, 76.2, 50.8, 25.4, 19.0, 9.5, 4.75, 2.0, 0.85, 0.425, 0.25, 0.15, 0.106, 0.075, 0.027, 0.018, 0.011, 0.008, 0.006, 0.003, 0.001, 0.0, 0.0, 0.0]',
|
|
16
|
+
GSP: '[100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, -1.0, 100.0, 99.0, 96.0, 86.0, 74.0, 61.0, 51.0, 32.0, 16.0, 0.0, 0.0, 0.0]',
|
|
17
|
+
ctCoarseISO: 2,
|
|
18
|
+
ctGravelISO: 0,
|
|
19
|
+
ctSandISO: 2,
|
|
20
|
+
ctFineISO: 98,
|
|
21
|
+
ctSiltISO: 72,
|
|
22
|
+
ctClayISO: 26
|
|
23
|
+
}
|
|
24
|
+
it(`should return ${out1} when dtIntrpPsdContentIso(dt)`, function() {
|
|
25
|
+
let r = dtIntrpPsdContentIso(dt)
|
|
26
|
+
let rr = out1
|
|
27
|
+
assert.strict.deepStrictEqual(r, rr)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
import { getDepthMaxMin } from '../src/getDepthMaxMin.mjs'
|
|
3
|
-
import rowsIn1 from './getDepthMaxMin-rowsIn1.json' assert { type: "json" }
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe(`getDepthMaxMin`, function() {
|
|
7
|
-
|
|
8
|
-
let ropt = {
|
|
9
|
-
1: { approximate: false },
|
|
10
|
-
2: { approximate: true },
|
|
11
|
-
}
|
|
12
|
-
let rout = {
|
|
13
|
-
1: { depthMax: 99.98, depthMin: 0 },
|
|
14
|
-
2: { depthMax: 100, depthMin: 0 },
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
it(`should return ${JSON.stringify(rout[1])} when getDepthMaxMin(rowsIn1, ${JSON.stringify(ropt[1])})`, function() {
|
|
18
|
-
let r = getDepthMaxMin(rowsIn1, ropt[1])
|
|
19
|
-
let rr = rout[1]
|
|
20
|
-
assert.strict.deepStrictEqual(r, rr)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it(`should return ${JSON.stringify(rout[2])} when getDepthMaxMin(rowsIn1, ${JSON.stringify(ropt[2])})`, function() {
|
|
24
|
-
let r = getDepthMaxMin(rowsIn1, ropt[2])
|
|
25
|
-
let rr = rout[2]
|
|
26
|
-
assert.strict.deepStrictEqual(r, rr)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
})
|
|
File without changes
|