Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
icdp-osg
mdis-datagen
Commits
17ee1472
Commit
17ee1472
authored
Aug 03, 2020
by
Knut Behrends
Browse files
finish work on fake-lithology inserter, but semantically not really correct
parent
bbd650c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/classes/fake-lithology.js
View file @
17ee1472
...
...
@@ -9,9 +9,10 @@ const Util = require("./fake-util")
const
util
=
new
Util
()
module
.
exports
=
class
LithologyGeology
{
constructor
(
props
,
section_split
)
{
constructor
(
props
,
section_split
,
previous_split
)
{
this
.
_props
=
props
this
.
_section
=
section_split
this
.
_previous
=
previous_split
for
(
let
k
of
[
"
id
"
,
"
archive_files
"
,
...
...
@@ -36,7 +37,9 @@ module.exports = class LithologyGeology {
this
.
_props
.
bottom_depth
=
b
return
b
}
find_litho_unit
()
{
return
faker
.
fake
(
"
{{random.number}}
"
)
%
4
}
find_top_depth
()
{
const
t
=
util
.
round
(
this
.
_section
.
top_depth
+
util
.
frac_below
(
0.3
)
*
this
.
_props
.
offset_m
,
//cm
...
...
@@ -73,6 +76,16 @@ module.exports = class LithologyGeology {
//return this._props.sample_type
}
find_composition
()
{
let
cond
=
util
.
shuffle
(
CoreDefaults
.
sample_state
)
.
map
((
c
)
=>
c
.
toLowerCase
())
.
slice
(
-
2
)
.
join
(
"
,
"
)
return
`
${
cond
}
`
}
find_description
()
{
let
cond
=
util
.
shuffle
(
CoreDefaults
.
sample_state
)
...
...
@@ -80,16 +93,38 @@ module.exports = class LithologyGeology {
.
slice
(
-
2
)
.
join
(
"
,
"
)
return
`
core id:
${
this
.
_section
.
core_id
}
${
this
.
_props
.
remarks
}
`
return
`
${
cond
}
${
this
.
_section
.
core_id
}
${
this
.
_props
.
remarks
}
`
}
find_color
()
{
return
util
.
round
(
faker
.
fake
(
"
{{random.color}}
"
))
}
find_mcd_top
()
{
return
Number
(
this
.
_props
.
top_depth
)
}
find_mcd_bottom
()
{
return
Number
(
this
.
_props
.
top_depth
)
}
find_mcd_top_depth_unit
()
{
return
0
}
find_mcd_bottom_unit
()
{
return
0
}
find_section_length
()
{
return
1
}
find_methods_core
()
{
return
util
.
shuffle
(
CoreDefaults
.
methods_core
).
pop
()
}
fake
()
{
Object
.
keys
(
this
.
_props
).
forEach
((
property
)
=>
{
this
.
_props
[
property
]
=
this
[
property
]
})
delete
this
.
_props
[
"
interval_cm
"
]
return
this
.
_props
}
...
...
src/geology-inserter.js
View file @
17ee1472
...
...
@@ -211,52 +211,76 @@ Promise.all(queries_map.values())
//assign 0-3 lithological descriptions to that split
// if 0, take last lithounit from previous split
//for 1-3 lithological units,
for
(
let
[
kc
,
core
]
of
Object
.
entries
(
splits_grouped
.
by_cores
))
{
for
(
let
[
ki
,
items
]
of
Object
.
entries
(
core
))
{
for
(
let
split
of
item
)
{
let
num_lithounits_per_split
=
util
.
shuffle
([
0
,
1
,
2
,
3
]).
pop
()
n
=
Math
.
floor
(
Math
.
random
()
*
core
.
rock_types
.
length
)
let
lsp
=
core
.
rock_types
.
slice
(
n
,
n
+
num_lithounits_per_split
)
for
(
let
s
=
0
;
s
<
num_lithounits_per_split
;
s
++
)
{
// let curation_sample_columns = {}
// axutil.get_columns(ax, "curation_sample_2")
// .then((curation_sample) => {
// let fake_sample_data = []
// let i = 0
// }
// }
// console.log(`Created ${i} fake lithology, will try to upload`)
// // console.log(fake_sample_data[0])
// return new Promise((resolve, reject) => {
// resolve(fake_sample_data), reject(fake_sample_data)
// })
// })
// .then((fake_sample_data) => {
// return fake_sample_data.flat().map((fake_sample, i) => {
// axutil.upload(
// ax,
// lithology_post_url,
// fake_sample,
// i
// )
// })
let
fake_lithologies
=
[]
axutil
.
get_columns
(
ax
,
"
geology_lithology
"
)
.
then
((
geology_lithology_columns
)
=>
{
let
i
=
0
// for all cores, build an array of fake lithologic descriptions
for
(
let
[
kc
,
by_cores
]
of
Object
.
entries
(
splits_grouped
))
{
for
(
let
[
ki
,
items
]
of
Object
.
entries
(
by_cores
.
items
))
{
for
(
let
sp
of
items
)
{
let
n_lithounits_per_split
=
util
.
shuffle
([
1
,
2
,
3
]).
pop
()
// n: we take a sample of 0-3 consecutive samples from shuffeled lithounits
let
n
=
Math
.
floor
(
Math
.
random
()
*
by_cores
.
rock_types
[
0
].
length
)
-
n_lithounits_per_split
let
lithounits_per_split
=
by_cores
.
rock_types
[
0
].
slice
(
n
,
n
+
n_lithounits_per_split
)
let
fake_lithology_data
=
[]
for
(
let
s
=
0
;
s
<
n_lithounits_per_split
;
s
++
)
{
let
sec_len
=
sp
.
section_length
?
sp
.
section_length
:
util
.
round
(
util
.
frac_above
(
0.5
),
2
)
let
fake_lithology
=
new
LithologyGeology
(
Object
.
assign
({},
geology_lithology_columns
,
{
section_split_id
:
sp
.
id
,
top_depth
:
sp
.
top_depth
,
bottom_depth
:
sp
.
bottom_depth
,
color
:
lithounits_per_split
[
s
]?.
color
||
"
red
"
,
litho_unit
:
s
,
rock_class
:
lithounits_per_split
[
s
]?.
class
||
"
artificial
"
,
rock_type
:
lithounits_per_split
[
s
]?.
type
||
"
rudimentary
"
,
section_length
:
sec_len
,
interval_cm
:
util
.
round
(
util
.
frac_below
(
0.1
)
*
sec_len
*
100
+
1
,
0
),
description
:
`Spl
${
sp
.
id
.
toString
()
.
padStart
(
4
,
"
0
"
)}
, U
${
s
.
toString
()
.
padStart
(
4
,
"
0
"
)}
, SecId:
${
sp
.
section_id
}
, secLen
${
util
.
round
(
sp
.
section_length
,
1
)}
m`
,
}),
sp
,
// current
sp
// previous
).
fake
()
fake_lithology_data
.
push
(
Object
.
assign
({},
fake_lithology
))
i
++
}
fake_lithologies
.
push
(
fake_lithology_data
)
}
}
}
}
}
console
.
log
(
`Created
${
i
}
fake lithologies, will try to upload`
)
// console.log(fake_lithology_data[0])
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
(
fake_lithologies
),
reject
(
fake_lithologies
)
})
})
.
then
((
fake_lithology_data
)
=>
{
return
fake_lithology_data
.
flat
().
map
((
fake_lithology
,
i
)
=>
{
axutil
.
upload
(
ax
,
lithology_post_url
,
fake_lithology
,
i
)
})
})
})
// .then((fake_request_promises) =>
// Promise.all(fake_request_promises).then((s) =>
// console.log(`
// #############################################################
// Expedition ${options.expedition}: Tried to upload ${fake_request_promises.length} lithounits
// ############################################################# `)
// )
// )
})
// })
.
catch
((
error
)
=>
console
.
dir
(
error
,
{
depth
:
0
}))
function
str_sort_by_core_type
(
a
,
b
)
{
...
...
src/sample-inserter.js
View file @
17ee1472
...
...
@@ -208,7 +208,6 @@ Promise.all(queries_map.values())
}
})
.
then
(()
=>
{
let
curation_sample_columns
=
{}
axutil
.
get_columns
(
ax
,
"
curation_sample_2
"
)
.
then
((
curation_sample
)
=>
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment