From 9261eaa1843fc9808bb3c1677c1409672f1d0bb0 Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Mon, 18 Nov 2024 20:39:56 +0100 Subject: [PATCH] Remove `propdict` and replace by `PropDicts.readprops` --- src/detector.jl | 4 ++-- src/impurity.jl | 2 +- src/legend_detector_to_ssd.jl | 2 +- src/pet_to_raw.jl | 4 ++-- src/stp_to_pss.jl | 4 ++-- src/temp_utils.jl | 17 ----------------- 6 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/detector.jl b/src/detector.jl index 7516e3b..7084c42 100644 --- a/src/detector.jl +++ b/src/detector.jl @@ -7,7 +7,7 @@ end # user generates detector metadata in code function simulate_fields(detector_metadata::AbstractString, environment_settings::PropDict, simulation_settings::PropDict; overwrite::Bool = false) - simulate_fields(propdict(detector_metadata), environment_settings, simulation_settings; overwrite) + simulate_fields(readprops(detector_metadata), environment_settings, simulation_settings; overwrite) end # user launches directly inputting separate dicts @@ -23,7 +23,7 @@ end # user launches with all settings in json function simulate_fields(detector_metadata::Union{AbstractString, PropDict}, all_settings::AbstractString; overwrite::Bool = false) - simulate_fields(detector_metadata, propdict(all_settings); overwrite) + simulate_fields(detector_metadata, readprops(all_settings); overwrite) end diff --git a/src/impurity.jl b/src/impurity.jl index 6fd577b..9939eaf 100644 --- a/src/impurity.jl +++ b/src/impurity.jl @@ -105,7 +105,7 @@ function impurity_density_model(meta::PropDict, crystal_metadata_path::AbstractS @error "Crystal $(crystal_name) does not exist in path $crystal_metadata_path" end - crystal_dict = propdict(crystal_path) + crystal_dict = readprops(crystal_path) # get fit parameters in crystal metadata coordinates i.e. e/cm^3 VS mm fit_param = impurity_density_model(crystal_dict) diff --git a/src/legend_detector_to_ssd.jl b/src/legend_detector_to_ssd.jl index 4af0989..adca322 100644 --- a/src/legend_detector_to_ssd.jl +++ b/src/legend_detector_to_ssd.jl @@ -4,7 +4,7 @@ to_SSD_units(::Type{T}, x, unit) where {T} = T(SolidStateDetectors.to_internal_u # if just want geometry function LEGEND_SolidStateDetector(metapath::AbstractString) - LEGEND_SolidStateDetector(propdict(metapath)) + LEGEND_SolidStateDetector(readprops(metapath)) end function LEGEND_SolidStateDetector(meta::PropDict) diff --git a/src/pet_to_raw.jl b/src/pet_to_raw.jl index 6146516..1032647 100644 --- a/src/pet_to_raw.jl +++ b/src/pet_to_raw.jl @@ -38,7 +38,7 @@ end # user launches directly inputting separate dicts function simulate_raw(detector_metadata::AbstractString, pet_filename::AbstractString, environment_settings::Union{Dict,PropDict}, simulation_settings::Union{Dict,PropDict}, setup_settings::Union{Dict,PropDict}, noise_settings::Union{Dict,PropDict}=Dict("type"=>"none"); n_waveforms::Int = 0) - pet_to_raw(propdict(detector_metadata), pet_filename, + pet_to_raw(readprops(detector_metadata), pet_filename, PropDict(environment_settings), PropDict(simulation_settings), PropDict(setup_settings), PropDict(noise_settings); n_waveforms) end @@ -51,5 +51,5 @@ end # user launches with all settings in json function simulate_raw(detector_metadata::AbstractString, pet_filename::AbstractString, all_settings::AbstractString; n_waveforms::Int = 0) - simulate_raw(detector_metadata, pet_filename, propdict(all_settings); n_waveforms) + simulate_raw(detector_metadata, pet_filename, readprops(all_settings); n_waveforms) end diff --git a/src/stp_to_pss.jl b/src/stp_to_pss.jl index 23e11a2..2a8f700 100644 --- a/src/stp_to_pss.jl +++ b/src/stp_to_pss.jl @@ -49,7 +49,7 @@ end function simulate_pulses(detector_metadata::AbstractString, pet_filename::AbstractString, environment_settings::Union{Dict,PropDict}, simulation_settings::Union{Dict,PropDict}, noise_settings::Union{Dict,PropDict} = Dict("type" => "none"); n_waveforms::Int = 0) ## step 1: stepping information - det_meta = propdict(detector_metadata) + det_meta = readprops(detector_metadata) stp_table = pet_to_stp(det_meta, pet_filename) # truncate if asked by user @@ -74,7 +74,7 @@ end # user launches with all settings in json function simulate_pulses(detector_metadata::AbstractString, pet_filename::AbstractString, all_settings::AbstractString; n_waveforms::Int = 0) - simulate_pulses(detector_metadata, pet_filename, propdict(all_settings); n_waveforms) + simulate_pulses(detector_metadata, pet_filename, readprops(all_settings); n_waveforms) end diff --git a/src/temp_utils.jl b/src/temp_utils.jl index 37d8be5..e486d08 100644 --- a/src/temp_utils.jl +++ b/src/temp_utils.jl @@ -11,23 +11,6 @@ E.g. filename("/some/path/to/file_name.ext") -> "file_name" filename(path) = splitext(basename(path))[1] -# this should be in PropDicts? -""" - propdict(json_file) - -AbstractString -> PropDict - -Construct a PropDict based on given . -Alias for `readprops` from PropDicts.jl - -""" -function propdict(json_file::AbstractString) - readprops(json_file) -end - - - - """ remove_negative(value)