- 
                Notifications
    You must be signed in to change notification settings 
- Fork 250
Open
Labels
Description
Not sure if AveragedSpecifiedTimes is meant to be used externally but when I tried to use it it doesn't work
Given an MWE like:
using Oceananigans
using Oceananigans.OutputWriters: AveragedSpecifiedTimes
using Printf
arch = CPU()
grid = RectilinearGrid(arch, size=(4, 4, 4), extent=(1, 1, 1))
model = NonhydrostaticModel(grid=grid)
simulation = Simulation(model, Δt=0.01, stop_time=1)
times = [0.1, 0.25, 0.5, 0.6, 1]
wall_time = Ref(time_ns())
function set_synthetic_values!(sim)
    t = time(sim)
    set!(sim.model, u=t, v=0, w=0)
    return nothing
end
simulation.callbacks[:set_synthetic_values] = Callback(set_synthetic_values!, IterationInterval(1))
simulation.output_writers[:jld2] = JLD2Writer(model, model.velocities;
                                              filename = "averagedspecified_times",
                                              schedule = AveragedSpecifiedTimes(times, window=0.1),
                                              # schedule = AveragedTimeInterval(0.2, window=0.1),
                                              # schedule = TimeInterval(0.2),
                                              overwrite_existing = true)
run!(simulation)
u = FieldTimeSeries("averagedspecified_times.jld2", "u")
u.times
u_values = interior(u, 1, 1, 1, :)we end up with
julia> u.times
102-element Vector{Float64}:
 0.0
 0.01
 0.02
 0.03
 0.04
 0.05
 0.060000000000000005
 0.07
 0.08
 0.09
 0.09999999999999999
 ⋮
 0.9099999999999971
 0.919999999999997
 0.9299999999999969
 0.9399999999999968
 0.9499999999999967
 0.9599999999999966
 0.9699999999999965
 0.9799999999999964
 0.9899999999999963
 0.9999999999999962
 1.0
julia> u_values
102-element view(::Array{Float64, 4}, 4, 4, 4, :) with eltype Float64:
 0.0
 0.009999999776482582
 0.019999999552965164
 0.029999999329447746
 0.03999999910593033
 0.05000000074505806
 0.05999999865889549
 0.07000000029802322
 0.07999999821186066
 0.09000000357627869
 0.10000000149011612
 ⋮
 0.9100000262260437
 0.9200000166893005
 0.9300000071525574
 0.9399999976158142
 0.949999988079071
 0.9599999785423279
 0.9700000286102295
 0.9800000190734863
 0.9900000095367432
 1.0
 1.0which is not expected behavior. The outputwriter is expected to only write fields at times so that it only has 6 time frames in this case. What eventually ended up happening is that fields at all timesteps are written into the file.