Skip to content

Commit ee445aa

Browse files
author
ky
committed
optimise plotter
1 parent 2150706 commit ee445aa

11 files changed

Lines changed: 735 additions & 556 deletions

LC_modules/LevelCompilerAge.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,33 +207,36 @@ class LevelCompilerAge {
207207
for(let i=0; i<model.ages.length; i++){
208208
const ageData = model.ages[i];
209209
num_total_ages ++;
210-
if (isNaN(ageData.event_free_depth) || ageData.event_free_depth == null || ageData.event_free_depth == undefined) {
210+
211+
if (!Number.isFinite(ageData.event_free_depth)) {
211212
num_error_efds += 1;
212213
//console.log(ageData);
213214
}
214-
if (isNaN(ageData.age_mid) || ageData.age_mid == null || ageData.age_mid == undefined) {
215+
216+
if (!Number.isFinite(ageData.age_mid)) {
215217
num_error_ages += 1;
216-
}else{
217-
//check Contradiction
218-
if(i<model.ages.length-1 && model.ages[i+1].age_mid!==null && isNaN(model.ages[i+1].age_mid)==false && model.ages[i+1].age_mid!==undefined){
219-
if(ageData.age_mid > model.ages[i+1].age_mid){
220-
num_contradiction += 1;
221-
model.ages[i+1].reliable = false;
222-
this.unreliable_ids.push(model.ages[i+1].id);
223-
224-
if(this.use_unreliable_data===true){
225-
model.ages[i+1].enable = true;
226-
}else{
227-
model.ages[i+1].enable = false;
228-
}
229-
//console.log("LCAge: Contradiction is detected between: ",model.ages[i+1].enable,"==", model.ages[i+1].reliable);
230-
console.log("LCAge: Contradiction is detected between: ",ageData.name,"==", model.ages[i+1].name);
231-
}else{
218+
}
219+
220+
//check Contradiction
221+
if(i<model.ages.length-1 && Number.isFinite(ageData.event_free_depth) && Number.isFinite(ageData.age_mid) && Number.isFinite(model.ages[i+1].age_mid)){
222+
if(ageData.age_mid > model.ages[i+1].age_mid){
223+
num_contradiction += 1;
224+
model.ages[i+1].reliable = false;
225+
this.unreliable_ids.push(model.ages[i+1].id);
226+
227+
if(this.use_unreliable_data===true){
232228
model.ages[i+1].enable = true;
233-
model.ages[i+1].reliable = true;
229+
}else{
230+
model.ages[i+1].enable = false;
234231
}
232+
//console.log("LCAge: Contradiction is detected between: ",model.ages[i+1].enable,"==", model.ages[i+1].reliable);
233+
console.log("LCAge: Contradiction is detected between: ",ageData.name,"(",ageData.age_mid,")==", model.ages[i+1].name,"(",model.ages[i+1].age_mid,")");
234+
}else{
235+
model.ages[i+1].enable = true;
236+
model.ages[i+1].reliable = true;
235237
}
236238
}
239+
237240
if (isNaN(ageData.age_upper_1std) || ageData.age_upper_1std == null || ageData.age_upper_1std == undefined) {
238241
num_error_ages_u += 1;
239242
}

LC_modules/LevelCompilerCore.js

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ class LevelCompilerCore extends EventEmitter{
492492
const model_r = projectData._model_data[marker_r];
493493
if (model_r[1] !== "") {
494494
const duo_connected_hole = lcfnc.zeroPadding(model_r[1]);
495-
const duo_connected_sec = lcfnc.zeroPadding(model_r[2]);
496-
const duo_connected_dist = Math.round(parseFloat(model_r[3]) * 10) / 10;
495+
const duo_connected_sec = lcfnc.zeroPadding(model_r[2]);
496+
const duo_connected_dist = lcfnc.round(parseFloat(model_r[3]), 1);
497497
this.projects[projectIdx[0]]._duo_connection[correlated_marker_id.toString()] = [
498498
duo_connected_hole,
499499
duo_connected_sec,
@@ -636,6 +636,7 @@ class LevelCompilerCore extends EventEmitter{
636636
//if old id, update to new id
637637
this.replaceNewId();
638638

639+
this.updateSearchIdx();
639640
}
640641
loadEventListFromCsv(filepath){
641642
if(this.projects.length==0) return false;
@@ -1428,21 +1429,27 @@ class LevelCompilerCore extends EventEmitter{
14281429
type:project.model_type,
14291430
evaluation:false,
14301431
is_connected_master: false,
1432+
distance_confliction_counts:0,
1433+
distance_confliction:[],
1434+
distance_confliction_name:[],
14311435

14321436
cd_error_incompleted_counts:0,
14331437
cd_error_floating_counts:0,
14341438
cd_confliction_counts:0,
14351439
cd_confliction:[],
1440+
cd_confliction_name:[],
14361441

14371442
efd_error_incompleted_counts:0,
14381443
efd_error_floating_counts:0,
14391444
efd_confliction_counts:0,
14401445
efd_confliction:[],
1446+
efd_confliction_name:[],
14411447

14421448
rank_error_counts:0,
14431449
age_error_counts:0,
14441450
age_confliction_counts:0,
14451451
age_confliction:[],
1452+
age_confliction_name:[],
14461453

14471454
max_rank:-1,
14481455
hole_counts: 0,
@@ -1467,10 +1474,31 @@ class LevelCompilerCore extends EventEmitter{
14671474
hole.sections.forEach((section) => {
14681475
//counts sections
14691476
result.section_counts += 1;
1470-
section.markers.forEach((marker) => {
1477+
const epsilon = 1e-3;
1478+
let inDuplicateGroup = false;
1479+
section.markers.forEach((marker, index) => {
14711480
//counts markers
14721481
result.marker_counts += 1;
14731482

1483+
if (index > 0) {
1484+
const prevMarker = section.markers[index - 1];
1485+
1486+
if (Math.abs(marker.distance - prevMarker.distance) < epsilon) {
1487+
if (!inDuplicateGroup) {
1488+
result.distance_confliction_counts += 1;
1489+
inDuplicateGroup = true;
1490+
}
1491+
result.distance_confliction_counts += 1;
1492+
result.distance_confliction.push(marker.id);
1493+
result.distance_confliction_name.push(hole.name+"-"+section.name+"-"+marker.distance+"cm");
1494+
1495+
console.log("LCCore: Duplicate distances detected at: "+hole.name+"-"+section.name+"-"+marker.distance+"cm")
1496+
} else {
1497+
inDuplicateGroup = false;
1498+
}
1499+
}
1500+
1501+
14741502
if (marker.composite_depth == null) {
14751503
//counts CD error
14761504
if(marker.depth_source[0]=="floating"){
@@ -1489,6 +1517,7 @@ class LevelCompilerCore extends EventEmitter{
14891517
result.cd_confliction_counts+=1;
14901518
if(marker.composite_depth && connected_cd){
14911519
result.cd_confliction.push(marker.composite_depth - connected_cd);
1520+
result.cd_confliction_name.push(hole.name+"-"+section.name+"-"+marker.distance+"cm");
14921521
}
14931522
}
14941523
}
@@ -1514,6 +1543,7 @@ class LevelCompilerCore extends EventEmitter{
15141543
result.efd_confliction_counts+=1;
15151544
if(marker.event_free_depth && connected_efd){
15161545
result.efd_confliction.push(marker.event_free_depth - connected_efd);
1546+
result.efd_confliction_name.push(hole.name+"-"+section.name+"-"+marker.distance+"cm");
15171547
}
15181548

15191549
}
@@ -1535,6 +1565,7 @@ class LevelCompilerCore extends EventEmitter{
15351565
result.age_confliction_counts+=1;
15361566
if((marker.age && connected_age)){
15371567
result.age_confliction.push(marker.age - connected_age);
1568+
result.age_confliction_name.push(hole.name+"-"+section.name+"-"+marker.distance+"cm");
15381569
}
15391570

15401571
}
@@ -1756,6 +1787,7 @@ class LevelCompilerCore extends EventEmitter{
17561787
tempUpperIdx = [p, h, s, m + 1];
17571788
}
17581789
}
1790+
17591791
if (distance >= sectionData.markers[m].distance && distance <= sectionData.markers[m + 1].distance) {
17601792
tempUpperIdx = [p, h, s, m];
17611793
tempLowerIdx = [p, h, s, m + 1];
@@ -1872,6 +1904,10 @@ class LevelCompilerCore extends EventEmitter{
18721904
//get section data
18731905
let sectionId = this.projects[upperIdxs[0][0]].holes[upperIdxs[0][1]].sections[upperIdxs[0][2]].id;
18741906
const masterIdx = this.search_idx_list[this.base_project_id.toString()];
1907+
if(masterIdx){
1908+
}else{
1909+
console.log(this.base_project_id, masterIdx)
1910+
}
18751911

18761912
//check duo connection
18771913
let isMasterExist = false;
@@ -2440,11 +2476,11 @@ class LevelCompilerCore extends EventEmitter{
24402476
if (event[0]=="erosion"){
24412477
event_border_drilling_depth = this.projects[projectIdx[0]].holes[h].sections[s].markers[m].drilling_depth;
24422478
event_border_distance = event_start_distance;
2443-
event_border_distance_for_check = Math.round(event_border_distance * 10) / 10;
2479+
event_border_distance_for_check = lcfnc.round(event_border_distance, 1);
24442480
} else if (event[0]=="deposition" || event[0]=="markup"){
24452481
event_border_drilling_depth = this.projects[projectIdx[0]].holes[h].sections[s].markers[m].drilling_depth + event[2];
24462482
event_border_distance = event_start_distance + event[2];
2447-
event_border_distance_for_check = Math.round(event_border_distance * 10) / 10;
2483+
event_border_distance_for_check = lcfnc.round(event_border_distance,1);
24482484
}
24492485
const startIdx = this.search_idx_list[this.projects[projectIdx[0]].holes[h].sections[s].markers[m].id.toString()];
24502486
const targetSectionData = this.projects[projectIdx[0]].holes[startIdx[1]].sections[startIdx[2]];
@@ -2458,7 +2494,7 @@ class LevelCompilerCore extends EventEmitter{
24582494
//get current data
24592495
const currentMarkerData = targetSectionData.markers[m2];
24602496
currentIdx = this.search_idx_list[currentMarkerData.id.toString()];
2461-
const current_distance = Math.round(currentMarkerData.distance * 10) / 10;
2497+
const current_distance = lcfnc.round(currentMarkerData.distance, 1);
24622498
if (current_distance > event_border_distance_for_check) {
24632499
//case through(layer exist between current and event border)
24642500
if (m2 == startIdx[3] - 1) {
@@ -2540,7 +2576,7 @@ class LevelCompilerCore extends EventEmitter{
25402576
//get current data
25412577
const currentMarkerData = targetSectionData.markers[m2];
25422578
currentIdx = this.search_idx_list[currentMarkerData.id.toString()];
2543-
const current_distance = Math.round(currentMarkerData.distance * 10) / 10;
2579+
const current_distance = lcfnc.round(currentMarkerData.distance,1);
25442580

25452581
if (current_distance < event_border_distance_for_check) {
25462582
//case through(layer exist between current and event border)
@@ -5498,7 +5534,7 @@ class LevelCompilerCore extends EventEmitter{
54985534
this.setStatus("completed","");
54995535
return output;
55005536
}
5501-
getIdxFromTrinity(projectId, [holeName, sectionName, distance]) {
5537+
getIdxFromTrinity(projectId, [holeName, sectionName, distance],epsilon = 1e-1) {
55025538
this.setStatus("running","getIdxFromTrinity");
55035539
//get idx
55045540
let projectIdx = null;
@@ -5521,7 +5557,7 @@ class LevelCompilerCore extends EventEmitter{
55215557
idx[2] = s;
55225558
for (let m = 0; m < section.markers.length; m++) {
55235559
const marker = section.markers[m];
5524-
if (Math.round(marker.distance * 10) / 10 == Math.round(parseFloat(distance) * 10) / 10) {
5560+
if(Math.abs(marker.distance - parseFloat(distance)) < epsilon){
55255561
idx[3] = m;
55265562
}
55275563
}
@@ -5950,10 +5986,12 @@ class LevelCompilerCore extends EventEmitter{
59505986
targetData.hole_name = holeData.name;
59515987
targetData.section_name = sectionData.name;
59525988
targetData.distance = markerData.distance;
5953-
const cd = this.getDepthFromTrinity(id, [targetData], "composite_depth");
5954-
if(cd[0][1]!==null){
5955-
compositeDepth = "@"+cd[0][1].toFixed(1);
5956-
}
5989+
const cd = resultIds[i][0];
5990+
compositeDepth = "@"+cd.toFixed(1);
5991+
//const cd = this.getDepthFromTrinity(id, [targetData], "composite_depth");
5992+
//if(cd[0][1]!==null){
5993+
// compositeDepth = "@"+cd[0][1].toFixed(1);
5994+
//}
59575995

59585996
//get event list
59595997
//Bore_hole core_number Event_top Event_bottom ID
@@ -6275,7 +6313,7 @@ class LevelCompilerCore extends EventEmitter{
62756313

62766314
//add zero point
62776315
if(r==1){
6278-
masterHole += "("+modelData[1][13].slice(1)+")";
6316+
masterHole += "("+modelData[1][13].slice(1)+")";
62796317
}
62806318

62816319
toRow.push(masterHole);

LC_modules/LevelCompilerPlot.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class LevelCompilerPlot {
1616

1717
this.data_collections = []; //dataRepository > dataCollection > dataset > data
1818
this.data_selected_id = null;
19+
20+
this.draw_collections = []; //temporary dataset for renderer
1921
}
2022

2123
//from new csv

LC_modules/lcfnc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ function randNormal(mean, std, n) {
145145

146146
return output;
147147
}
148-
148+
function round(val, order=4){
149+
const rounded = Math.round(val * 10**order) / 10**order;
150+
return rounded;
151+
}
149152

150153
module.exports = {
151154
readcsv,
@@ -157,4 +160,5 @@ module.exports = {
157160
makeMarkerIdBase,
158161
zeroPadding,
159162
randNormal,
163+
round,
160164
};

0 commit comments

Comments
 (0)