In [4]:
import os
import numpy as np
import scipy.stats
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
import warnings
warnings.filterwarnings('ignore', module='numpy')
warnings.filterwarnings('ignore')
In [2]:
import sys
sys.path.append("/SNS/users/m2d/git/reflectivity_ui/test/notebooks")
from plot_utils import plot1d, plot_heatmap
In [33]:
def load_data(file_path, ncols=3):
offspec_data = np.loadtxt(file_path)
unique_qy = np.unique(offspec_data.T[0])
qybins = len(unique_qy)
unique_qz = np.unique(offspec_data.T[1])
qzbins = len(unique_qz)
print("\n\nFile: %s" % file_path)
print("Binning: %s %s [%s]" %(qybins, qzbins, qybins*qzbins))
fd = open(file_path, 'r')
first_list = fd.readlines()
print(first_list[0]+first_list[1]+first_list[2])
fd.close()
off = np.reshape(offspec_data, (qybins, qzbins, ncols))
qz = (off.T[1]).T[0]
qy = (off.T[0])[0]
#print "Qy [%s] %s - %s" % (len(qy), np.min(qy), np.max(qy))
#print "Qz [%s] %s - %s" % (len(qz), np.min(qz), np.max(qz))
quick_intensity = off.T[2].T
scale = 1
quick_intensity /= scale
quick_intensity[quick_intensity<1.0e-9] = 1.0e-9
return qy, qz, quick_intensity
In [55]:
filepath = '/SNS/users/m2d/git/reflectivity_ui/test/comparison/v1/REF_M_30806+30807+30808_GISANS_3.000-5.500_Off_Off_set_1.dat'
qy, qz, off_spec_band1_v1 = load_data(filepath, ncols=4)
plot_heatmap(qy, qz, np.log(off_spec_band1_v1).T, x_title='Qy', y_title='Qz', surface=False,
x_log=False, y_log=False)
In [56]:
filepath = '/SNS/users/m2d/git/reflectivity_ui/test/comparison/v2/REF_M_30806+30807+30808_GISANS_3.000-5.500_Off-Off_set_1.dat'
qy_v2, qz_v2, off_spec_band1_v2 = load_data(filepath, ncols=4)
plot_heatmap(qy_v2, qz_v2, np.log(off_spec_band1_v2).T, x_title='Qy', y_title='Qz', surface=False,
x_log=False, y_log=False)
In [58]:
cut_v1 = [qz, off_spec_band1_v1.sum(0)]
cut_v2 = [qz_v2, off_spec_band1_v2.sum(0)]
cut_y_v1 = [qy, off_spec_band1_v1.sum(1)]
cut_y_v2 = [qy_v2, off_spec_band1_v2.sum(1)]
plot1d([cut_v1,cut_v2, cut_y_v1, cut_y_v2],
data_names=['qz v1', 'qz v2', 'qy v1', 'qy v2'], y_log=True, x_title='Q axis (see legend)', y_title='Total signal')
In [60]:
filepath = '/SNS/users/m2d/git/reflectivity_ui/test/comparison/v1/REF_M_30806+30807+30808_GISANS_5.500-8.000_Off_Off_set_1.dat'
qy_band2_v1, qz_band2_v1, off_spec_band2_v1 = load_data(filepath, ncols=4)
plot_heatmap(qy_band2_v1, qz_band2_v1, np.log(off_spec_band2_v1).T, x_title='Qy', y_title='Qz', surface=False,
x_log=False, y_log=False)
In [66]:
filepath = '/SNS/users/m2d/git/reflectivity_ui/test/comparison/v2/REF_M_30806+30807+30808_GISANS_5.500-8.000_Off-Off_set_1.dat'
qy_band2_v2, qz_band2_v2, off_spec_band2_v2 = load_data(filepath, ncols=4)
plot_heatmap(qy_band2_v2, qz_band2_v2, np.log(off_spec_band2_v2).T, x_title='Qy', y_title='Qz', surface=False,
x_log=False, y_log=False)
In [67]:
cut_v1 = [qz_band2_v1, off_spec_band2_v1.sum(0)]
cut_v2 = [qz_band2_v2, off_spec_band2_v1.sum(0)]
cut_y_v1 = [qy_band2_v1, off_spec_band2_v1.sum(1)]
cut_y_v2 = [qy_band2_v2, off_spec_band2_v1.sum(1)]
plot1d([cut_v1,cut_v2, cut_y_v1, cut_y_v2],
data_names=['qz v1', 'qz v2', 'qy v1', 'qy v2'], y_log=True, x_title='Q axis (see legend)', y_title='Total signal')