Skip to content

Commit 7ce21d8

Browse files
committed
local changes in heatmap sampler
1 parent c8ff144 commit 7ce21d8

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

ext/HeatmapSampler.jl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,16 @@ end
160160

161161
# Helper function to construct HGD
162162
function HeatmapGridDensity(
163-
data::AbstractMatrix{<:Real},
163+
# NAME SUGGESTION: SAMPLEABLE_FIELD, GenericField
164+
field_on_grid::AbstractMatrix{<:Real},
164165
domain::Tuple{<:AbstractVector{<:Real}, <:AbstractVector{<:Real}},
166+
# encapsulate above
165167
hint_callback::Union{<:Function, Nothing} = nothing,
166168
bw_factor::Real = 0.7; # kde spread between domain points
167169
N::Int = 10000,
168170
)
169171
#
170-
pos, weights_ = sampleHeatmap(data, domain..., 0)
172+
pos, weights_ = sampleHeatmap(field_on_grid, domain..., 0)
171173
# recast to the appropriate shape
172174
@cast support_[i, j] := pos[j][i]
173175

@@ -178,9 +180,9 @@ function HeatmapGridDensity(
178180

179181
@cast vec_preIS[j][i] := pts_preIS[i, j]
180182

181-
# weight the intermediate samples according to interpolation of raw data
183+
# weight the intermediate samples according to interpolation of raw field_on_grid
182184
# interpolated heatmap
183-
hm = Interpolations.linear_interpolation(domain, data) # depr .LinearInterpolation(..)
185+
hm = Interpolations.linear_interpolation(domain, field_on_grid) # depr .LinearInterpolation(..)
184186
d_scalar = Vector{Float64}(undef, length(vec_preIS))
185187

186188
# interpolate d_scalar for intermediate test points
@@ -225,7 +227,7 @@ end
225227

226228
# legacy construct helper
227229
function LevelSetGridNormal(
228-
data::AbstractMatrix{<:Real},
230+
field_on_grid::AbstractMatrix{<:Real},
229231
domain::Tuple{<:AbstractVector{<:Real}, <:AbstractVector{<:Real}},
230232
level::Real,
231233
sigma::Real;
@@ -235,8 +237,18 @@ function LevelSetGridNormal(
235237
N::Int = 10000,
236238
)
237239
#
238-
hgd = HeatmapGridDensity(data, domain, hint_callback, bw_factor; N = N)
239-
return LevelSetGridNormal(level, sigma, float(sigma_scale), hgd)
240+
field = HeatmapGridDensity(field_on_grid, domain, hint_callback, bw_factor; N = N)
241+
return LevelSetGridNormal(level, sigma, float(sigma_scale), field)
240242
end
241243

244+
# Field: domain (R^2/3), image (R^1/n scalar or tensor) e.g.: x,y -> elevation ;; x, y, z, t -> EM-field (R^(4x4))
245+
# Field( grid_x, grid_y,.... field_grid )
246+
# Field^ = interpolator(field_at_grid, grid)
247+
#
248+
# FieldGrid(data_on_grid, grid_domain) # internally does interpolation vodoo (same as Field^)
249+
# BeliefGrid <: FieldGrid
250+
# BeliefGrid(field_data: FieldGrid, measurement: Normal(mean: image_domain, cov: image_domain^2) ) -> domain, R_0+
251+
#
252+
# calcApproxLoss(ref::BeliefGrid, appr::ManifoldKernelDensity)::Field{Real}
253+
# ref = Normal(ScalarField - measurement, cov)
242254
#

0 commit comments

Comments
 (0)