Ejemplo n.º 1
0
 def load_BCF(self,bcf_file):
     self.bcf_file = bcf_file
     bcf=bru.BCF_reader(bcf_file)
     header_file = bcf.get_file('EDSDatabase/HeaderData')
     header_byte_str = header_file.get_as_BytesIO_string().getvalue()
     hd_bt_str = bru.fix_dec_patterns.sub(b'\\1.\\2', header_byte_str)  
     root = ET.fromstring(hd_bt_str)
     root = root.find("./ClassInstance[@Type='TRTSpectrumDatabase']")
     self.root = root
Ejemplo n.º 2
0
def test_fast_bcf():
    thingy = pytest.importorskip("hyperspy.io_plugins.unbcf_fast")
    from hyperspy.io_plugins import bruker
    for bcffile in test_files:
        filename = os.path.join(my_path, 'bruker_data', bcffile)
        thingy = bruker.BCF_reader(filename)
        for j in range(2, 5, 1):
            print('downsampling:', j)
            bruker.fast_unbcf = True              # manually enabling fast parsing
            hmap1 = thingy.parse_hypermap(downsample=j)    # using cython
            bruker.fast_unbcf = False            # manually disabling fast parsing
            hmap2 = thingy.parse_hypermap(downsample=j)    # py implementation
            np.testing.assert_array_equal(hmap1, hmap2)
Ejemplo n.º 3
0
def load_bcf_dump_xml(bcf_file,xml_file):
    '''
    Loads bcf file, dumps header contents to XML file
    s'''
    # hd_bt_str = _load_bruker_bcf_as_bytestream(bcf_file)
    
    bcf=bru.BCF_reader(import_file)
    header_file = bcf.get_file('EDSDatabase/HeaderData')
    header_byte_str = header_file.get_as_BytesIO_string().getvalue()
    hd_bt_str = bru.fix_dec_patterns.sub(b'\\1.\\2', header_byte_str)  

    xml_file = open(xml_file,'wb')
    xml_file.write(hd_bt_str)
    xml_file.close()
Ejemplo n.º 4
0
    def _load_bruker_bcf_as_xml(self, import_file):
        """
        Loads Bruker BCF file as XML,
        useful for mosaic extraction
        
        Returns root xml tree object
        """

        # for mosaic extraction
        bcf = bru.BCF_reader(import_file)

        header_file = bcf.get_file('EDSDatabase/HeaderData')

        header_byte_str = header_file.get_as_BytesIO_string().getvalue()
        hd_bt_str = bru.fix_dec_patterns.sub(b'\\1.\\2', header_byte_str)

        root = ET.fromstring(hd_bt_str)
        root = root.find("./ClassInstance[@Type='TRTSpectrumDatabase']")

        return root
Ejemplo n.º 5
0
Created on Sat Apr 24 22:30:26 2021

@author: Mike
"""

import hyperspy.api as hs
import os
import hyperspy.io_plugins.bruker as brk

bcf_file = 'kvr-btm-180deg-100ms-1det.bcf'

os.chdir(u'D:/Google Drive/археология/soft/test')
#%%
bcf = hs.load('kvr-btm-180deg-100ms-1det.bcf')
#%%
b1 = brk.BCF_reader(bcf_file)  #brk.BCF_reader class

h = b1.header  #brk.HyperHeader class instance

d2 = h.estimate_map_channels()  # incorrect map channels

# =============================================================================
# bruker_hv_range = self.spectra_data[index].amplification / 1000
# if self.hv >= bruker_hv_range:
#     return self.spectra_data[index].data.shape[0]
# else:
#     return self.spectra_data[index].energy_to_channel(self.hv)
# =============================================================================

h.spectra_data[0].amplification  # line 768, = 40 000
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
"""
Created on Sat Jul  3 09:56:12 2021

@author: Mike
"""
#%% init

import hyperspy.io_plugins.bruker as bru

import_file = 'fang-A.bcf'
#%% load file
bcf = bru.BCF_reader(import_file)

header_file = bcf.get_file('EDSDatabase/HeaderData')

header_byte_str = header_file.get_as_BytesIO_string().getvalue()
hd_bt_str = bru.fix_dec_patterns.sub(b'\\1.\\2', header_byte_str)
#%% dump xml file
h_file = open('h_file.xml', 'wb')
h_file.write(hd_bt_str)
h_file.close()