Skip to content

Commit

Permalink
Special case binning for instant correlations
Browse files Browse the repository at this point in the history
This shouldn't be a special case, but instant correlations has been designed to return `available_energies(sc) = NaN` so this is the work around
  • Loading branch information
Lazersmoke committed Oct 31, 2023
1 parent 4efaea1 commit 9e4d25c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Intensities/Binning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function unit_resolution_binning_parameters(ωvals,latsize,args...)
params
end

unit_resolution_binning_parameters(sc::SampledCorrelations; kwargs...) = unit_resolution_binning_parameters(available_energies(sc),sc.latsize,sc;kwargs...)
unit_resolution_binning_parameters(sc::SampledCorrelations; kwargs...) = unit_resolution_binning_parameters(available_energies_including_zero(sc),sc.latsize,sc;kwargs...)

function unit_resolution_binning_parameters(ωvals::AbstractVector{Float64})
if !all(abs.(diff(diff(ωvals))) .< 1e-12)
Expand Down Expand Up @@ -282,7 +282,7 @@ function slice_2D_binning_parameters(ωvals::Vector{Float64},cut_from_q,cut_to_q
end

function slice_2D_binning_parameters(sc::SampledCorrelations,cut_from_q,cut_to_q,args...;kwargs...)
slice_2D_binning_parameters(available_energies(sc),cut_from_q,cut_to_q,args...;kwargs...)
slice_2D_binning_parameters(available_energies_including_zero(sc),cut_from_q,cut_to_q,args...;kwargs...)
end

"""
Expand Down Expand Up @@ -353,7 +353,7 @@ function reciprocal_space_path_bins(ωvals,qs,density,args...;kwargs...)
end
return params, markers, ranges
end
reciprocal_space_path_bins(sc::SampledCorrelations, qs::Vector, density,args...;kwargs...) = reciprocal_space_path_bins(available_energies(sc), qs, density,args...;kwargs...)
reciprocal_space_path_bins(sc::SampledCorrelations, qs::Vector, density,args...;kwargs...) = reciprocal_space_path_bins(available_energies_including_zero(sc), qs, density,args...;kwargs...)


"""
Expand Down Expand Up @@ -382,7 +382,7 @@ function intensities_binned(sc::SampledCorrelations, params::BinningParameters,
return_type = typeof(formula).parameters[1]
output_intensities = zeros(return_type,numbins...)
output_counts = zeros(Float64,numbins...)
ωvals = available_energies(sc)
ωvals = available_energies_including_zero(sc)

# Find an axis-aligned bounding box containing the histogram.
# The AABB needs to be in r.l.u for the (possibly reshaped) crystal
Expand Down Expand Up @@ -478,3 +478,8 @@ function intensities_binned(sc::SampledCorrelations, params::BinningParameters,
return output_intensities, output_counts
end

function available_energies_including_zero(x)
ωs = available_energies(x)
# Special case due to NaN definition of instant_correlations
(length(ωs) == 1 && isnan(ωs[1])) ? [0.] : ωs
end

0 comments on commit 9e4d25c

Please sign in to comment.