Skip to content

Commit

Permalink
added function convertWellJSONToObjV2 as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGOSSES committed Mar 12, 2020
1 parent 2a3b0ef commit c110fa7
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 51 deletions.
26 changes: 25 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ help:function(){
* @returns {array} returns array of objects that contain key:value pairs of curve name and value at each depth. Depth is also a key:value pair.
*/
convertWellJSONToObj:function (well_log_json,CurveNames,UWI,depth_curve_name){
let depth = well_log_json["CURVES"][depth_curve_name]
let depth = well_log_json["CURVES"][depth_curve_name]
let curve_data = []
for(let eachCr in CurveNames){
curve_data.push(well_log_json["CURVES"][CurveNames[eachCr]])
Expand All @@ -201,6 +201,30 @@ help:function(){
}
return array_of_obj
},
/**
* convertWellJSONToObjV2 is a function that takes in sparse style JSON and other information and returns an array of that information properly packaged,
* array of curves names, and a string for UWI
* and returns the data array of objects that D3.js likes for data used in plotting.
* @param {array} depth An array of strings that can be parsed into floats that represents the depth along the well log curves in a curvebox.
* @param {array} curve_data An array of arrays of strings that can be parsed into floats that represents each of the well log curves in a curvebox.
* @param {string} UWI A string for the well log UWI ID
* @param {array} CurveNames An array of strings that represent curvenames, one for each well log curve in curve_data
* @returns {array} An array of objects properly formatted for next step ___.
*/
convertWellJSONToObjV2: function (depth, curve_data, UWI, CurveNames) {
depth = depth[0];
array_of_obj = []
for (eachPt in depth) {
obj = {}
obj["UWI"] = UWI
for (i in CurveNames) {
obj[CurveNames[i]] = parseFloat(curve_data[CurveNames[i]][eachPt])
obj["DEPTH"] = parseFloat(depth[eachPt])
}
array_of_obj.push(obj)
}
return array_of_obj
},


///////////////////////////////
Expand Down
144 changes: 95 additions & 49 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset='utf-8'>
<title>wellioviz 0.0.10 | Documentation</title>
<title>wellioviz 0.0.15 | Documentation</title>
<meta name='description' content='Provides functionality to visualize well logs, particularly those already converted to JSON, using d3.js visualization library.'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
Expand All @@ -15,7 +15,7 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>wellioviz</h3>
<div class='mb1'><code>0.0.10</code></div>
<div class='mb1'><code>0.0.15</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down Expand Up @@ -134,9 +134,9 @@ <h3 class='mb0 no-anchor'>wellioviz</h3>


<li><a
href='#wellio'
href='#d3'
class="">
wellio
d3

</a>

Expand Down Expand Up @@ -164,29 +164,29 @@ <h3 class='mb0 no-anchor'>wellioviz</h3>


<li><a
href='#getexampletemplate'
href='#getfakeincomingsparsedataexample'
class="">
getExampleTemplate
getFakeIncomingSparseDataExample

</a>

</li>


<li><a
href='#getfakeincomingsparsedataexample'
href='#convertwelljsontoobj'
class="">
getFakeIncomingSparseDataExample
convertWellJSONToObj

</a>

</li>


<li><a
href='#convertwelljsontoobj'
href='#convertwelljsontoobjv2'
class="">
convertWellJSONToObj
convertWellJSONToObjV2

</a>

Expand Down Expand Up @@ -658,17 +658,23 @@ <h2>Code of Conduct</h2>
<h2>How I'm Keeping Things In Sync During Development.</h2>
<p>The way I'm developing is to do changes in Observable notebook first. For this type of work, it has been a faster way to write working code. Because all the code is automatically executed in each cell when code changes, it allows me to catch bugs earlier than I would otherwise. I can have multiple plots of different types built in the same notebook and make sure they all still build as I change code! </p>
<p>The active notebook is noted in the README. </p>
<p><i>I try to sync changes to the index.js file in this code repository after each work session.</i> </p>
<p>Potential code to keep in sync is in several locations: </p>
<h4>How I try develop this repository now...</h4>
<ol>
<li>Make changes to <a href="https://observablehq.com/@justingosses/well-log-in-d3-js-v5-notebook-2">an Observable notebook</a> that has all the code. These changes are usually for one, or maybe two issues, on the <a href="https://github.com/JustinGOSSES/wellioviz/projects/1">kanban board</a>. </li>
<li>Create a branch for these changes on the git repo. </li>
<li>When I'm happy with the changes in the Observable notebook, I copy them to the <a href="https://github.com/JustinGOSSES/wellioviz/blob/master/dist/index.js">index.js file</a> in the git repository.</li>
<li>Merge the forked branch back into master. </li>
<li>Change version in the package.json file. Push that change.</li>
<li>Run npm publish. </li>
<li>Clear issues that are fixed due to the version bump.</li>
</ol>
<p>These means the code in certain <a href="https://observablehq.com/@justingosses/well-log-in-d3-js-v5-notebook-2"> Observable notebooks</a> where I'm actively working with the code might be ahead of the master branch in private mode, but I try to only publish (share the changes to the notebook publically) once I have pushed to the github repository.</p>
<ul>
<li>An Observable notebook</li>
<li>This code repository, particularly in the index.js file in the dist directory. </li>
<li>Documentation as found in the docs folder in this code repository.</li>
<li>The demo page found in the docs folder in this code repository.</li>
<li>The code in master branch will always be in sync with code on NPM.</li>
<li>Index.js &#x26; Observable notebook are almost always kept in sync. When they aren't, I'll let people know and put it in the README.</li>
<li>The docs are updated gradually. Sometimes there will be new or changing functions that aren't populated yet.</li>
<li>The html demo page is not kept in sync and will only be updated occasionally. The Observable notebooks are better places to look for up-to-date demos. In particular, <a href="https://observablehq.com/@justingosses/first-wellio-example-with-all-wellioviz-functions-from-npm">this</a> notebook, which pulls all its wellioviz code from NPM. You can change which version of wellioviz code is pulled from NPM by changing the cell towards the top that pulls in wellioviz for use.</li>
</ul>
<h4>Index.js &#x26; Observable notebook are almost always kept in sync. When they aren't, I'll let people know and put it in the README.</h4>
<h4>The demo page is not kept in sync and will only be updated occasionally.</h4>
<h4>The docs are updated gradually. Sometimes there will be new or changing functions that aren't populated yet.</h4>
<h2>Ways to Contribute!</h2>
<h3>Documentation</h3>
<p>Anything confusing or absent in documentation as well. Inline documentation, documentation built with documentation.js, tests, example incoming data jsons, and code changes are all welcome. Briefly check issues to see if your issue already exists.</p>
Expand Down Expand Up @@ -1056,8 +1062,8 @@ <h4>Transformation functions for data that comes in as sparse style JSON</h4>

<div class='clearfix'>

<h3 class='fl m0' id='wellio'>
wellio
<h3 class='fl m0' id='d3'>
d3
</h3>


Expand All @@ -1075,7 +1081,7 @@ <h3 class='fl m0' id='wellio'>
<p>Central to this idea is that how to plot and what to plot be put into a JSON template that has sensible defaults,
such that the end-user only has to understand what they want to change about the plotting, not the whole d3.js code.</p>

<div class='pre p1 fill-light mt0'>wellio</div>
<div class='pre p1 fill-light mt0'>d3</div>



Expand Down Expand Up @@ -1229,17 +1235,19 @@ <h3 class='fl m0' id='define_wellioviz'>

<div class='clearfix'>

<h3 class='fl m0' id='getexampletemplate'>
getExampleTemplate
<h3 class='fl m0' id='getfakeincomingsparsedataexample'>
getFakeIncomingSparseDataExample
</h3>


</div>


<p>getExampleTemplate is a function that provides an example template for what to supply to the curveBox function further down.</p>
<p>getFakeIncomingSparseDataExample is a function that takes nothing and returns a JSON of fake sparse incoming data.
This is much less than the JSON wellio gives when it converts a LAS file into a JSON. This is one of the type examples of data input. It is an alternative to wellio.js style JSON.
It is used next by funtion _<strong><em> and </em></strong>.</p>

<div class='pre p1 fill-light mt0'>getExampleTemplate(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>
<div class='pre p1 fill-light mt0'>getFakeIncomingSparseDataExample(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>



Expand All @@ -1258,11 +1266,7 @@ <h3 class='fl m0' id='getexampletemplate'>

<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></code>:
returns an array that contains a single object that is the template for what will be given to the curveBox function for creating the SVG.
EXAMPLE: =
[
!!!!!!!!! THIS IS OUT OF DATE SO DELETING UNTIL IT STABLIZES !!!!!!!
]
returns an array that contains an object. probably just a single object? Many of the things like max and min depth that are auto-calculated when the input is a wellio JSON and instead explicitly defined here. This saves data transmission from a backend as well as front-end calculation time.



Expand All @@ -1289,18 +1293,19 @@ <h3 class='fl m0' id='getexampletemplate'>

<div class='clearfix'>

<h3 class='fl m0' id='getfakeincomingsparsedataexample'>
getFakeIncomingSparseDataExample
<h3 class='fl m0' id='convertwelljsontoobj'>
convertWellJSONToObj
</h3>


</div>


<p>getFakeIncomingSparseDataExample is a function that takes nothing and returns a JSON of fake sparse incoming data. This is much less than the JSON wellio gives when it converts a LAS file into a JSON. This is one of the type examples of data input.
It is used next by funtion _<strong><em> and </em></strong>.</p>
<p>convertWellJSONToObj is a function that takes in wellio style JSON of all LAS file well log information,
array of curves names, and a string for UWI
and returns the data array of objects that D3.js likes for data used in plotting.</p>

<div class='pre p1 fill-light mt0'>getFakeIncomingSparseDataExample(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>
<div class='pre p1 fill-light mt0'>convertWellJSONToObj(well_log_json: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>, CurveNames: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>, UWI: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, depth_curve_name: any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>



Expand All @@ -1312,14 +1317,54 @@ <h3 class='fl m0' id='getfakeincomingsparsedataexample'>



<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>well_log_json</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
a full wellio style JSON

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>CurveNames</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>)</code>
array of curve names as strings

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>UWI</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
a string the represents the well name

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>depth_curve_name</span> <code class='quiet'>(any)</code>

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></code>:
returns an array that contains an object. probably just a single object? Many of the things like max and min depth that are auto-calculated when the input is a wellio JSON and instead explicitly defined here. This saves data transmission from a backend as well as front-end calculation time.
returns array of objects that contain key:value pairs of curve name and value at each depth. Depth is also a key:value pair.



Expand All @@ -1346,19 +1391,19 @@ <h3 class='fl m0' id='getfakeincomingsparsedataexample'>

<div class='clearfix'>

<h3 class='fl m0' id='convertwelljsontoobj'>
convertWellJSONToObj
<h3 class='fl m0' id='convertwelljsontoobjv2'>
convertWellJSONToObjV2
</h3>


</div>


<p>convertWellJSONToObj is a function that takes in wellio style JSON of all LAS file well log information,
<p>convertWellJSONToObjV2 is a function that takes in sparse style JSON and other information and returns an array of that information properly packaged,
array of curves names, and a string for UWI
and returns the data array of objects that D3.js likes for data used in plotting.</p>

<div class='pre p1 fill-light mt0'>convertWellJSONToObj(well_log_json: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>, CurveNames: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>, UWI: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, depth_curve_name: any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>
<div class='pre p1 fill-light mt0'>convertWellJSONToObjV2(depth: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>, curve_data: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>, UWI: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, CurveNames: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></div>



Expand All @@ -1375,17 +1420,17 @@ <h3 class='fl m0' id='convertwelljsontoobj'>

<div class='space-bottom0'>
<div>
<span class='code bold'>well_log_json</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
a full wellio style JSON
<span class='code bold'>depth</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>)</code>
An array of strings that can be parsed into floats that represents the depth along the well log curves in a curvebox.

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>CurveNames</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>)</code>
array of curve names as strings
<span class='code bold'>curve_data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>)</code>
An array of arrays of strings that can be parsed into floats that represents each of the well log curves in a curvebox.

</div>

Expand All @@ -1394,16 +1439,17 @@ <h3 class='fl m0' id='convertwelljsontoobj'>
<div class='space-bottom0'>
<div>
<span class='code bold'>UWI</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
a string the represents the well name
A string for the well log UWI ID

</div>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>depth_curve_name</span> <code class='quiet'>(any)</code>

<span class='code bold'>CurveNames</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a>)</code>
An array of strings that represent curvenames, one for each well log curve in curve_data

</div>

</div>
Expand All @@ -1417,7 +1463,7 @@ <h3 class='fl m0' id='convertwelljsontoobj'>

<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">array</a></code>:
returns array of objects that contain key:value pairs of curve name and value at each depth. Depth is also a key:value pair.
An array of objects properly formatted for next step ___.



Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wellioviz",
"version": "0.0.15",
"version": "0.0.16",
"description": "Provides functionality to visualize well logs, particularly those already converted to JSON, using d3.js visualization library.",
"main": "dist/index.js",
"unpkg": "dist/index.js",
Expand Down

0 comments on commit c110fa7

Please sign in to comment.