Commit 6c34d194 authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Add the begining of the tutorial into the README

parent 8492dbdf
get started
Get started
===========
download the module MYPLTEMPLATE
A. Install the template module
------------------------------
rename the module mymodule (name should be only letters: python requirements)
NOTES: step 3 has two version with and without an account at gitlab.aip.de
put it anywhere ex: home/src/mymodule
in home/src/mymodule type
git git@gitlab.aip.de:yfournier/myplotlib.git --branch tools
---- STEP 1: download source --------------------------------------------------------
python -m myplotlib -t
download zip/tar of the module mypltemplate at https://gitlab.aip.de/yfournier/mypltemplate
Should execute a series of tests and say ok at the end
Now the install is ok let us start
# IMPORT the MODULE
from mymodule import *
---- STEP 2: extract and rename the module ------------------------------------------
# READ Some data
run1 = readRun('./mypltemplate/data/serie1/run1.txt')
you can rename mypltemplate to any name you whish.
for the exemple we rename it to "mymodule" in the directory "/home/user/src/"
(python requires that module name should be only small letters)
---- STEP 3: (with account at gitlab.aip.de) clone myplotlib from gitlab.aip.de -----
in home/src/mymodule type:
git git@gitlab.aip.de:yfournier/myplotlib.git --branch tools
---- STEP 3: (without an account at gitlab.aip.de) download source ------------------
download zip/tar of the module myplotlib at https://gitlab.aip.de/yfournier/myplotlib
take care to download the source of the branch tools.
extract and rename like "/home/user/src/mymodule/myplotlib"
---- STEP 4: testing the myplotlib install ------------------------------------------
in "/home/user/src/mymodule/" type
python2.7 -m myplotlib -t
This will execute a series of tests, they should be all successful.
---- STEP 5: DONE!!! congratulation! ------------------------------------------------
Now you can start to enjoy the power of myplotlib
B. Plotting the interactively some Exemples
-------------------------------------------
---- STEP 1: launch python2.7
>$ python2.7
---- STEP 2: Import the module.
>>> # IMPORT the MODULE
>>> from mymodule import *
This imports all variables, functions and classes from "mymodule/__init__.py"
---- STEP 3: Open and Access some data
The template modules has some dummy data for demonstration in "mymodule/data"
This data are of two type:
- some structured data set (run1.txt, run2.txt, ...)
- some database (serie1.txt, serie2.txt)
In python (this is a general remark) it exists two powerful objects for
storing and accessing these types of data.
- for structured data sets the python dictionaries are suitable (https://docs.python.org/2/tutorial/datastructures.html#dictionaries)
- for database data sets the numpy.recarray are the perfect tool (https://docs.scipy.org/doc/numpy/reference/generated/numpy.recarray.html)
In "mymodule/myIOs" are two files containing the functions readRun, and readSeries
- the function readRun reads a run-text-file (structured data set) and stores the information into a python dictionary.
- the function readSeries reads a series-text-file (database data set) and stores the data into a numpy recarray.
Both function returns the data container of myplotlib, MyData
>>> # READ Some data
>>> run1 = readRun('./mymodule/data/serie1/run1.txt')
you can now type
>>> run1
it will return:
>>> <mymodule.myplotlib.myData.MyData instance at ...>
as you can see the object run1 is an object of type MyData. The ... shows the address of these object in the memory
this identifier is unique for any instance (again this is a general remark for python)
Now you can call
>>> run1.data['name']
>>> run1.data['input1']
>>> run1.data['results']
...
---- STEP 4: Visualising some RUN data
In "mymodule/myAxes" are a few files starting with ax these contain classes of Axes.
These classes are build over a general class MyAxes (from myplotlib). The class MyAxes
is build such that it can be used with any user defined class build on MyFig.
We will start with the class AxResults (see axResults.py)
In order to plot the Axes we need to integrate it into a Figure.
For the confort of the user, myplotlib comes with a few standard classes like FigOneAxes3D.
This class is build over MyFig (compatible with any MyAxes) and can be used as a container
for a single MyAxes.
We can now create a figure fig an instance of FigOneAxes3D with the
dataset (run1,) given to the class AxResults.
>>> # Create a figure to show the data
>>> fig = FigOneAxes3D((run1,), AxResults)
you can now type:
>>> fig
<mymodule.myplotlib.mytool.figOneAxes3D.FigOneAxes3D at ...>
We can also access the axes:
>>> fig.get_axes()
[<mypltemplate.myAxes.axResults.AxResults at ...>]
or even store the axes into a variable:
>>> ax = fig.get_axes()[0]
>>> ax
<mypltemplate.myAxes.axResults.AxResults at ...>
The FigOneAxes3D has (alike any MyFig instance) a function plot()
The plot function will call all plotting function of all axes contained in FigOneAxes3D.
In that case just one ax.plotting.
The plotting function will act on some attributes of the AxResults ax.
It will change the label for example.
>>> # The label of the axes before plotting
>>> ax.get_xlabel()
u''
>>> # CALL the PLOT procedure
>>> fig.plot()
>>> # The label after plotting
>>> ax.get_xlabel()
u'${\\rm x}~[{\\rm m}]$'
As you can see any part of the object can be access for more details
see matplotlib documentation (http://matplotlib.org/api/axes_api.html)
Now it is time to show the data set on the screen. To do so myplotlib
comes with a class called MyWin. This class will create a window,
containing a canvas.
- The window has some buttons like close, reduce and so one...
- The canvas can be seen as a white sheet of paper
on which you will draw a Figure (only one figure can be drawn on a canvas).
>>> # Create a window where the figure is shown
>>> win = MyWin(fig)
This should produce a window on which fig should be plotted.
# Create a figure to show the data
fig = FigOneAxes3D((run1,), AxResults)
# Create a window where the figure is shown
win = MyWin(fig, fignum=0)
# READ Some other data
run2 = readRun('./mypltemplate/data/serie1/run2.txt')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment