Skip to content

Commit 1edea02

Browse files
committed
Parse ~Log_Parameter section
1 parent 6c62290 commit 1edea02

6 files changed

Lines changed: 326 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ basic LAS (Log Ascii Standard) well-log parser in c++
1616

1717
`parseLas` partially reads a las formatted file.
1818

19-
The parser currently parses and displays the Version and Well-Information
20-
sections. Additional sections to be added in future iterations.
19+
The parser currently parses and displays the following sections:
20+
- Version
21+
- Well-Information
22+
- Log-Parameter
23+
24+
Additional sections to be added in future iterations.
2125

2226

2327
OPTIONS
@@ -39,13 +43,14 @@ make
3943
BUGS
4044
----
4145

46+
- Seg fault if '-f' used.
4247
- Functionality is very basic.
4348

4449

4550
AUTHOR
4651
------
4752

48-
D'Cage
53+
dCage
4954

5055
COPYRIGHT
5156
------

src/example.las

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,88 @@
2828
# LATI . 45.37? 12' 58" : X LOCATION
2929
# LONG . 13.22? 30' 09" : Y LOCATION
3030
UTM . : UTM LOCATION
31+
32+
~Log_Parameter
33+
#MNEM.UNIT VALUE DESCRIPTION
34+
#-------------- ---------------- ---------------------------
35+
RUNS. 2 : # of Runs for this well.
36+
RUN[1]. 1 : Run 1
37+
RUN[2]. 2 : Run 2
38+
39+
#Parameters that are zoned.
40+
NMAT_Depth[1].M 500,1500 : Neutron Matrix Depth interval {F}
41+
NMAT_Depth[2].M 1500,2500 : Neutron Matrix Depth interval {F}
42+
DMAT_Depth[1].M 500,1510 : Density Matrix Depth interval {F}
43+
DMAT_Depth[2].M 1510,2510 : Density Matrix Depth interval {F}
44+
45+
#Service Company specific Parameters
46+
MATR . SAND : Neutron Porosity Matrix | NMAT_Depth[1]
47+
MATR . LIME : Neutron Porosity Matrix | NMAT_Depth[2]
48+
MDEN .KG/M3 2650 : Matrix Bulk Density | DMAT_Depth[1]
49+
MDEN .KG/M3 2710 : Matrix Bulk Density | DMAT_Depth[2]
50+
51+
#Required Parameters
52+
#Run 1 Parameters
53+
RUN_DEPTH.M 0, 1500 : Run 1 Depth Interval {F} | Run[1]
54+
RUN_DATE. 22/09/1998 : Run 1 date {DD/MM/YYYY} | Run[1]
55+
DREF . : Depth Reference (KB,DF,CB) | RUN[1]
56+
EREF .M : Elevation of Depth Reference | RUN[1]
57+
TDL .M : Total Depth Logger | RUN[1]
58+
TDD .M : Total Depth Driller | RUN[1]
59+
CSGL .M : Casing Bottom Logger | RUN[1]
60+
CSGD .M : Casing Bottom Driller | RUN[1]
61+
CSGS .MM : Casing Size | RUN[1]
62+
CSGW .KG/M : Casing Weight | RUN[1]
63+
BS .MM : Bit Size | RUN[1]
64+
MUD . : Mud type | RUN[1]
65+
MUDS . : Mud Source | RUN[1]
66+
MUDD .KG/M3 : Mud Density | RUN[1]
67+
MUDV .S : Mud Viscosity (Funnel) | RUN[1]
68+
FL .CC : Fluid Loss | RUN[1]
69+
PH . : PH | RUN[1]
70+
RM .OHMM : Resistivity of Mud | RUN[1]
71+
RMT .DEGC : Temperature of Mud | RUN[1]
72+
RMF .OHMM : Rest. of Mud Filtrate | RUN[1]
73+
RMFT .DEGC : Temp. of Mud Filtrate | RUN[1]
74+
RMC .OHMM : Rest. of Mud Cake | RUN[1]
75+
RMCT .DEGC : Temp. of Mud Cake | RUN[1]
76+
TMAX .DEGC : Max. Recorded Temp. | RUN[1]
77+
TIMC . : Date/Time Circulation Stopped | RUN[1]
78+
TIML . : Date/Time Logger Tagged Bottom | RUN[1]
79+
UNIT . : Logging Unit Number | RUN[1]
80+
BASE . : Home Base of Logging Unit | RUN[1]
81+
ENG . : Recording Engineer | RUN[1]
82+
WIT . : Witnessed By | RUN[1]
83+
84+
#Run 2 Parameters
85+
RUN_DEPTH.M 1500,2513 : Run 2 Depth Interval {F} | Run[2]
86+
RUN_DATE. 23/10/1998 : Run 2 date {DD/MM/YYYY} | Run[2]
87+
DREF . : Depth Reference (KB,DF,CB) | RUN[2]
88+
EREF .M : Elevation of Depth Reference | RUN[2]
89+
TDL .M : Total Depth Logger | RUN[2]
90+
TDD .M : Total Depth Driller | RUN[2]
91+
CSGL .M : Casing Bottom Logger | RUN[2]
92+
CSGD .M : Casing Bottom Driller | RUN[2]
93+
CSGS .MM : Casing Size | RUN[2]
94+
CSGW .KG/M : Casing Weight | RUN[2]
95+
BS .MM : Bit Size | RUN[2]
96+
MUD . : Mud type | RUN[2]
97+
MUDS . : Mud Source | RUN[2]
98+
MUDD .KG/M3 : Mud Density | RUN[2]
99+
MUDV .S : Mud Viscosity (Funnel) | RUN[2]
100+
FL .CC : Fluid Loss | RUN[2]
101+
PH . : PH | RUN[2]
102+
RM .OHMM : Resistivity of Mud | RUN[2]
103+
RMT .DEGC : Temperature of Mud | RUN[2]
104+
RMF .OHMM : Rest. of Mud Filtrate | RUN[2]
105+
RMFT .DEGC : Temp. of Mud Filtrate | RUN[2]
106+
RMC .OHMM : Rest. of Mud Cake | RUN[2]
107+
RMCT .DEGC : Temp. of Mud Cake | RUN[2]
108+
TMAX .DEGC : Max. Recorded Temp. | RUN[2]
109+
TIMC . : Date/Time Circulation Stopped | RUN[2]
110+
TIML . : Date/Time Logger Tagged Bottom | RUN[2]
111+
UNIT . : Logging Unit Number | RUN[2]
112+
BASE . : Home Base of Logging Unit | RUN[2]
113+
ENG . : Recording Engineer | RUN[2]
114+
WIT . : Witnessed By | RUN[2]
115+

