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

UnicodeDecodeError when using Hartree-Slater GOS #95

Open
winston-song opened this issue Nov 14, 2024 · 2 comments
Open

UnicodeDecodeError when using Hartree-Slater GOS #95

winston-song opened this issue Nov 14, 2024 · 2 comments

Comments

@winston-song
Copy link

winston-song commented Nov 14, 2024

I enabled the access to the Gatan GOS table,

exspy.preferences.EELS.eels_gos_files_path = 'C:\ProgramData\Gatan\EELS Reference Data\HS GOS Tables'
exspy.preferences.save()

After I create a component here:

M_L3 = exspy.components.EELSCLEdge("Co_L3", GOS="Hartree-Slater")

It gives error that I cannot figure out since my code can work well for previous hyperspy version without exspy. Can anyone help me out?

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
Cell In[39], line 1
----> 1 M_L3 = exspy.components.EELSCLEdge("Co_L3", GOS="Hartree-Slater")

File ~\AppData\hyperspy-bundle\lib\site-packages\exspy\components\eels_cl_edge.py:189, in EELSCLEdge.__init__(self, element_subshell, GOS, gos_file_path)
    185     self.GOS = GoshGOS(
    186         element_subshell, gos_file_path=gos_file_path, source="dirac"
    187     )
    188 elif GOS == "Hartree-Slater":  # pragma: no cover
--> 189     self.GOS = HartreeSlaterGOS(element_subshell)
    190 elif GOS == "hydrogenic":
    191     self.GOS = HydrogenicGOS(element_subshell)

File ~\AppData\hyperspy-bundle\lib\site-packages\exspy\_misc\eels\base_gos.py:115, in TabulatedGOS.__init__(self, element_subshell)
    113 self.element, self.subshell = element_subshell.split("_")
    114 self.read_elements()
--> 115 self.read_gos_data()

File ~\AppData\hyperspy-bundle\lib\site-packages\exspy\_misc\eels\hartree_slater_gos.py:142, in HartreeSlaterGOS.read_gos_data(self)
    134     raise FileNotFoundError(
    135         "Parametrized Hartree-Slater GOS files not "
    136         f"found in {gos_root}. Please define a valid "
    137         "location for the files in the preferences as "
    138         "`preferences.EELS.eels_gos_files_path`."
    139     )
    141 with open(gos_file) as f:
--> 142     GOS_list = f.read().replace("\r", "").split()
    144 # Map the parameters
    145 info1_1 = float(GOS_list[2])

File ~\AppData\hyperspy-bundle\lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
     22 def decode(self, input, final=False):
---> 23     return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 71: character maps to <undefined>
@CSSFrancis
Copy link
Member

Perhaps this is related?

#91

@ericpre
Copy link
Member

ericpre commented Nov 15, 2024

By default, the default EELSModel now uses open GOS and doesn't need anymore the Gatan GOS - see exspy documentation: https://hyperspy.org/exspy/user_guide/eels.html#generalised-oscillator-strengths.

If you want to use the Gatan GOS, you will need the ones provided in old version of GMS... however, it is currently not documented when GMS started to use the new closed GOS.

@ericpre ericpre changed the title How to use the GOS to fit EELS? UnicodeDecodeError when using Hartree-Slater GOS Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants