Skip to content

Commit

Permalink
Remove propdict and replace by LegendDataManagement.readlprops
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann authored and oschulz committed Nov 22, 2024
1 parent 9b7c017 commit aad2868
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Distributions = "0.23, 0.24, 0.25"
ElasticArrays = "1"
IntervalSets = "0.5, 0.6, 0.7"
JSON = "0.21"
LegendDataManagement = "0.2.1, 0.3, 0.4"
LegendDataManagement = "0.2.8, 0.3, 0.4"
LegendDataTypes = "0.1"
LegendHDF5IO = "0.1"
LegendTextIO = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/detector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(readlprops(detector_metadata), environment_settings, simulation_settings; overwrite)
end

# user launches directly inputting separate dicts
Expand All @@ -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, readlprops(all_settings); overwrite)
end


Expand Down
2 changes: 1 addition & 1 deletion src/impurity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = readlprops(crystal_path)

# get fit parameters in crystal metadata coordinates i.e. e/cm^3 VS mm
fit_param = impurity_density_model(crystal_dict)
Expand Down
2 changes: 1 addition & 1 deletion src/legend_detector_to_ssd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(readlprops(metapath))
end

function LEGEND_SolidStateDetector(meta::PropDict)
Expand Down
4 changes: 2 additions & 2 deletions src/pet_to_raw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(readlprops(detector_metadata), pet_filename,
PropDict(environment_settings), PropDict(simulation_settings), PropDict(setup_settings), PropDict(noise_settings); n_waveforms)
end

Expand All @@ -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, readlprops(all_settings); n_waveforms)
end
4 changes: 2 additions & 2 deletions src/stp_to_pss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = readlprops(detector_metadata)

stp_table = pet_to_stp(det_meta, pet_filename)
# truncate if asked by user
Expand All @@ -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, readlprops(all_settings); n_waveforms)
end


17 changes: 0 additions & 17 deletions src/temp_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 <json_file>.
Alias for `readprops` from PropDicts.jl
"""
function propdict(json_file::AbstractString)
readprops(json_file)
end




"""
remove_negative(value)
Expand Down

0 comments on commit aad2868

Please sign in to comment.