[enh] update codegeneration (bilinear interpolation + classname)
This commit is contained in:
@@ -31,17 +31,16 @@ begin
|
||||
using Mustache
|
||||
end
|
||||
|
||||
# ╔═╡ 873cff93-d9d4-462a-8214-7ac3ada6ec42
|
||||
|
||||
|
||||
# ╔═╡ 49cf91c7-8737-4171-ac5d-e66faff128b5
|
||||
plotly();
|
||||
|
||||
# ╔═╡ 10631e71-39b5-4c26-b452-ba9305def4c9
|
||||
begin
|
||||
BASE = "../batch_25-03-10_10-19_keV-2"
|
||||
BASE = "../batch_25-03-11_10-19_keV-rearwall-2"
|
||||
# BASE = "../batch_25-03-10_10-19_keV-2"
|
||||
BINS_RANGE_COARSE = range(100, 9000, step=100)
|
||||
BINS_RANGE_FINE = range(0, 100, step=1)
|
||||
OUT_CLASSNAME = "RearTrapInterpolator"
|
||||
HVS = [
|
||||
10_000.0,
|
||||
12_000.0,
|
||||
@@ -98,7 +97,7 @@ begin
|
||||
hists_coarse = gen_hists(BINS_RANGE_COARSE)
|
||||
hists_fine = gen_hists(BINS_RANGE_FINE)
|
||||
|
||||
plot(hists_fine, hists_coarse, layout=(2,1), link = :y)
|
||||
plot(hists_fine, hists_coarse, layout=(2,1), legend=false, link = :y)
|
||||
end
|
||||
|
||||
# ╔═╡ 8ec237b8-62a1-41a0-b974-742308fa0340
|
||||
@@ -124,7 +123,7 @@ let
|
||||
end
|
||||
end
|
||||
end
|
||||
plot(fig_fine, fig_coarse, layout=(1,2), link = :y)
|
||||
plot(fig_fine, fig_coarse, layout=(1,2), legend=false, link = :y)
|
||||
end
|
||||
|
||||
# ╔═╡ ae512256-b428-4773-b553-094f81accae3
|
||||
@@ -144,14 +143,18 @@ function extract_x_from_hist(hists)
|
||||
first(hists.series_list)[:x][2:2:end]
|
||||
end
|
||||
|
||||
# ╔═╡ 852bcc1e-ff9d-46f7-b9ed-296b7c946ee3
|
||||
hists_coarse.series_list[1][:y][end-4:end]
|
||||
|
||||
# ╔═╡ 63874e2c-0eaf-4894-b463-7baab22808ef
|
||||
function extract_grid_from_hist(hists, binning)
|
||||
map(entry -> begin
|
||||
(idx, hv) = entry
|
||||
idx
|
||||
grid = hists.series_list[idx][:y][1:2:end] ./ binning.step ./ traps[hv][:pass]
|
||||
grid[1] = grid[2]
|
||||
Dict(
|
||||
"hv"=>hv,
|
||||
"grid"=>hists.series_list[idx][:y][2:2:end] ./ binning.step ./ traps[hv][:pass]
|
||||
"grid"=>grid
|
||||
)
|
||||
end, enumerate(HVS))
|
||||
end
|
||||
@@ -187,6 +190,7 @@ end
|
||||
let
|
||||
gridKt = Mustache.render_from_file("./trap.kt.mustache", Dict(
|
||||
"generated_dt" => Dates.now(),
|
||||
"classname" => OUT_CLASSNAME,
|
||||
"hvs" => map(ele -> Float64(ele), HVS),
|
||||
"coarse_y" => map(ele -> Float64(ele), BINS_RANGE_COARSE),
|
||||
"coarse_grid" => extract_grid_from_hist(hists_coarse, BINS_RANGE_COARSE),
|
||||
@@ -1848,7 +1852,6 @@ version = "1.4.1+1"
|
||||
"""
|
||||
|
||||
# ╔═╡ Cell order:
|
||||
# ╠═873cff93-d9d4-462a-8214-7ac3ada6ec42
|
||||
# ╠═e3181cfe-1f1f-11ef-29c2-9bd8a45d756d
|
||||
# ╠═49cf91c7-8737-4171-ac5d-e66faff128b5
|
||||
# ╠═10631e71-39b5-4c26-b452-ba9305def4c9
|
||||
@@ -1860,6 +1863,7 @@ version = "1.4.1+1"
|
||||
# ╠═ae512256-b428-4773-b553-094f81accae3
|
||||
# ╠═33d5b8d6-dbec-4dd6-abd2-d581d906930c
|
||||
# ╠═d44da0e3-8d85-47b8-aaab-42714045b782
|
||||
# ╠═852bcc1e-ff9d-46f7-b9ed-296b7c946ee3
|
||||
# ╠═63874e2c-0eaf-4894-b463-7baab22808ef
|
||||
# ╠═cb538f05-95a7-49b4-95e2-460c079485f3
|
||||
# ╠═dc3599be-7eb1-4e50-a130-0c48a4a6ffe0
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Code generated by trap-spectrum-2024-11.jl Julia notebook {{generated_dt}}
|
||||
package ru.inr.mass.scripts
|
||||
import org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolator
|
||||
|
||||
class TrapInterpolator {
|
||||
class {{classname}} {
|
||||
private val x = arrayOf({{#hvs}}{{.}}, {{/hvs}}).toDoubleArray()
|
||||
|
||||
private val yCoarse = arrayOf(
|
||||
@@ -16,7 +15,7 @@ class TrapInterpolator {
|
||||
).toDoubleArray(),
|
||||
{{/coarse_grid}}
|
||||
)
|
||||
private val coarseInterpolator = PiecewiseBicubicSplineInterpolator().interpolate(x, yCoarse, gridCoarse)
|
||||
private val coarseInterpolator = BilinearInterpolator(x, yCoarse, gridCoarse)
|
||||
|
||||
private val yFine = arrayOf(
|
||||
{{#fine_y}}{{.}}, {{/fine_y}}
|
||||
@@ -29,7 +28,7 @@ class TrapInterpolator {
|
||||
{{/fine_grid}}
|
||||
)
|
||||
|
||||
private val fineInterpolator = PiecewiseBicubicSplineInterpolator().interpolate(x, yFine, gridFine)
|
||||
private val fineInterpolator = BilinearInterpolator(x, yFine, gridFine)
|
||||
|
||||
fun value(ei: Double, delta: Double): Double {
|
||||
if (ei < x.first() || ei > x.last())
|
||||
|
||||
Reference in New Issue
Block a user