Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added function to plot Run_diatest result 1 #127

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Calibration/Calibration_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import (absolute_import, division, print_function, unicode_literals)

# import mantid algorithms, numpy and matplotlib
import mantid.simpleapi as ms
from mantid import plots
import matplotlib.pyplot as plt

import numpy as np
def plot_gr_nr(gr_wksp,nr_wksp,xlims=(0,10),nrylims=(0,30),expected_n=None):
"""
plots the g(r) workspace (gr_wksp) and coordination number, n(r) (nr_wksp)
xlims is a tuple (min,max) and its default is (0,10) in units of Angstrom
nrylims is a tuple (min,max) and its default is (0,30)
expected_n is a list of expected coordination numbers. A horizontal line will be plotted
for each value given. If none then no line will be plotted. default is None
returns a handle to the figure
"""
gr_h=ms.mtd[gr_wksp]
nr_h=ms.mtd[nr_wksp]
f1,ax1=plt.subplots(subplot_kw={'projection':'mantid'})
ax1.plot(gr_h)
ax1.set_ylabel('g(r)')
ax2=ax1.twinx()
plots.plotfunctions.plot(ax2,nr_h,'r')
ax2.set_ylim(nrylims)
ax1.set_xlim(xlims)
ax2.set_ylabel('n(r)')
if expected_n != None:
for n_val in expected_n:
ax2.plot(xlims,[n_val,n_val],'g-')
return f1
Binary file added tests/diamond_gr.nxs
Binary file not shown.
Binary file added tests/diamond_nr.nxs
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/gr_nr_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import (absolute_import, division, print_function, unicode_literals)

# import mantid algorithms, numpy and matplotlib
import time
import mantid.simpleapi as ms
from mantid import plots
import matplotlib.pyplot as plt

import numpy as np

import sys
sys.path.append('../Calibration')
from Calibration_plots import plot_gr_nr
#f1.show()
#if __name__=="__main__":
ms.LoadNexusProcessed('diamond_gr.nxs',OutputWorkspace='gr')
ms.LoadNexusProcessed('diamond_nr.nxs',OutputWorkspace='nr')
f1=plot_gr_nr('gr','nr',expected_n=[4,16,28])
f1.show()
time.sleep(5)