Skip to content

Commit

Permalink
spell-check all files
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jun 27, 2024
1 parent c94ead6 commit 6357ea4
Show file tree
Hide file tree
Showing 23 changed files with 239 additions and 74 deletions.
150 changes: 150 additions & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Custom Dictionary Words
allclose
ALLUSERSPROFILE
amperemeter
analyser
arange
archiver
argwhere
ARPES
astype
autoclass
automodule
autoreload
autosummary
axhline
AXISNAME
axvline
basepath
bitshift
bysource
calib
checkscan
clim
codemirror
coeff
COLLECTIONCOLUMN
colorbar
COMPES
configpath
Croping
cropit
damatrix
dapolymatrix
dataconverter
dataframe
delaystage
dtype
dxda
dxde
dyda
dyde
Ekin
electronanalyser
elems
endstation
energydispersion
eshift
faddr
Faradayweg
fftshift
filt
fluence
fspath
FWHM
genindex
hline
ifftshift
IMAGEJ
imgj
imread
imshow
imutils
imwrite
Interp
ipykernel
ipympl
ipython
ipywidgets
irfft
kernelspec
kwds
labview
Laurenz
lensmodes
lineh
linev
listf
literalinclude
loadtxt
matplotlib
maxdepth
mbar
meshgrid
modindex
mpes
nanos
nbagg
nbconvert
nbformat
nbsphinx
ndarray
ndarrays
ndim
ndimage
ndims
ndmin
nesteddict
nestedentry
numpy
nxdl
Nxpix
Nxpixels
Nypixels
OPCPA
pcolormesh
Phoibos
polyfit
polyval
pyenv
pygments
pynxtools
pyplot
pyproject
quickstart
RAWDATA
Rettig
rfft
rrvec
rtol
rtype
scanvector
specsanalyzer
Specslab
specsscan
stype
tempa
tifffile
tmpdirname
toctree
tomlkit
topfloor
tqdm
typehints
TZCYXS
undoc
venv
vline
vmax
vmin
xarray
xarrays
xdata
xgrid
Xmpes
xpos
Xuser
ydata
ygrid
ypos
zinner
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@ dmypy.json
*.h5
*.tiff
*.nxs
*.pxp

# poetry
poetry.toml
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is the package `specsanalyzer` for conversion and handling of SPECS Phoibos

This package contains two modules:
`specsanalyzer` is a package to import and convert MCP analyzer images from SPECS Phoibos analyzers into energy and emission angle/physical coordinates.
`specsscan` is a Python package for loading Specs Phoibos scans accquired with the labview software developed at FHI/EPFL
`specsscan` is a Python package for loading Specs Phoibos scans acquired with the labview software developed at FHI/EPFL

