I use FMU a lot for simulation of Modelica models in a Python environment. It would be nice to bundle the obtained FMU from compilation with a png-file that shows the system. Is that possible?
And how to access that png-file and show it in a Jupyter notebook?
With the input from Christian and Dag and reading about package zipfile https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.open we can handle the problem as follows for FMU (2.0):
The person who receive this FMU can now do the following in Python to show the process_diagram.png
import matplotlib.pyplot as plt
import matplotlib.image as img
import zipfile
fmu_file = zipfile.ZipFile('fmu_model.fmu', 'r')
process_diagram = fmu_file.open('documentation/processDiagram.png')
plt.imshow(img.imread(process_diagram))
plt.axis('off')
plt.show()
For a safe handling we need to also include a system with checksum or similar to avoid the possibility to corrupt the FMU with wrong png-files. Design of this safety handling I leave to the designers of PyFMI and FMPy. In fact FMPy has some general handling of checksum already for FMI 2.0, but to my knowledge no functionality to extract a process_diagram file.