Skip to content

Fix tutorial bug - sampling interval of the input PDF (0.1047...) is larger than the Nyquist interval (0.10471975...) #147

Closed

Description

@bobleesj

Problem

The following tutorial example

srmise data/Ag_nyquist_qmax30.gr --plot --range 2 3.5
    --baseline "Polynomial(degree=1)"
Screenshot 2024-10-24 at 11 02 27 PM

gives the following error message:

(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.

Activity

  1. bobleesj commented on Oct 25, 2024

    @bobleesj
    ContributorAuthor
  2. sbillinge commented on Oct 25, 2024

    @sbillinge
    Contributor

    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?

  3. added this to the 0.8.0 milestone on Apr 3, 2026
  4. stevenhua0320 commented on Apr 8, 2026

    @stevenhua0320
    Contributor

    @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.)

  5. sbillinge commented on Apr 8, 2026

    @sbillinge
    Contributor

    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?

  6. stevenhua0320 commented on Apr 8, 2026

    @stevenhua0320
    Contributor

    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.

  7. sbillinge commented on Apr 8, 2026

    @sbillinge
    Contributor

    we probably need to get to the bottom of this one before we release, as we seem to have broken the code somehow?

  8. stevenhua0320 commented on Apr 8, 2026

    @stevenhua0320
    Contributor

    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'
    
  9. stevenhua0320 commented on Apr 9, 2026

    @stevenhua0320
    Contributor

    @sbillinge This is the same issue as issue #5 We can now close this.

  10. sbillinge commented on Apr 9, 2026

    @sbillinge
    Contributor

    closing as completed in #178

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