# source:Tutorials/PythonScript/data/sim.py@4946

Last change on this file since 4946 was 4946, checked in by vondreele, 12 months ago

delete 2dtexture - will be rebuilt

• Property svn:eol-style set to `native`
• Property svn:mime-type set to `text/html`
File size: 1.4 KB
Line
1'''Sample script to demonstrate use of GSASIIscriptable to simulate a powder pattern
2
3This script is described in this tutorial:
4https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/PythonScript/Scripting.htm
5'''
6
7import os,sys
8sys.path.insert(0,'/Users/toby/software/G2/GSASII')
9import GSASIIscriptable as G2sc
10
11workdir = "/Users/toby/Scratch/PythonScript"
13
14gpx = G2sc.G2Project(filename='PbSO4sim.gpx') # create a project
15
16# step 1, setup: add a phase to the project
18                      phasename="PbSO4",fmthint='CIF')
19
20# step 2, setup: add a simulated histogram and link it to the previous phase(s)
23                          5.,120.,0.01,
24                          phases=gpx.phases())
25
26# Step 3: Set the scale factor to adjust the y scale
27hist1.SampleParameters['Scale'][0] = 1000000.
28
29# step 4, compute: turn off parameter optimization and calculate pattern
30gpx.data['Controls']['data']['max cyc'] = 0 # refinement not needed
31gpx.do_refinements([{}])
32gpx.save()
33
34# step 5, retrieve results & plot
35x = gpx.histogram(0).getdata('x')
36y = gpx.histogram(0).getdata('ycalc')
37import matplotlib.pyplot as plt
38plt.plot(x,y)
39plt.savefig('PbSO4.png') # to show on screen use: plt.show()
40
41
42
Note: See TracBrowser for help on using the repository browser.