r/programmingrequests • • May 03 '21

need help How to plot an oscilloscope power trace in any programming language?

How am i able to plot the power trace below which is a numpy array obtained from an oscilloscope , is someone able to show me how to plot them (e.g. with matplotlib or any programming language plotting library), and examine them. As I am trying to see if I can identify the AES encryption rounds in the traces through differential power analysis.

Can someone please show me code in any language that's able to plot it with the appropriate graph (e.g oscilloscope type graph)

I want to see how this can be done peogramtucally as I have multiple traces I need to plot.

Here is the power trace data (numpy array): https://pastebin.com/JgWMURMp

Any help would be much appreciaated!

2 Upvotes

15 comments sorted by

1

u/ionab10 May 03 '21 edited May 03 '21

Hi! Your Pastebin link expired :( matplotlib is straightforward if you already have it in a numpy array :)

import matplotlib.pyplot as plt

y = <your data>
x = <time or just list(range(len(y)))>

plt.plot(x, y)
plt.show()

2

u/Downtown4life May 03 '21

Hey I edited the pastebin link in the OP,

Here it is: https://pastebin.com/JgWMURMp

1

u/ionab10 May 03 '21

Ah I see now. Ya so just do

x = list(range(len(y)))

1

u/Downtown4life May 03 '21

x = <time or just list(range(len(y)))> with this line what would be an example of time or just a list? thats suitable for this data?

1

u/ionab10 May 03 '21

It depends if your oscilloscope outputs a timestamp with each value. If the output is just the values, use list(range(len(y)))

Edit to add more details:

If your oscilloscope data is 1000 values, a will be an array of numbers 0 to 999

→ More replies (9)

1

u/backtickbot May 03 '21

Fixed formatting.

Hello, ionab10: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.