From e13c07671ecd02bd3b6c33bb00d3f6539fe40e24 Mon Sep 17 00:00:00 2001 From: Aswathi Balagopal Date: Mon, 15 Sep 2025 15:16:40 -0500 Subject: [PATCH 1/3] The llh array was getting flipped while reshapping. Maintaing the indexing so that the spectral-index vs llh mapping remains consistent. --- mla/threeml/profilellh.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mla/threeml/profilellh.py b/mla/threeml/profilellh.py index 3bfe386..a96b030 100644 --- a/mla/threeml/profilellh.py +++ b/mla/threeml/profilellh.py @@ -45,7 +45,7 @@ def __init__( super().__init__(name, nuisance_parameters) if spline is not None: self.spline = spline - self.df = None + self.df = df#None #I am not sure why df should be set at None here. This seems to create issues while minimizing else: self.df = df self.par_name = list(df.columns) @@ -53,10 +53,11 @@ def __init__( listofpoint = [] shape = [] for n in self.par_name: + sort_idx = np.lexsort([df_ver[p].values for p in reversed(par_name)]) points = np.unique(df[n]) listofpoint.append(points) shape.append(points.shape[0]) - llh = np.reshape(df["llh"].values, shape) + llh = np.reshape(df["llh"].values[sort_idx], shape) self.spline = RegularGridInterpolator( listofpoint, llh, bounds_error=False, fill_value=fill_value ) From 6f9cfb3db2d075d65180a9e616d704b926aac57d Mon Sep 17 00:00:00 2001 From: Aswathi Balagopal Date: Mon, 15 Sep 2025 15:29:06 -0500 Subject: [PATCH 2/3] Fix name of df --- mla/threeml/profilellh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mla/threeml/profilellh.py b/mla/threeml/profilellh.py index a96b030..396f87b 100644 --- a/mla/threeml/profilellh.py +++ b/mla/threeml/profilellh.py @@ -53,7 +53,7 @@ def __init__( listofpoint = [] shape = [] for n in self.par_name: - sort_idx = np.lexsort([df_ver[p].values for p in reversed(par_name)]) + sort_idx = np.lexsort([df[p].values for p in reversed(par_name)]) points = np.unique(df[n]) listofpoint.append(points) shape.append(points.shape[0]) From 878fda0c3d3152ecc75a41c79032081241ce83e0 Mon Sep 17 00:00:00 2001 From: Aswathi Balagopal Date: Mon, 15 Sep 2025 15:37:57 -0500 Subject: [PATCH 3/3] Getting rid of the loop --- mla/threeml/profilellh.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mla/threeml/profilellh.py b/mla/threeml/profilellh.py index 396f87b..e292266 100644 --- a/mla/threeml/profilellh.py +++ b/mla/threeml/profilellh.py @@ -50,14 +50,9 @@ def __init__( self.df = df self.par_name = list(df.columns) self.par_name.pop() - listofpoint = [] - shape = [] - for n in self.par_name: - sort_idx = np.lexsort([df[p].values for p in reversed(par_name)]) - points = np.unique(df[n]) - listofpoint.append(points) - shape.append(points.shape[0]) - llh = np.reshape(df["llh"].values[sort_idx], shape) + listofpoint = [np.unique(df[n]) for n in par_name] + shape = [len(points) for points in listofpoint] + sort_idx = np.lexsort([df[p].values for p in reversed(par_name)]) self.spline = RegularGridInterpolator( listofpoint, llh, bounds_error=False, fill_value=fill_value )