Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
 for scipy
  • Loading branch information
robertdstein committed Jan 24, 2025
1 parent f0b2f54 commit 2ad3e28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions flarestack/core/llh.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def create_energy_functions(self):
with open(acc_path, "rb") as f:
[dec_bins, gamma_bins, acc] = pickle.load(f)

# acc_spline = scipy.interpolate.interp2d(
# acc_spline = scipy.interpolate.bisplrep(
# dec_bins, gamma_bins, np.array(acc).T, kind='linear')
#
# def acc_f(source, params):
Expand Down Expand Up @@ -807,7 +807,7 @@ def create_energy_functions(self):
# dec_bins = acc_dict["dec"]
# gamma_bins = acc_dict["gamma"]
# values = acc_dict["acceptance"]
# f = scipy.interpolate.interp2d(
# f = scipy.interpolate.bisplrep(
# dec_bins, gamma_bins, values.T, kind='linear')
# return f

Expand All @@ -824,7 +824,7 @@ def create_acceptance_function(self):
with open(acc_path, "rb") as f:
[dec_bins, gamma_bins, acc] = pickle.load(f)

f = scipy.interpolate.interp2d(dec_bins, gamma_bins, acc.T, kind="linear")
f = scipy.interpolate.bisplrep(dec_bins, gamma_bins, acc.T, kind="linear")
return f

def new_acceptance(self, source, params=None):
Expand Down
10 changes: 5 additions & 5 deletions flarestack/icecube_utils/reference_sensitivity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import numpy as np
import logging
from scipy.interpolate import interp1d, interp2d
from scipy.interpolate import interp1d, bisplrep
from flarestack.data.icecube.ic_season import get_published_sens_ref_dir


Expand Down Expand Up @@ -61,7 +61,7 @@ def reference_7year_sensitivity(sindec=np.array(0.0), gamma=2.0):

sens = np.vstack((sens[0], sens))
sens = np.vstack((sens, sens[-1]))
sens_ref = interp2d(np.array(sindecs), np.array(gammas), np.log(sens.T))
sens_ref = bisplrep(np.array(sindecs), np.array(gammas), np.log(sens.T))

if np.array(sindec).ndim > 0:
return np.array([np.exp(sens_ref(x, gamma))[0] for x in sindec])
Expand Down Expand Up @@ -97,7 +97,7 @@ def reference_7year_discovery_potential(sindec=0.0, gamma=2.0):

disc = np.vstack((disc[0], disc))
disc = np.vstack((disc, disc[-1]))
disc_ref = interp2d(np.array(sindecs), np.array(gammas), np.log(disc.T))
disc_ref = bisplrep(np.array(sindecs), np.array(gammas), np.log(disc.T))

if np.array(sindec).ndim > 0:
return np.array([np.exp(disc_ref(x, gamma))[0] for x in sindec])
Expand Down Expand Up @@ -129,7 +129,7 @@ def reference_10year_sensitivity(sindec=np.array(0.0), gamma=2.0):
scaling = np.array([10 ** (3 * (i)) for i in range(2)])
sens *= scaling

sens_ref = interp2d(np.array(sindecs), np.array(gammas), np.log(sens.T))
sens_ref = bisplrep(np.array(sindecs), np.array(gammas), np.log(sens.T))

if np.array(sindec).ndim > 0:
return np.array([np.exp(sens_ref(x, gamma))[0] for x in sindec])
Expand Down Expand Up @@ -161,7 +161,7 @@ def reference_10year_discovery_potential(sindec=np.array(0.0), gamma=2.0):
scaling = np.array([10 ** (3 * i) for i in range(2)])
sens *= scaling

sens_ref = interp2d(np.array(sindecs), np.array(gammas), np.log(sens.T))
sens_ref = bisplrep(np.array(sindecs), np.array(gammas), np.log(sens.T))

if np.array(sindec).ndim > 0:
return np.array([np.exp(sens_ref(x, gamma))[0] for x in sindec])
Expand Down
2 changes: 1 addition & 1 deletion flarestack/utils/percentile_SoB.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def make_plot(hist, savepath, normed=True):

order = 1

spline = scipy.interpolate.interp2d(x, y, np.log(ratio))
spline = scipy.interpolate.bisplrep(x, y, np.log(ratio))

for x_val in [2.0, 3.0, 7.0]:
print(x_val, spline(0.0, x_val), spline(0.5, x_val))
Expand Down

0 comments on commit 2ad3e28

Please sign in to comment.