Dear STKO Team,
I am currently running the same postprocessing script on multiple output databases generated by STKO for different accelerograms.
The general form of the instructions is:
1. OpneDatabase --> App.runCommand("OpenDatabase", "RECORDERS.mpco")
2. Instructions --> runpy.run_path(path_name='POST_PROCESSING_FILE.py')
3. CloseDatabase -->doc.removeDatabase(db)
I can successfully open the database, run the instructions and close the database once.
However, I am unable to repeat this sequence of instructions more than once. In fact, after the first time, the software crashes. I think this is due to the import of modules multiple times?
Can you please help me with this issue?
Thank you in advance for your help.
Best wishes,
Raffaele
STRUCTURE OF THE CODE: - The Green Line is the line that does not work.
from PyMpc import *
from os import chdir
import runpy
App.clearTerminal()
chdir('ACC_1')
App.runCommand("OpenDatabase", "RECORDERS_PART_1.mpco")
doc = App.postDocument()
doc.clearPlotGroups()
doc.clearCharts()
doc.clearChartData()
doc.commitChanges()
doc.dirty = True
doc.select(None)
runpy.run_path(path_name='POST_PROCESSING_FINAL_PART_1.py')
db = doc.getDatabase(1)
doc.removeDatabase(db)
App.setBusy(False)
App.clearTerminal()
App.runCommand("OpenDatabase", "RECORDERS_PART_2.mpco")
doc = App.postDocument()
doc.clearPlotGroups()
doc.clearCharts()
doc.clearChartData()
doc.commitChanges()
doc.dirty = True
doc.select(None)
runpy.run_path(path_name='POST_PROCESSING_FINAL_PART_2.py')
db = doc.getDatabase(1)
doc.removeDatabase(db)
App.setBusy(False)
chdir("..")
Running postprocessing on multiple results
-
raffaele.derisi
- Posts: 7
- Joined: Sun May 09, 2021 7:51 pm
Re: Running postprocessing on multiple results
Hi Raffaele,
I've never used runpy, but I've seen that there could be many side effects.
Are you really sure you need it?
Probably you can just import the module and use functions there...
For example, if "POST_PROCESSING_FINAL_PART_1.py" contains functions that take the document or the databse as argument and work with it, you can simply put that script into one of the folder you loaded into your ScriptExplored,
and import your module with
import POST_PROCESSING_FINAL_PART_1 as instructions
then you can replace your green line with something else
#runpy.run_path(path_name='POST_PROCESSING_FINAL_PART_2.py')
instruction.compute(doc)
I've never used runpy, but I've seen that there could be many side effects.
Are you really sure you need it?
Probably you can just import the module and use functions there...
For example, if "POST_PROCESSING_FINAL_PART_1.py" contains functions that take the document or the databse as argument and work with it, you can simply put that script into one of the folder you loaded into your ScriptExplored,
and import your module with
import POST_PROCESSING_FINAL_PART_1 as instructions
then you can replace your green line with something else
#runpy.run_path(path_name='POST_PROCESSING_FINAL_PART_2.py')
instruction.compute(doc)
Re: Running postprocessing on multiple results
Hello,
Where can I find the syntax list of this code?
For example, for numpy, mathplotlib libraries in Python, there are some website to explain the syntaxes.
Thank you,
Buu
Where can I find the syntax list of this code?
For example, for numpy, mathplotlib libraries in Python, there are some website to explain the syntaxes.
Thank you,
Buu
Re: Running postprocessing on multiple results
each of them has it's own documentation, just google it...