Author Topic: Get frame file path  (Read 55 times)

MikeShi

  • Newbie
  • *
  • Posts: 4
Get frame file path
« on: July 05, 2019, 02:38:16 PM »
Dear OVITO experts,

I am working writing some Python scripts with Ovito functions. Ovito is very powerful and useful. But I have a problem. How can I know the file path of the current frame when I load lots of dumps through wildcard character like *.cfg ? I try to use
Code: [Select]
pipline.source.source_path but it just returns
Code: [Select]
*.cfg.gz.

Thanks for your help

Yours Sincerely,

Linyuan

Constanze Kalcher

  • Administrator
  • Sr. Member
  • *****
  • Posts: 289
Re: Get frame file path
« Reply #1 on: July 05, 2019, 04:02:24 PM »
Dear Linyuan,

when you loop over your frames you can simply check the global attributes of each frame, which contain additional information like the current timestep 'Timestep', frame 'SourceFrame' or file path 'SourceFile'.
Try, e.g.
Code: [Select]
from ovito.io import *
pipeline = import_file("yourfilename*.cfg.gz")

for frame in range(pipeline.source.num_frames):
    data = pipeline.compute(frame)
    print(data.attributes['SourceFile'])

Does that answer your question?

-Constanze

MikeShi

  • Newbie
  • *
  • Posts: 4
Re: Get frame file path
« Reply #2 on: July 05, 2019, 10:37:00 PM »
Thanks for your kind reply and help. It totally answeres my question.

Cheers,

Linyuan