<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Python code for outputting analysis results]]></title><description><![CDATA[<p dir="auto">Excuse me for butting in.<br />
Nice to meet you. I’m currently a graduate student conducting research on temperature distribution in liver tumors with respiratory motion using Sim4Life.<br />
Could you please share some code that uses Python scripts to output the analysis results of temperature distributions after running the simulation?</p>
]]></description><link>https://forum.zmt.swiss/topic/782/python-code-for-outputting-analysis-results</link><generator>RSS for Node</generator><lastBuildDate>Tue, 12 May 2026 21:12:06 GMT</lastBuildDate><atom:link href="https://forum.zmt.swiss/topic/782.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 May 2026 05:48:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Python code for outputting analysis results on Mon, 11 May 2026 08:03:11 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">If you would just like to export the temperature distributions computed by the solver, you can use one of the built in Exporter tools (e.g. VTK, MATLAB, Text files), which produce formats that can be read externally.</p>
<p dir="auto">I would recommend that you do this manually first by using the GUI. Once you are satisfied with the configuration, you can right-click on your analysis tree and select 'To Python' to automatically generate the code required to reproduce the analysis.</p>
<p dir="auto">For example:</p>
<pre><code>import s4l_v1.analysis as analysis
import s4l_v1.document as document

# Incident EM parent simulation
simulation = document.AllSimulations["EM Simulation Name"]
simulation_extractor = simulation.Results()

# Thermal simulation 
simulation = document.AllSimulations["Thermal Simulation Name"]
simulation_extractor_2 = simulation.Results()

# Choose a sensor to extract
thermo_sensor_extractor = simulation_extractor_2["Overall Field"]
document.AllAlgorithms.Add(thermo_sensor_extractor)

# Adding a new MatlabExporter
inputs = [thermo_sensor_extractor.Outputs["T(x,y,z,t)"&rsqb;&rsqb;
matlab_exporter = analysis.exporters.MatlabExporter(inputs=inputs)
matlab_exporter.FileName = u"C:\\Users\\Test\\Downloads\\myfile.mat"
matlab_exporter.UpdateAttributes()
document.AllAlgorithms.Add(matlab_exporter)

# Call Update() to trigger writing the file
matlab_exporter.Update()
</code></pre>
<p dir="auto">This will produce a .mat file that contains separate arrays for every 'Snapshot' in your thermal simulation. For transient thermal simulations, a snapshot represents the field distribution at some point in time. It is dependent on the 'Maximum No. Samples' option in the Sensor settings of the simulation configuration.</p>
]]></description><link>https://forum.zmt.swiss/post/2449</link><guid isPermaLink="true">https://forum.zmt.swiss/post/2449</guid><dc:creator><![CDATA[brown]]></dc:creator><pubDate>Mon, 11 May 2026 08:03:11 GMT</pubDate></item></channel></rss>