Methods
(async) WKriging(psSrc, psTar, optopt) → {Promise}
- Description:
Kriging內外插值,支援2D與3D
- Source:
Example
async function test2d1() {
let psSrc = [
{
x: -0.1, y: -0.1, z: 0
},
{
x: 1, y: 0, z: 0
},
{
x: 1, y: 1, z: 10
},
{
x: 0, y: 1, z: 0
},
]
let psTar = [
{ x: 0.1, y: 0.95 },
]
let opt = {
variogram_model: 'gaussian',
nlags: 9,
}
let r = await WKriging(psSrc, psTar, opt)
console.log('test2d1', r)
// => test2d [ { x: 0.1, y: 0.95, z: 1.8997805977145759 } ]
}
test2d1()
.catch((err) => {
console.log('catch', err)
})
async function test2d2() {
let psSrc = [{ x: 243, y: 206, z: 95 }, { x: 233, y: 225, z: 146 }, { x: 21, y: 325, z: 22 }, { x: 953, y: 28, z: 223 }, { x: 1092, y: 290, z: 39 }, { x: 744, y: 200, z: 191 }, { x: 174, y: 3, z: 22 }, { x: 537, y: 368, z: 249 }, { x: 1151, y: 371, z: 86 }, { x: 814, y: 252, z: 125 }]
let psTar = [{
x: 243,
y: 205,
}]
let opt = {
variogram_model: 'exponential',
nlags: 9,
}
let r = await WKriging(psSrc, psTar, opt)
console.log('test2d2', r)
// => test2d [ { x: 243, y: 205, z: 94.89492366904084 } ]
}
test2d2()
.catch((err) => {
console.log('catch', err)
})
async function test3d1() {
let psSrc = [
{
x: -0.1, y: -0.1, z: -0.1, v: 0
},
{
x: 1, y: 0, z: 0, v: 0
},
{
x: 1, y: 1, z: 0, v: 0
},
{
x: 0, y: 0, z: 1, v: 0
},
{
x: 1, y: 0, z: 1, v: 0
},
{
x: 1, y: 1, z: 1, v: 10
},
]
let psTar = [
{
x: 0.1, y: 0.1, z: 0.95
},
]
let opt = {
variogram_model: 'gaussian',
nlags: 9,
}
let r = await WKriging(psSrc, psTar, opt)
console.log('test3d1', r)
// => test3d [ { x: 0.1, y: 0.1, z: 0.95, v: 1.666666666666666 } ]
}
test3d1()
.catch((err) => {
console.log('catch', err)
})
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
psSrc |
Array | 輸入二維座標加觀測數據點陣列,為[{x:x1,y:y1,z:z1},{x:x2,y:y2,z:z2},...]點物件之陣列,或可為[[x1,y1,z1],[x2,y2,z2],...]點陣列之陣列,亦可支援三維座標加觀測數據點陣列,為[{x:x1,y:y1,z:z1,v:v1},{x:x2,y:y2,z:z2,v:v2},...]點物件之陣列,或可為[[x1,y1,z1,v1],[x2,y2,z2,v2],...]點陣列之陣列 |
|||||||||||||||||||||||||||||||||||||
psTar |
Array | Object | 輸入二維座標點陣列或點物件,為[{x:x1,y:y1},{x:x2,y:y2},...]點物件之陣列,或{x:x1,y:y1}點物件,亦可支援三維座標點陣列或點物件,為[{x:x1,y:y1,z:z1},{x:x2,y:y2,z:z2},...]點物件之陣列,或{x:x1,y:y1,z:z1}點物件 |
|||||||||||||||||||||||||||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息
- Type
- Promise
(async) autoDownloadFiles() → {Promise}
- Description:
取得kriging.exe,回傳kriging.exe的絕對路徑
經ensureBins依bin/manifest.json之SHA-256與大小校驗後取得(快取、鏡像、GitHub釘選提交),首次使用才下載,安裝時不下載, 離線與內網之用法(W_BIN_CACHE、W_BIN_MIRROR、W_BIN_OFFLINE)見README〈外部執行檔〉
供w-kriging自身與其他依賴w-kriging的套件調用,無須各自實作偵測與下載邏輯
因kriging.exe只能用於Windows作業系統,故調用前須自行檢核作業系統
- Source:
- Deprecated:
- 請改用ensureBins(w-kriging/src/ensureBins.mjs,或WKriging.ensureBins),本函數僅為既有深層匯入者保留
Example
import autoDownloadFiles from 'w-kriging/src/autoDownloadFiles.mjs'
async function test() {
//autoDownloadFiles, 無快取時自動取得, 取得或校驗失敗則reject
let { fpExe } = await autoDownloadFiles()
console.log('fpExe', fpExe)
// fpExe D:\xxx\node_modules\w-kriging\bin-cache\<sha256>\kriging.exe
}
test()
.catch((err) => {
console.log('catch', err)
})
Returns:
回傳Promise,resolve回傳執行檔路徑物件,內含fpExe為kriging.exe的絕對路徑字串,reject回傳帶code之Error(E_OFFLINE_MISSING、E_HASH_MISMATCH等)
- Type
- Promise
ensureBins(optopt) → {Promise}
- Description:
取得本套件之外部執行檔kriging.exe: 首次使用時下載(或自鏡像取得)並以bin/manifest.json之SHA-256與大小校驗, 之後自快取取得(亦校驗) 規格: 外部執行檔之存放下載校驗與離線(制式規格)§6; 實作為wsemi之fsEnsureBins, 本套件不另寫下載、快取、鏡像、校驗 環境變數: W_BIN_CACHE、W_BIN_MIRROR、W_BIN_OFFLINE, 見README〈外部執行檔〉
- Source:
Example
import ensureBins from 'w-kriging/src/ensureBins.mjs'
async function test() {
//部署前預先取得(連網機器設W_BIN_CACHE=<資料夾>後執行, 該資料夾即可作為離線鏡像W_BIN_MIRROR)
let bins = await ensureBins()
console.log('bins', bins)
// bins { 'kriging.exe': 'D:\\xxx\\node_modules\\w-kriging\\bin-cache\\<sha256>\\kriging.exe' }
}
test()
.catch((err) => {
console.log('catch', err)
})
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
opt |
Object |
<optional> |
{}
|
輸入設定物件, 交wsemi之fsEnsureBins(names、cacheDir、mirror、offline、onProgress等), pkgRoot固定為本套件根 |
Returns:
回傳Promise,resolve回傳{ [檔名]: 絕對路徑 },reject回傳帶code之Error(E_OFFLINE_MISSING等)
- Type
- Promise