Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bruker XRF #2694

Merged
merged 5 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ RELEASE_next_patch (Unreleased)
* Fix broken events when changing signal type `#2683 <https://github.com/hyperspy/hyperspy/pull/2683>`_
* Make DictionaryTreeBrowser lazy by default - see `#368 <https://github.com/hyperspy/hyperspy/issues/368>`_ (`#2623 <https://github.com/hyperspy/hyperspy/pull/2623>`_)
* Fix setting offset in rebin: the offset was changed in the wrong axis (`#2690 <https://github.com/hyperspy/hyperspy/pull/2690>`_)

* Fix reading XRF bruker file, close `#2689 <https://github.com/hyperspy/hyperspy/issues/2689>`_ (`#2694 <https://github.com/hyperspy/hyperspy/pull/2694>`_)
* Speed up setting CI on azure pipeline (`#2694 <https://github.com/hyperspy/hyperspy/pull/2694>`_)

Changelog
*********
Expand Down
3 changes: 1 addition & 2 deletions conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ dependencies:
- prettytable
- python
- python-dateutil
- pyusid
- pyyaml
- requests
- scikit-image
- scikit-learn
- scipy
- sparse
- sympy
- tifffile >=2019.07.26
- tifffile >=2019.07.26,!=2021.3.31
- toolz
- tqdm
- traits
Expand Down
2 changes: 1 addition & 1 deletion conda_environment_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
# We pin freetype and matplotlib for the image comparison
- freetype=2.9
- matplotlib=3.1
- matplotlib-base=3.1
- cython
- pytest
- pytest-mpl
Expand Down
11 changes: 9 additions & 2 deletions hyperspy/io_plugins/bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ def __init__(self, spectrum):
# ESMA could stand for Electron Scanning Microscope Analysis
spectrum_header = spectrum.find(
"./ClassInstance[@Type='TRTSpectrumHeader']")
xrf_header = TRTHeader.find("./ClassInstance[@Type='TRTXrfHeader']")

# map stuff from harware xml branch:
self.hardware_metadata = dictionarize(hardware_header)
Expand All @@ -530,15 +531,21 @@ def __init__(self, spectrum):
self.detector_metadata['DetLayers'][i.tag] = dict(i.attrib)

# map stuff from esma xml branch:
self.esma_metadata = dictionarize(esma_header)
if esma_header:
self.esma_metadata = dictionarize(esma_header)
if xrf_header:
xrf_header_dict = dictionarize(xrf_header)
self.esma_metadata = {
'PrimaryEnergy':xrf_header_dict['Voltage'],
'ElevationAngle':xrf_header_dict['ExcitationAngle']
}
# USED:
self.hv = self.esma_metadata['PrimaryEnergy']
self.elev_angle = self.esma_metadata['ElevationAngle']
date_time = gen_iso_date_time(spectrum_header)
if date_time is not None:
self.date, self.time = date_time

# map stuff from spectra xml branch:
self.spectrum_metadata = dictionarize(spectrum_header)
self.offset = self.spectrum_metadata['CalibAbs']
self.scale = self.spectrum_metadata['CalibLin']
Expand Down
1,467 changes: 1,467 additions & 0 deletions hyperspy/tests/io/bruker_data/bruker_m6_jetstream_file_example.spx

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions hyperspy/tests/io/test_bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,27 @@ def test_decimal_regex():
for j in dummy_xml_negative:
assert b'.' not in fix_dec_patterns.sub(b'\\1.\\2', j)


def test_all_spx_loads():
for spxfile in spx_files:
filename = os.path.join(my_path, 'bruker_data', spxfile)
s = load(filename)
assert s.data.dtype == np.uint64
assert s.metadata.Signal.signal_type == 'EDS_SEM'


def test_stand_alone_spx():
filename = os.path.join(my_path, 'bruker_data', 'bruker_nano.spx')
s = load(filename)
assert s.metadata.Sample.elements == ['Fe', 'S', 'Cu']
assert s.metadata.Acquisition_instrument.SEM.Detector.EDS.live_time == 7.385


def test_bruker_XRF():
# See https://github.com/hyperspy/hyperspy/issues/2689
# Bruker M6 Jetstream SPX
filename = os.path.join(my_path, 'bruker_data',
'bruker_m6_jetstream_file_example.spx')
s = load(filename)
assert s.metadata.Acquisition_instrument.TEM.Detector.EDS.live_time == 28.046
assert s.metadata.Acquisition_instrument.TEM.beam_energy == 50