Jump to content

File:Sawtooth harmonics.png

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikibooks, open books for an open world

Original file (812 × 612 pixels, file size: 38 KB, MIME type: image/png)

Summary

Description
English: A periodic sawtooth wave in both time-domain and (truncated) frequency-domain representation
Date
Source Own work
Author Ldo

Generated with the following code:

import numpy as np
import matplotlib.pyplot as plt

frames_per_cycle = 256
freq = 3
nr_frames = frames_per_cycle * freq
phase = 0
audio = np.fromfunction(lambda y : (y /  frames_per_cycle + phase) % 1 - 0.5, (nr_frames,))
maxfreq = 16
freq_plotstyle = "o"
ft = np.fft.rfft(audio[:frames_per_cycle]) / (frames_per_cycle / 2)
if maxfreq != None :
    ft = ft[:maxfreq]
#end if
abs_mag = True

fig, ax = plt.subplots(nrows = 2 + int(not abs_mag))
ax[0].plot(np.linspace(0, freq, nr_frames), audio, "-")
ax[0].set_title("Time Domain")
if abs_mag :
    ax[1].plot(np.linspace(0, len(ft), len(ft)), np.abs(ft), freq_plotstyle)
    ax[1].set_title("Frequency Domain")
else :
    ax[1].plot(np.linspace(0, len(ft), len(ft)), np.real(ft), freq_plotstyle)
    ax[1].set_title("Frequency Domain (Real)")
    ax[2].plot(np.linspace(0, len(ft), len(ft)), np.imag(ft), freq_plotstyle)
    ax[2].set_title("Frequency Domain (Imag)")
#end if
plt.subplots_adjust(hspace = 0.5)
plt.show()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

19 July 2014

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:42, 19 July 2014Thumbnail for version as of 10:42, 19 July 2014812 × 612 (38 KB)LdoUser created page with UploadWizard

The following page uses this file:

Metadata