src/las.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
#include "las_version.h"
3636
#include "las_utils.h"
3737
#include "las_well.h"
38+
#include "las_log_param.h"
3839

3940
#endif /* LAS_H */

src/las_log_param.cpp

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
las_log_param.cpp - LasLogParam class methods for ~Log_Parameters
3+
4+
This file is part of the Parsers::Parse-Las-Cpp project
5+
6+
Copyright (C) 2019 cages
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
License-Identifier: Apache-2.0
21+
*/
22+
23+
// ParseLas includes
24+
#include "las.h"
25+
26+
LasLogParam::LasLogParam()
27+
{
28+
}
29+
30+
LasLogParam::~LasLogParam()
31+
{
32+
}
33+
34+
/* -------------------------------------------------------------------
35+
* Line formats:
36+
*
37+
* 1. Section Header
38+
* ~[section-name]
39+
* Example:
40+
* ~Well Information
41+
*
42+
* 2. name/value line
43+
* [name].[optional unit][space][value]:[description]|[optional associations]
44+
* Example:
45+
* STRT.M 1649.0000 : Description | Associations
46+
*
47+
* -------------------------------------------------------------------*/
48+
void LasLogParam::parseLine(std::string line)
49+
{
50+
std::string field_name;
51+
std::string unit;
52+
std::string value;
53+
std::string desc;
54+
std::string assocs;
55+
56+
57+
// Get section title or field name
58+
std::stringstream ss(line);
59+
std::getline(ss, field_name, '.');
60+
trim(field_name);
61+
62+
if (field_name[0] == '~') {
63+
setHeader(field_name);
64+
} else if ( field_name.size() == 0) {
65+
return;
66+
} else {
67+
name_vec.push_back(field_name);
68+
69+
// Get unit is there is one
70+
std::getline(ss, unit, ' ');
71+
unit_vec.push_back(unit);
72+
73+
// Get value if there is one
74+
std::getline(ss, value, ':');
75+
trim(value);
76+
value_vec.push_back(value);
77+
78+
// Get description
79+
std::getline(ss, desc, '|');
80+
trim(desc);
81+
desc_vec.push_back(desc);
82+
83+
// TODO: Add parsing for formats
84+
85+
// Get associations
86+
std::getline(ss, assocs);
87+
trim(assocs);
88+
assocs_vec.push_back(assocs);
89+
90+
}
91+
}
92+
93+
94+
void LasLogParam::setHeader(const std::string line)
95+
{
96+
header = line;
97+
}
98+
99+
100+
std::string LasLogParam::getHeader()
101+
{
102+
return header;
103+
}
104+
105+
106+
void LasLogParam::printInfo()
107+
{
108+
std::cout
109+
<< "# ------------------------------------------------------\n"
110+
<< "# " << getHeader() << "\n"
111+
<< "# ------------------------------------------------------\n";
112+
std::cout
113+
<< std::left
114+
<< std::setw(14) << "Name"
115+
<< " :: "
116+
<< std::setw(7) << "Unit"
117+
<< " :: "
118+
<< std::setw(10) << "Value"
119+
<< " :: "
120+
<< std::setw(35) << "Desc"
121+
<< " :: "
122+
<< "Assocs"
123+
<< "\n"
124+
<< "# -------------------------------------------------"
125+
<< "---------------------------------------------\n"
126+
<< "\n";
127+
128+
size_t record_count = name_vec.size();
129+
for(size_t idx = 0; idx < record_count; idx++) {
130+
std::string rec_name = name_vec[idx];
131+
std::cout
132+
<< std::left
133+
<< std::setw(14) << name_vec[idx]
134+
<< " :: "
135+
<< std::setw(7) << unit_vec[idx]
136+
<< " :: "
137+
<< std::setw(10) << value_vec[idx]
138+
<< " :: "
139+
<< std::setw(35) << desc_vec[idx]
140+
<< " :: "
141+
<< assocs_vec[idx]
142+
<< "\n";
143+
}
144+
}

src/las_log_param.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
las_log_param.h - log_param class definition for parseLas
3+
4+
This file is part of the Parsers::Parse-Las-Cpp project
5+
6+
Copyright (C) 2019 cages
7+
8+
Licensed under the Apache License, Well 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
License-Identifier: Apache-2.0
21+
*/
22+
23+
24+
#ifndef LAS_LOG_PARAM_H
25+
#define LAS_LOG_PARAM_H
26+
27+
#include "las.h"
28+
29+
30+
class LasLogParam
31+
{
32+
public:
33+
LasLogParam();
34+
~LasLogParam();
35+
void parseLine(std::string line);
36+
void printInfo();
37+
void setHeader(const std::string line);
38+
39+
std::string getHeader();
40+
private:
41+
// header fields
42+
std::string header;
43+
std::vector<std::string> name_vec;
44+
std::vector<std::string> unit_vec;
45+
std::vector<std::string> value_vec;
46+
std::vector<std::string> desc_vec;
47+
std::vector<std::string> format_vec;
48+
std::vector<std::string> assocs_vec;
49+
};
50+
51+
#endif /* LAS_LOG_PARAM_H */

src/main.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ int main(int argc, char *argv[])
3131
exit(EXIT_FAILURE);
3232
}
3333

34-
LasVersion LVer;
3534
char *file_to_parse = get_filename_arg();
3635

3736

@@ -46,6 +45,8 @@ int main(int argc, char *argv[])
4645
/* ----------------------------------------------------
4746
* Get Version Section
4847
* ----------------------------------------------------*/
48+
LasVersion LVer;
49+
4950
std::getline(DataSrc, line);
5051
trim(line);
5152
LVer.setHeader(line);
@@ -76,11 +77,46 @@ int main(int argc, char *argv[])
7677
continue;
7778
}
7879

80+
// If we have a section header and the well section header
81+
// is already set (greater than zero) then we are at the next
82+
// section so break out of the well section processing
83+
// ----------------------------------------------------------
84+
if (line[0] == '~') {
85+
if (LWell.getHeader().size() > 0) {
86+
break;
87+
}
88+
}
89+
7990
LWell.parseLine(line);
8091
}
8192

8293
LWell.printInfo();
8394

95+
/* ----------------------------------------------------
96+
* Get Log_Parameter Section
97+
* ----------------------------------------------------*/
98+
LasLogParam LLogParam;
99+
100+
trim(line);
101+
if ( line == "~Parameter" || line == "~Log_Parameter" ) {
102+
LLogParam.parseLine(line);
103+
104+
while (std::getline(DataSrc, line))
105+
{
106+
if (line[0] == '#') {
107+
continue;
108+
}
109+
110+
if (line[0] == '~') {
111+
break;
112+
}
113+
114+
LLogParam.parseLine(line);
115+
}
116+
117+
LLogParam.printInfo();
118+
}
119+
84120
DataSrc.close();
85121

86122
return 0;

0 commit comments

Comments
 (0)