Giter VIP home page Giter VIP logo

seg2js's Introduction

seg2js

Javascript reader of SEG 2 data

example of plotted SEG 2 data

This works intents to be a library to read SEG 2 data. The idea is to help develop tools in the web that read SEG 2 files. Since the data sets are sometimes pretty big, the scope is for the library to have a high performance. Currently only the file header and traces header are read when loading the file. This will allow in the future to filter what traces the user wants to display, contrary to loading the whole file in memory which could be prohibitive.

Table of Contents

Installation

You should download or checkout this repository. If you just want to use the library, you only need to include the minified version which you can find in the root directory of the project: seg2js.min.js

If you want develop or debug the library, you can edit the source file located in the src directory: seg2js.src.js. You must generate the minified version so the function is properly packaged as a module.

To generate the minified file you can use rollup. You need to have node installed, then just do

npm install
rollup -c

To run the example you can use http-server

npm run serve

Usage

Get the handle of a file and read headers

The first thing is to get a handle of a file. You can look at the example located in examples/example1.html. Then you should read the headers. For that you must first create a headers object

let seg2headers = seg2js.createHeader();

after which you can read the readers using the method readHeader which returns a promise:

seg2js.readHeader(file, seg2headers)
.then(() => 
{
    data = new Array(seg2headers.ntraces);
    promises = new Array(seg2headers.ntraces);
    for (var ii=0; ii<seg2headers.ntraces; ii++)
    {	
        data[ii] = new Array(seg2headers.trace[ii].nsamples);
        promises[ii] =  seg2js.readTraceData(file, seg2headers, ii, data[ii])
    }
    Promise.all(promises).then(() => {
        let data2plot = seg2js.buildArraysToPlot(seg2headers, data);
        plotData(data2plot);
    })
})

yout must enable CORS in your server

API

The library exposes the following methods:

  • createHeader()

    • returns: Header object.
  • readHeader(file, header)

    • input:
      • file: file handle.
      • header

The library exposes the following objects:

  • fileHeader:

    {
    ntraces: 0, offsets: [], versionNumber: 0, st: 0, lt: 0, size_st: 0, fileDescriptor: {}, sizeTracePointer: 0, trace: [] }

where:

  • ntraces: Number of traces in the whole file.
  • offsets: Array with the offset of each trace in bytes from the beggining of the file.
  • versionNumber: The version number of the file.
  • st: String termination character for the file descriptor.
  • lt: Line termination character.
  • fileDescriptor: Object (see below).
  • sizeTracePointer: Size of the trace pointer.
  • trace: Array of traces (see below).

seg2js's People

Contributors

dependabot[bot] avatar jbcolme avatar

Watchers

 avatar  avatar

Forkers

cleancoindev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.