Skip to content

Commit

Permalink
🎨 Sort the methods in G class.
Browse files Browse the repository at this point in the history
In the future they are split into three
  • Loading branch information
arafune committed Apr 28, 2024
1 parent 5fa0519 commit 5ff8d78
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 186 deletions.
11 changes: 5 additions & 6 deletions src/arpes/analysis/band_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ def unpack_bands_from_fit(
label = identified_band_results.loc[first_coordinate].values.item()[i]

def dataarray_for_value(param_name: str, i: int = i, *, is_value: bool) -> xr.DataArray:
"""[TODO:summary].
"""Return DataArray representing the fit results.
Args:
param_name (str): [TODO:description]
i (int): [TODO:description]
is_value (bool): [TODO:description]
"""
values: NDArray[np.float_] = np.ndarray(
shape=identified_band_results.values.shape,
values: NDArray[np.float_] = np.zeros_like(
identified_band_results.values,
dtype=float,
)
it = np.nditer(values, flags=["multi_index"], op_flags=[["writeonly"]])
Expand All @@ -185,7 +185,6 @@ def dataarray_for_value(param_name: str, i: int = i, *, is_value: bool) -> xr.Da
param = band_results.values[it.multi_index].params[prefix + param_name]
it[0] = param.value if is_value else param.stderr
it.iternext()

return xr.DataArray(
values,
identified_band_results.coords,
Expand Down Expand Up @@ -219,8 +218,8 @@ def _identified_band_results_etc(
return of broadcast_model().results
weights (tuple[float, float, float]): weight values for sigma, amplitude, center
Returns:
[TODO:description]
Returns: tuple[xr.DataArray, dict[Hashable, float], list[str]]
identified_band_results, first_coordinate, prefixes
"""
band_results = band_results if isinstance(band_results, xr.DataArray) else band_results.results
prefixes = [component.prefix for component in band_results.values[0].model.components]
Expand Down
32 changes: 21 additions & 11 deletions src/arpes/models/band.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Band:
Attribute:
label (str): label of the band.
_data (xr.Dataset): consists of several DataArrays representing the fitting results.
_data (xr.Dataset): Dataset consists of several DataArrays representing the fitting results.
`data_vars` are "center", "center_stderr", "amplitude", "amplitude_stdrr",
"sigma", and "sigma_stderr"
"""
Expand All @@ -65,16 +65,7 @@ def velocity(self) -> xr.DataArray:
"""
spacing = float(self.coords[self.dims[0]][1] - self.coords[self.dims[0]][0])

def embed_nan(values: NDArray[np.float_], padding: int) -> NDArray[np.float_]:
embedded: NDArray[np.float_] = np.full(
shape=(values.shape[0] + 2 * padding,),
fill_value=np.nan,
dtype=np.float_,
)
embedded[padding:-padding] = values
return embedded

raw_values = embed_nan(self.center.values, 50)
raw_values = self.embed_nan(self.center.values, 50)

masked = np.copy(raw_values)
masked[raw_values != raw_values] = 0
Expand Down Expand Up @@ -178,6 +169,25 @@ def dims(self) -> tuple[str, ...]:
assert isinstance(self._data, xr.Dataset)
return self._data.center.dims

@staticmethod
def embed_nan(values: NDArray[np.float_], padding: int) -> NDArray[np.float_]:
"""Return np.ndarray padding before and after the original NDArray with nan.
Args:
values: [TODO:description]
padding: the length of the padding
Returns: NDArray[np.float_]
[TODO:description]
"""
embedded: NDArray[np.float_] = np.full(
shape=(values.shape[0] + 2 * padding,),
fill_value=np.nan,
dtype=np.float_,
)
embedded[padding:-padding] = values
return embedded


class MultifitBand(Band):
"""Convenience class that reimplements reading data out of a composite fit result."""
Expand Down
Loading

0 comments on commit 5ff8d78

Please sign in to comment.