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
Is this the expected behavior? Should I be doing this a different way? Perhaps instantiating a new Profile and passing that to the recipe through recipe.crystal.setProfile?
Below is the full code for a working example. Data is attached
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile
from diffpy.srfit.pdf import PDFParser, PDFGenerator
import numpy as np
def check_qmax(desired,actual):
print(f"\nMetadata in new file suggests Q_max should be {desired}, q_max is now {actual}")
if not np.isclose(actual,desired):
print("\nThese are not equal\n")
elif np.isclose(actual,desired):
print("\nThese are equal\n")
profile = Profile()
parser = PDFParser()
parser.parseFile("test_1.txt")
profile.loadParsedData(parser)
generator = PDFGenerator("G1")
contribution = FitContribution("crystal")
contribution.addProfileGenerator(generator)
contribution.setProfile(profile, xname="r")
recipe = FitRecipe()
recipe.addContribution(contribution)
old_q_max = recipe.crystal.G1.getQmax()
parser = PDFParser()
parser.parseFile("test_2.txt")
metadata = parser.getMetaData()
file_q_max = metadata['qmax']
recipe.crystal.profile.loadParsedData(parser)
new_q_max = recipe.crystal.G1.getQmax()
check_qmax(file_q_max,new_q_max)
recipe.crystal.G1.setQmax(file_q_max)
new_q_max = recipe.crystal.G1.getQmax()
check_qmax(file_q_max,new_q_max)
The text was updated successfully, but these errors were encountered:
test_1.txt
test_2.txt
If I call this code with the appropriate PDF data file containing qmax metadata
and then call
recipe.crystal.G1.getQmax()
I get the correct qmax from the file metadata.If I then however replace the profile data with
new_q_max
will still contain the old qmax value, from the first file.This will successfully change it:
Is this the expected behavior? Should I be doing this a different way? Perhaps instantiating a new
Profile
and passing that to the recipe throughrecipe.crystal.setProfile
?Below is the full code for a working example. Data is attached
The text was updated successfully, but these errors were encountered: