Skip to content
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
be202ce
Add krmap functions
mcidlaso Dec 18, 2025
f5e80e7
Add correction functions
mcidlaso Dec 18, 2025
639c67c
Add selection functions
mcidlaso Dec 18, 2025
196bb7d
Add test functions for correction functions
mcidlaso Dec 18, 2025
0ee5db0
Add lifetime fit and drift velocity functions
mcidlaso Dec 18, 2025
27c2632
Add tests functions for the krmap functions
mcidlaso Dec 19, 2025
7e66555
Add tests functions for the krmap functions
mcidlaso Dec 19, 2025
7ae012e
correct error
mcidlaso Dec 22, 2025
b4ee6fb
Correct error
mcidlaso Dec 22, 2025
4ee1dd5
Correct error again
mcidlaso Dec 22, 2025
bf7c147
correct all errors
mcidlaso Dec 22, 2025
3984730
correct error
mcidlaso Dec 22, 2025
5f9baea
Drop dropna() from normalization function
mcidlaso Jan 16, 2026
a79497b
Add optional parameters in a single argument
mcidlaso Jan 16, 2026
b4b0895
Import functions for creating krmaps and t_evol in the same file
mcidlaso Jan 16, 2026
0023370
Change description and correct create_empty_map function
mcidlaso Jan 16, 2026
846c8be
Change name and add explanation comment in get_median() function
mcidlaso Jan 16, 2026
405d528
Change function and variables names in gaussian_fit function
mcidlaso Jan 16, 2026
5c0f4c0
Change function name from map_3D_fits to fit_map
mcidlaso Jan 16, 2026
c4e94ea
Changes in fit_map function
mcidlaso Jan 16, 2026
a86acf4
Add description for merge_maps function
mcidlaso Jan 16, 2026
068f521
Change variable name for krmap in include_coordinates function
mcidlaso Jan 16, 2026
ee5480c
Change variable and function names in compute_3D_map function
mcidlaso Jan 16, 2026
27065c5
Add function to get map info (metadata)
mcidlaso Jan 16, 2026
45f640c
Add functions (from icaros/krcal/core/fit_functions.py) to do fits
mcidlaso Jan 16, 2026
80eec15
Add function to divide dataframe into time slices
mcidlaso Jan 16, 2026
d3095fe
Add function to calculate time evolution parameters
mcidlaso Jan 16, 2026
fffafe1
Add function to save map
mcidlaso Jan 16, 2026
de04df5
Simplify select_lifetime_region function
mcidlaso Jan 16, 2026
9b9fcf6
Change LT_fit function to use fit function from IC
mcidlaso Jan 16, 2026
e9b9e6f
Comment print
mcidlaso Jan 16, 2026
e9e53d2
Change and move eff_of_sel function
mcidlaso Jan 16, 2026
e62aab7
Change load_files to be more straightforward
mcidlaso Jan 16, 2026
fdee97e
Move and change line in eff_of_selection function
mcidlaso Jan 16, 2026
1a485fe
Add line in apply_correctionmap function so the corrected kdst ends u…
mcidlaso Jan 16, 2026
9d6d21a
Use in_range function from IC
mcidlaso Jan 16, 2026
68ed946
Add comment explaining the function and change variable name
mcidlaso Jan 16, 2026
3efa220
Remove range_S2t variable
mcidlaso Jan 16, 2026
6f9a9e5
Use in_range function from IC
mcidlaso Jan 16, 2026
2d43137
Change order on selections and correct typo
mcidlaso Jan 16, 2026
2185eca
Change column names so we don't get a warning when using df_writer
mcidlaso Jan 16, 2026
92023cb
Create test for lifetime and drift velocity
mcidlaso Jan 19, 2026
f5eed65
Change test names to be more explicit
mcidlaso Jan 19, 2026
627315e
Change function names, remove one line and remove dtype = int
mcidlaso Jan 19, 2026
91432d5
Remove comment
mcidlaso Jan 19, 2026
02a4991
Change function that computes metadata
mcidlaso Jan 19, 2026
23319f7
Change function that saves maps so it doesn't raise an error when ope…
mcidlaso Jan 19, 2026
9cee111
Monitoring function to plot time evolution parameters
mcidlaso Jan 19, 2026
7dbcb49
Change function so the yranges of the plots depend on the values of t…
mcidlaso Jan 19, 2026
9d210dd
Import functions with the right name
mcidlaso Jan 20, 2026
cb216df
Import functions to make tests and change one line in test_method_norm()
mcidlaso Jan 20, 2026
c547809
Add test for apply_3Dmap function
mcidlaso Jan 20, 2026
b8f494e
Add one comment
mcidlaso Jan 20, 2026
75679e9
Add control plots functions
mcidlaso Jan 20, 2026
47af789
Added run numbers, bins for each variable and put ylimits in one plot
mcidlaso Jan 20, 2026
5368c9a
Added normalization methods to calculate the median values of mu
mcidlaso Jan 20, 2026
f3b15bf
Corrected name error in get_time_evol function and now the resolution…
mcidlaso Jan 20, 2026
71a963e
Added functions to append multiple time evolutions from different run…
mcidlaso Jan 20, 2026
d389b96
Removed run_number variable because it wasnt being used
mcidlaso Jan 20, 2026
032a630
Correct typo
mcidlaso Jan 20, 2026
56eb4b9
Include median in normalization function test
mcidlaso Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions invisible_cities/icaros/correction_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pandas as pd
import numpy as np
from scipy.interpolate import griddata


