Skip to content

Commit

Permalink
Update doctring and reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
AitorBengoechea committed Jun 27, 2022
1 parent 760eaf1 commit 8910d9f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
9 changes: 2 additions & 7 deletions sandy/core/lpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,8 @@ def custom_perturbation(self, pert):
Parameters
----------
pert : `sandy.Pert`
pert : `sandy.Pert` or pd.Dataframe
tabulated perturbations
mat : `int`, optional
MAT material number. The default is None.
mt : `int`, optional
MT reaction number. The default is None.
p : `int`, optional
order of the Legendre polynomial coefficient. The default is None.
Returns
-------
Expand Down Expand Up @@ -224,6 +218,7 @@ def custom_perturbation(self, pert):
Name: 1, dtype: float64
"""
pert_ = sandy.Pert(pert) if not isinstance(pert, sandy.Pert) else pert
# Endf6 mf=34 incosistency solver:
if 'L' in pert_.data.columns.names:
pert_.data.columns = pert_.data.columns.set_names('P', level='L')

Expand Down
4 changes: 0 additions & 4 deletions sandy/core/xs.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ def custom_perturbation(self, pert, **kwargs):
pert : `sandy.Pert` or `pd.Dataframe`
tabulated perturbations with the index representing the energy grid
and the columns representing MT.
mat : `int`, optional
MAT number. The default is None.
mt : `int`, optional
MT number. The default is None.
**kwargs : `dict`
keyword argument to pass to `sandy.Xs._recontruct_sums`.
Expand Down
9 changes: 6 additions & 3 deletions sandy/pert.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Pert():
Attributes
----------
data : `pandas.Series`
series of groupwise perturbation coefficients
data : `pandas.DataFrame`
DataFrame of groupwise perturbation coefficients
left : `pandas.Series`
perturbation coefficients with left-bounds of the energy intervals as
index
Expand Down Expand Up @@ -114,7 +114,7 @@ def right(self):
Returns
-------
`pandas.Series`
`pandas.DataFrame`
perturbations
Examples
Expand Down Expand Up @@ -240,6 +240,9 @@ def reshape(self, eg, inplace=False, right_values=1):
monotonic energy grid with non-negative values
inplace : `bool`, optional, default is `False`
apply changes **inplace** and return `None`
right_values: `float`, optional, default is 1
This value will be used to fill in for requested points outside of
the data range at the upper limit.
Returns
-------
Expand Down
26 changes: 14 additions & 12 deletions sandy/pfns.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,17 @@ def normalize(self):
1 9437 18 0 2.00000e+00 1.00000e+00
"""
integrals = self.get_integrals()
data = self.data.copy()
keys = ["MAT", "MT", "K", "EIN"]
out = []
for (mat, mt, k, ein), chi in data.groupby(keys):
mask = (integrals.MAT == mat) & \
(integrals.MT == mt) & \
(integrals.K == k) & \
(integrals.EIN == ein)
chi.loc[:, "VALUE"] /= integrals[mask].INTEGRAL.squeeze()
out.append(chi)
df = pd.concat(out)

def foo(df, integrals):
data = df.iloc[0]
mask = (integrals.MAT == data.MAT) & \
(integrals.MT == data.MT) & \
(integrals.K == data.K) & \
(integrals.EIN == data.EIN)
df.loc[:, "VALUE"] /= integrals[mask].INTEGRAL.squeeze()
return df

df = self.data.groupby(["MAT", "MT", "K", "EIN"]).apply(foo, integrals)
return self.__class__(df)

def custom_perturbation(self, pert):
Expand All @@ -445,7 +445,7 @@ def custom_perturbation(self, pert):
Parameters
----------
pert : `sandy.Pert` or `pd.Series`
pert : `sandy.Pert` or `pd.DataFrame`
perturbation object.
Returns
Expand Down Expand Up @@ -504,8 +504,10 @@ def foo(df, pert):
.values.flatten()
df["VALUE"] = df['VALUE'].values + pert_
return df

pert_edistr = self.data.groupby(['MAT', 'MT', 'K', 'EIN'])\
.apply(foo, u_pert)

return self.__class__(pert_edistr).normalize()

def _perturb(self, pert, method=2, normalize=True, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions sandy/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ def reshape_bfill(x, y, xnew, left_values="first", right_values=0):
new energy grid
y : `numpy.ndarray` with at least two entries and same length as `x`
array to interpolate
left_values:`str` or `float`
This value will be used to fill in for requested points outside of the
data range at the lower limit.ç
right_values:`str` or `float`
This value will be used to fill in for requested points outside of the
data range at the upper limit.
Returns
-------
Expand Down

0 comments on commit 8910d9f

Please sign in to comment.