Skip to content

Commit

Permalink
Merge branch 'main' into doc-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne authored Jul 14, 2023
2 parents cf0754b + cf48f32 commit f1016e6
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3.5.3
- uses: actions/setup-python@v4
- uses: psf/black@stable
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
VERSION: ${{ env.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.3
- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
Expand All @@ -47,7 +47,7 @@ jobs:
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3.5.3

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
PYTEST_ARGS_COVERAGE: --cov=lumispy --cov-report=xml
LABEL: /coverage
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3.5.3

- uses: actions/setup-python@v4
name: Install Python
Expand Down
16 changes: 16 additions & 0 deletions doc/source/user_guide/signal_tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,19 @@ The default operational mode is ``inplace=False`` (a new signal object is return
>>> s.remove_negative(0.1)
.. _crop_edges:

Crop edges
==========

The function :py:meth:`~.signals.common_luminescence.CommonLumi.crop_edges`
removes the specified number of pixels from all four edges of a spectral map.
It is a convenience wrapper for the ``inav`` :external+hyperspy:ref:`method in
HyperSpy <signal.indexing>`.

.. code-block:: python
>>> s.crop_edges(crop_px=2)
*[TODO: add possibility to crop different amounts of pixels on different sides]*
61 changes: 44 additions & 17 deletions doc/source/user_guide/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Utility functions

This section summarizes various useful functions implemented in LumiSpy.


.. _join_spectra:

Join spectra
Expand All @@ -27,27 +26,53 @@ signals in the range of +/- 50 pixels around the centre of the overlapping regio
>>> s = lum.join_spectra([s1,s2])
.. _spectral_map_utils:
.. _exporting_text_files:

Utilities for spectral maps
===========================
Exporting text files
====================

The function :py:meth:`~.signals.common_luminescence.CommonLumi.crop_edges`
removes the specified number of pixels from all four edges of a spectral map.
It is a convenience wrapper for the ``inav`` :external+hyperspy:ref:`method in
HyperSpy <signal.indexing>`.
LumiSpy includes a function :py:meth:`~.signals.luminescence_spectrum.LumiSpectrum.savetxt`
that exports the data of a signal object
(with not more than two axes) to a simple `.txt` (or `.csv`) file. Can facilitate
data transfer to other programs, but no metadata is included. By default,
the axes are saved as first column (and row in 2d case). Set ``axes=False`` to
save the data object only. The function can also ``transpose`` (default ``False``)
the dataset or take a custom ``fmt`` (default ``%.5f``) or delimiter (default
``\t``) string.

.. code-block:: python
>>> s.crop_edges(crop_px=2)
*[TODO: add possibility to crop different amounts of pixels on different sides]*

>>> import lumispy as lum
>>> import numpy as np
...
>>> # Spectrum:
>>> S = lum.signals.LumiSpectrum(np.arange(5))
>>> lum.savetxt(S, 'spectrum.txt')
0.00000 0.00000
1.00000 1.00000
2.00000 2.00000
3.00000 3.00000
4.00000 4.00000
...
>>> # Linescan:
>>> L = lum.signals.LumiSpectrum(np.arange(25).reshape((5,5)))
>>> lum.savetxt(L, 'linescan.txt')
0.00000 0.00000 1.00000 2.00000 3.00000 4.00000
0.00000 0.00000 5.00000 10.00000 15.00000 20.00000
1.00000 1.00000 6.00000 11.00000 16.00000 21.00000
2.00000 2.00000 7.00000 12.00000 17.00000 22.00000
3.00000 3.00000 8.00000 13.00000 18.00000 23.00000
4.00000 4.00000 9.00000 14.00000 19.00000 24.00000
.. _mathematical_utilities:

Mathematical routines
=====================

.. _unit_conversion:

Unit conversion
===============
---------------

For convenience, LumiSpy provides functions that convert between different
units commonly used for the signal axis. Namely,
Expand All @@ -64,8 +89,10 @@ index of air.
.. _grating_equation:

Solving the grating equation
============================
----------------------------

The function :py:func:`~.utils.axes.solve_grating_equation` (relationship between
wavelength and pixel position in the detector plane) follows the conventions
described in the tutorial from `Horiba Scientific
<https://horiba.com/uk/scientific/products/optics-tutorial/wavelength-pixel-position>`_.

The function :py:func:`~.utils.axes.solve_grating_equation` follows the
conventions described in the tutorial from
`Horiba Scientific <https://horiba.com/uk/scientific/products/optics-tutorial/wavelength-pixel-position>`_.
7 changes: 3 additions & 4 deletions lumispy/tests/signals/test_cl_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ def test__make_signal_mask(self):

def test_remove_spikes(self):
s = CLSpectrum(np.ones((2, 3, 30)))
np.random.seed(1)
s.add_gaussian_noise(1e-5)
# Add three spikes
s.data[1, 0, 1] += 2
s.data[0, 2, 29] += 1
s.data[0, 2, 29] += 1.001

if not "threshold" in getfullargspec(s.spikes_removal_tool)[0]:
try:
Expand All @@ -67,7 +66,7 @@ def test_remove_spikes(self):
s1 = s.remove_spikes()

np.testing.assert_almost_equal(s1.data[1, 0, 1], 1, decimal=4)
# np.testing.assert_almost_equal(s1.data[0, 2, 29], 1, decimal=4)
np.testing.assert_almost_equal(s1.data[0, 2, 29], 1, decimal=4)

s3 = s.remove_spikes(show_diagnosis_histogram=True)
hist_data = s._spikes_diagnosis(
Expand All @@ -82,7 +81,7 @@ def test_remove_spikes(self):
expected_data[-1] = 1
np.testing.assert_allclose(hist_data.data, expected_data)
np.testing.assert_almost_equal(s3.data[1, 0, 1], 1, decimal=4)
# np.testing.assert_almost_equal(s3.data[0, 2, 29], 1, decimal=5)
np.testing.assert_almost_equal(s3.data[0, 2, 29], 1, decimal=4)

lum_roi = [1, 1]
s4 = s.remove_spikes(luminescence_roi=lum_roi, threshold=0.5)
Expand Down

0 comments on commit f1016e6

Please sign in to comment.