Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. read output files

read output files

Scheduled Pinned Locked Moved Python API
3 Posts 2 Posters 590 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michaelsch
    wrote on last edited by
    #1

    hi
    after simulation completed saved files :
    input.h5
    output.h5

    i want to use python to read the output data voltages x,y,z as generated after simulation completed

    1 Reply Last reply
    0
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      Hi,
      I would recommend to perform the postprocessing in the GUI first, then right-click in the Explorer window of the Analysis tab and select "To-Python" in the context menu. This will generate a script (visible in the Scripter window) that reproduces your postprocessing pipeline. You can then modify the script to your liking.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        michaelsch
        wrote on last edited by michaelsch
        #3

        solved with h5py read :
        import h5py

        with h5py.File(fname,'r') as hdf:
        FieldGroups=hdf['FieldGroups']
        keygroup = list(FieldGroups.keys())
        valField = FieldGroups[keygroup[0]]
        AllFields = valField['AllFields']
        EMPotential = AllFields['EM Potential(x,y,z,f0)']
        EMPotentialObject = EMPotential['_Object']
        AdditionalFieldDataCollection =
        EMPotentialObject['AdditionalFieldDataCollection']
        Snapshots = EMPotentialObject['Snapshots']
        Potential = Snapshots['0']['comp0']

        #(n, m, k, 2)  numpy array
        PotentialData = Potential[()]
        

        ==========
        this can be plotted
        import pyvista as pv

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Search