Tutorials for usage and the API documentation can be found in the [Documentation](https://opencompes.github.io/specsanalyzer/)

Expand Down Expand Up @@ -47,9 +47,9 @@ python -m ipykernel install --user --name=specs_kernel
```

#### Configuration and calib2d file
The conversion procedures require to set up several configuration parameters in a config file. An example config file is provided as part of the package (see documentation). Configuration files can either be passed to the class constructures, or are read from system-wide or user-defined locations (see documentation).
The conversion procedures require to set up several configuration parameters in a config file. An example config file is provided as part of the package (see documentation). Configuration files can either be passed to the class constructors, or are read from system-wide or user-defined locations (see documentation).

Most importantly, conversion of analyzer data to energy/angular coordinates requires detector calibration data provided by the manufacturer. The corresponding *.calib2d file (e.g. phoibos150.calbid2d) are provided together with the spectrometer software, and need to be set in the config file.
Most importantly, conversion of analyzer data to energy/angular coordinates requires detector calibration data provided by the manufacturer. The corresponding *.calib2d file (e.g. phoibos150.calib2d) are provided together with the spectrometer software, and need to be set in the config file.

### For Contributors

Expand Down
23 changes: 23 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "0.2",
"ignorePaths": [
"./tests/data/*",
"*.toml",
"Makefile",
"*.bat",
"*.pxp"
],
"dictionaryDefinitions": [
{
"name": "custom-dictionary",
"path": "./.cspell/custom-dictionary.txt",
"addWords": true
}
],
"dictionaries": [
"custom-dictionary"
],
"words": [],
"ignoreWords": [],
"import": []
}
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def _get_project_meta():
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx_autodoc_typehints",
# "bokeh.sphinxext.bokeh_autodoc",
# "bokeh.sphinxext.bokeh_plot",
"nbsphinx",
"myst_parser",
]
Expand Down
10 changes: 0 additions & 10 deletions docs/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/specsanalyzer/config.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Config
===================================================
The config module contains a mechanis to collect configuration parameters from various sources and configuration files, and to combine them in a hierachical manner into a single, consistent configuration dictionary.
The config module contains a mechanics to collect configuration parameters from various sources and configuration files, and to combine them in a hierarchical manner into a single, consistent configuration dictionary.
It will load an (optional) provided config file, or alternatively use a passed python dictionary as initial config dictionary, and subsequently look for the following additional config files to load:

* ``folder_config``: A config file of name :file:`specs_config.yaml` in the current working directory. This is mostly intended to pass calibration parameters of the workflow between different notebook instances.
Expand Down
4 changes: 2 additions & 2 deletions specsanalyzer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ def load_config(config_path: str) -> dict:
def save_config(config_dict: dict, config_path: str, overwrite: bool = False):
"""Function to save a given config dictionary to a json or yaml file. Normally, it loads any
existing file of the given name, and keeps any existing dictionary keys not present in the
provided dictionary. The overwrite option creates a fully empty dictionry first.
provided dictionary. The overwrite option creates a fully empty dictionary first.
Args:
config_dict (dict): The dictionry to save.
config_dict (dict): The dictionary to save.
config_path (str): A string containing the path to the file where to save the dictionary
to.
overwrite (bool, optional): Option to overwrite an existing file with the given dictionary.
Expand Down
2 changes: 1 addition & 1 deletion specsanalyzer/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ magnification: 4.54
angle_offset_px: 0
# offset in pixels along the energy dispersing axis
energy_offset_px: 0
# flag controlling the application of a Fourier filter to remove grid artefacts
# flag controlling the application of a Fourier filter to remove grid artifacts
apply_fft_filter: false
36 changes: 18 additions & 18 deletions specsanalyzer/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from scipy.ndimage import map_coordinates


def get_damatrix_fromcalib2d(
def get_damatrix_from_calib2d(
lens_mode: str,
kinetic_energy: float,
pass_energy: float,
Expand All @@ -14,7 +14,7 @@ def get_damatrix_fromcalib2d(
) -> tuple[float, np.ndarray, float, str, list[str]]:
"""This function estimates the best angular conversion coefficients for the current analyser
mode, starting from a dictionary containing the specs .calib2d database. A linear interpolation
is performed from the tabulated coefficients based on the retardatio ratio value.
is performed from the tabulated coefficients based on the retardation ratio value.
Args:
lens_mode (str): the lens mode string description
Expand Down Expand Up @@ -104,7 +104,7 @@ def bisection(array: np.ndarray, value: float) -> int:
Given an ``array`` , and given a ``value`` , returns an index j such that ``value`` is between
array[j] and array[j+1]. ``array`` must be monotonic increasing. j=-1 or j=len(array) is
returned to indicate that ``value`` is out of range below and above respectively.
This should mimick the function BinarySearch in igor pro 6
This should mimic the function BinarySearch in igor pro 6
Args:
array (np.ndarray): ordered array
Expand Down Expand Up @@ -148,7 +148,7 @@ def second_closest_rr(rrvec: np.ndarray, closest_rr_index: int) -> int:
int: nearest rr index to calculate the best da coefficients
"""
if closest_rr_index == (rrvec.size - 1):
# we are the edge: the behaviour is to not change the index
# we are the edge: the behavior is to not change the index
second_closest_rr_index = closest_rr_index
else:
second_closest_rr_index = closest_rr_index + 1
Expand All @@ -160,7 +160,7 @@ def get_rr_da(
lens_mode: str,
calib2d_dict: dict,
) -> tuple[np.ndarray, np.ndarray]:
"""Get the retardatio ratios and the da for a certain lens mode from the confugaration
"""Get the retardation ratios and the da for a certain lens mode from the configuration
dictionary
Args:
Expand All @@ -173,7 +173,7 @@ def get_rr_da(
ValueError: Raised if no da values are found for the given mode
Returns:
tuple[np.ndarray, np.ndarray]: rr vector, matrix of da coeffients
tuple[np.ndarray, np.ndarray]: rr vector, matrix of da coefficients
per row row0 : da1, row1: da3, .. up to da7.
Non angle resolved lens modes do only posses da1.
"""
Expand Down Expand Up @@ -236,26 +236,26 @@ def calculate_polynomial_coef_da(
pass_energy: float,
e_shift: np.ndarray,
) -> np.ndarray:
"""Given the da coeffiecients contained in the scanpareters, the program calculates the energy
"""Given the da coefficients contained in the scan parameters, the program calculates the energy
range based on the eshift parameter and fits a second order polynomial to the tabulated values.
The polynomial coefficients are packed in the dapolymatrix array (row0 da1, row1 da3, ..)
The function returns a matrix of the fit coeffiecients, given the physical energy scale
The function returns a matrix of the fit coefficients, given the physical energy scale
Each line of the matrix is a set of coefficients for each of the da[i] corrections
Args:
da_matrix (np.ndarray): the matrix of interpolated da coefficients
kinetic_energy (float): photoelectorn kinetic energy
kinetic_energy (float): photoelectron kinetic energy
pass_energy (float): analyser pass energy
e_shift (np.ndarray): e shift parameter, defining the energy
range around the center for the polynomial fit of the da coefficients
Returns:
np.ndarray: dapolymatrix containg the fit results (row0 da1, row1 da3, ..)
np.ndarray: dapolymatrix containing the fit results (row0 da1, row1 da3, ..)
"""
# calcualte the energy values for each da, given the eshift
# calculate the energy values for each da, given the eshift
da_energy = e_shift * pass_energy + kinetic_energy * np.ones(e_shift.shape)

# create the polynomial coeffiecient matrix, each is a second order polynomial
# create the polynomial coefficient matrix, each is a second order polynomial
da_poly_matrix = np.zeros(da_matrix.shape)

for i in range(0, da_matrix.shape[0]):
Expand All @@ -279,12 +279,12 @@ def zinner(
mcp withing the a_inner boundaries
Args:
kinetic_energy (flonp.ndarrayat): kinetic energies
kinetic_energy (np.ndarray): kinetic energies
angle (np.ndarray): angles
da_poly_matrix (np.ndarray): matrix with polynomial coefficients
Returns:
np.ndarray: returns the calcualted positions on the mcp, valid for low angles (< ainner)
np.ndarray: returns the calculated positions on the mcp, valid for low angles (< a_inner)
"""
out = np.zeros(angle.shape, float)

Expand All @@ -303,7 +303,7 @@ def zinner_diff(
da_poly_matrix: np.ndarray,
) -> np.ndarray:
"""Auxiliary function for mcp_position_mm, uses kinetic energy and angle starting from the
dapolymatrix, to get the zinner_diff coefficient to coorect the electron arrival position on
dapolymatrix, to get the zinner_diff coefficient to correct the electron arrival position on
the mcp outside the a_inner boundaries
Args:
Expand All @@ -313,7 +313,7 @@ def zinner_diff(
Returns:
np.ndarray: zinner_diff the correction for the zinner position on the MCP for high
(>ainner) angles.
(>a_inner) angles.
"""

out = np.zeros(angle.shape, float)
Expand Down Expand Up @@ -349,7 +349,7 @@ def mcp_position_mm(
np.ndarray: lateral position of photoelectron on the mcp (angular dispersing axis)
"""

# define two angular regions: within and outsied the a_inner boundaries
# define two angular regions: within and outside the a_inner boundaries
mask = np.less_equal(np.abs(angle), a_inner)

a_inner_vec = np.ones(angle.shape) * a_inner
Expand Down Expand Up @@ -513,7 +513,7 @@ def physical_unit_data(
e_correction_matrix = np.ones(angular_correction_matrix.shape) * e_correction

# flatten the x and y to a 2 x N coordinates array
# N = Nxpix x Nypixels
# N = Nxpixels x Nypixels
coords = np.array([angular_correction_matrix.flatten(), e_correction_matrix.flatten()])

# the image is expressed as intensity vs pixels,
Expand Down
Loading

0 comments on commit 6357ea4

Please sign in to comment.