def Tester(): import numpy as np import matplotlib.pyplot as plt from MJOLNIR import _tools from MJOLNIR.Data import DataSet # To generate a list of data files from nubers numbers = '457-458,460,461' files = _tools.fileListGenerator(numbers,'/home/lass/Dropbox/PhD/CAMEAData/',year=2018) ## Creating a non-linear distribution of points points = np.exp(np.linspace(-1,np.log(10),21)) minimumBinSize = 1 Bins = _tools.binEdges(points,minimumBinSize) fig,ax = plt.subplots() ax.scatter(points,np.ones_like(points),c='r',label='Data Points',zorder=2) [ax.plot([Bins[i],Bins[i]],[0.5,1.5],'k',zorder=1) for i in range(len(Bins))] ax.plot(np.concatenate([Bins,np.flip(Bins)]),np.concatenate([np.ones_like(Bins)*0.5,np.ones_like(Bins)*1.5]),c='k',label='Bins',zorder=1) ax.set_xticks(np.linspace(0,10,11)) ax.set_yticks([]) ax.set_ylim(-1,3) ax.grid(True,c='k',zorder=0) fig.legend() fig.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Tools/Binning.png',format='png',dpi=300)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np numbers = '483-489,494-500' # String of data numbers fileList = _tools.fileListGenerator(numbers,'/home/lass/Dropbox/PhD/CAMEAData/',2018) # Create file list from 2018 in specified folder # Create the data set ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) # Choose energy limits for binning EMin = 3.5 EMax = 4.0 # Generate a figure making use of binning in polar coordinates Data,Bins,ax = ds.plotQPlane(EMin=EMin, EMax=EMax,xBinTolerance=0.03,yBinTolerance=0.03,binning='polar',vmin=2e-7,vmax=1e-5) fig = ax.get_figure() # Extract figure from returned axis fig.colorbar(ax.pmeshs[0]) # Create colorbar from plot ax.set_xlim(-2.6,0.68) ax.set_ylim(-1.76,2.58) fig.set_size_inches(4.3,4) fig.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/ConstantEnergy3DPolar.png',format='png',dpi=300) # Generate a figure making use of binning in regular orthonormal coordinates Data2,Bins2,ax2 = ds.plotQPlane(EMin=EMin, EMax=EMax,xBinTolerance=0.03,yBinTolerance=0.03,binning='xy',vmin=2e-7,vmax=1e-5) fig2 = ax2.get_figure() fig2.colorbar(ax2.pmeshs[0]) fig2.set_size_inches(4.3,4) fig2.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/ConstantEnergy3DXY.png',format='png',dpi=300)
def test_DataSet_MultiFLEXX(): fileLocation = _tools.fileListGenerator('65059',folder=os.path.join('Data',''),instrument='MultiFLEXX') ds = DataSet(fileLocation) ds.convertDataFile(saveFile = False) import matplotlib matplotlib.use('Agg') V = ds.View3D(0.05,0.05,0.5,grid=True)
def test_fileListGenerator(): numberStr = '0,20-23-24,4000' year = 2018 folder = os.path.join('', 'home', 'camea') try: files = fileListGenerator(numberStr, folder, year) assert False # Too many dasches except AttributeError: assert True numberStr = '0,20-23,4000' files = fileListGenerator(numberStr, folder, year) filesCorrect = np.array([ os.path.join('', 'home', 'camea', 'camea2018n000000.hdf'), os.path.join('', 'home', 'camea', 'camea2018n000020.hdf'), os.path.join('', 'home', 'camea', 'camea2018n000021.hdf'), os.path.join('', 'home', 'camea', 'camea2018n000022.hdf'), os.path.join('', 'home', 'camea', 'camea2018n000023.hdf'), os.path.join('', 'home', 'camea', 'camea2018n004000.hdf') ]) assert (np.all(filesCorrect == np.array(files)))
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D numbers = '483-489,494-500' # String of data numbers fileList = _tools.fileListGenerator( numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) fig = plt.figure(figsize=(10, 11)) ax = fig.add_subplot(111, projection='3d') ### Generate own color map with transparency from matplotlib.colors import ListedColormap cmap = plt.cm.coolwarm my_cmap = cmap(np.arange(cmap.N)) my_cmap[:, -1] = np.linspace(0, 1, cmap.N) my_cmap = ListedColormap(my_cmap) Energies = np.concatenate(ds.energy, axis=0) E = np.arange(Energies.min(), Energies.max(), 0.35) [I,Monitor,Norm,NormCount],[xBins,yBins],ax = \ ds.plotQPlane(EBins=E,ax = ax,xBinTolerance=0.03,yBinTolerance=0.03, binning='polar',vmin=2e-7,vmax=2e-5,antialiased=True,cmap=cmap) ax.set_xlabel('$Q_x$ [1/AA]') ax.set_ylabel('$Q_y$ [1/AA]') ax.set_zlabel('$E$ [meV]') ax.set_xlim(-3, 1.0) ax.set_ylim(-1, 3) fig.tight_layout() fig.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/ConstantEnergy3D.png', format='png', dpi=300)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np import matplotlib.pyplot as plt numbers = '483-489,494-500' # String of data numbers fileList = _tools.fileListGenerator( numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) # Define the positions to be cut through Q1 = np.array([0, 0, 0]) Q2 = np.array([0, 0, 1]) Q3 = np.array([-1, 0, 1]) Q4 = np.array([-1, 0, 0]) Q5 = np.array([0, 0, 1]) # Collect them into one array QPoints = np.array([Q1, Q2, Q3, Q4, Q5]) # Define orthogonal width and minimum pixel size along Q-cut width = 0.05 # 1/AA minPixel = 0.01 # 1/AA # Define energy bins Energies = np.concatenate(ds.energy, axis=0) EnergyBins = np.linspace(np.min(Energies), np.max(Energies), 31) fig = plt.figure(figsize=(14, 6)) ax = fig.gca() ax,DataLists,Bins = \ ds.plotCutQELine(QPoints=QPoints, width=width, minPixel=minPixel, \ ax=ax, EnergyBins=EnergyBins) # Change the colorbar of the plot ax.set_clim(0, 2e-5) fig.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/plotCutQELineMnF2.png', format='png', dpi=300)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools import numpy as np from lmfit.models import GaussianModel numbers = '499,500' files = _tools.fileListGenerator(numbers,'/home/lass/Dropbox/PhD/CAMEAData/',year=2018) ds = DataSet.DataSet(files) ds.convertDataFile(binning=8,saveFile=False) # utility function to return points in array before a given value def index_of(arrval, value): """Return index of array *at or below* value.""" if value < min(arrval): return 0 if np.sum(np.diff(arrval))>0: # Positive change return max(np.where(arrval <= value)[0]) else: return max(np.where(arrval >= value)[0]) # Define qut in Q space q1 = [-1,0,-1.2] q2 = [-1,0,1.0] q3 = [0,0,1.0] # Create two different energy ranges for the cut from q1 to q2 and q2 to q3 EBins = [np.linspace(ds.energy.min(),ds.energy.max(),31),np.linspace(ds.energy.min(),ds.energy.max(),25)] # Perform the cut and plot it. Returns a cutObject ax,Data,Bin,center,Distance = ds.plotCutQELine(QPoints=[q1,q2,q3],width=0.05,minPixel=0.01,EnergyBins=EBins) # Extract axis and save figure fig = ax.get_figure() fig.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/RawQEPlot.png',format='png',dpi=600) # Define plotting parameters for error bar plot to be created ErrorBarKwargs = {'markersize':4, 'capsize':2,'elinewidth':1,'markeredgewidth':2,'mfc':'white','fmt':'o'} out = [] # Holder for fitting results # Utilize the groupby function of the pandas DataFrame to loop through the different cuts for ID,_cutdata in Data.groupby('qCut'): # ID: which segment, either 0: q1->q2, or 1: q2->q3 # _data: pandas frame containing data for this cut for _,_data in _cutdata.groupby('energyCut'): # Transpose as to easier perform fit x = _data[['H','K','L','Energy']] # Calculate intensity and remove points that has not been measured y = _data['Int'].values NoNNans = (_data['Monitor']>0).values y = y[NoNNans] x = x[NoNNans] # Fit depends on which cut is in question if ID==0: # Fit consists of three 1D Gaussians gauss1 = GaussianModel(prefix='g1_') gauss2 = GaussianModel(prefix='g2_') # Give the Gaussians different prefixes gauss3 = GaussianModel(prefix='g3_') # Model is simply the sum of these mod = gauss1 + gauss2 + gauss3 # Direction along which to fit fittingX = x['L'] # Cut out portions to make use of the automatic parameter estimation ix1 = fittingX< -0.1 # All points before -0.1 is for first Gaussian ix2 = np.logical_and(fittingX> -0.1,fittingX<0.5) # Between ix1 and ix2 is second Gaussian ix3 = fittingX>0.5 # values bigger than 0.5 # Third Gaussian is from 0.5 and the rest. # Use lmfit's parameter starting guess pars = gauss1.guess(y[ix1],x=fittingX[ix1].values) pars.update(gauss2.guess(y[ix2],x=fittingX[ix2].values)) pars.update(gauss3.guess(y[ix3],x=fittingX[ix3].values)) elif ID == 1: # Repeat procedure from above for second segment with only 2 Gaussians or 1 depending on energy fittingX = x['H'].values gauss1 = GaussianModel(prefix='g1_') E = x['Energy'].values[0] if E<6.1: gauss2 = GaussianModel(prefix='g2_') mod = gauss1 + gauss2 ix1 = fittingX<-0.5 ix2 = np.logical_not(ix1) pars = gauss1.guess(y[ix1],x=fittingX[ix1]) pars.update(gauss2.guess(y[ix2],x=fittingX[ix2])) elif E<6.6: mod = gauss1 pars = gauss1.guess(y,x=fittingX) else: continue # Perform fit and save results in the 'out' array result = mod.fit(y, pars, x=fittingX) out.append(result) # For plotting Centres and widths are needed (Their errors are extracted as well, but unused) centres = [] centres_err = [] widths = [] widths_err = [] for parname, par in result.params.items(): if 'center' in parname: centres.append(par.value) centres_err.append(par.stderr) if 'sigma' in parname: widths.append(par.value) widths_err.append(par.stderr) # Depending on segment, the centres of the Gaussians are either [-1,0,c] or [c,0,-1] # 'Errors' refers to the errorbars and are in this case plotted as the widths if ID == 0: Center3D = [[-1.0,0,c] for c in centres] Center3DErr = [[-1.0,0,c+err] for c,err in zip(centres,widths)] elif ID == 1: Center3D = [[c,0,-1] for c in centres] Center3DErr = [[c+err,0,-1] for c,err in zip(centres,widths)] # Calculate the position along the plot for the HKL points. XPosition = [ax.converterFunction(c,ID=ID) for c in Center3D] XPositionErr = [ax.converterFunction(CE,ID=ID)-XC for CE,XC in zip(Center3DErr,XPosition)] # The above is needed as an axis only has one x-axis and plotting multiple segments require some trickery, # resulting in rescaling and offsets. It is all taken care of in the converterFunction of the axis. ax.errorbar(XPosition,[x.values[0][-1]]*len(XPosition),xerr=XPositionErr,c = 'b', **ErrorBarKwargs) # plot the errorbar on top of intensity data fig = ax.get_figure() fig.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/FittedQEPlot.png',format='png',dpi=600)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools import numpy as np import matplotlib.pyplot as plt numbers = '483-489,494-500' fileList = _tools.fileListGenerator(numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) # Define the positions to be cut through Q1 = np.array([0, 0, 0]) Q2 = np.array([0, 0, 1]) Q3 = np.array([-1, 0, 1]) Q4 = np.array([-1, 0, -1]) # Collect them into one array QPoints = np.array([Q1, Q2, Q3, Q4]) # Define orthogonal width and minimum pixel size along Q-cut width = np.array([0.05, 0.03, 0.05]) # 1/AA minPixel = np.array([0.03, 0.01, 0.01]) # 1/AA # Define energy bins through the binEdges methods found in _tools Energies = np.concatenate(ds.energy, axis=0) EnergyBins = np.array([ _tools.binEdges(Energies, 0.04), _tools.binEdges(Energies, 0.1), _tools.binEdges(Energies, 0.07) ]) # Create figure into which the plot is made fig = plt.figure(figsize=(14, 6)) ax = fig.gca() ax,DataLists,BinListTotal,centerPositionTotal,binDistanceTotal = \ ds.plotCutQELine(QPoints=QPoints, width=width, minPixel=minPixel, \ ax=ax, EnergyBins=EnergyBins, ticks = 12,\ vmin=1e-8, vmax=1e-5, tickRound = 4, plotSeperator = True, seperatorWidth=0.5,zorder=10) ax.grid(True, zorder=0, c='k') fig.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/plotCutQELineMnF2.png', format='png', dpi=300) # Plot a single cut through the data set fig2, ax2 = plt.subplots() segID = 2 # Find all energies in segment E = np.array([x[0][-1] for x in centerPositionTotal[segID]]) # Find index of energies corresponding to the list EnergyIndexes = [E.searchsorted(x) for x in np.linspace(1.5, 6.5, 5)] plot = 0 for energyID in EnergyIndexes: # Extract data for segment 2 and current energy _dataList = DataLists[np.logical_and( DataLists['qCut'] == segID, DataLists['energyCut'] == energyID)].astype(float) Intensity = _dataList['Int'] * 1e5 Intensity_err = np.divide( np.sqrt(_dataList['Intensity']) * _dataList['BinCount'], _dataList['Monitor'] * _dataList['Normalization']) position = _dataList['L'] # Plotting along L Energy = np.mean(_dataList['Energy']) ax2.errorbar(position, Intensity + len(EnergyIndexes) - plot, yerr=Intensity_err, fmt='-', label='E = {:.1f} meV'.format(Energy)) plot += 1 ax2.set_title('Cut through data along $L$') ax2.set_xlabel('L [rlu]') ax2.set_ylabel('Int [arb]') ax2.legend() ax2.grid(True) fig2.tight_layout() fig2.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/plotCutQELineMnF21D.png', format='png', dpi=300)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np import matplotlib.pyplot as plt numbers = '137' # String of data numbers fileList = _tools.fileListGenerator( numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) mask = np.zeros_like(ds.I.data) # Define mask, see FAQ for explanation mask[:, :, :3] = True ds.mask = mask # Create RLU axis ax = ds.createRLUAxes() # Get the figure corresponding to the returned axis fig = ax.get_figure() # The axis should contain v1 and v2 v1 = [-1.5, -1.5, 0] v2 = [1.5, 1.5, 0] ax.set_axis(v1, v2) # Generate some points to plot points = np.array([[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]).T # Use points as distance along projections projection = np.array(ax.sample.inv_tr(points[0], points[1])) # Convert into HKL (corresponds to the points above) HKL = np.array([points[0], points[1], np.zeros_like(points[0])]) # Calculate actual position of HKL points P1P2 = np.array(ax.sample.calculateHKLtoProjection(HKL[0], HKL[1], HKL[2])) QxQy = np.array(ax.sample.inv_tr(P1P2[0], P1P2[1])) # Plot all 3 lines ax.plot(points[0], points[1], label='QxQy') ax.plot(projection[0], projection[1], label='Projection') ax.plot(QxQy[0], QxQy[1], 'g', label='HK', marker='o', linestyle='dashed') ax.legend() ax.grid(True) fig.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Tools/RLUAxis.png', format='png', dpi=300) ############### Second example ############### numbers = '422' # String of data numbers fileList = _tools.fileListGenerator( numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) ax = ds.createRLUAxes() fig = ax.get_figure() # The axis should contain v1 and v2 v1 = [-2, 1, 1] v2 = [2, -1, -1] ax.set_axis(v1, v2) ax.grid(True) fig.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Tools/RLUAxis2.png', format='png', dpi=300)
def Tester(): from MJOLNIR.Data import DataSet, Mask from MJOLNIR import _tools # Usefull tools useful across MJOLNIR import numpy as np import matplotlib.pyplot as plt numbers = '494-500' # String of data numbers fileList = _tools.fileListGenerator( numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) # Create file list from 2018 in specified folder ds = DataSet.DataSet(fileList) ds.convertDataFile() # Define circular mask at -1 0 0 in hkl with radius 0.25 circle = Mask.circleMask(center=[-1, 0], radiusPoint=[-1.25, 0], coordinates=['h', 'l']) # only provide h,l # The circle mask is only to be on when energy is between 3.0 meV and 4.0 meV lowEnergy = Mask.lineMask(start=3.0, end=4.0, coordinates='energy') # Mask dispersion above -1 0 1 with a rectangle corner1 = np.array([-1.5, 1.0]) # in h,l (k=0.0) corner2 = np.array([-1.1, 0.65]) # in h,l corner3 = np.array([-0.5, 0.9]) # in h,l rectangle = Mask.rectangleMask(corner1, corner2, corner3, coordinates=['h', 'l']) # but only for energies not between 3.0 and 4.0, which is achieved by negating lowEnergy # the total mask then becomes mask = circle * lowEnergy + rectangle * lowEnergy.bar() # Apply the mask ds.mask = mask # Generate a 3d viewer view = ds.View3D(0.05, 0.05, 0.05) # it is started in the hkl plane, where we can also plot our masks. # However, the transformation used by view3D is from qx,qy to hkl, so the inverse # is to be provided. This is stored in trans = view.ax.sample.inv_tr mask.plot(view.ax, transformation=trans, zorder=20) # tune the colorbar view.caxis = (1e-8, 5e-6) view.Energy_slider.set_val(10) view.ax.get_figure().savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/masking_10.png', format='png', dpi=300) view.Energy_slider.set_val(40) view.ax.get_figure().savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/masking_40.png', format='png', dpi=300) # Along the Q-E direction the masking looks differently QPoints = np.array([[-1.0, 0.0, -1.0], [-1.0, 0.0, 1.25]]) Energies = np.concatenate(ds.energy, axis=0) EnergyBins = np.linspace(np.min(Energies), np.max(Energies), 31) ax,*_ = ds.plotCutQELine(QPoints=QPoints, width=0.05, minPixel=0.05, \ EnergyBins=EnergyBins) # Change the colorbar of the plot ax.set_clim(0, 2e-5) ax.get_figure().savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick/masking_QELine.png', format='png', dpi=300)
def Tester(): from matplotlib import animation import matplotlib.pyplot as plt import numpy as np # Turn of interactivity of figures (back-end dependend) plt.ioff() f = plt.figure() line = f.gca().plot([], [], lw=2) def View3DAnimator(V, name, folder, frames=None, keyFrame=None, fps=3): """Function to facilitate generation of animations for Viewer3D""" if not frames is None: Frames = frames nFrames = len(Frames) def animate(i, correct=False): if not correct: I = Frames[i] print('{i} of {frames}'.format(i=i, frames=nFrames)) else: I = i V.Energy_slider.set_val(I) return line if not frames is None: fig = V.ax.get_figure() anim = animation.FuncAnimation(fig, animate, frames=nFrames, interval=10, blit=True) anim.save(folder + name + '.gif', fps=fps, dpi=100, writer='imagemagick') if not keyFrame is None: fig = V.ax.get_figure() animate(keyFrame, correct=True) fig.savefig(folder + name + '.png', format='png', dpi=300) plt.close(fig) from MJOLNIR.Data import DataSet from MJOLNIR import _tools numbers = '161-169' # Load and convert data fileName = _tools.fileListGenerator( numbers, folder='/home/lass/Dropbox/PhD/CAMEAData/', year=2018) ds = DataSet.DataSet(dataFiles=fileName) ds.convertDataFile(saveFile=False) # Plotting data quickly in equi-sized voxels can be done by Viewer = ds.View3D(0.03, 0.03, 0.09, grid=9, rlu=True) #Generate the viewer with voxel size 0.03 Å x 0.03 Å x 0.05 meV, using # the key word grid, one toggles the regular grid but providing the input # as a number the zorder of the grid is specified (Data is plotted at 10). # It is also possible to plot data without making use of reciprocal lattice # units, chosen by rlu = True or False. Viewer.caxis = (1e-8, 5e-7) nFrames = Viewer.Z.shape[-1] # Number of energy planes frames = np.arange(3, nFrames - 3) frames = np.concatenate([frames, np.flip(frames[1:-1])]) # # Generate animation as mp4 and create key frame as plane 75 View3DAnimator( Viewer, 'ViewerAnimationEPlane', '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/', frames=frames, keyFrame=75, fps=7)
def Tester(): from MJOLNIR.Data import DataSet from MJOLNIR import _tools import numpy as np import matplotlib.pyplot as plt numbers = '483-489,494-500' fileList = _tools.fileListGenerator(numbers, '/home/lass/Dropbox/PhD/CAMEAData/', 2018) ds = DataSet.DataSet(fileList) ds.convertDataFile(saveFile=False) # Define the positions to be cut through Q1 = np.array([0, 0, 0]) Q2 = np.array([0, 0, 1]) Q3 = np.array([-1, 0, 1]) Q4 = np.array([-1, 0, -1]) # Collect them into one array QPoints = np.array([Q1, Q2, Q3, Q4]) # Define orthogonal width and minimum pixel size along Q-cut width = np.array([0.05, 0.03, 0.05]) # 1/AA minPixel = np.array([0.03, 0.01, 0.01]) # 1/AA # Define energy bins through the binEdges methods found in _tools Energies = np.concatenate(ds.energy, axis=0) EnergyBins = np.array([ _tools.binEdges(Energies, 0.04), _tools.binEdges(Energies, 0.1), _tools.binEdges(Energies, 0.07) ]) ax,DataLists,BinListTotal = \ ds.plotCutQELine(QPoints=QPoints, width=width, minPixel=minPixel, \ EnergyBins=EnergyBins, ticks = 12,\ vmin=1e-8, vmax=1e-5, plotSeperator = True, seperatorWidth=0.5,zorder=10) ax.grid(True, zorder=0, c='k') ax.get_figure().savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/plotCutQELineMnF2.png', format='png', dpi=300) # Plot a single cut through the data set fig2, ax2 = plt.subplots() segID = 2 # Extract the data from SegmentId df = DataLists[segID] for energy, EnergyDF in df.groupby('Energy'): Intensity = EnergyDF['Int'] * 1e5 Intensity_err = EnergyDF['Int_err'] position = EnergyDF['L'] # Plotting along L ax2.errorbar(position, Intensity, yerr=Intensity_err, fmt='-', label='E = {:.1f} meV'.format(energy)) ax2.set_title('Cut through data along $L$') ax2.set_xlabel('L [rlu]') ax2.set_ylabel('Int [arb]') ax2.legend() ax2.grid(True) fig2.tight_layout() fig2.savefig( '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced/plotCutQELineMnF21D.png', format='png', dpi=300)