kdavies4 / modelicares Goto Github PK
View Code? Open in Web Editor NEWSet up, analyze, and plot Modelica simulations in Python
Home Page: http://kdavies4.github.io/ModelicaRes/
License: Other
Set up, analyze, and plot Modelica simulations in Python
Home Page: http://kdavies4.github.io/ModelicaRes/
License: Other
Base this functionality on SimRes.names()
.
Hello again!
I am having this error when importing SimRes
Traceback (most recent call last):
File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\msv_framework_gui.py", line 11, in <module>
from gui import UI_LoadSources, UI_ConfigSolver, UI_Simulation, UI_Plot
File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\__init__.py", line 3, in <module>
from mee_simulation_gui import UI_Simulation
File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\mee_simulation_gui.py", line 13, in <module>
from modelicares import SimRes
File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\__init__.py", line 50, in <module>
from .simres import SimRes, SimResList, SimResSequence
File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\simres.py", line 52, in <module>
from natu import core as nc
File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\core.py", line 171, in <module>
from .exponents import Exponents, split_code, u, i
File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\exponents.py", line 177, in <module>
parser = re.compile('%s%s?%s?' % (base, exponent, remainder))
File "C:\IDE\Python27\lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\IDE\Python27\lib\re.py", line 245, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
I am reading in "the web" that this issue might come from the re.compile() function. I guess you did not face this issue with the natu library. Any idea?
Edited: I am running the code in Eclipse Mars PyDev, under Windows 7
Cheers!
It would be nice to see a more recent PyPI package.
Dear Kevin,
Thank you for this nice project. Unfortunately I cannot use your software directly. The files 00-reindent.py
and 00-tabnanny.py
from the folder modelicares
are symbolic links and I had to delete them in order to run the installation routine successfully.
Please check if these files are necessary and consider removing the symlinks or add the real files.
Thanks again,
Jorrit
The SimResList
class does an excellent job of plotting simulation results of different simulations with the same start and stop time.
For continued simulations, it is unnecessary to divide the plot in different segments and give each segment a new name and color. For example:
I see two solutions:
plot()
method to take this into accountmerge()
) which merges the different simulation results in a new single result fileKevin, are you still using ModelicaRes often? I keep getting error messages with respect to natu
:) If I want to translate the SimRes
object to a dataFrame I get the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-85a33601c9f3> in <module>()
----> 1 data.to_pandas(names=keys)
/home/arnout/anaconda/lib/python2.7/site-packages/ModelicaRes-0.12.2_117_g9339ef6_dirty-py2.7.egg/modelicares/simres.pyc in to_pandas(self, names, aliases)
1649
1650 if unit:
-> 1651 data.update({name + ' / ' + unit: values})
1652 else:
1653 data.update({name: values})
/home/arnout/anaconda/lib/python2.7/site-packages/natu/exponents.pyc in __add__(x, y)
461 """x.__add__(y) <==> x+y"""
462 copy = x.copy()
--> 463 for base, exp in y.items():
464 copy[base] += exp
465 return copy
AttributeError: 'str' object has no attribute 'items'
Use the displayUnit
by default but allow custom override in SimRes.get_values()
, SimRes.get_IV()
, etc.
Ideas for implementation:
f
argument to SimRes.get_values()
, etc. with a unit
argument:
None
), then use displayUnit
."m/s2"
). The units may contain SI prefixes.m/s**2
) where the values are available from a submodule (modelicares.units
).degC
, dB
), also from a submodule.unit
argument, default units, displayUnit
attribute, unit
attributeunits
submodule (e.g., c/(m/s)
should return 299792458
).modelicares.units
.This may require using Qt instead of WX (Issue #11).
There's two syntax errors in the sources.
substitute '<>' by '!='.
Hi Kevin, (or whoever who read it)
I am trying to use modelicares in Jython (using easy_install, pip, ...) and I am getting this error:
ImportError: No module named py3k
(Installation in Python works fine!)
Do you know what is this py3k? Any experience about this issue?
Cheers!
The simulator.run()
method should be able to set start and stop times for the simulation. This can be done by changing their respective values in the corresponding dsin.txt
if we extend the write_params()
method. For example:
import modelicares.exps.write_params as write_params
write_params({
'StartTime': 0,
'StopTime': 1000
}
I'm no expert in these file manipulations so could you @kdavies4 have a look at how to efficiently implement this?
Hi Kevin,
we're trying to set up MPC (model predictive control) with Modelica, and we need a continue-run framework. We can implement it with dymosim.exe or pyfmi, and we're happy to see that you have implemented this functionality. However, when we install mdoelica res with pip, the following doesn't work::
from modelicares.exps.simulators import dymosim
Any idea why not? And is it possible to do continue-simulations with pyfmi too?
Thanks,
Roel
See astropy issue #2662.
Hi!
I am using this class, in modelicares.exps.simulators file, and... the script seems to be written fine, but I do not see how the class executes the .mos file. Its run method seems only to write commands into the .mos file, but how the .mos file is executed?
Cheers!
@kdavies4 When I try the new merged version for simulations I get the following importerror:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-5715e1a567d2> in <module>()
----> 1 from modelicares.exps.simulators import dymosim
c:\Users\u0098668\AppData\Local\Continuum\Anaconda\lib\site-packages\modelicares\__init__.py in <module>()
48 # These will be available directly from modelicares; others must be loaded from
49 # their submodules.
---> 50 from .simres import SimRes, SimResList, SimResSequence
51 from .linres import LinRes, LinResList
52 from .util import (add_arrows, add_hlines, add_vlines, ArrowLine, closeall,
c:\Users\u0098668\AppData\Local\Continuum\Anaconda\lib\site-packages\modelicares\simres.py in <module>()
581
582 # List of file-loading functions for SimRes
--> 583 from ._io.dymola import readsim as dymola
584 READERS = [('dymola', dymola)] # SimRes tries these in order.
585 # All of the keys should be in lowercase.
c:\Users\u0098668\AppData\Local\Continuum\Anaconda\lib\site-packages\modelicares\_io\dymola.py in <module>()
69 from six import PY2
70
---> 71 from .._display import default_display_units
72 from ..simres import Variable
73 from ..util import next_nonblank
ImportError: No module named _display
Did you remove this module?
Include this as an example in the tutorial.
When multiple Sankey diagrams are generated at successive times in a simulation, the labels are appended. I need to submit a fix to the Sankey class of matplotlib. After it is accepted, remove the temporary change to 00-make-gh-pages.sh in the gh-pages branch.
Consider merging this project with those listed in the "see also" section of the README.
- Support FMI (see PyFMI and pySimulator).
- Improve the GUI (pySimulator).
- Model testing (BuildingsPy).
When trying to export simulation data to a dataFrame pandas raises a KeyError.
The problem is that Dymola does not store the units into the *.mat-file when using Dymola functions like "writeTrajectory" or "Export Results".
It would be great if the function's return line could be updated to a more dynamic one, like:
return DataFrame(data).set_index('Time / '+self['Time'].unit)
This way one could use to_pandas() for modified simulation data.
Of course it would also be possible to change the data entry 'Time / ' to 'Time / s'.
Run TODO.sh
for a current listing.
The line
import modelicares # Only to read the version number
Is a problem because this, by itself, tries to load a bunch of dependencies.
There are two ways to approach this:
control
package to the path during setup.py
import
and provide the version number some other way.If you do 1) there are lots of dependencies. Some are listed in the setup.py
file (matplotlib
, wx
and numpy
). Of these, wx
is not the correct name for the extension you want. You want wxPython
(which installs a package named wx
, but is not the same as the PyPI listing for wx
). But scipy
is also a dependency even though it is not listed. The big problem here is that the mechanisms in setup.py
don't kick in to load all these things. In other words, since modelicares
is imported into setup.py
, all the dependencies have to be installed in advance. On the other hand, if the import wasn't there and pip
was used to install modelicares
from PyPI, all the dependencies could actually be loaded automatically. Even if you load all of those dependencies, you still have the problem that the control
package really needs to be installed first (because the external/control/src
directory name doesn't match the package name). After all of this, I eventually gave up on this approach.
Taking approach 2 (which simply means commenting out the import
line and substituting the version number ("0.8.1", in my case) into the setup.py
script worked perfectly and modelicares
installed without issue. Of course, this doesn't address the dependency issue (since a local install doesn't pull in all the dependencies). The issue with the dependencies (that wx
should be wxPython
that scipy
is missing) are not addressed. Also, the control
package still needs to be installed manually in that case.
One word of advice...the best way to test for these kinds of issues is to use virtualenv
to create a pristine "install". These things come out of the woodwork in such cases.
Carry-over from discussion in #26.
Currently returns NotImplementedError
That way, can use doctest on it.
Implement coveralls (see https://pypi.python.org/pypi/coveralls/0.4.2 and https://github.com/z4r/python-coveralls).
ImportError Traceback (most recent call last)
in ()
----> 1 from modelicares.exps.simulators import dymosim
/home/danie/.virtualenvs/vhm/local/lib/python2.7/site-packages/modelicares/exps/simulators.py in ()
42 from multiprocessing import Pool
43 from shutil import copy, move, rmtree
---> 44 from . import read_options, read_params, write_options, write_params
45 from ..simres import SimRes, SimResSequence
46 from ..util import ParamDict, call, cleanpath
ImportError: cannot import name read_options
Hi,
I started working with ModelicaRes today. I was exploring the options but I'm stuck at the following.
I'd like to use the subplot command from matplotlib. Intuitively I tried:
sim = SimRes(arguments)
sim.add_subplot(2,1,1) //from http://matplotlib.org/examples/animation/subplots.html
sim.plot(title="Title", ynames1= ... etc)
but this does not seem to work. I can't seem to find an example in the documentation either. How can I approach this?
Thank you!
When trying to import SimRes I receive the following error.
In [1]: from modelicares import SimRes
Traceback (most recent call last):
File "C:\ProgramData\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-7373672c4d21>", line 1, in <module>
from modelicares import SimRes
File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\__init__.py", line 50, in <module>
from .simres import SimRes, SimResList, SimResSequence
File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\simres.py", line 1723
if attr == 'value' and len(self) <> self.n_constants:
^
SyntaxError: invalid syntax
Is there any way to fix this?
Consider using hierarchical column headings to reflect the structure of a Modelica model.
Do this with version 1.0, and start with a fresh repository?
The following doc files link to _images
which is not available.
base.html
index.html
linres.html
multi.html
simres.html
Getting this error for .mat files generated by Dymola 2014 FD01.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 33-34: ordinal not in range(128)
This is issue is probably related to scipy/scipy@ecfae8b
I think the encoding should be 'latin-1' instead of 'ascii'
I was just starting to use Modelica res however it seems that something does not quite work as it should:
In [11]:
from modelicares import SimRes
sim = SimRes('test.mat')
sim.find('ramp.y')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-3c4dae3c8df3> in <module>()
----> 1 sim.find('ramp.y')
AttributeError: 'SimRes' object has no attribute 'find'
QT is used more widely, and it still seems to be difficult to get wx running with Python 3.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.