Skip to content

Cannot extract single peak #5

Closed

Description

@czhao9

I met a problem when I am trying the first example in the tutorial (i.e., single-peak extraction). The PDF of Ag can be successfully plotted without extracting peak. However, when I execute

srmise data/Ag_nyquist_qmax30.gr --plot --range 2 3.5 --baseline "Polynomial(degree=1)"

on my PC, following warning appears:

The input PDF appears to be missing information: The sampling interval of the input PDF (0.10471976036) is larger than the Nyquist interval (0.10471975512) defined by qmax=30.0. This information is irretrievable.
Traceback (most recent call last):
File "c:\programdata\anaconda2\lib\runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "c:\programdata\anaconda2\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\ProgramData\Anaconda2\Scripts\srmise.exe_main
.py", line 9, in
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\applications\extract.py", line 388, in main
cov = ext.extract()
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\pdfpeakextraction.py", line 386, in extract
ext.fit() # Clean up parameters after resampling.
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 878, in fit
orig_qual = self.quality()
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 1112, in quality
evaluator_inst.evaluate(self, **kwds)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelevaluators\aic.py", line 71, in evaluate
self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 1067, in value
return self.valuebl(r)+(self.model.value(self.r_data, self.slice)[self.slice])
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelparts.py", line 272, in value
total += p.value(r, range)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelparts.py", line 468, in value
return self._owner.value(self, r, range)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\peaks\terminationripples.py", line 226, in value
output[rng] = value[ext_slice][::segments]
TypeError: slice indices must be integers or None or have an index method

Can anyone help with this problem?

Thanks!

Activity

  1. JMSkelton commented on Mar 16, 2019

    @JMSkelton

    This error appears to be due to a bug on line 216 in terminationripples.py:

    segments = np.ceil(dr/dr_super)

    At least in newer versions of NumPy, np.ceil() returns a floating-point value, which cannot be used as an array index.

    An easy solution is to edit terminationripples.py and change the line to e.g. the following:

    segments = int(np.ceil(dr/dr_super))

  2. added this to the 0.8.0 milestone on Apr 3, 2026
  3. stevenhua0320 commented on Apr 7, 2026

    @stevenhua0320
    Contributor

    @sbillinge Maybe we could move this issue later or close this one and open another one since the code might be refactored at some moment and I did a global search on the repo, which I didn't find the line that these users report that might be the culprit of the issue.

  4. sbillinge commented on Apr 7, 2026

    @sbillinge
    Contributor

    I think we should maybe try and close this. Can you do a search for part of the code, like dr/dr_super or segments? I doubt we refactored names of variables

  5. stevenhua0320 commented on Apr 7, 2026

    @stevenhua0320
    Contributor

    Yes, I tried all the possible way to pinpoint it, but there is no such code on the global search.

  6. sbillinge commented on Apr 7, 2026

    @sbillinge
    Contributor

    Is that dataset in the repo as an example one? In that case can you run that command and see if it works? We may have renamed the file....

  7. stevenhua0320 commented on Apr 7, 2026

    @stevenhua0320
    Contributor

    The issue might still exist... I run the command but still the issue persists. Let me dive into the issue tonight and see if I can find it out...

    (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 10, in <module>
        sys.exit(main())
                 ~~~~^^
      File "/opt/miniconda3/envs/diffpy.srmise_env/lib/python3.14/site-packages/diffpy/srmise/applications/extract.py", line 537, in main
        cov = ext.extract()
      File "/opt/miniconda3/envs/diffpy.srmise_env/lib/python3.14/site-packages/diffpy/srmise/pdfpeakextraction.py", line 417, in extract
        pe.extract_single()
        ~~~~~~~~~~~~~~~~~^^
      File "/opt/miniconda3/envs/diffpy.srmise_env/lib/python3.14/site-packages/diffpy/srmise/peakextraction.py", line 829, in extract_single
        y = self.y[rangeslice] - bl.value(x) - ip.value(x)
                                 ^^^^^^^^
    AttributeError: 'str' object has no attribute 'value'
    
  8. sbillinge commented on Apr 7, 2026

    @sbillinge
    Contributor

    thanks! It is an easy fix if you can find it, we just have to int the ceil

  9. stevenhua0320 commented on Apr 8, 2026

    @stevenhua0320
    Contributor

    thanks! It is an easy fix if you can find it, we just have to int the ceil

    To tell the truth, it is not a quite easy thing to fix it. Because of the property of python 2 legacy issue (since this package is lack of test as we found out in 2024, there are still quite a lot py2 legacy in the code). So, it takes me some time to fix it 😂
    But I somewhat fixes the bug, the only issue is I'm not quite sure whether it is really behaving properly. So, I would now open a PR for this and I would also attach the plot that it produces.

  10. sbillinge commented on Apr 9, 2026

    @sbillinge
    Contributor

    This was finally truly fixed by @stevenhua0320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions