Global

Methods

(async) WDataMseed(fp, optopt) → {Promise}

Description:
  • 讀取miniSEED檔案,只能用於Windows作業系統

    轉檔由mseed2ascii.exe(與相鄰之cygwin1.dll、cygz.dll)完成,這些外部執行檔不含於npm包,首次轉檔時經ensureBins自GitHub(釘選提交)或環境變數W_BIN_MIRROR之鏡像取得,以bin/manifest.json之SHA-256與大小逐檔校驗後存於快取(預設為套件根之bin-cache/,可由W_BIN_CACHE改位置),之後自快取取得(亦校驗);環境變數W_BIN_OFFLINE=1時不連網。取得失敗則reject字串,內含錯誤代碼(如E_OFFLINE_MISSING、E_HASH_MISMATCH)與原因,詳見README〈External executable〉

    轉檔之暫存輸出夾建於作業系統暫存夾os.tmpdir()下(夾名為${fdOutPre}<時間>-<亂數>),呼叫端之工作路徑內不會出現任何檔。轉檔成功且readWithData=true時刪除該夾;失敗時保留該夾供查找,reject之訊息末行附其絕對路徑(output folder kept for inspection: <路徑>)

    轉檔子行程由wsemi之execProcess(spawn模式)啟動,以其cwd選項指向輸出夾(mseed2ascii之輸出檔寫在工作路徑),不改本行程之process.cwd(),故多個轉換可併發。無輸出檔時之reject字串依來源為:離開碼非0為code[N]:\n輸出,無法啟動為spawn[錯誤碼]:\noperation failed (code 錯誤碼)(wsemi 1.9.66起帶錯誤碼之原生錯誤改為此固定詞彙,不再帶原生訊息原文;輸出夾於啟動前已不存在時為spawn[ENOENT]:\ncwd is not an existing folder: <輸出夾>),離開碼為0而無輸出檔(如輸入非miniSEED)為mseed2ascii之輸出訊息

Source:
Example
import wds from './src/WDataMseed.mjs'

async function test() {

    //fp
    let fp = './g.mseed'

    //wds
    let r = await wds(fp)
    console.log(r)
    // [
    //   {
    //     name: 'SE.RST01.00.HNE.D.2020-09-17T013552.000000.csv',
    //     path: null,
    //     data: { heads: [Object], records: [Array] }
    //   },
    //   {
    //     name: 'SE.RST01.00.HNN.D.2020-09-17T013552.000000.csv',
    //     path: null,
    //     data: { heads: [Object], records: [Array] }
    //   },
    //   {
    //     name: 'SE.RST01.00.HNZ.D.2020-09-17T013552.000000.csv',
    //     path: null,
    //     data: { heads: [Object], records: [Array] }
    //   }
    // ]

}
test()
    .catch((err) => {
        console.log('catch', err)
    })
Parameters:
Name Type Attributes Default Description
fp String

輸入檔案路徑字串

opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
ver String <optional>
'4.8'

輸入調用windows程序之Net Framework版本字串,可有'4.5'、'4.6'、'4.7.2'與'4.8',預設'4.8'

fdOutPre String <optional>
'_'

輸入暫存輸出夾之夾名前綴字串,預設'_';為相對名稱時夾建於os.tmpdir()下,給絕對路徑則於該處建立

readWithData Boolean <optional>
true

輸入是否讀取輸出檔數據布林值,預設true;為false時保留輸出夾,回傳之各項path為輸出檔位置,由呼叫端自行刪除

Returns:

回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息字串(輸出夾已建立後之錯誤,訊息末行附保留之輸出夾絕對路徑)

Type
Promise

ensureBins(optopt) → {Promise}

Description:
  • 取得本套件之外部執行檔組mseed2ascii(mseed2ascii.exe與其相鄰之cygwin1.dll、cygz.dll): 首次使用時下載(或自鏡像取得)並以bin/manifest.json之SHA-256與大小逐檔校驗, 整組原子放入快取, 之後自快取取得(亦校驗)

    規格: 外部執行檔之存放下載校驗與離線(制式規格)§6、M6; 實作為wsemi之fsEnsureBins, 本套件不另寫下載、快取、鏡像、校驗 環境變數: W_BIN_CACHE(共用快取資料夾)、W_BIN_MIRROR(鏡像, 本地資料夾或http(s)網址)、W_BIN_OFFLINE(1為離線), 見README〈External executable〉

Source:
Example
import WDataMseed from 'w-data-mseed'

//部署前預先取得, 回傳之組資料夾內有mseed2ascii.exe、cygwin1.dll與cygz.dll
let bins = await WDataMseed.ensureBins()
console.log(bins.mseed2ascii)
console.log(bins.bundles.mseed2ascii.files['mseed2ascii.exe'])
Parameters:
Name Type Attributes Default Description
opt Object <optional>
{}

輸入設定物件, 交wsemi之fsEnsureBins(names、cacheDir、mirror、offline、onProgress等), pkgRoot固定為本套件根

Returns:

回傳Promise, resolve回傳{ mseed2ascii: 組資料夾絕對路徑 }, 並帶不可列舉之bundles: { mseed2ascii: { dir, id, files: { 'mseed2ascii.exe': 絕對路徑, 'cygwin1.dll': 絕對路徑, 'cygz.dll': 絕對路徑 } } }, reject回傳帶code之Error(E_OFFLINE_MISSING等)

Type
Promise