|
|
coming soon... |
|
|
\ No newline at end of file |
|
|
## Get started
|
|
|
|
|
|
### Install the template module
|
|
|
|
|
|
> **NOTES:** STEP 3 has two version with and without an account at gitlab.aip.de
|
|
|
|
|
|
#### STEP 1: download source
|
|
|
|
|
|
download the source of the module mypltemplate:
|
|
|
- zip [https://gitlab.aip.de/yfournier/mypltemplate/repository/archive.zip?ref=master](https://gitlab.aip.de/yfournier/mypltemplate/repository/archive.zip?ref=master)
|
|
|
- tar.gz [https://gitlab.aip.de/yfournier/mypltemplate/repository/archive.tar.gz?ref=master](https://gitlab.aip.de/yfournier/mypltemplate/repository/archive.tar.gz?ref=master)
|
|
|
|
|
|
#### STEP 2: extract and rename the module
|
|
|
|
|
|
you can rename `mypltemplate` to any name you whish.
|
|
|
|
|
|
> **NOTES:** for the exemple we rename it to `mymodule` in the directory `/home/user/src/`
|
|
|
> (python requires that module name should be only letters)
|
|
|
|
|
|
#### STEP 3: Clone myplotlib from gitlab.aip.de **(with account at gitlab.aip.de)**
|
|
|
|
|
|
in `/home/user/src/mymodule`:
|
|
|
|
|
|
```
|
|
|
git git@gitlab.aip.de:yfournier/myplotlib.git --branch tools
|
|
|
```
|
|
|
|
|
|
#### STEP 3: download source **(without an account at gitlab.aip.de)**
|
|
|
|
|
|
download source of the module myplotlib
|
|
|
|
|
|
- zip [https://gitlab.aip.de/yfournier/myplotlib/repository/archive.zip?ref=tools](https://gitlab.aip.de/yfournier/myplotlib/repository/archive.zip?ref=tools)
|
|
|
- tar.gz [https://gitlab.aip.de/yfournier/myplotlib/repository/archive.tar.gz?ref=tools](https://gitlab.aip.de/yfournier/myplotlib/repository/archive.tar.gz?ref=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. |
|
|
\ No newline at end of file |