xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
MIT License
138 stars 68 forks source link

[larix] `process_normalization` fails #504

Closed maurov closed 8 months ago

maurov commented 8 months ago

@newville

Related to what I was observing in #501, I have tested with the latest master version and I have the same problem with process_normalization when loading files.

With specfile_importer:

  File "/home/mauro/devel/xraylarch/larch/wxlib/specfile_importer.py", line 547, in onOK
    self.read_ok_cb(script, self.path, scanlist,
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1266, in onReadSpecfile_OK
    dgroup = self.install_group(gname, displayname, journal=jrnl)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1642, in install_group
    self.ShowFile(groupname=groupname, filename=filename,
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 460, in ShowFile
    self.process_normalization(dgroup, force=True, use_form=False)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 398, in process_normalization
    self.get_nbpage('xasnorm')[1].process(dgroup, force=force, use_form=use_form)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasnorm_panel.py", line 936, in process
    val = f"{int(form[attr])}"
ValueError: invalid literal for int() with base 10: 'linear'
Encode Warning: generic object dump for  <larch.io.specfile_reader.DataSourceSpecH5 object at 0x7f3ae430b940>

With columnframe:

  File "/home/mauro/devel/xraylarch/larch/wxlib/columnframe.py", line 1127, in onOK
    self.read_ok_cb(script, self.path, conf)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1509, in onRead_OK
    self.install_group(groupname, filename, source=path, journal=journal)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1642, in install_group
    self.ShowFile(groupname=groupname, filename=filename,
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 460, in ShowFile
    self.process_normalization(dgroup, force=True, use_form=False)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 398, in process_normalization
    self.get_nbpage('xasnorm')[1].process(dgroup, force=force, use_form=use_form)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasnorm_panel.py", line 936, in process
    val = f"{int(form[attr])}"
ValueError: invalid literal for int() with base 10: 'linear'

Do you have an idea why this is happening? I am afraid this should fixed before next release.

newville commented 8 months ago

@maurov ack, okay, I think this is now fixed... doing a bunch of testing of various inputs now.

maurov commented 8 months ago

@newville thanks for looking into this. I updated to latest master but I still get an error:

Traceback (most recent call last):
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasnorm_panel.py", line 463, in set_nnorm_widget
    nnorm = int(nnorm)
ValueError: invalid literal for int() with base 10: 'linear'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mauro/devel/xraylarch/larch/wxlib/columnframe.py", line 1127, in onOK
    self.read_ok_cb(script, self.path, conf)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1509, in onRead_OK
    self.install_group(groupname, filename, source=path, journal=journal)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 1642, in install_group
    self.ShowFile(groupname=groupname, filename=filename,
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasgui.py", line 480, in ShowFile
    cur_panel.fill_form(dgroup)
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasnorm_panel.py", line 421, in fill_form
    self.set_nnorm_widget(opts.get('nnorm'))
  File "/home/mauro/devel/xraylarch/larch/wxxas/xasnorm_panel.py", line 465, in set_nnorm_widget
    nnorm = nnorm_default
UnboundLocalError: local variable 'nnorm_default' referenced before assignment
newville commented 8 months ago

@maurov Thanks for checking... Can you send an example file? Apparently, I am not triggering those bugs with the files I'm using for testing.

maurov commented 8 months ago

@newville I was checking with the files in examples/xafsdata/beamlines. b577bc68c0a54ddf05a7cd9b57ae07a8f54ec750 seems have fixed the problem.