{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Memory Reader","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":true,"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"memory-reader","__idx":0},"children":["Memory Reader"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This tutorial demonstrates how seismic data can be stored in memory and displayed in a SeismicViewWidget. This example uses ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MemoryReader"]}," which allows working in synchronous and asynchronous modes. In the synchronous mode, the reader calls the several callbacks to provide trace samples \"getTraceData\", trace headers \"getTraceHeader\" and data statistics to get results immediately. This mode is appropriate to use if data is stored completely in the memory. In the asynchronous mode the reader calls \"getAsyncData\" and passes a callback function that must be called when data is received. This approach can be used for data located on the server and memory reader can be considered as a query manager. The code below creates a memory reader and fills traces by request using asynchronous mode."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"creating-a-seismic-memoryreader","__idx":1},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#/Seismic/Readers/memoryReader#MemoryReader"},"children":["#"]}," Creating a Seismic MemoryReader"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The code below creates a new empty reader. The image above shows several samples from two first traces."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[]},{"$$mdtype":"Tag","name":"iframe","attributes":{"src":"https://dc2-documentation.s3.amazonaws.com/documentation/slb-docs-test/5.0/examples/vue/tutorials/index.html#/Seismic/Readers/memoryReader?section=MemoryReader&extract=true","width":"100%","height":"338.5px","style":{"border":"none"}},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"display-this-seismic-in-a-widget","__idx":2},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#/Seismic/Readers/memoryReader#Source"},"children":["#"]}," Display this Seismic in a Widget"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The code below creates a pipeline, passes an instance of the reader, and creates a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SeismicViewWidget"]}," to display the data."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"main","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ts","header":{"controls":{"copy":{}}},"source":"import { SeismicViewWidget } from \"@int/geotoolkit/seismic/widgets/SeismicViewWidget.ts\";\nimport { SeismicPipeline } from \"@int/geotoolkit/seismic/pipeline/SeismicPipeline.ts\";\nimport { SeismicColors } from \"@int/geotoolkit/seismic/util/SeismicColors.ts\";\nimport { Group } from \"@int/geotoolkit/scene/Group.ts\";\nimport { AnchorType } from \"@int/geotoolkit/util/AnchorType.ts\";\nimport { Text } from \"@int/geotoolkit/scene/shapes/Text.ts\";\nimport { MemoryReader } from \"@int/geotoolkit/seismic/data/MemoryReader.ts\";\nimport { Plot } from \"@int/geotoolkit/plot/Plot.ts\";\nfunction createScene(memoryReaderCanvas, widgetCanvas) {\n  const sampleRate = 1;\n  const sampleCount = 250;\n  const traceCount = 350;\n  const reader = new MemoryReader({\n    \"numberoftraces\": traceCount,\n    \"numberofsamples\": sampleCount,\n    \"samplerate\": sampleRate\n  }).setTraceProcessor({\n    \"getAsyncData\": (query, callback) => {\n      callback({ \"getTraceData\": (reader2, samples, traceId) => {\n        for (let i = 0; i < reader2.getNumberOfSamples(); i++) {\n          samples[i] = Math.cos(i / 8);\n        }\n      } });\n    },\n    \"getDataStatistics\": () => ({\n      \"average\": 0,\n      \"min\": -1,\n      \"max\": 1,\n      \"rms\": Math.sqrt(2) / 2\n    })\n  });\n  let shapesGroup;\n  reader.select({\n    \"from\": 0,\n    \"to\": 10\n  }, (result) => {\n    const shapes = [];\n    let i;\n    const COLUMN_WIDTH = 140;\n    for (i = 0; i < 2; i++) {\n      shapes.push(\n        new Text({\n          \"text\": \"Trace # \" + i,\n          \"ax\": i * COLUMN_WIDTH + COLUMN_WIDTH / 2,\n          \"ay\": 0,\n          \"alignment\": AnchorType.TopCenter\n        })\n      );\n    }\n    const tmpBuffer = [];\n    for (i = 0; i < 2; i++) {\n      const trace = result.getTrace(i);\n      trace.getSamples(tmpBuffer);\n      for (let j = 0; j < 13; j++) {\n        shapes.push(\n          new Text({\n            \"text\": tmpBuffer[j].toFixed(12),\n            \"ax\": i * COLUMN_WIDTH + COLUMN_WIDTH / 2,\n            \"ay\": j * 15 + 30\n          })\n        );\n      }\n    }\n    for (i = 0; i < 2; i++) {\n      shapes.push(\n        new Text(\n          {\n            \"text\": \"...\",\n            \"ax\": i * COLUMN_WIDTH + COLUMN_WIDTH / 2,\n            \"ay\": 13 * 15 + 30\n          }\n        )\n      );\n    }\n    shapes.push(\n      new Text({\n        \"text\": \"...\",\n        \"ax\": i * COLUMN_WIDTH,\n        \"ay\": 13 / 2 * 15 + 30,\n        \"alignment\": AnchorType.LeftCenter\n      })\n    );\n    shapesGroup = new Group().setAutoModelLimitsMode(true).addChild(shapes);\n  });\n  const plots = [];\n  plots.push(new Plot({\n    \"canvaselement\": memoryReaderCanvas,\n    \"root\": shapesGroup\n  }));\n  let stats = null;\n  reader.readDataSetStatistics((reader2, statistics) => {\n    stats = statistics;\n  });\n  const pipeline = createPipeline(reader, stats);\n  const widget = createWidget(pipeline);\n  plots.push(new Plot({\n    \"canvaselement\": widgetCanvas,\n    \"root\": widget\n  }));\n  return plots;\n}\nfunction createPipeline(reader, stats) {\n  const colorProvider = SeismicColors.getDefault();\n  return new SeismicPipeline({\n    \"name\": \"MemorySeismic\",\n    \"reader\": reader,\n    \"statistics\": stats\n  }).setOptions({\n    \"colors\": {\n      \"colormap\": colorProvider.createNamedColorMap(\"WhiteBlack\", 32)\n    },\n    \"plot\": {\n      \"type\": {\n        \"wiggle\": false,\n        \"interpolateddensity\": true\n      }\n    }\n  });\n}\nfunction createWidget(pipeline) {\n  return new SeismicViewWidget({\n    \"pipeline\": pipeline,\n    \"colorbar\": {\n      \"axis\": {\n        \"tickgenerator\": {\n          \"edge\": {\n            \"tickvisible\": false,\n            \"labelvisible\": false\n          }\n        }\n      }\n    },\n    \"layouttype\": \"inside\",\n    \"scroll\": {\n      \"horizontal\": {\n        \"visible\": true,\n        \"cssclass\": \"horizontal-scroll\",\n        \"type\": \"geotoolkit.controls.tools.scroll.HorizontalScroll\",\n        \"options\": {\n          \"rounded\": true\n        }\n      },\n      \"vertical\": {\n        \"visible\": true,\n        \"cssclass\": \"vertical-scroll\",\n        \"type\": \"geotoolkit.controls.tools.scroll.VerticalScroll\",\n        \"options\": {\n          \"rounded\": true\n        }\n      }\n    }\n  }).setScaleOptions({\n    \"tracescale\": 10,\n    \"samplescale\": 50,\n    \"deviceunit\": \"in\",\n    \"sampleunit\": \"ms\"\n  });\n}\nexport { createScene };\n\ncreateScene(document.querySelector('[ref=\"MemoryReader\"]'), document.querySelector('[ref=\"Widget\"]'));\n\n","lang":"ts"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"css","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"css","header":{"controls":{"copy":{}}},"source":"\n.cg-tooltip-holder {\n  position: relative;\n}\n\n.cg-tooltip {\n  position: absolute;\n  display: block;\n  padding: 2px 12px 3px 7px;\n  overflow: visible !important;\n  font-family: Roboto, Helvetica, Arial, sans-serif;\n  font-size: 13px;\n  background: white !important;\n  opacity: 0.9;\n  color: #333333;\n  border: solid 1px gray;\n  border-radius: 5px;\n  text-align: left;\n  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\n  border-radius: 5px;\n  margin: 0 !important;\n  z-index: 10000;\n  max-width: 400px;\n  text-wrap: normal !important;\n  white-space: normal !important;\n}\n/* Default setting for tooltip */\n.cg-tooltip-container {\n  position: absolute;\n  display: block;\n  overflow: visible !important;\n  font-family: Roboto, Helvetica, Arial, sans-serif;\n  font-size: 12px;\n  padding: 3px 7px;\n  background: #f7f7f7;\n  color: #333333;\n  border: 1px solid #938e8e;\n  opacity: 0.8;\n  text-align: left;\n  box-shadow: 3px 3px 10px #888;\n  margin: 0 !important;\n  z-index: 10000;\n  max-width: 400px;\n  text-wrap: normal !important;\n  white-space: normal !important;\n  user-select: none;\n}\n@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n  .cg-tooltip-container {\n    border-radius: 0;\n  }\n}\n/* Default left arrow for tooltip */\n.cg-tooltip-arrow-left::before {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 0;\n  top: 50%;\n  border: 5px solid transparent;\n  border-left: 0;\n  border-right: 5px solid  #938e8e;\n  transform: translate(calc(-100%), -50%);\n}\n.cg-tooltip-arrow-left::after {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 0;\n  top: 50%;\n  border: 4px solid transparent;\n  border-left: 0;\n  border-right: 4px solid #f7f7f7;\n  transform: translate(calc(-100%), -50%);\n}\n/* Default top arrow for tooltip */\n.cg-tooltip-arrow-top::before {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 50%;\n  top: 0;\n  border: 5px solid transparent;\n  border-top: 0;\n  border-bottom: 5px solid #938e8e;\n  transform: translate(-50%, -100%);\n}\n.cg-tooltip-arrow-top::after {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 50%;\n  top: 0;\n  border: 4px solid transparent;\n  border-top: 0;\n  border-bottom: 4px solid #f7f7f7;\n  transform: translate(-50%, -100%);\n}\n/* Default right arrow for tooltip */\n.cg-tooltip-arrow-right::before {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  right: 0;\n  top: 50%;\n  border: 5px solid transparent;\n  border-right: 0;\n  border-left: 5px solid #938e8e;\n  transform: translate(100%, -50%);\n}\n.cg-tooltip-arrow-right::after {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  right: 0;\n  top: 50%;\n  border: 4px solid transparent;\n  border-right: 0;\n  border-left: 4px solid #f7f7f7;\n  transform: translate(100%, -50%);\n}\n/* Default bottom arrow for tooltip */\n.cg-tooltip-arrow-bottom::before {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 50%;\n  bottom: 0px;\n  border: 5px solid transparent;\n  border-bottom: 0;\n  border-top: 5px solid #938e8e;\n  transform: translate(-50%, 100%);\n  z-index: 10000;\n}\n.cg-tooltip-arrow-bottom::after {\n  content: '';\n  position: absolute;\n  display: block;\n  width: 0px;\n  left: 50%;\n  bottom: 0;\n  border: 4px solid transparent;\n  border-bottom: 0;\n  border-top: 4px solid #f7f7f7;\n  transform: translate(-50%, 100%);\n  z-index: 10000;\n}\n/* Tooltip item name */\n/* Tooltip item value */\n/* .cg-tooltip-item-value */\n/* Tooltip item value */\n.cg-tooltip-item-unit {\n  text-transform: none;\n}\n\n.cg-tooltip-item-name {\n    text-transform: capitalize;\n    white-space: nowrap;\n    vertical-align: middle;\n    font-size: 13px;\n}\n.cg-tooltip-row {\n  display: flex;\n  flex-direction: row;\n  align-items: center;\n  white-space: pre-wrap;\n  font-size: 12px;\n  line-height: 100%;\n  margin: 1px 0;\n}\n.cg-tooltip-title {\n  font-size: 13px;\n  height: 14px;\n  text-transform: capitalize;\n}\n.cg-tooltip-title .cg-tooltip-symbol {\n  margin-right: 0 !important;\n}\n.cg-tooltip-title-name {\n  vertical-align: middle;\n}\n.cg-tooltip-row + .cg-tooltip-row {\n  margin-top: 4px;\n}\n.cg-tooltip-row.cg-tooltip-title + .cg-tooltip-row {\n  margin-top: 5px;\n}\n.cg-tooltip-item-value + .cg-tooltip-item-unit {\n    margin-left: 1px;\n}\n/* Tooltip symbol */\n.cg-tooltip-symbol-cell {\n  display: inline-flex;\n  min-width: 13px; /* 10px size + 3px margin */\n}\n.cg-tooltip-symbol {\n  margin-right: 3px;\n  background-color: transparent;\n  display: block;\n}\n.cg-tooltip-symbol > img {\n  display: block;\n}\n.cg-tooltip-list-cell {\n  display: inline-flex;\n}\n.cg-tooltip-list-symbol {\n  display: block;\n  margin-right: 3px;\n  width: 6px;\n  height: 6px;\n  vertical-align: middle;\n  border-radius: 50%;\n  border: 1px solid rgba(0,0,0,.4);\n}\n.cg-tooltip-symbol-legacy {\n  border-radius: 4px;\n  margin-right: 5px;\n  height: 8px;\n  width: 8px;\n  display: inline-block;\n}\n.cg-tooltip-title-legacy {\n  font-weight: 900;\n}\n\n/* Tooltip symbol circle */\n.cg-tooltip-symbol.circle {\n  height: 10px;\n  width: 10px;\n  display: inline-block;\n  border-radius: 50%;\n  border: 1px solid rgba(0,0,0,.4);\n}\n/* Tooltip symbol line */\n.cg-tooltip-symbol.line {\n    height: 10px;\n    width: 10px;\n    display: inline-block;\n    transform: scale(1.2, 0.2);\n}\n/* Tooltip symbol diamond */\n.cg-tooltip-symbol.diamond {\n    height: 10px;\n    width: 10px;\n    display: inline-block;\n    transform: rotate(45deg);\n    border-radius: 0px;\n}\n/* Tooltip symbol square */\n.cg-tooltip-symbol.square {\n    height: 10px;\n    width: 10px;\n    display: inline-block;\n    border-radius: 0px;\n    border: 1px solid rgba(0,0,0,.4);\n}\n\n","lang":"css"},"children":[]}]}]},{"$$mdtype":"Tag","name":"iframe","attributes":{"src":"https://dc2-documentation.s3.amazonaws.com/documentation/slb-docs-test/5.0/examples/vue/tutorials/index.html#/Seismic/Readers/memoryReader?section=Source&extract=true","width":"100%","height":"488.5px","style":{"border":"none"}},"children":[]}]},"headings":[{"value":"Memory Reader","id":"memory-reader","depth":1},{"value":"Creating a Seismic MemoryReader","id":"creating-a-seismic-memoryreader","depth":3},{"value":"Display this Seismic in a Widget","id":"display-this-seismic-in-a-widget","depth":3}],"frontmatter":{"title":"Memory Reader","seo":{"title":"Memory Reader"}},"lastModified":"2026-02-11T19:54:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/geotoolkit/tutorials/seismic/readers/memory-reader","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}