You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix tutorial bug - sampling interval of the input PDF (0.1047...) is larger than the Nyquist interval (0.10471975...) #147
(diffpy.srmise_env) macbook@Macbook-Air-327 examples % srmise data/Ag_nyquist_qmax30.gr --plot --range 2 3.5
--baseline "Polynomial(degree=1)"
The input PDF appears to be missing information: The sampling interval of the input PDF (0.10471976036036036) is larger than the Nyquist interval (0.10471975511965977) defined by qmax=30.0. This information is irretrievable.
Traceback (most recent call last):
File "/Users/macbook/miniconda3/envs/diffpy.srmise_env/bin/srmise", line 10, in <module>
sys.exit(main())
~~~~^^
File "/Users/macbook/miniconda3/envs/diffpy.srmise_env/lib/python3.13/site-packages/diffpy/srmise/applications/extract.py", line 537, in main
cov = ext.extract()
File "/Users/macbook/miniconda3/envs/diffpy.srmise_env/lib/python3.13/site-packages/diffpy/srmise/pdfpeakextraction.py", line 417, in extract
pe.extract_single()
~~~~~~~~~~~~~~~~~^^
File "/Users/macbook/miniconda3/envs/diffpy.srmise_env/lib/python3.13/site-packages/diffpy/srmise/peakextraction.py", line 853, in extract_single
for step in dclusters:
^^^^^^^^^
File "/Users/macbook/miniconda3/envs/diffpy.srmise_env/lib/python3.13/site-packages/diffpy/srmise/dataclusters.py", line 208, in __next__
if test_idx < self.clusters[nearest_cluster[0], 0]:
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
zsh: command not found: --baseline
Proposed solution
It could be based on comparing two numbers that are meant to be identical but slightly different in values.
When we fix this we could maybe also make sure that we use Andrew's whittaker-shannon interpolation function in diffpy-utils. Since this is Andew's baby it is also possible that he made this switch already and this is causing the break?
@sbillinge This is actually the same issue as #5 here. I think somehow it is because there is a lot of py2 legacy there. So, I managed to fix this and reproduce the plot here (from the g statistics I confirmed that I reproduced the same one, the only difference is the scale of the difference becomes wider as matplotlib makes the numerical scale somewhat wider, but this is not an issue I believe.)
I was worried that the fix was not working though, because although the plot was successfully generated and there was no crash, the code no longer fit the data well. This plot kind of confirms that. The plot from Bob gives a good fit, but the code now results in a very bad fit. Do we know why?
When we fix this we could maybe also make sure that we use Andrew's whittaker-shannon interpolation function in diffpy-utils. Since this is Andew's baby it is also possible that he made this switch already and this is causing the break?
It might be though, since I both run the extract-single-peak.py in the examples (which in the tutorial claims would produce the same result as in the tutorial one). Now it also produces the break one. The issue might lie in extract.py or Polynomial.py, or both...
I also checked the old result file, seems somehow Luke also had terminationripples.py running at some step in the fit, but now we are not using that, that might also be one cause of failure of fit.
I'm not sure... I checked all the commit history and also reverted some of the incorrect fix before, but still got the same plot. But also I checked with what Luke did in the fitting, he also introduced the terminationripples.py at some step during the fitting and got the final plot shown in the tutorial, but I'm still not sure how he managed to do this... Moreover, with the current code architecture, we also had some problem in the CLI namespace identification problems, as kept with the current CLI namespace, it could not convert the --baseline "Polynomial(1)" from a string to Polynomial object. So, some of the namespace fix is still needed.
(diffpy.srmise_env) huarundong@Stevens-MacBook-Pro-405 diffpy.srmise % srmise docs/examples/data/Ag-nyquist-qmax30.gr --plot --range 2 3.5 --baseline "Polynomial(degree=1)"
The input PDF appears to be missing information: The sampling interval of the input PDF (0.10471976036036036) is larger than the Nyquist interval (0.10471975511965977) defined by qmax=30.0. This information is irretrievable.
Traceback (most recent call last):
File "/opt/miniconda3/envs/diffpy.srmise_env/bin/srmise", line 6, in <module>
sys.exit(main())
~~~~^^
File "/Users/huarundong/dbs/diffpy.srmise/diffpy.srmise/src/diffpy/srmise/applications/extract.py", line 547, in main
cov = ext.extract()
File "/Users/huarundong/dbs/diffpy.srmise/diffpy.srmise/src/diffpy/srmise/pdfpeakextraction.py", line 424, in extract
pe.extract_single()
~~~~~~~~~~~~~~~~~^^
File "/Users/huarundong/dbs/diffpy.srmise/diffpy.srmise/src/diffpy/srmise/peakextraction.py", line 842, in extract_single
y = self.y[rangeslice] - bl.value(x) - ip.value(x)
^^^^^^^^
AttributeError: 'str' object has no attribute 'value'
Activity
bobleesj commentedon Oct 25, 2024
Tutorial link: https://www.diffpy.org/diffpy.srmise/tutorial/extract_single_peak.html
sbillinge commentedon Oct 25, 2024
When we fix this we could maybe also make sure that we use Andrew's whittaker-shannon interpolation function in diffpy-utils. Since this is Andew's baby it is also possible that he made this switch already and this is causing the break?
stevenhua0320 commentedon Apr 8, 2026
@sbillinge This is actually the same issue as #5 here. I think somehow it is because there is a lot of
py2legacy there. So, I managed to fix this and reproduce the plot here (from thegstatistics I confirmed that I reproduced the same one, the only difference is the scale of the difference becomes wider asmatplotlibmakes the numerical scale somewhat wider, but this is not an issue I believe.)sbillinge commentedon Apr 8, 2026
I was worried that the fix was not working though, because although the plot was successfully generated and there was no crash, the code no longer fit the data well. This plot kind of confirms that. The plot from Bob gives a good fit, but the code now results in a very bad fit. Do we know why?
stevenhua0320 commentedon Apr 8, 2026
It might be though, since I both run the
extract-single-peak.pyin the examples (which in the tutorial claims would produce the same result as in the tutorial one). Now it also produces the break one. The issue might lie inextract.pyorPolynomial.py, or both...I also checked the old result file, seems somehow Luke also had
terminationripples.pyrunning at some step in the fit, but now we are not using that, that might also be one cause of failure of fit.sbillinge commentedon Apr 8, 2026
we probably need to get to the bottom of this one before we release, as we seem to have broken the code somehow?
stevenhua0320 commentedon Apr 8, 2026
I'm not sure... I checked all the commit history and also reverted some of the incorrect fix before, but still got the same plot. But also I checked with what Luke did in the fitting, he also introduced the
terminationripples.pyat some step during the fitting and got the final plot shown in the tutorial, but I'm still not sure how he managed to do this... Moreover, with the current code architecture, we also had some problem in the CLI namespace identification problems, as kept with the current CLI namespace, it could not convert the--baseline "Polynomial(1)"from a string toPolynomialobject. So, some of the namespace fix is still needed.stevenhua0320 commentedon Apr 9, 2026
@sbillinge This is the same issue as issue #5 We can now close this.
sbillinge commentedon Apr 9, 2026
closing as completed in #178