Пример #1
0
    
title = 'Fitting of sequential 2D plots in as 1D Gaussians'

introText = 'After a spectrum has been measured, it is sensible to extract some of the physical quantities of excitations. In this tutorial, '\
+'one possible method of doing so by the use of QELine as well as LMFIT is presented. The data is the MnF2 data set where only as subset of '\
+'the data is used. Specifically from 4.8 meV to 6.9 meV and the parameters wanted are the positions and widths of the magnon along two cuts in Q. '\
+'More specifically, there will be performed a cut from (-1,0,-67) RLU to (-1,0,1) RLU to (0,0,1) RLU. For each of the two segments, the data is '\
+'split into horizontal (energy) slices of same energy width and Gaussians are used to model the spin wave line shapes. Below is the data as '\
+'seen before the fitting routine has been performed.\n .. figure:: RawQEPlot.png\n  :width: 80%\n  :align: center\n\nFrom this it is clear '\
+'that the number of horizontal Gaussians changes for the second segment. This is all done in the code. Further, the start guess for the parameters '\
+'are found from the estimators build in to the Gaussian objects of the LMFIT module.'


outroText = 'In the above code, a lot of things are going, showing just one way of treating the data. If one does not like to work with pandas DataFrames, '\
    +'one can convert them into a set of numpy arrays. However, this then requires the user to deal with all of the indices themself. '\
        +'Further, if LMFIT is not your cup of tea, many other fitting routines exist '\
        +'for Python.'


introText = title+'\n'+'^'*len(title)+'\n'+introText


    
Example = Tutorial('AdvancedFitting1D',introText,outroText,Tester,fileLocation = '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Advanced')

def test_AdvancedFitting1D():
    Example.test()

#if __name__ == '__main__':
Example.generateTutorial()
Пример #2
0
+'The discussion of the location of the tick marks is quite long and deserves a section of it\'s own. It all revolves about the usage of the curve linear axis, which is provided as an '\
+'experimental/development feature in the *matplotlib* package. This in change then introduces some difficulties with the compability of the code with both python 2 and 3 as '\
+'some calls are only supported with python 3. Thus to keep the compability of MJOLNIR to both versions, the customization of tick locations and number is only used '\
+'for python versions 3. \n\n Codewise, what is done is to create two subclasses of the *mticker.MultipleLocator* and the *mticker.MaxLocator* classes designed to calculate '\
+'the positions of tick marks using two different methods. The *MaxLocator* expects a integer input signifying the maximal number of ticks along the given axis, which are '\
+'chosen at \'suitable\' positions and will update with zooming and panning. \n \n The *MultipleLocator* is designed to place tick marks at multiples of a given value. That is, '\
+'if the base is 0.1, tick marks are located at all integer multiples of 0.1 inside of the viewable area. For static or panning, this solution is suitable and sufficient, but '\
+'allowing the user to zoom requires the class to be more complex. In order to find a suitable base value, the class finds the window limits and given a wanted number of tick marks '\
+'it finds the average wanted distance between the marks. As to be scale invariant this number is mapped to a value between 0.1 and 1, where it is compared to a predefined list '\
+'of allowed fractions (1/1,1/2,1/3,1/4,1/5) where the closest is used.\n\n With the new tick marks found, a hook is created to overview the panning and zooming of the axis and '\
+'force an update of the drawing of tick marks. '

introText = title + '\n' + '^' * len(title) + '\n' + introText

Example = Tutorial(
    'RLUAxis',
    introText,
    outroText,
    Tester,
    fileLocation='/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Tools'
)


def test_RLUAxis():
    Example.test()


#if __name__ == '__main__':
Example.generateTutorial()
#print(outroText)
Пример #3
0
+'rectangleMask\n-------------\n\nInstead of only being allowed to mask in circles, one can also mask a rectangle. This can be achieved with the rectangleMask.  '\
+'To create one, a starting corner is to be provided together with a second corner. From these two, the rectangle is created. Alternatively, one can provide 3 points. '\
+'If this is done, the first two points are used to define an edge, and the last point gives the extend of the rectangle orthogonal to this edge. That is, '\
+'the third point might not be located on the edge of the rectangle. This three-input option allows the creation of rotated rectangles. Points are then masked by '\
+'rotating then such that the rectangle lines up with the coordinate axes and center at (0,0). This allows for two simple 1D checks.\n\n'\
+'boxMask\n-------\n\nExtending the rectangle into 3D creates the boxMask. This mask also supports two different inpunts; either three corner points making the '\
+'edges of the box parallel to the coordinate axes, or 4 point input. In this latter case, the two first points creates on edge, which is extended to form a rectangular '\
+'base with width corresponding to the orthogonal distance to the third point. Lastly, this rectangle is extended by the orthogonal distance to the last point. Like '\
+'the rectangleMask, points are masked by rotating the box such that it center is in (0,0,0) and edges are along the coordinate axes. Due to the complexity of 3D '\
+'rotations, three rotations matrices are involved.\n\n'\
+'indexMask\n---------\n\nLastly, it can at times be necessary to perform masking depending on the indices of the points. This could be when a full detector tube '\
+'is to be masks, but the A4 value is unknown. This can be performed by the indexMask, where a start and end index together with an axis defines the masks.'

