andrewrgarcia/powerxrd

ValueError: not enough values to unpack (expected 2, got 1)

mulinaiolo opened this issue · 2 comments

Dear Andrew,

I found your package today and realized that it would be pretty straight forward. However, I got the same issue as mentioned in the youtube tutorial:

"x,y = np.array(df).T
ValueError: not enough values to unpack (expected 2, got 1)"

in the attachment my XRD file (i was shortening it for the purpose of the question here).
Sample_XRD.zip

The code is the same as the one in the tutorial:

#import packages
import powerxrd as xrd
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def test_allpeaks():
data = xrd.Data('Sample_XRD.xy').importfile()
chart = xrd.Chart(data)
chart.backsub(tol=1,show=True)
chart.allpeaks(tols=(0.1,0.9), verbose=False, show=True)
plt.xlabel('2 $\theta$')
plt.suptitle('backsub & Automated Scherrer width calculation of all peaks
')
plt.show()

def test_backsub():

Any ideas what I could try out?

Greets
mulinaiolo

Dear Andrew,

I found your package today and realized that it would be pretty straight forward. However, I got the same issue as mentioned in the youtube tutorial:

"x,y = np.array(df).T ValueError: not enough values to unpack (expected 2, got 1)"

in the attachment my XRD file (i was shortening it for the purpose of the question here). Sample_XRD.zip

The code is the same as the one in the tutorial:

#import packages import powerxrd as xrd import numpy as np import pandas as pd import matplotlib.pyplot as plt

def test_allpeaks(): data = xrd.Data('Sample_XRD.xy').importfile() chart = xrd.Chart(data) chart.backsub(tol=1,show=True) chart.allpeaks(tols=(0.1,0.9), verbose=False, show=True) plt.xlabel('2 $\theta$') plt.suptitle('backsub & Automated Scherrer width calculation of all peaks') plt.show()

def test_backsub():

Any ideas what I could try out?

Greets mulinaiolo

@mulinaiolo

Thanks for bringing this up. It was a bug in the pandas separator. I have patched it up and it should work in the new release.
To install the new release, run:

pip install --upgrade powerxrd

With this update, I ran your code with your file and got a plot with the chart.backsub method; the chart.allpeaks method will not work because there are not enough points to fit Gaussians in your xy data (i.e. the number of undetermined coefficients for the Gaussian exceed the amount of data you have); I recommend going for longer scans on the XRDiffractometer.

#import packages
import powerxrd as xrd
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def test_allpeaks():

    # data = xrd.Data('sample0.xy').importfile()
    data = xrd.Data('Sample_XRD.xy').importfile()

    chart = xrd.Chart(*data)

    chart.backsub(tol=1,show=True)
    # chart.allpeaks(tols=(0.1,0.025), verbose=False, show=True)
    plt.xlabel('2 $\\theta$')
    plt.suptitle('backsub & Automated Scherrer width calculation of all peaks*')
    plt.show()

test_allpeaks()

Figure_1

Regards,
Andrew

published patch powerxrd v.2.2.0