Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion invisible_cities/cities/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def run_git_command(git_command: str, quiet: bool = False):
print(f"Following error encountered when running: {git_command}")
print(e.stderr)
return "None"
except Exception as e:
except Exception:
print(traceback.format_exc())


Expand Down
2 changes: 0 additions & 2 deletions invisible_cities/cities/hypathia.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from .. io . trigger_io import trigger_writer
from .. types.symbols import WfType
from .. types.symbols import CutAlgo
from .. types.symbols import SiPMThreshold

from .. dataflow import dataflow as fl
from .. dataflow.dataflow import push
Expand All @@ -47,7 +46,6 @@
from . components import compute_and_write_pmaps
from . components import simulate_sipm_response
from . components import calibrate_sipms
from . components import get_actual_sipm_thr
from . components import sensor_masker
from . components import select_cutting_algorithm

Expand Down
1 change: 0 additions & 1 deletion invisible_cities/cities/irene.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from .. io .dst_io import df_writer
from .. types.symbols import WfType
from .. types.symbols import CutAlgo
from .. types.symbols import SiPMThreshold

from .. database.load_db import DataPMT
from .. database.load_db import DataSiPM
Expand Down
1 change: 0 additions & 1 deletion invisible_cities/cities/zemrude.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from .. icaros .control_plots_functions import make_control_plots
from .. icaros .control_plots_functions import plot_time_evolution_with_errors_and_dates

from typing import Tuple
from typing import Union
from typing import Callable
from typing import List
Expand Down
1 change: 0 additions & 1 deletion invisible_cities/core/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from typing import get_args
from typing import Sequence
from typing import Callable
from typing import Optional
from typing import Mapping
from typing import Union
from typing import Tuple
Expand Down
18 changes: 10 additions & 8 deletions invisible_cities/icaros/control_plots_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .. icaros .lifetime_vdrift_functions import select_lifetime_region

from typing import Callable
from typing import Tuple

matplotlib.set_loglevel("warning")

Expand Down Expand Up @@ -542,7 +541,7 @@ def plot_sigmoid(df : pd.DataFrame,

fig, axs = plt.subplots(1, 1)
axs.plot(bin_centers, counts, 'o', color = 'black', markersize = 5, label = 'DT mean')
axs.plot(bin_centers, sigmoid(bin_centers, *f.values), color = 'red', label = f'Sigmoid_fit')
axs.plot(bin_centers, sigmoid(bin_centers, *f.values), color = 'red', label = 'Sigmoid_fit')
axs.set_xlabel(r'DT($\mu$s)');
axs.set_ylabel('Event distribution');
axs.set_xlim(1200, 1500);
Expand Down Expand Up @@ -619,7 +618,7 @@ def plot_time_evolution_with_errors_and_dates(df_time_evolution : pd.DataFrame,
that contains the timestamp data in seconds since epoch.
output_dir (str, optional): Directory to save plots. If None, plots are displayed.
"""
print(f"\n--- Processing /time_evolution data ---")
print("\n--- Processing /time_evolution data ---")
ts_col_name = 'ts'

try:
Expand Down Expand Up @@ -693,14 +692,17 @@ def plot_time_evolution_with_errors_and_dates(df_time_evolution : pd.DataFrame,

if output_dir:
plot_filename = os.path.join(output_dir, f"time_evolution_{plot_name}_with_errors_dates.png")
plt.savefig(plot_filename)
print(f"Saved plot for {plot_name} to {plot_filename}")
plt.close() # Close the plot to free memory
try:
plt.savefig(plot_filename)
except Exception as error:
print(f"Error trying to write {plot_filename}: {error}")
else:
print(f"Saved plot for {plot_name} to {plot_filename}")
finally:
plt.close() # Close the plot to free memory
else:
plt.show()

except FileNotFoundError:
print(f"Error: The HDF5 file '{h5_file_path}' was not found. Please check the path.")
except KeyError as ke:
print(f"Error accessing HDF5 group or column: {ke}. Please ensure the '/time_evolution' group and the 'ts' column name are correct.")
except Exception as e:
Expand Down
19 changes: 7 additions & 12 deletions invisible_cities/icaros/krmap_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,10 @@ def get_time_evol_single_slice(df : pd.DataFrame,
f = fit(expo, kdst_in_region.DT, kdst_in_region.S2e, p0)
magnitudes, uncertainties = f.values, (f[2][0], f[2][1])

lifetime = - magnitudes[1]
ulifetime = uncertainties[1]
e0 , lifetime = magnitudes
e0u, ulifetime = uncertainties

e0 = magnitudes[0]
e0u = uncertainties[0]
lifetime = -lifetime

except:
lifetime = np.nan
Expand All @@ -556,19 +555,15 @@ def get_time_evol_single_slice(df : pd.DataFrame,
dv, udv = compute_drift_v(kdst_in_region.DT.to_numpy(), dtbins_dv, seed = None)

try:
f = quick_gauss_fit(df['Ec'].values, bins_Ec, sigma = error)
_, mu, sigma = f.values
_, u_mu, u_sigma = f.errors

chi2_ec_prelim = f.chi2
Comment on lines -559 to -563

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

get_time_evol_single_slice() now appears a bit strange, as later in the function almost the exact same procedure is followed, but using underscore notation.

Perhaps:

_, mu,   _ = f.values
_, u_mu, _ = f.erors

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

f = quick_gauss_fit(df['Ec'].values, bins_Ec, sigma = error)
_, mu, _ = f.values
_, u_mu, _ = f.errors
chi2_ec_prelim = f.chi2

except:
median = get_median(df['Ec'])
mu = median.mu
sigma = median.sigma
u_mu = median.mu_error
u_sigma = median.sigma_error

chi2_ec_prelim = np.nan

try:
Expand Down
2 changes: 1 addition & 1 deletion invisible_cities/icaros/selection_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def apply_selections(kdst : pd.DataFrame,
df, eff_DTrange = select_var_inrange(df, 'DT', low_DT, high_DT, f'events in DT range [{low_DT}, {high_DT}]')
df_final, eff_nsipm = select_var_inrange(df,'Nsipm', low_nsipm, high_nsipm, f'events in NSipm range [{low_nsipm}, {high_nsipm}]')

total_efficiency = eff_of_selection(kdst, df_final, f'total events after all selections')
total_efficiency = eff_of_selection(kdst, df_final, 'total events after all selections')

d = {'Diffusion_band': eff_DTband,
'Xrays': eff_Xrays,
Expand Down
3 changes: 0 additions & 3 deletions invisible_cities/reco/hits_functions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import numpy as np
import pandas as pd

from itertools import compress
from copy import deepcopy
from typing import List
from sklearn.cluster import DBSCAN

from .. types.ic_types import NN
Expand Down
2 changes: 0 additions & 2 deletions invisible_cities/reco/hits_functions_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pandas as pd

from pytest import mark
from pytest import fixture
from numpy.testing import assert_almost_equal

from .. core.testing_utils import assert_dataframes_close
Expand Down
4 changes: 0 additions & 4 deletions invisible_cities/types/ic_types_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from string import ascii_letters

import numpy as np

from . ic_types import minmax
from . ic_types import xy
from . ic_types import NN

from pytest import raises

from hypothesis import given
from hypothesis.strategies import floats
from hypothesis.strategies import builds
from hypothesis.strategies import text


def make_minmax(a,b):
Expand Down
Loading