Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Godoy, William
jexio
Commits
1b13014e
Commit
1b13014e
authored
Jun 25, 2020
by
William F Godoy
Browse files
Linear model from test
parent
cc6f2128
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/extractor/AmrexCastro.jl
View file @
1b13014e
include
(
"../helper/helperSystem.jl"
)
@time
import
DataFrames
import
DataFrames
import
GLM
struct
AmrexCastro
<:
AbstractAmrex
app
::
String
...
...
@@ -23,7 +24,10 @@ struct AmrexCastro <: AbstractAmrex
"castro.max_grid_size"
,
],
Dict
{
String
,
Array
{
String
}}(
"plots_size"
=>
[
"max_step"
,
"amr.plot_int"
,
"amr.n_cell"
,
"amr.max_level"
],
"plots_size"
=>
[
"amr.nplot_files"
,
"amr.ncells"
,
"amr.max_level"
],
"checks_size"
=>
[
"amr.check_int"
,
"amr.ncheck_files"
,
"amr.ncells"
,
"amr.max_level"
,
"amr.regrid_int"
],
),
runlogFile
,
)
...
...
@@ -93,9 +97,10 @@ end
function
_run_linear_model_plots_size
(
extractor
::
AmrexCastro
,
X
::
DataFrames
.
DataFrame
)
XColumns
::
Array
{
String
}
=
extractor
.
outputs
[
"plots_size"
]
outputDirs
=
helper_get_prefix_directories
(
extractor
.
outputPrefix
)
# single column DataFrame Y in the linear model
plotsSizesData
=
DataFrames
.
DataFrame
(
plots_sizes
=
Int64
[])
for
outputDir
in
outputDirs
...
...
@@ -111,19 +116,34 @@ function _run_linear_model_plots_size(extractor::AmrexCastro, X::DataFrames.Data
for
plotFileDir
in
plotFileDirs
sizeDir
::
Int64
=
helper_get_directory_size
(
plotFileDir
)
plotsSize
+=
sizeDir
println
(
plotFileDir
,
" size: "
,
sizeDir
)
end
println
(
"plots_size: "
,
plotsSize
)
# println(plotFileDirs)
# todo add nprocs to the X matrix
# extractor.runlogFile
push!
(
plotsSizesData
,
[
plotsSize
])
end
# Prepare the X independent variables in the linear model
XNames
::
Array
{
String
}
=
extractor
.
outputs
[
"plots_size"
]
for
XName
in
XNames
columnName
=
Symbol
(
XName
)
# this syntax [!, symbol] does not make a copy, use [:, symbol] for copies
plotsSizesData
[
!
,
columnName
]
=
X
[
!
,
columnName
]
end
# formula from https://discourse.julialang.org/t/glm-jl-with-unknown-column-names/20692/5
response
=
Symbol
(
names
(
plotsSizesData
)[
1
])
println
(
response
)
predictors
=
Symbol
.
(
names
(
plotsSizesData
)[
2
:
end
])
println
(
predictors
)
println
(
plotsSizesData
)
f
=
@eval
(
GLM
.
@formula
(
$
response
~
(
+
)(
1
,
$
(
predictors
...
))))
println
(
f
)
ols
=
GLM
.
lm
(
f
,
plotsSizesData
)
println
(
ols
)
#import Plots
#display(Plots.plot(X, Y))
end
src/helper/helperSystem.jl
View file @
1b13014e
...
...
@@ -38,6 +38,7 @@ function helper_get_prefix_files(prefix::String, path::String)::Array{String}
pattern
::
String
=
string
(
prefix
,
"*"
)
files
=
Glob
.
glob
(
pattern
,
path
)
return
files
end
...
...
test/test_AmrexCastro.jl
View file @
1b13014e
...
...
@@ -77,13 +77,3 @@ end
test_AmrexCastro
()
X
=
[
1
,
2
,
3
,
4
,
5
,
6
]
Y
=
[
2
,
4
,
7
,
9
,
11
,
13
]
#@time import GLM
#ols = GLM.lm(GLM.@formula(Y ~ X), data)
# println(ols)
@time
import
Plots
display
(
Plots
.
plot
(
X
,
Y
))
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