Skip to content

Commit

Permalink
feat: Simplify summaries
Browse files Browse the repository at this point in the history
Rewrite the module for summary statistics to simplify it.  Instead of
using a single struct containing each statistic, use a tuple of structs.
This enables much more code reuse; structs can be mixed and matched
withing the tuple as needed.

BREAKING CHANGE: All but the default summary statistics break.
  • Loading branch information
musoke committed May 9, 2022
1 parent 532987e commit 5b58c5f
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 92 deletions.
2 changes: 1 addition & 1 deletion examples/growth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
"output_dir = \"$(pwd())/output\"\n",
"num_saves = 100\n",
"output_times = t_init:(t_final-t_init)/num_saves:t_final\n",
"output_config = OutputConfig(output_dir, output_times, summary_statistics=UltraDark.Output.SummaryStatisticsMeanMaxRms)\n",
"output_config = OutputConfig(output_dir, output_times, summary_statistics=(Summary.SimulationTime,Summary.MeanDensity,Summary.MaxDensity,Summary.RmsDensityContrast,Summary.ScaleFactor,Summary.TimeStep))\n",
"\n",
"options = Config.SimulationConfig(a=a)"
]
Expand Down
4 changes: 2 additions & 2 deletions src/UltraDark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export Grids, PencilGrids
export dV
export Config, SimulationConfig, constant_scale_factor, TimeStepOptions
export OutputConfig
export SummaryStatistics, SummaryStatisticsMeanMaxRms
export Summary

include("grids.jl")
include("pencil_grids.jl")
include("phase_diff.jl")
include("time_step.jl")
include("summary.jl")
include("output.jl")
include("config.jl")

import .Output: OutputConfig
import .Output: output_grids, output_xyz
import .Output: output_summary_row, output_summary_header
import .Output.Summary: SummaryStatistics, SummaryStatisticsMeanMaxRms
import .Config: SimulationConfig, constant_scale_factor, TimeStepOptions

"""
Expand Down
8 changes: 3 additions & 5 deletions src/output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import PencilFFTs, MPI
import NPZ
using Statistics

include("summary.jl")

import .Summary: output_summary_header, output_summary_row
import ..Summary: output_summary_header, output_summary_row

export Summary
export OutputConfig
Expand Down Expand Up @@ -38,13 +36,13 @@ struct OutputConfig
rho::Bool

"Type of summary statistics to collect"
summary_statistics::DataType
summary_statistics::Tuple
end

function OutputConfig(
directory, output_times;
box=true, slice=false, psi=true, rho=true,
summary_statistics=SummaryStatistics,
summary_statistics=(Summary.WallTime, Summary.SimulationTime,)
)

OutputConfig(directory, output_times, box, slice, psi, rho, summary_statistics)
Expand Down
Loading

0 comments on commit 5b58c5f

Please sign in to comment.