erlab.accessors.kspace¶
Defines an accessor for momentum conversion related utilities.
Classes
|
A view of angle-scale compensation factors for momentum conversion. |
|
|
|
A class representing an offset view for an |
Exceptions
|
Raised when the data is not in the expected format for momentum conversion. |
- class erlab.accessors.kspace.AngleScaleView(xarray_obj)[source]¶
Bases:
objectA view of angle-scale compensation factors for momentum conversion.
The scale factors compensate extrinsic warping in the stored angle coordinates. Missing scale attributes default to
1.0. Momentum conversion usesraw angle * scalefor each axis.
- exception erlab.accessors.kspace.IncompleteDataError(kind, name)[source]¶
Bases:
ValueErrorRaised when the data is not in the expected format for momentum conversion.
See conventions for required data attributes and coordinates.
- class erlab.accessors.kspace.MomentumAccessor(xarray_obj)[source]¶
Bases:
ERLabDataArrayAccessorxarray.DataArray.kspaceaccessor for momentum conversion related utilities.This class provides convenient access to various momentum-related properties of a data object. It allows getting and setting properties such as configuration, inner potential, work function, angle resolution, slit axis, momentum axes, angle parameters, and offsets.
- property configuration: AxesConfiguration¶
Experimental configuration.
For data loaded with a properly implemented data loader plugin, the configuration attribute is automatically set upon loading. If the configuration is missing, the attributes of the data may have been lost since loading due to averaging or other operations. In such cases, try to reload the data after setting
xr.set_options(keep_attrs='True').See
erlab.constants.AxesConfigurationfor possible configurations.Data from some ARPES setups may have a dynamic configuration that changes per data. In such cases, the configuration should be converted with
xarray.DataArray.kspace.as_configuration().
- property inner_potential: float¶
Inner potential of the sample in eV.
The inner potential is stored in the
inner_potentialattribute of the data. If the inner potential is not set, a warning is issued and a default value of 10.0 eV is assumed.Note
This property provides a setter method that takes a float value and sets the data attribute accordingly.
Example
>>> data.kspace.inner_potential = 13.0 >>> data.kspace.inner_potential 13.0
- property work_function: float¶
Work function of the system in eV.
Here, the work function here refers to the work function of the entire system in electrical contact with the sample, which determines the Fermi level.
The work function is stored in the
sample_workfunctionattribute of the data. If not found, a warning is issued and a default value of 4.5 eV is assumed.Note
This property provides a setter method that takes a float value and sets the data attribute accordingly.
Example
>>> data.kspace.work_function = 4.5 >>> data.kspace.work_function 4.5
- property angle_resolution: float¶
Retrieve the angular resolution of the data in degrees.
Checks for the
angle_resolutionattribute of the data. If not found, a default value of 0.1° is silently assumed.This property is used in
best_kp_resolutionupon estimating momentum step sizes throughestimate_resolution.Note
This property provides a setter method that takes a float value and sets the data attribute accordingly.
Example
>>> data.kspace.angle_resolution = 0.05 >>> data.kspace.angle_resolution 0.05
- property angle_scales: AngleScaleView¶
Angle-scale compensation factors used in momentum conversion.
The mapping has
"alpha"and"beta"keys. Values are stored in the DataArray attributesalpha_scaleandbeta_scaleand must be finite positive scalars. Use these factors sparingly to compensate known extrinsic angle-coordinate warping.Added in version 3.24.0.
- property slit_axis: Literal['kx', 'ky']¶
Momentum axis parallel to the analyzer slit.
- Returns:
str– Returns'kx'for type 1 configurations,'ky'otherwise.
- property other_axis: Literal['kx', 'ky']¶
Momentum axis perpendicular to the analyzer slit.
- Returns:
str– Returns'ky'for type 1 configurations,'kx'otherwise.
- property momentum_axes: tuple[Literal['kx', 'ky', 'kz'], ...]¶
Momentum axes of the data after conversion.
- Returns:
tuple– For photon energy dependent scans, it returns the slit axis and'kz'. For maps, it returns'kx'and'ky'. Otherwise, it returns only the slit axis.
- property angle_params: dict[str, float]¶
Parameters passed to
erlab.analysis.kspace.get_kconv_func().
- property offsets: OffsetView¶
Angle offsets used in momentum conversion.
- Returns:
OffsetView– A mapping between valid offset keys and their corresponding offsets.
Examples
View all offsets
>>> data.kspace.offsets {'delta': 0.0, 'xi': 0.0, 'beta': 0.0}
Offsets to dictionary
>>> dict(data.kspace.offsets) {'delta': 0.0, 'xi': 0.0, 'beta': 0.0}
View single offset
>>> data.kspace.offsets["beta"] 0.0
Set single offset
>>> data.kspace.offsets["beta"] = 3.0 >>> data.kspace.offsets {'delta': 0.0, 'xi': 0.0, 'beta': 3.0}
Overwrite offsets with dictionary
>>> data.kspace.offsets = dict(delta=1.5, xi=2.7) >>> data.kspace.offsets {'delta': 1.5, 'xi': 2.7, 'beta': 0.0}
Update offsets
>>> data.kspace.offsets.update(beta=0.1, xi=0.0) {'delta': 1.5, 'xi': 0.0, 'beta': 0.1}
Reset all offsets
>>> data.kspace.offsets.reset() {'delta': 0.0, 'xi': 0.0, 'beta': 0.0}
See also
set_normalMethod to set angle offsets from normal emission angles.
- set_normal(alpha, beta, *, delta=None, alpha_scale=None, beta_scale=None)[source]¶
Set offsets from normal emission angles.
This method sets the angle offsets so that the provided normal emission angles \((\alpha, \beta)\) in the raw data map to \((k_x, k_y) = (0, 0)\) in momentum space after angle-scale compensation is applied.
- Parameters:
alpha (
float) – Angle \(\alpha\) in degrees corresponding to sample normal emission.beta (
float) – Angle \(\beta\) in degrees corresponding to sample normal emission.delta (
float|None, default:None) – Optional azimuthal offset \(\delta\) in degrees. If omitted, the existingdeltaoffset is preserved.alpha_scale (
float|None, default:None) – Optional angle-scale compensation factors. If provided, the factors are stored before solving the offsets. Omitted factors use the currently stored scale values.beta_scale (
float|None, default:None) – Optional angle-scale compensation factors. If provided, the factors are stored before solving the offsets. Omitted factors use the currently stored scale values.
Examples
>>> data.kspace.set_normal(alpha=1.2, beta=-0.4) >>> dict(data.kspace.offsets) {'delta': 0.0, 'xi': -1.2, 'beta': -0.4}
Changed in version 3.24.0: Added
alpha_scaleandbeta_scalecompensation factors. The provided normal-emission angles are interpreted in raw data coordinates.See also
offsetsAttribute used to manipulate angle offsets directly.
- set_normal_like(other)[source]¶
Set offsets like another DataArray.
This method reads the normal emission angles implied by another DataArray’s current offsets and applies the same normal emission angles to the current data.
The azimuthal offset \(\delta\) and angle-scale compensation factors are copied as well.
- Parameters:
other (
DataArray) – Another DataArray in angle space whose current offsets define the reference normal emission position.
See also
set_normalMethod used to set angle offsets from explicitly provided normal emission angles.
- property best_kp_resolution: float¶
Estimated minimum in-plane momentum resolution.
The resolution is estimated with the kinetic energy and angular resolution:
\[\Delta k_{\parallel} \sim \sqrt{2 m_e E_k/\hbar^2} \cos(\alpha) \Delta\alpha\]
- property best_kz_resolution: float¶
Estimated minimum out-of-plane momentum resolution.
The resolution is estimated based on the mean free path [Seah and Dench, 1979] and the kinetic energy. Note that this is a rough estimate based on the universal curve of mean free path.
\[\Delta k_z \sim 1/\lambda\]
- estimate_bounds()[source]¶
Estimate the bounds of the data in momentum space.
- estimate_resolution(axis, lims=None, from_numpoints=False)[source]¶
Estimate target grid spacing for a momentum axis.
The returned value controls interpolation sampling. It is not an estimate of the instrumental momentum resolution.
- Parameters:
axis (
Literal['kx','ky','kz']) – Momentum axis for which to estimate the spacing.lims (
tuple[float,float] |None, default:None) – Lower and upper axis bounds in Å⁻¹, used whenfrom_numpointsisTrue. If omitted,estimate_bounds()supplies the bounds.from_numpoints (
bool, default:False) – IfTrue, estimate the spacing from the number of points in the relevant measured axis. IfFalse, estimate it from the angular resolution or, forkz, the photoelectron inelastic mean free path. Default isFalse.
- Returns:
float– Estimated target grid spacing in Å⁻¹.- Raises:
ValueError – If no photon energy axis is found in data for axis
'kz'.- Return type:
- convert_coords()[source]¶
Convert coordinates to momentum space.
Assign exact momentum coordinates without interpolating the intensity.
- Returns:
xarray.DataArray– A new array with the same dimensions, coordinate sampling, intensity values, name, and attributes as the input. The applicablekxandkycoordinates are added. For photon-energy-dependent data,kzis also added. All units for momentum are in Å⁻¹. The momentum coordinates can depend on more than one measured dimension. The input is not modified.- Return type:
- convert(bounds=None, resolution=None, *, method='linear', silent=True, **coords)[source]¶
Convert to momentum space.
- Parameters:
bounds (
dict[str,tuple[float,float]] |None, default:None) – Lower and upper bounds for each target momentum axis, in Å⁻¹. Keys can be"kx","ky", or"kz"when that axis applies to the input. Any omitted bound is estimated from the measured angular range.resolution (
dict[str,float] |None, default:None) – Target grid spacing for each momentum axis, in Å⁻¹. This is interpolation sampling, not instrumental momentum resolution. The final spacing can differ slightly because the requested bounds contain an integer number of intervals. If omitted, the target spacing is estimated from the input. For in-plane momentum, the estimate uses the angular resolution and kinetic energy. Forkz, the smaller estimate from the photon-energy sampling and the photoelectron inelastic mean free path is used.method (
str, default:'linear') – The interpolation method to use, passed toerlab.analysis.interpolate.interpn(). Using methods other than'linear'will result in slower performance.silent (
bool, default:True) – IfFalse, print progress messages during the conversion.**coords – Explicit one-dimensional target coordinates, in Å⁻¹, supplied as
kx,ky, orkz. An explicit coordinate overridesboundsandresolutionfor that axis.
- Returns:
xarray.DataArray– A new array containing the intensity interpolated on the target momentum grid. Automatically generated momentum coordinates are regularly spaced; explicit coordinates supplied throughcoordsare used as given. Unaffected dimensions retain their names. For fixed-photon-energy cuts,alphais replaced by the momentum axis parallel to the analyzer slit. For angular maps,alphaandbetaare replaced bykxandky. For photon-energy-dependent cuts,alphaandhvare replaced by the slit-parallel momentum axis andkz. TheeVdimension is retained and uses binding energy. The data name and attributes are preserved, and the interpolated values use a floating dtype. Points outside the measured angular coverage contain missing values. The input is not modified.- Return type:
Notes
This method converts the data to a new coordinate system specified by the provided bounds and resolution. It uses interpolation to map the data from the original coordinate system to the new one.
The converted data is returned as a DataArray object with updated coordinates and dimensions.
For non-
hvscans, if theeVaxis is all-positive, it is interpreted as kinetic energy and converted to binding energy. Forhv-dependent scans, theeVaxis must already be in binding energy.Examples
Set parameters and convert with automatic bounds and resolution:
data.kspace.offsets = {"delta": 0.1, "xi": 0.0, "beta": 0.3} data.kspace.work_function = 4.3 data.kspace.inner_potential = 12.0 converted_data = data.kspace.convert()
Convert with specified bounds and resolution:
bounds = {"kx": (0.0, 1.0), "ky": (-1.0, 1.0)} resolution = {"kx": 0.01, "ky": 0.01} converted_data = data.kspace.convert(bounds, resolution)
- interactive(**kwargs)[source]¶
Open the interactive momentum space conversion tool.
The interactive tool currently supports the following kinds of data:
2D data with
alphaandbetadimensions (constant energy surfaces)2D data with
alphaandeVdimensions, and a fixed or assignedbetacoordinate (angle-energy cuts)3D data with dimensions including
alphaandeV(including maps and hv-dependent cuts)
- as_configuration(configuration)[source]¶
Return a new DataArray with modified experimental configuration.
Use this method for an endstation that can acquire data in more than one physical configuration. The coordinates of the new DataArray are renamed by their physical roles to match the given configuration. The original data is not modified.
This method does not infer the acquisition geometry or repair arbitrary coordinate names from an incorrect loader implementation. The input must use the standard coordinate names for its current configuration.
- Parameters:
configuration (
AxesConfiguration|int) – The new configuration to apply.- Returns:
xarray.DataArray– A new array with unchanged data values, shape, dimension order, name, and dtype. Standard angle coordinates are renamed by their physical roles. A dimension is also renamed when it uses one of those coordinates. Other coordinates and attributes are retained, and theconfigurationattribute is updated.- Return type:
Note
This method assumes a conversion between 4 typical setups listed in the table in Nomenclature. Any non-standard setups should be handled by the user.
- hv_to_kz(hv)[source]¶
Return \(k_z\) for a given photon energy.
Useful when creating overlays on \(hν\)-dependent data.
- Parameters:
- Returns:
xarray.DataArray– Calculatedkzvalues in Å⁻¹. A scalar photon energy returns values along the applicableeVand slit-parallel momentum dimensions. An array of photon energies adds anhvdimension with the supplied values. The converted intensity data is not changed.- Return type:
Notes
This method returns an overlay curve \(k_z(hν)\) for converted momentum data. The returned values depend on the requested photon energies, binding energy, and in-plane momentum coordinates, but never on the converted data’s current
kzgrid.If the carried in-plane momentum perpendicular to the slit is independent of the converted
kzaxis, \(k_z\) is evaluated directly from\[k_z = \sqrt{\frac{2 m_e}{\hbar^2}(E_k + V_0) - k_x^2 - k_y^2}.\]If that carried orthogonal momentum depends on the converted
kzaxis, the method solves the sampled fixed-point relation\[k_z = \sqrt{\frac{2 m_e}{\hbar^2}(E_k + V_0) - k_{\mathrm{slit}}^2 - k_{\mathrm{other}}(k_z)^2}\]on the stored
kzgrid. If several sampled roots are present, a continuous branch is selected across the momentum axis along the slit. Slices with no sampled solution are returned asNaN. The legacy angle-roundtrip path is only used when the orthogonal in-plane momentum coordinate is unavailable.
- class erlab.accessors.kspace.OffsetView(xarray_obj)[source]¶
Bases:
objectA class representing an offset view for an
xarray.DataArray.This class provides a convenient way to access and manipulate angle offsets associated with the given data.
- Parameters:
xarray_obj (
DataArray) – Thexarray.DataArrayfor which the offset view is created.
- __len__() int:¶
Returns the number of valid offset keys.
- __iter__() Iterator[str, float]:[source]¶
Returns an iterator over the valid offset keys and their corresponding values.