JustinGOSSES / wellio.js

JavaScript for converting well-log standard .las file format to json format
https://justingosses.github.io/wellio.js/
MIT License
34 stars 5 forks source link

Add a sketch of lasiojson2wellio function #32

Closed dcslagel closed 4 years ago

dcslagel commented 4 years ago

This is a branch to explore and identify some of the specific details for implementing #7 (wellio <-> lasio (python)) via JSON objects. Feedback/Input appreciated.

Thanks, DC

The first commit is a very basic lasiojson2wellio function just to help reveal what work is needed.

Here are the lasio steps used to create the Lasio Json object.

import json
import lasio
from lasio import las
l = lasio.read("./tests/examples/2.0/sample_2.0.las")
with open('sample_2.0.json', 'w') as fp:
    json.dump(l, fp, cls=las.JSONEncoder)

Here are the steps to import into wellio.js.

$>cd wellio.js
$>node
>w = require('./dist/index.js'); 
>lj = w.lasiojson2wellio('assets/json_files/sample_2.0.json')

Three issues identified are:

1. The lasio json metadata is mostly empty. That can be changed/improved, but for now should Wellio.js assume defaults for Version and Wrapped?

metadata: {
    Version: [ {}, {} ],
    Well: [
      {}, {}, {}, {}, {},
      {}, {}, {}, {}, {},
      {}, {}
    ],
    Curves: [
      {}, {}, {}, {},
      {}, {}, {}, {}
    ],
    Parameter: [
      {}, {}, {}, {},
      {}, {}, {}, {}
    ],
    Other: 'Note: The logging tools became stuck at 625 metres causing the data\n' +
      'between 625 metres and 615 metres to be invalid.'

2. Does Wellio.js want to bring in the 'Other' section?

3. Lasio Json has the curve data in number format. Wellio.js has the curve data in string format. I think the answer here is to transform from numbers to strings. Here are examples:

3.a Lasio json curve data read into the Wellio.js structure:

  CURVES: {
    DEPT: [ 1670, 1669.875, 1669.75 ],
    DT: [ 123.45, 123.45, 123.45 ],
    RHOB: [ 2550, 2550, 2550 ],
    NPHI: [ 0.45, 0.45, 0.45 ],
    SFLU: [ 123.45, 123.45, 123.45 ],
    SFLA: [ 123.45, 123.45, 123.45 ],
    ILM: [ 110.2, 110.2, 110.2 ],
    ILD: [ 105.6, 105.6, 105.6 ]
  }

3.b Native Wellio.js json curve data:

  CURVES: {
    DEPT: [ '1670.000', '1669.875', '1669.750' ],
    DT: [ '123.450', '123.450', '123.450' ],
    RHOB: [ '2550.000', '2550.000', '2550.000' ],
    NPHI: [ '0.450', '0.450', '0.450' ],
    SFLU: [ '123.450', '123.450', '123.450' ],
    SFLA: [ '123.450', '123.450', '123.450' ],
    ILM: [ '110.200', '110.200', '110.200' ],
    ILD: [ '105.600', '105.600', '105.600' ]
  }
kinverarity1 commented 4 years ago

Great work! I would love to improve lasio's JSON format, so very open to changing the current format on my end. Is this of any use? https://jsonwelllogformat.org/

JustinGOSSES commented 4 years ago

This is good work, @dcslagel ! Looks good to me.

In regards to (question 3) curve data in strings vs. numbers, changing how wellio handles things to numbers would be preferred to be in line with others I think... However, I'd have to look at the other code to double check there wouldn't be problems. Will try to give it a look this weekend.

In any case, the code in this pull request that just applies to converting it to LASIO json looks fine.

JustinGOSSES commented 4 years ago

In terms of https://jsonwelllogformat.org/ , thanks for highlighting it again @kinverarity1 ! I had looked at it when it first came out. I think what they call "transitions" on their README were added since that initial release. If my memory is right, I think by not having the "transitions" part of the JSON they were therefore losing some information in the metadata fields of some LAS.

Additionally, they provide libraries to read their format but not to convert LAS files into it. They charge for that. Those were my initial reasons to not look at them too closely.

That being said, it would be nice to have everything work as nicely and smoothly together as possible.

JustinGOSSES commented 4 years ago

In terms of question 2, I think we should include an Other section. If I remember right, I didn't initially as I wasn't sure all the various that might ensue in an Other section. @kinverarity1 Do you find the other section a problem or can you just dump everything into a string value field and that works almost always?

kinverarity1 commented 4 years ago

Yep I think leaving Other as a string is the best way to handle it. It sometimes has important information, so I would lean towards including it.

dcslagel commented 4 years ago

I added reading the 'Other' field in commit 6dfcc57.

Here is a sample output:

> mj = w.lasiojson2wellio('assets/json_files/sample_2.0.json')
{
  'VERSION INFORMATION': {},
  'WELL INFORMATION BLOCK': {},
  'CURVE INFORMATION BLOCK': {},
  'PARAMETER INFORMATION': {},
  CURVES: {
    DEPT: [ 1670, 1669.875, 1669.75 ],
    DT: [ 123.45, 123.45, 123.45 ],
    RHOB: [ 2550, 2550, 2550 ],
    NPHI: [ 0.45, 0.45, 0.45 ],
    SFLU: [ 123.45, 123.45, 123.45 ],
    SFLA: [ 123.45, 123.45, 123.45 ],
    ILM: [ 110.2, 110.2, 110.2 ],
    ILD: [ 105.6, 105.6, 105.6 ]
  },
  OTHER: 'Note: The logging tools became stuck at 625 metres causing the data\n' +
    'between 625 metres and 615 metres to be invalid.'
}
dcslagel commented 4 years ago

Regarding curve data in strings vs. numbers:

If we accept well_json.CURVES as numbers when reading from lasio's json, do we want to change las2json() so reading from a LAS file also imports CURVES data as numbers?

JustinGOSSES commented 4 years ago

Regarding curve data in strings vs. numbers:

If we accept well_json.CURVES as numbers when reading from lasio's json, do we want to change las2json() so reading from a LAS file also imports CURVES data as numbers?

I think so....I just looked around and didn't see anything in wellio code or the demo page that it would break.

dcslagel commented 4 years ago

Regarding curve data in strings vs. numbers: If we accept well_json.CURVES as numbers when reading from lasio's json, do we want to change las2json() so reading from a LAS file also imports CURVES data as numbers?

I think so....I just looked around and didn't see anything in wellio code or the demo page that it would break.

Okay we can make that change on a separate branch. Would the change effect wellioviz?

JustinGOSSES commented 4 years ago

Regarding curve data in strings vs. numbers: If we accept well_json.CURVES as numbers when reading from lasio's json, do we want to change las2json() so reading from a LAS file also imports CURVES data as numbers?

I think so....I just looked around and didn't see anything in wellio code or the demo page that it would break.

Okay we can make that change on a separate branch. Would the change effect wellioviz?

It shouldn't. If it does, should be easy fix.

dcslagel commented 4 years ago
dcslagel commented 4 years ago
dcslagel commented 4 years ago

I've made pull request #33 based on the input and work on this exploratory branch. Closing this pull request.