Using variables in the output file path/name

Forum for asking and answering questions related to use of the OpenSeesPy module

Moderators: silvia, selimgunay, Moderators

Post Reply
openseas
Posts: 2
Joined: Fri Oct 14, 2022 9:24 pm

Using variables in the output file path/name

Post by openseas » Fri Oct 14, 2022 9:30 pm

Hi there,

I am running multiple time history analyses using openseespy. For the output file, I would like to put them in different folders or name the output files based on the input ground motion names, either way would work for me. To achieve this, I would need to include variables before the output file DFree.out. I tried a few different way but it didn't appear to work. Any suggestions would be much appreciated!


op.recorder('Node', '-file', '(need something here to relate the output with input file name)DFree.out','-time', '-node', 2, '-dof', 1,2,3, 'disp')

mhscott
Posts: 872
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: Using variables in the output file path/name

Post by mhscott » Sat Oct 15, 2022 7:56 am

Use Python f-strings

blah = 1
foo = 'abc'
bar = 123

ops.recorder(...,f'{blah}{foo}{bar}Dfree.out',...)

openseas
Posts: 2
Joined: Fri Oct 14, 2022 9:24 pm

Re: Using variables in the output file path/name

Post by openseas » Sat Oct 15, 2022 8:24 am

Thank you Prof. Scott. Your online teaching content makes opensees a powerful tool.

Post Reply