Skip to content

Commit

Permalink
Merge branch 'v0.3.0rc2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cklb committed Oct 4, 2018
2 parents 60eef18 + dd734b5 commit db95f88
Show file tree
Hide file tree
Showing 24 changed files with 899 additions and 265 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ examples/results/processing*
# log files, created during runtime of PyMoskito
pymoskito.log.1
pymoskito.log.2
pymoskito.log.3
pymoskito.log.3

.DS_Store
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
language: python
python:
- '3.5'
- '3.6'

matrix:
include:
- python: '3.5'
- python: '3.6'
- python: '3.7'
dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069)

install:
- sudo apt-get update
- pip install -r requirements.txt
- pip install .

Expand Down
3 changes: 2 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Development Lead
----------------

* Stefan Ecklebe <stefan.ecklebe@tu-dresden.de>
* Christoph Burggraf <chris.burggraf@web.de>

Contributors
------------

* Christoph Burggraf
* Marcus Riesmeier
* Jonas Hoffmann
* Jens Wurm
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
History
=======

0.3.0 (2018-10-01)
------------------

* Added a new plot system
* Added a last simulation list
* Added more log messages
* Removed latex as an requirement for the main GUI, only required for the Postprocessor

0.2.3 (2018-05-14)
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

# General information about the project.
project = u'PyMoskito'
copyright = u'2017, Stefan Ecklebe'
copyright = u'2018, Stefan Ecklebe'

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
Expand Down
9 changes: 6 additions & 3 deletions pymoskito/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
os.environ["PYQTGRAPH_QT_LIB"] = "PyQt5"

from .registry import *
from .generic_processing_modules import *
from .generic_simulation_modules import *

from .processing_core import *
from .processing_gui import *
from .generic_processing_modules import *

from .simulation_gui import *
from .simulation_modules import *
from .generic_simulation_modules import *

from .tools import *
from .controltools import *
from .visualization import *
from .resources import *

__author__ = 'Stefan Ecklebe'
__email__ = 'stefan.ecklebe@tu-dresden.de'
__version__ = '0.2.3'
__version__ = '0.3.0'

# configure logging
with open(get_resource("logging.yaml", ""), "r") as f:
Expand Down
4 changes: 3 additions & 1 deletion pymoskito/examples/balltube/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class ErrorProcessor(XYMetaProcessor):

