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
c03dbf3d
Commit
c03dbf3d
authored
Jun 26, 2020
by
William F Godoy
Browse files
Added usage example for AmrexCastro
parent
1b13014e
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/ExampleAmrexCastro.jl
0 → 100644
View file @
c03dbf3d
import
Exio
function
main
()
#### Configuration section ######
## exio_init requires three inputs and returns a handler of type exioH
# only supported: AmrexCastro
app
::
String
=
"AmrexCastro"
# location where several run outputs are located they must have a common prefix
outputPrefix
::
String
=
"/home/wgodoy/workspace/Castro/Exec/hydro_tests/Sedov/case"
# file name inside outputs directories
logFile
::
String
=
"run.log"
#################################
# init Exio (can create as many entities as needed)
exio
=
Exio
.
exio_init
(
app
,
outputPrefix
,
logFile
)
# create a linear model based on provided runs (the larger, the better)
# it will report the formula for dependent and independent variables
Exio
.
run_linear_models
(
exio
)
end
main
()
src/Exio.jl
View file @
c03dbf3d
...
...
@@ -21,5 +21,8 @@ function exio_init(app::String, outputPrefix::String, runlogFile::String)::ExioH
return
exioH
end
function
run_linear_models
(
exioH
::
ExioH
)
run_linear_models
(
exioH
.
extractor
)
end
end
src/extractor/AmrexCastro.jl
View file @
c03dbf3d
...
...
@@ -24,10 +24,14 @@ struct AmrexCastro <: AbstractAmrex
"castro.max_grid_size"
,
],
Dict
{
String
,
Array
{
String
}}(
"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"
],
"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
,
)
...
...
@@ -98,9 +102,9 @@ end
function
_run_linear_model_plots_size
(
extractor
::
AmrexCastro
,
X
::
DataFrames
.
DataFrame
)
outputDirs
=
helper_get_prefix_directories
(
extractor
.
outputPrefix
)
# single column DataFrame Y in the linear model
plotsSizesData
=
DataFrames
.
DataFrame
(
plots_sizes
=
Int64
[])
plotsSizesData
=
DataFrames
.
DataFrame
(
plots_sizes
=
Int64
[])
for
outputDir
in
outputDirs
...
...
@@ -117,33 +121,31 @@ function _run_linear_model_plots_size(extractor::AmrexCastro, X::DataFrames.Data
sizeDir
::
Int64
=
helper_get_directory_size
(
plotFileDir
)
plotsSize
+=
sizeDir
end
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
]
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
)
println
(
"I/O linear model formula:"
)
println
(
ols
)
#import Plots
#display(Plots.plot(X, Y))
end
test/test_AmrexCastro.jl
View file @
c03dbf3d
...
...
@@ -76,4 +76,3 @@ end
test_AmrexCastro
()
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