Skip to content

Commit

Permalink
Merge pull request #7 from ericpre/add_datasets
Browse files Browse the repository at this point in the history
Add hologram datasets
  • Loading branch information
ericpre committed Aug 30, 2023
2 parents 0862bae + 4fab963 commit cbfddce
Show file tree
Hide file tree
Showing 9 changed files with 802 additions and 13 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion holospy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from holospy import signals
from holospy import misc
from holospy import datasets

from . import release_info

__all__ = [
"signals",
"__version__",
"datasets",
"misc",
"signals",
]


def __dir__():
return sorted(__all__)


__version__ = release_info.version
__author__ = release_info.author
__copyright__ = release_info.copyright
Expand Down
Binary file not shown.
Binary file not shown.
97 changes: 97 additions & 0 deletions holospy/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*-
# Copyright 2007-2023 The HyperSpy developers
#
# This file is part of HyperSpy.
#
# HyperSpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HyperSpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.

from pathlib import Path
import warnings

import hyperspy.api as hs

__all__ = [
"Fe_needle_hologram",
"Fe_needle_reference_hologram",
]


def __dir__():
return sorted(__all__)


def _resolve_dir():
"""Returns the absolute path to this file's directory."""
return Path(__file__).resolve().parent


def Fe_needle_hologram():
"""
Load an object hologram image.
Notes
-----
Sample: Fe needle with YOx nanoparticle inclusions. See reference for more
details
Migunov, V. et al. Model-independent measurement of the charge density
distribution along an Fe atom probe needle using off-axis electron
holography without mean inner potential effects. J. Appl. Phys. 117,
134301 (2015). https://doi.org/10.1063/1.4916609
TEM: FEI Titan G2 60-300 HOLO
Boothroyd, C. et al. FEI Titan G2 60-300 HOLO. Journal of large-scale
research facilities JLSRF 2, 44 (2016).
https://doi.org/10.17815/jlsrf-2-70
Signal is loaded "read-only" to ensure data access regardless of
install location
"""

file_path = _resolve_dir().joinpath("01_holo_Vbp_130V_0V_bin2_crop.hdf5")
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UserWarning)
return hs.load(file_path, mode="r", reader="hspy")


def Fe_needle_reference_hologram():
"""
Load a reference hologram image.
Notes
-----
Sample: Fe needle with YOx nanoparticle inclusions. See reference for more
details
Migunov, V. et al. Model-independent measurement of the charge density
distribution along an Fe atom probe needle using off-axis electron
holography without mean inner potential effects. J. Appl. Phys. 117,
134301 (2015). https://doi.org/10.1063/1.4916609
TEM: FEI Titan G2 60-300 HOLO
Boothroyd, C. et al. FEI Titan G2 60-300 HOLO. Journal of large-scale
research facilities JLSRF 2, 44 (2016).
https://doi.org/10.17815/jlsrf-2-70
Signal is loaded "read-only" to ensure data access regardless of
install location
"""

file_path = _resolve_dir().joinpath("00_ref_Vbp_130V_0V_bin2_crop.hdf5")

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UserWarning)
return hs.load(file_path, mode="r", reader="hspy")
5 changes: 5 additions & 0 deletions holospy/signals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@

from .hologram_image import HologramImage, LazyHologramImage


__all__ = [
"HologramImage",
"LazyHologramImage",
]


def __dir__():
return sorted(__all__)
17 changes: 8 additions & 9 deletions holospy/signals/hologram_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ def estimate_sideband_position(
Examples
--------
>>> import hyperspy.api as hs
>>> s = hs.datasets.example_signals.object_hologram()
>>> import holospy as holo
>>> s = holo.datasets.Fe_needle_hologram()
>>> sb_position = s.estimate_sideband_position()
>>> sb_position.data
Expand Down Expand Up @@ -293,8 +292,8 @@ def estimate_sideband_size(
Examples
--------
>>> import hyperspy.api as hs
>>> s = hs.datasets.example_signals.object_hologram()
>>> import holospy as holo
>>> s = holo.datasets.Fe_needle_hologram()
>>> sb_position = s.estimate_sideband_position()
>>> sb_size = s.estimate_sideband_size(sb_position)
>>> sb_size.data
Expand Down Expand Up @@ -399,8 +398,8 @@ def reconstruct_phase(
Examples
--------
>>> import hyperspy.api as hs
>>> s = hs.datasets.example_signals.object_hologram()
>>> import holospy as holo
>>> s = holo.datasets.Fe_needle_hologram()
>>> sb_position = s.estimate_sideband_position()
>>> sb_size = s.estimate_sideband_size(sb_position)
>>> wave = s.reconstruct_phase(sb_position=sb_position, sb_size=sb_size)
Expand Down Expand Up @@ -785,8 +784,8 @@ def statistics(
Examples
--------
>>> import hyperspy.api as hs
>>> s = hs.datasets.example_signals.reference_hologram()
>>> import holospy as holo
>>> s = holo.datasets.Fe_needle_reference_hologram()
>>> sb_position = s.estimate_sideband_position(high_cf=True)
>>> s.statistics(sb_position=sb_position)
{'Fringe spacing (nm)': 3.4860442674236256,
Expand Down
6 changes: 4 additions & 2 deletions holospy/tests/signals/test_hologram_image_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import scipy.constants as constants

import hyperspy.api as hs
from hyperspy.datasets.example_signals import reference_hologram

import holospy as holo


# Set parameters outside the tests
Expand All @@ -44,7 +45,8 @@
class TestStatistics:
def setup_method(self, method):
# Set the stack
self.ref_holo = hs.stack([reference_hologram()] * 2)
s = holo.datasets.Fe_needle_reference_hologram()
self.ref_holo = hs.stack([s] * 2)
self.ref_holo = hs.stack([self.ref_holo] * 3)

# Parameters measured using Gatan HoloWorks:
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
python_requires=">=3.7",
package_data={
"": ["LICENSE", "README.rst"],
"holospy": ["*.py", "hyperspy_extension.yaml"],
"holospy": [
"datasets/01_holo_Vbp_130V_0V_bin2_crop.hdf5",
"datasets/00_ref_Vbp_130V_0V_bin2_crop.hdf5",
"hyperspy_extension.yaml",
],
},
)

0 comments on commit cbfddce

Please sign in to comment.