introText = title + '\n' + '^' * len(title) + '\n' + introText

Example = Tutorial(
    'masking',
    introText,
    outroText,
    Tester,
    fileLocation='/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Quick'
)


def test_masking():
    Example.test()


#if __name__ == '__main__':
Example.generateTutorial()
Пример #4
0
+'   :language: xml \n'\
+'   :linenos:\n'\
+'\nOne starts with the instrument and gives some informations. Next level is the wedge where position and concept is provided. For each wedge, one specifies the analysers with their positions, '\
+' direction of surface, d-spacing, mosaicity, width and height, and afterwards the detectors. These are specified with position, direction along which the tube extends, number of pixels, length and diameter of tube, '\
+'how the pixels are split into segments (only applicable if concept "ManyToMany" is used).'

outroText = 'Most of the above code is in reality only plotting commands for the instrument and the calculated A4 and Ef values.\n\n'\
+'.. figure:: SimpleInstrument2.png\n  :width: 50%\n  :align: center\n\n'\
+'Instrument generated from XML file. Currently, the figure is rendered wrongly due to a visualization problem... \n\n'\
+'.. figure:: SimpleInstrument2_A4.png\n  :width: 50%\n  :align: center\n'\
+'\nCorresponding A4 values as calculated from instrument. Here it is seen that the A4 values are energy dependent if one has radial detectors that are "non-optimally" placed '\
+'with respect to the analyser. Only the central detector tube has the same A4 value independent of position.\n .. figure:: SimpleInstrument2_Ef.png\n  :width: 50%\n  :align: center\n\n'\
+'Energies as calculated. With this setup of analysers and detectors there is a whole lot of energy coverage for all of the segments. This is not what will happen in a real experiment as '\
+'all of the segments have "inactive" ends that are cut of. However, some overlap remains.'


introText = title+'\n'+'^'*len(title)+'\n'+introText


    
Example = Tutorial('XMLLoad',introText,outroText,Tester,fileLocation = '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Instrument',dependentFiles=['/home/lass/Dropbox/PhD/Software/MJOLNIR/Tutorials/SimpleInstrument.xml'])

def test_XMLLoad():
    Example.test()




#if __name__ == '__main__':
Example.generateTutorial()
Пример #5
0
    ax.set_xlim(-0.1,1.1)
    ax.set_ylim(-0.1,1.1)
    ax.set_zlim(-0.1,1.1)

    fig.savefig('/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Instrument/SimpleInstrument.png',format='png')
    
title = 'Build simple instrument'

introText = 'One can build a virtual representation of the instrument in question throughout the Instrument module. It consists of a series of different objects: '\
+'Instrument, Wedge, Detector, and Analyser, which are the objects needed to create the basics of the instrument. Everything regarding the guide has not been implemented. '\
+'Below is a simple example of how to create an instrument consisting of an analyser and a radial detector.'

outroText = 'The instrument is simply initialized without any objects. Then the detector and analyser are created and joined in the wedge object. '\
+'The wedge is then appended to the instrument which automatically adds it to it instrument description. Another way of achieving the same result is to '\
+'first create the wedge containing the detector and analyser, add the two to the wedge and then initialize the instrument with the wedge as argument. '\
+'In any case, the instrument is plotted throughout the plot method and the resulting image is shown below\n .. figure:: SimpleInstrument.png\n  :width: 50%\n  :align: center\n'\


introText = title+'\n'+'^'*len(title)+'\n'+introText


    
Example = Tutorial('instrument',introText,outroText,Tester,fileLocation = '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials/Instrument')

def test_instrument():
    Example.test()

#if __name__ == '__main__':
Example.generateTutorial()
Пример #6
0

title = 'Template for tutorial generation'

introText = 'This is a short and simple template for creating a tutorial for the MJOLNIR package. What is needed for the developer to define' \
    +' is a title, an intro text, an outro text, and then the actual code to be formated. All of this is done by filling in the template and '\
    +'running the bash script "tutorials" found in the same folder. This initiates testing of the code written and a restructured text file '\
    +'is saved in the indicated folder. As an example, the code below can be used:'

outroText = 'This is just a simple example code generating a figure denoted "figure0.png". However, in the actual code this figure is called "MJOLNIR/docs/Tutorials2/DataSet/Here.png" ' \
+'and can be shown with the use of rst commands\n .. figure:: Here.png\n  :width: 30%\n  :align: center\n'\
+'\n All of this is to work, I hope.'

introText = title + '\n' + '^' * len(title) + '\n' + introText

Example = Tutorial(
    'template',
    introText,
    outroText,
    Tester,
    fileLocation=
    '/home/lass/Dropbox/PhD/Software/MJOLNIR/docs/Tutorials2/DataSet')


def test_template():
    Example.test()


#if __name__ == '__main__':
Example.generateTutorial()