Ask Your Question

Using Dyntools to Plot Many .OUT Files

asked 2019-07-29 07:44:24 -0600

municipalpower gravatar image

I am trying to use Dyntools to plot each .OUT file in a directory, one by one. What I am doing is setting up my optnchn dictionary, then looping through each .OUT file in the directory, creating a chnf object, updating the filename, and calling .xyplots() to plot it. This works fine, in the sense that I get a pdf file output for each .OUT file, but I get the following error:

C:\Python34\lib\site-packages\matplotlib\cbook\ MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.

What ends up happening is that each subsequent plot is overlapping the previous plot. It seems to be 're-using' the previous plot that was created. The only way around this that I have found is to run each plot individually one by one. I have tried many things like moving the .xyplots() call to its own function, and returning chnf. I have also tried to put a .plots_close after the plot is created, and this just terminates the program. Code is inserted below. Any ideas as to what I am missing?

# Create list with all .OUT files in directory
outlist = glob.glob(r'C:\Users\Manny\Documents\PRC-12\2019_____SPS_Effectiveness_Study\results\dynamics\Phase_I\_OUT\*.out')

# Setup Channels - Each .OUT file has 7 plots, with 6 channels each.
optnchn = {1:{'chns':[7,9,53,55,59,79]},
            6:{'chns': [100,103,105,109,119,120]},
            7:{'chns': [81,83,85,86,88,89]}

# Counter for filenames
j = 1

# Loop thru each .OUT file
for i in outlist:

    # Create object with current out file, set options
    chnf = dyntools.CHNF(i)
    optn = {'size': 'Letter', 'orientation': 'Landscape', 'title': '2019 ___SPS Effectiveness Study - Phase I', 'dpi': 300, 'showttl': True}

    # Set Filename for current .OUT file plot results
    plotfile1 = r'C:\Users\Manny\Documents\PRC-12\2019____SPS_Effectiveness_Study\results\plot_logs\PHASE I\SimPlots'
    plotfile2 = j
    plotfile3 = '.pdf'
    plotfile = plotfile1 + str(plotfile2) + plotfile3
    j = j+1

    # Produce Plot
    ierr = chnf.xyplots(optnchn, optn, plotfile)

    if ierr:
        print('Errors Were Found')

        print('No Errors Found')
edit retag flag offensive close merge delete


Have you found a fix to your problem? I am having the same issue and I have not found a fix other than possibly rewriting code as mentioned in the answers.

dquick gravatar imagedquick ( 2021-08-12 10:09:29 -0600 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2019-07-30 10:01:55 -0600

jconto gravatar image

Check the post "Channels - tool to process outs files" for a tool that does plotting by channel type.

edit flag offensive delete link more

answered 2019-07-29 13:57:15 -0600

drsgao gravatar image

I actually think the warning explains it all. It does tell you that it's gonna overlap.

I also noticed that you are using Python 3.4, which suggests that you are using PSSE 34.4+? Maybe Siemens forgot to update the dyntools module accordingly?

I would suggest you to try 2 things.

  1. Force PSSE to use Python 2 and see whether it works or not.
  2. I remember the dyntools module actually allows you to get all the raw data out? If that's still the case, get all the raw data out and plot them with matplotlib. You can get rid of Siemens' label this way and have a bit more freedom with subplots. See these posts: Export all channels of a .out (Dyntools) to excel file Convert dynamic OUT files to Excel XLSX files
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


Asked: 2019-07-29 07:44:24 -0600

Seen: 715 times

Last updated: Jul 30 '19