First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

TIME ARRAY EXTRACTION

asked Jan 12 '16

MAMAMO gravatar image

Hi After running simulations, I want to extract simulation running time (from 0 to 20s, with defined time step,around 2000 numbers in array) as an array. Because I want to work on outputs and change their scales and then plot them with time array to have accurate results. Could you help me to make this? A hint could be so helpful. thanks

1 answer

Sort by » oldest newest most voted
0

answered Feb 19 '16

IanMelbourne93 gravatar image

Hey try this. Will help you extract your time and then separate your data into a list format rather than the default dictionary. Once you have this, you can plot it with Matplotlibs. Let me know how you go

import dyntools

# Run dyntools to extract the data
chnfobj = dyntools.CHNF(os.path.join(folder, outfile))
sh_ttl, ch_id, ch_data = chnfobj.get_data()

# Extract time as a variable
time = ch_data['time']

# Number of channels, (-1 as 'time' is represented in channel data)
count = len(ch_id) - 1

# Extract channel data
data = [ch_data[x + 1] for x in xrange(count)]
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Jan 12 '16

Seen: 3,510 times

Last updated: Feb 19 '16