def __init__(self):
XYMetaProcessor.__init__(self, ["modules", "Controller"], ["modules", "Solver", "end time"],
XYMetaProcessor.__init__(self,
["modules", "Controller"],
["modules", "Solver", "end time"],
["metrics", "L1NormITAE"])

1 change: 0 additions & 1 deletion pymoskito/examples/car/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

# create an Application instance (needed)
app = QApplication([])
prog = None
sim = pm.SimulationGui()

# load defaults
Expand Down
1 change: 1 addition & 0 deletions pymoskito/examples/car/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ def check_consistency(self, x):
def calc_output(self, input):
return input


pm.register_simulation_module(pm.Model, CarModel)
1 change: 1 addition & 0 deletions pymoskito/examples/car/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,5 @@ def calc_positions(self, x1, x2, theta1, theta2, theta3, dia, d1, l2, d2, l3, ca
x1_trailer2, x2_trailer2,
x2T1_1, y2T1_1, x2T1_2, y2T1_2, x2T2_1, y2T2_1, x2T2_2, y2T2_2)


pm.register_visualizer(CarVisualizer)
16 changes: 16 additions & 0 deletions pymoskito/examples/simple_pendulum/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from . import model
from . import controller
from . import visualizer_mpl
# from . import visualizer_vtk

import pymoskito as pm

# register model
pm.register_simulation_module(pm.Model, model.PendulumModel)

# register controller
pm.register_simulation_module(pm.Controller, controller.BasicController)

# register visualizer
pm.register_visualizer(visualizer_mpl.MplPendulumVisualizer)
# pm.register_visualizer(visualizer_vtk.VtkPendulumVisualizer)
57 changes: 1 addition & 56 deletions pymoskito/generic_processing_modules.py
Original file line number Diff line number Diff line change
@@ -1,71 +1,16 @@
# -*- coding: utf-8 -*-


import matplotlib as mpl
import numpy as np
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.lines import Line2D as Line

from .processing_core import PostProcessingModule, MetaProcessingModule
from .tools import sort_tree
from .resources import colors
from .tools import sort_tree

__all__ = ["StepResponse", "PlotAll", "XYMetaProcessor"]


def get_figure_size(scale):
"""
calculate optimal figure size with the golden ratio
:param scale:
:return:
"""
# TODO: Get this from LaTeX using \the\textwidth
fig_width_pt = 448.13095
inches_per_pt = 1.0 / 72.27 # Convert pt to inch (stupid imperial system)
golden_ratio = (np.sqrt(5.0) - 1.0) / 2.0 # Aesthetic ratio
fig_width = fig_width_pt * inches_per_pt * scale # width in inches
fig_height = fig_width * golden_ratio # height in inches
fig_size = [fig_width, fig_height]
return fig_size


latex_settings = {
# change this if using contex, xetex or lualatex
"pgf.texsystem": "pdflatex",
# use LaTeX to write all text
"text.usetex": True,
'font.family': 'lmodern',
# blank entries should cause plots to inherit fonts from the document
# "font.serif": [],
# "font.sans-serif": [],
# "font.monospace": [],
# "text.fontsize": 11,
"legend.fontsize": 9, # Make the legend/label fonts a little smaller
"xtick.labelsize": 9,
"ytick.labelsize": 9,
"figure.figsize": get_figure_size(1), # default fig size of 1\textwidth
"lines.linewidth": 0.5,
"axes.labelsize": 11, # LaTeX default is 10pt font.
"axes.linewidth": 0.5,
"axes.unicode_minus": False,
# subfig related
"figure.subplot.left": 0.1,
"figure.subplot.right": 0.95,
"figure.subplot.bottom": 0.125,
"figure.subplot.top": 0.95,
# the amount of width reserved for blank space between subplots
"figure.subplot.wspace": 0.4,
# the amount of height reserved for white space between subplots
"figure.subplot.hspace": 0.4,
# Patches are graphical objects that fill 2D space, like polygons or circles
"patch.linewidth": 0.5,
}
mpl.rcParams.update(latex_settings)
mpl.rcParams['text.latex.preamble'].append(r'\usepackage{lmodern}'),
mpl.rcParams['text.latex.preamble'].append(r'\usepackage{siunitx}'),


class StepResponse(PostProcessingModule):
"""
Postprocessor that creates diagrams for step response experiments.
Expand Down
51 changes: 51 additions & 0 deletions pymoskito/mpl_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import logging
import matplotlib as mpl

from .tools import get_figure_size

_logger = logging.getLogger("mpl_settings")

orig_settings = {**mpl.rcParams}
latex_settings = {
# change this if using contex, xetex or lualatex
"pgf.texsystem": "pdflatex",
# use LaTeX to write all text
"text.usetex": True,
'font.family': 'lmodern',
# blank entries should cause plots to inherit fonts from the document
# "font.serif": [],
# "font.sans-serif": [],
# "font.monospace": [],
# "text.fontsize": 11,
"legend.fontsize": 9, # Make the legend/label fonts a little smaller
"xtick.labelsize": 9,
"ytick.labelsize": 9,
"figure.figsize": get_figure_size(1), # default fig size of 1\textwidth
"lines.linewidth": 0.5,
"axes.labelsize": 11, # LaTeX default is 10pt font.
"axes.linewidth": 0.5,
"axes.unicode_minus": False,
# subfig related
"figure.subplot.left": 0.1,
"figure.subplot.right": 0.95,
"figure.subplot.bottom": 0.125,
"figure.subplot.top": 0.95,
# the amount of width reserved for blank space between subplots
"figure.subplot.wspace": 0.4,
# the amount of height reserved for white space between subplots
"figure.subplot.hspace": 0.4,
# Patches are graphical objects that fill 2D space, like polygons or circles
"patch.linewidth": 0.5,
}


def enable_latex():
_logger.info("LaTeX export enabled")
mpl.rcParams['text.latex.preamble'].append(r'\usepackage{lmodern}'),
mpl.rcParams['text.latex.preamble'].append(r'\usepackage{siunitx}'),
mpl.rcParams.update(latex_settings)


def disable_latex():
_logger.info("LaTeX export disabled")
mpl.rcParams = orig_settings
13 changes: 12 additions & 1 deletion pymoskito/processing_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

from PyQt5.QtCore import Qt, pyqtSignal, QSize, QSettings
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtGui import QIcon, QKeySequence, QCloseEvent
from PyQt5.QtWidgets import (
QWidget, QAction, QMainWindow, QListWidget, QListWidgetItem, QToolBar,
QStatusBar, QLabel, QShortcut, QFileDialog, QGridLayout, QSizePolicy,
Expand All @@ -14,6 +14,7 @@
from . import registry as pm
from .processing_core import PostProcessingModule, MetaProcessingModule
from .tools import get_resource, PlainTextLogger, PostFilter
from .mpl_settings import enable_latex, disable_latex

__all__ = ["PostProcessor"]

Expand Down Expand Up @@ -162,6 +163,16 @@ def __init__(self, parent=None):
self.statusBar = QStatusBar(self)
self.setStatusBar(self.statusBar)

# activate latex formatting in plots
self._logger.info("TeX on")
enable_latex()

def closeEvent(self, QCloseEvent):
self._logger.info("Close Event received, closing Postprocessing GUI")
self._logger.info("TeX off")
disable_latex()
super().closeEvent(QCloseEvent)

def load_result_files(self):
path = self._settings.value("path/simulation_results")

Expand Down
Loading

0 comments on commit db95f88

Please sign in to comment.