Parsing Without a View
Read byte sources into seismic blocks or typed frame columns without a browser session or renderer.
Turn text into plotted columns
Edit CSV or JSON, then plot its columns. Runs locally on the calling thread; this example accepts up to 64 KiB.
Use the root readers entry for calculations, conversions or views of your own. It needs a byte source, not a browser session or renderer.
Read a Trace Range
import { memorySource, openSeismic, readTraces } from '@bs/outkrop-readers'
export async function firstTraces(bytes: Uint8Array) {
const source = memorySource(bytes)
const file = await openSeismic(source)
return readTraces(source, file, 0, Math.min(8, file.layout.traces))
}
The range is [start, end), zero-based. Options s0 / s1 restrict samples; group averages samples per output column; headers requests header values. Read block dimensions from the result rather than assuming fixed encoding or spacing.
Parse a Browser Blob
import { blobSource, readLas } from '@bs/outkrop-readers'
export async function inspectLas(file: Blob, signal?: AbortSignal) {
const parsed = await readLas(blobSource(file, signal))
return parsed.frames.map((frame) => ({
id: frame.id,
rows: frame.index.values.length,
curves: frame.curves.map((curve) => curve.mnemonic),
}))
}
Use readDelimited or readJson for tables. blobSource reads slices and checks cancellation; direct calls execute on the calling thread. Choose LocalDataSource for worker-backed interactive sessions.
Supply Another Storage Adapter
import type { ByteSource } from '@bs/outkrop-readers'
export function fromRangeReader(
size: number,
read: (offset: number, length: number) => Promise<Uint8Array>,
): ByteSource {
return { size, read }
}
flowchart TD
accTitle: Parse data from different storage environments
accDescr: Memory buffers, browser blobs and application range adapters all provide a ByteSource. A format reader produces seismic blocks or typed frames for the application's own use.
Memory["Uint8Array"] --> Bytes["ByteSource"]
Blob["File or Blob"] --> Bytes
Adapter["Your range adapter"] --> Bytes
Bytes --> Parser["Format reader"]
Parser --> Output["Seismic blocks or typed frames"]
Output --> App["Your calculations or views"]
| Adapter | Contract |
|---|---|
memorySource(bytes) |
Keep its backing bytes unchanged during reads |
| HTTP range reader | Validate range responses; do not mistake a full file for a slice |
| Filesystem reader | Handle short reads; keep handle open until parsing ends |
Any ByteSource |
Return requested bytes; fewer only at end of source |
Your app owns external handles and closing them. Wrap a source with abortable(source, signal) for cooperative cancellation between reads.
Bound Work and Handle Errors
Catch parser failures; preserve warnings on successful reads. readJson(source, maxBytes) sets a whole-document cap. Direct parsers do not inherit browser-session memory budgets. Limit retained arrays and release references when finished. See formats and units.