Skip to content

Commit

Permalink
🎨 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Feb 16, 2024
1 parent cf92e56 commit 12e4504
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 34 deletions.
10 changes: 0 additions & 10 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,6 @@ Available as methods via ``.F`` accessor.
xarray_extensions.ARPESDatasetFitToolAccessor
xarray_extensions.ARPESFitToolsAccessor

NorthStar Laue
==============

Loading Laue data from the NorthStar DAQ program

.. autosummary::
:toctree: generated/

laue.load_laue

Plotting
========

Expand Down
13 changes: 13 additions & 0 deletions src/arpes/utilities/conversion/fast_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import math
from dataclasses import dataclass
from logging import DEBUG, INFO, Formatter, StreamHandler, getLogger
from typing import TYPE_CHECKING

import numba
Expand All @@ -23,6 +24,18 @@
"Interpolator",
]

LOGLEVELS = (DEBUG, INFO)
LOGLEVEL = LOGLEVELS[1]
logger = getLogger(__name__)
fmt = "%(asctime)s %(levelname)s %(name)s :%(message)s"
formatter = Formatter(fmt)
handler = StreamHandler()
handler.setLevel(LOGLEVEL)
logger.setLevel(LOGLEVEL)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.propagate = False


@numba.njit
def to_fractional_coordinate(
Expand Down
55 changes: 31 additions & 24 deletions src/arpes/utilities/conversion/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,46 @@ def convert_coordinate_forward(
Args:
data (XrTypes): The data defining the coordinate offsets and experiment geometry.
(should be DataArray)
(should be DataArray, and S.spectrum_type is "cut" or "map".)
coords (dict[str, float]): The coordinates of a *point* in angle-space to be converted.
k_coords: Coordinate for k-axis
Returns:
The location of the desired coordinate in momentum.
"""
data_arr = data if isinstance(data, xr.DataArray) else normalize_to_spectrum(data)
if "eV" in coords:
coords = dict(coords)
energy_coord = coords.pop("eV")
data_arr = data_arr.sel(eV=energy_coord, method="nearest")
elif "eV" in data_arr.dims:
warnings.warn(
"""You didn't specify an energy coordinate for the high symmetry point but the
dataset you provided has an energy dimension. This will likely be very
slow. Where possible, provide an energy coordinate
""",
stacklevel=2,
)
if not k_coords:
k_coords = {
"kx": np.linspace(-4, 4, 300),
"ky": np.linspace(-4, 4, 300),
}
data = data if isinstance(data, xr.DataArray) else normalize_to_spectrum(data)
assert data.spectrum_type in ("cut", "map"), 'spectrum type must be "cut" or "map"'
if data.spectrum_type == "map":
if "eV" in coords: # TODO: correction is required for "cut" data
coords = dict(coords)
energy_coord = coords.pop("eV")
data = data.sel(eV=energy_coord, method="nearest")
elif "eV" in data.dims:
warnings.warn(
"""You didn't specify an energy coordinate for the high symmetry point but the
dataset you provided has an energy dimension. This will likely be very
slow. Where possible, provide an energy coordinate
""",
stacklevel=2,
)
if not k_coords:
k_coords = {
"kx": np.linspace(-4, 4, 300),
"ky": np.linspace(-4, 4, 300),
}
elif not k_coords: # data.spectrum_type = map
k_coords = {"kp": np.linspace(-4, 4, 300)}
# Copying after taking a constant energy plane is much much cheaper
data_arr = data_arr.copy(deep=True)
data = data.copy(deep=True)

data_arr.loc[data_arr.G.round_coordinates(coords)] = data_arr.values.max() * 100000
data_arr = gaussian_filter_arr(data_arr, default_size=3)
kdata = convert_to_kspace(data_arr, **k_coords)
data.loc[data.G.round_coordinates(coords)] = data.values.max() * 100000
data = gaussian_filter_arr(data, default_size=3)
kdata = convert_to_kspace(data, **k_coords)
near_target = kdata.G.argmax_coords()
if "eV" in near_target and data.spectrum_type == "cut":
del near_target["eV"]
kdata_close = convert_to_kspace(
data_arr,
data,
**{k: np.linspace(v - 0.08, v + 0.08, 100) for k, v in near_target.items()},
)

Expand Down Expand Up @@ -185,6 +191,7 @@ def convert_through_angular_pair( # noqa: PLR0913
Returns:
The momentum cut passing first through `first_point` and then through `second_point`.
"""
assert data.spectrum_type == "map"
k_first_point = convert_coordinate_forward(data, first_point, **k_coords)
k_second_point = convert_coordinate_forward(data, second_point, **k_coords)

Expand Down

0 comments on commit 12e4504

Please sign in to comment.