Open arnoutaertgeerts opened 9 years ago
The error is caused by this factor:
:#(type=Modelica_Fluid_Types*Dynamics)
I don't know why natu wants to parse this? Maybe you should prevent natu from parsing types like this?
@kdavies4 Did you find some time to look at this issue? :)
Sorry for the delay. Could you send me the SolarCollector.mat file? ModelicaRes is trying to use natu to parse known units out of the unit attribute of the Modelica variable. What is :#(type=ModelicaFluidTypes*Dynamics)
and where is it written?
Interesting. That file works for me. Could you update natu if it's not at v0.1.1? (Do pip install --upgrade natu
.) Also, please check that you have the latest modelicares (currently commit c5bed955 -- unreleased).
Kevin, I tried again with the latest Modelicares commit https://github.com/kdavies4/ModelicaRes/commit/9339ef6885ad663f855edb820dd6ef61053b322b and natu 0.1.1 but the file still fails to load with the same error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-2fff0ce928b3> in <module>()
----> 1 data = SimRes(r'../Results/SolarCollector.mat')
/home/arnout/anaconda/lib/python2.7/site-packages/ModelicaRes-0.12.2_117_g9339ef6-py2.7.egg/modelicares/simres.pyc in __init__(self, fname, constants_only, tool)
954 raise LookupError("%s isn't one of the available tools (%s)."
955 % (tool, ', '.join(list(readerdict))))
--> 956 variables = read(fname, constants_only)
957 self.update(variables)
958
/home/arnout/anaconda/lib/python2.7/site-packages/ModelicaRes-0.12.2_117_g9339ef6-py2.7.egg/modelicares/_io/dymola.pyc in readsim(fname, constants_only)
375 if not display_unit:
376 display_unit = unit_str
--> 377 unit = U._units(**nc.Exponents.fromstr(unit_str))
378 try:
379 _apply_unit(signed_values, unit)
/home/arnout/anaconda/lib/python2.7/site-packages/natu/exponents.pyc in fromstr(cls, expr)
442 new -= cls.fromstr(subexpr)
443 else:
--> 444 expr = process_expression(expr, new, add)
445
446 # Get the operator for the next loop.
/home/arnout/anaconda/lib/python2.7/site-packages/natu/exponents.pyc in process_expression(expr, exponents, add)
421
422 # Find the base, exponent, and remainder of the expression.
--> 423 base, exp, remainder = _split(expr)
424
425 # Update the exponents.
/home/arnout/anaconda/lib/python2.7/site-packages/natu/exponents.pyc in _split(factor)
183 # Parse the factor.
--> 184 base, exp_fr, exp_fl, exp_i, remainder = parser.match(factor).groups()
185
186 # Cast the exponent into the appropriate number type.
AttributeError: 'NoneType' object has no attribute 'groups'
When trying to load a file with ModelicaRes I get the following error:
any idea what might be causing this? The result file is generated by Dymola.