def normalization(krmap, method, xy_params = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will discuss how to do this with symbols


mu_values = krmap.mu.dropna()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropna should affect all options of method. Right now, it's only affecting the first two, the other three do not use this variable. You should redefine kr_map so it doesn't contain nan values.:
krmap = krmap.dropna(subset=["mu"]). Then use krmap.mu.something everywhere


if method == 'max':
E_reference_max = mu_values.max()
return E_reference_max

if method == 'mean chamber':
E_reference_chamber = mu_values.mean()
return E_reference_chamber

if method == 'mean anode':
mu_values_anode = krmap[krmap.k == 0].mu
E_reference_anode = mu_values_anode.mean()
return E_reference_anode

mask_region = (krmap['x'] <= xy_params['x_high']) & (krmap['x'] >= xy_params['x_low']) & (krmap['y'] <= xy_params['y_high']) & (krmap['y'] >= xy_params['y_low'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use in_range


if method == 'mean region anode':
region = krmap[krmap.k == 0][mask_region]
E_reference_slice_anode = region.mu.mean()
return E_reference_slice_anode

if method == 'mean region chamber':
region = krmap[mask_region]
E_reference_region = region.mu.mean()
return E_reference_region


def apply_3Dmap(krmap, norm_method, dt, x, y, E, xy_params = None, keV = False):

map_points = krmap['dt x y'.split()].values
norm = normalization(krmap, norm_method, xy_params)

data_points = np.stack([dt, x, y], axis = 1)
E_interpolated_data = griddata(map_points, krmap.mu.values, data_points, method = 'nearest')

correction_factor = norm/E_interpolated_data
Ec = E * correction_factor

if keV:
Ec = Ec * (41.55 / norm)

return Ec



43 changes: 43 additions & 0 deletions invisible_cities/icaros/correction_functions_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from correction_functions import normalization


def test_method_norm():

k_vals = np.arange(10)
i_vals = np.arange(12)
j_vals = np.arange(12)

k, i, j = np.meshgrid(k_vals, i_vals, j_vals, indexing='ij')
k = k.ravel()
i = i.ravel()
j = j.ravel()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k, i, j = np.meshgrid(k_vals, i_vals, j_vals, indexing='ij')
k = k.ravel()
i = i.ravel()
j = j.ravel()
k, i, j = map(np.ravel,
np.meshgrid(k_vals, i_vals, j_vals, indexing='ij'))


x = i * 25
y = j * 25
dt = k * 45

mu = (k*i + 800)*j

map_test = pd.DataFrame({
'k': k,
'i': i,
'j': j,
'x': x,
'y': y,
'dt': dt,
'mu': mu
})

region_mask = (
(map_test.x <= 100) & (map_test.x >= -100) &
(map_test.y <= 100) & (map_test.y >= -100)
)

Comment on lines +33 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in_range

assert normalization(map_test, 'max', None, None, None, None) == 9889
assert normalization(map_test, 'mean chamber', None, None, None, None) == 4536.125
assert normalization(map_test, 'mean anode', None, None, None, None) == 4400
assert normalization(map_test, 'mean region anode', -100, 100, -100, 100) == map_test.loc[(map_test.k == 0) & region_mask,'mu'].mean()
assert normalization(map_test, 'mean region chamber', -100, 100, -100, 100) == map_test.loc[region_mask,'mu'].mean()
Loading
Loading