Ignore:
Timestamp:
Jan 11, 2018 9:44:24 AM (4 years ago)
Author:
toby
Message:

add new stuff to simulate tutorial

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Tutorials/PythonScript/data/sim.py

    r3209 r3218  
    1414gpx = G2sc.G2Project(filename='PbSO4sim.gpx') # create a project
    1515
    16 # setup step 1: add a phase to the project
     16# step 1, setup: add a phase to the project
    1717phase0 = gpx.add_phase(os.path.join(datadir,"PbSO4-Wyckoff.cif"),
    1818                      phasename="PbSO4",fmthint='CIF')
    1919
    20 # setup step 2: add a simulated histogram and link it to the previous phase(s)
     20# step 2, setup: add a simulated histogram and link it to the previous phase(s)
    2121hist1 = gpx.add_simulated_powder_histogram("PbSO4 simulation",
    2222                          os.path.join(datadir,"inst_d1a.prm"),
    2323                          5.,120.,0.01,
    2424                          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
    2530gpx.data['Controls']['data']['max cyc'] = 0 # refinement not needed
    2631gpx.do_refinements([{}])
    2732gpx.save()
    2833
     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()
    2940
    3041
     42
Note: See TracChangeset for help on using the changeset viewer.