diff --git a/Project.toml b/Project.toml index 18fd15e..092c4b9 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,6 @@ DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2" DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" LegendDataManagement = "9feedd95-f0e0-423f-a8dc-de0970eae6b3" @@ -48,7 +47,6 @@ DSP = "0.7" DelimitedFiles = "1" Distributions = "0.23, 0.24, 0.25" ElasticArrays = "1" -HDF5 = "0.15, 0.16, 0.17" IntervalSets = "0.5, 0.6, 0.7" JSON = "0.21" LegendDataManagement = "0.2.1, 0.3, 0.4" diff --git a/docs/Project.toml b/docs/Project.toml index e01b169..5e8104d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,5 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" LegendHDF5IO = "c9265ca6-b027-5446-b1a4-febfa8dd10b0" LegendTestData = "33d6da08-6349-5f7c-b5a4-6ff4d8795aaf" Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" diff --git a/docs/src/tutorials/simulate_ideal_pulses_lit.jl b/docs/src/tutorials/simulate_ideal_pulses_lit.jl index f29fa5c..32be8c2 100644 --- a/docs/src/tutorials/simulate_ideal_pulses_lit.jl +++ b/docs/src/tutorials/simulate_ideal_pulses_lit.jl @@ -78,14 +78,13 @@ plot(pss_table.waveform[1:5], legend=false, title="only p+ contact pulses") # You can save simulated pulses in a file that can be used later. -using HDF5 using LegendHDF5IO # pss_name = "cache/test_100wfs_pss.hdf5" -h5open(pss_name, "w") do f - LegendHDF5IO.writedata(f, "pss/pss", pss_table[1:5]) - LegendHDF5IO.writedata(f, "pss/truth", pss_truth[1:5]) +lh5open(pss_name, "w") do f + LegendHDF5IO.writedata(f.data_store, "pss/pss", pss_table[1:5]) + LegendHDF5IO.writedata(f.data_store, "pss/truth", pss_truth[1:5]) end diff --git a/docs/src/tutorials/simulate_realistic_waveforms_lit.jl b/docs/src/tutorials/simulate_realistic_waveforms_lit.jl index 8870d55..4753ccf 100644 --- a/docs/src/tutorials/simulate_realistic_waveforms_lit.jl +++ b/docs/src/tutorials/simulate_realistic_waveforms_lit.jl @@ -96,14 +96,13 @@ plot(raw_table.waveform[1:10], legend=false, title="only p+ contact waveforms") # You can save simulated waveforms in a file that can be used later -using HDF5 using LegendHDF5IO # raw_name = "cache/test_100wfs_raw.hdf5" -h5open(raw_name, "w") do f - LegendHDF5IO.writedata(f, "raw", raw_table[1:10]) +lh5open(raw_name, "w") do f + LegendHDF5IO.writedata(f.data_store, "raw", raw_table[1:10]) end # ## Simulate from `pss` table in code @@ -131,14 +130,13 @@ plot( # Save the pss file for the next section using LegendHDF5IO -using HDF5 # pss_name = "cache/test_100wfs_pss.hdf5" -h5open(pss_name, "w") do f - LegendHDF5IO.writedata(f, "pss/pss", pss_table[1:10]) - LegendHDF5IO.writedata(f, "pss/truth", pss_truth[1:10]) +lh5open(pss_name, "w") do f + LegendHDF5IO.writedata(f.data_store, "pss/pss", pss_table[1:10]) + LegendHDF5IO.writedata(f.data_store, "pss/truth", pss_truth[1:10]) end # ## Simulate from pre-saved `pss` hdf5 file diff --git a/src/LegendGeSim.jl b/src/LegendGeSim.jl index f42c354..99ce7d7 100644 --- a/src/LegendGeSim.jl +++ b/src/LegendGeSim.jl @@ -16,7 +16,6 @@ using DelimitedFiles using Distributions using DSP using ElasticArrays -using HDF5 using IntervalSets using JSON using LegendDataManagement diff --git a/src/baselines.jl b/src/baselines.jl index c704eed..11582a1 100644 --- a/src/baselines.jl +++ b/src/baselines.jl @@ -37,16 +37,18 @@ function baseline_catalog(raw_filename::AbstractString) if isfile(base_filename) @info "Selecting baseline samples from $base_filename" - baseline_table = h5open(base_filename) do input Table(waveform = LegendDataTypes.readdata(input, "raw/waveform")) end + baseline_table = LegendHDF5IO.lh5open(base_filename) do input + Table(waveform = LegendDataTypes.readdata(input.data_store, "raw/waveform")) + end else @info "Extracting baseline samples from $raw_filename" - raw_table = HDF5.h5open(raw_filename, "r") do input - LegendHDF5IO.readdata(input, "raw") + raw_table = LegendHDF5IO.lh5open(raw_filename, "r") do input + LegendHDF5IO.readdata(input.data_store, "raw") end baseline_table = baseline_catalog(raw_table) # cache for later if !ispath(dirname(base_filename)) mkpath(dirname(base_filename)) end - h5open(base_filename, "w") do f LegendHDF5IO.writedata(f, "raw", baseline_table) end + LegendHDF5IO.lh5open(base_filename, "w") do f LegendHDF5IO.writedata(f.data_store, "raw", baseline_table) end @info "Baselines saved to $base_filename" end diff --git a/src/detector.jl b/src/detector.jl index 285561e..7516e3b 100644 --- a/src/detector.jl +++ b/src/detector.jl @@ -107,15 +107,15 @@ function simulate_detector(det_meta::PropDict, env::Environment, simulator::SSDS if !ispath(dirname(h5fn)) mkpath(dirname(h5fn)) end - HDF5.h5open(h5fn, "w") do h5f - LegendHDF5IO.writedata(h5f, "SSD_electric_potential", NamedTuple(sim.electric_potential)) - LegendHDF5IO.writedata(h5f, "SSD_point_types", NamedTuple(sim.point_types)) - LegendHDF5IO.writedata(h5f, "SSD_q_eff_fix", NamedTuple(sim.q_eff_fix)) - LegendHDF5IO.writedata(h5f, "SSD_q_eff_imp", NamedTuple(sim.q_eff_imp)) - LegendHDF5IO.writedata(h5f, "SSD_dielectric_distribution", NamedTuple(sim.ϵ_r)) - LegendHDF5IO.writedata(h5f, "SSD_electric_field", NamedTuple(sim.electric_field)) + LegendHDF5IO.lh5open(h5fn, "w") do h5f + LegendHDF5IO.writedata(h5f.data_store, "SSD_electric_potential", NamedTuple(sim.electric_potential)) + LegendHDF5IO.writedata(h5f.data_store, "SSD_point_types", NamedTuple(sim.point_types)) + LegendHDF5IO.writedata(h5f.data_store, "SSD_q_eff_fix", NamedTuple(sim.q_eff_fix)) + LegendHDF5IO.writedata(h5f.data_store, "SSD_q_eff_imp", NamedTuple(sim.q_eff_imp)) + LegendHDF5IO.writedata(h5f.data_store, "SSD_dielectric_distribution", NamedTuple(sim.ϵ_r)) + LegendHDF5IO.writedata(h5f.data_store, "SSD_electric_field", NamedTuple(sim.electric_field)) for i in eachindex(sim.weighting_potentials) - LegendHDF5IO.writedata(h5f, "SSD_weighting_potential_$(i)", NamedTuple(sim.weighting_potentials[i])) + LegendHDF5IO.writedata(h5f.data_store, "SSD_weighting_potential_$(i)", NamedTuple(sim.weighting_potentials[i])) end end @info("-> Saved cached simulation to $h5fn") @@ -125,7 +125,7 @@ function simulate_detector(det_meta::PropDict, env::Environment, simulator::SSDS # read from previously cached sim = construct_ssd_simulation(det_meta, env, simulator) @info("Reading SSD simulation from cached file $h5fn") - HDF5.h5open(h5fn, "r") do h5f + LegendHDF5IO.lh5open(h5fn, "r") do h5f sim.electric_potential = ElectricPotential(LegendHDF5IO.readdata(h5f, "SSD_electric_potential")) sim.point_types = PointTypes(LegendHDF5IO.readdata(h5f, "SSD_point_types")) sim.q_eff_fix = EffectiveChargeDensity(LegendHDF5IO.readdata(h5f, "SSD_q_eff_fix")) diff --git a/src/pss_to_raw.jl b/src/pss_to_raw.jl index e6ceeb3..c6a52f6 100644 --- a/src/pss_to_raw.jl +++ b/src/pss_to_raw.jl @@ -66,9 +66,9 @@ end # wrapper for user reading from pre-saved pss file function pss_to_raw(pss_file::AbstractString, setup_settings::Dict, noise_settings::Dict=Dict("type"=>"none"); n_waveforms::Int=0) - pss_h5 = h5open(pss_file, "r") - pss_table = LegendHDF5IO.readdata(pss_h5, "pss/pss") - pss_truth = LegendHDF5IO.readdata(pss_h5, "pss/truth") + pss_h5 = LegendHDF5IO.lh5open(pss_file, "r") + pss_table = LegendHDF5IO.readdata(pss_h5.data_store, "pss/pss") + pss_truth = LegendHDF5IO.readdata(pss_h5.data_store, "pss/truth") close(pss_h5) pss_to_raw(pss_table, pss_truth, setup_settings, noise_settings; n_waveforms) diff --git a/src/stp_to_pss.jl b/src/stp_to_pss.jl index 5f44546..23e11a2 100644 --- a/src/stp_to_pss.jl +++ b/src/stp_to_pss.jl @@ -30,8 +30,8 @@ end # function stp_to_pss(stp_filepath::AbstractString, det_meta_fullpath::AbstractString, sim_config_filename::AbstractString) -# stp_table = h5open(stp_filepath, "r") do input -# LegendHDF5IO.readdata(input, "stp") +# stp_table = LegendHDF5IO.lh5open(stp_filepath, "r") do input +# LegendHDF5IO.readdata(input.data_store, "stp") # end # stp_to_pss(stp_table, det_meta_fullpath, sim_config_filename) diff --git a/test/runtests.jl b/test/runtests.jl index 08d3107..3df1d2b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,7 @@ using Test using LegendGeSim -using LegendHDF5IO, HDF5 +using LegendHDF5IO using LegendTestData using Unitful @@ -62,9 +62,9 @@ end end pss_name = "cache/" * LegendGeSim.filename(path_to_pet_file) * "_pss.hdf5" - h5open(pss_name, "w") do f - LegendHDF5IO.writedata(f, "pss/pss", pss_table) - LegendHDF5IO.writedata(f, "pss/truth", pss_truth) + LegendHDF5IO.lh5open(pss_name, "w") do f + LegendHDF5IO.writedata(f.data_store, "pss/pss", pss_table) + LegendHDF5IO.writedata(f.data_store, "pss/truth", pss_truth) end @testset "pss I/O using LegendHDF5IO" begin