File:Gaussianbeam travelling PRGn.gif
Gaussianbeam_travelling_PRGn.gif (240 × 140 pixels, file size: 335 KB, MIME type: image/gif, looped, 16 frames, 0.8 s)
File information
Structured data
Captions
Summary edit
DescriptionGaussianbeam travelling PRGn.gif |
English: Animation of the field amplitude of a propagating Gaussian beam, white background, field amplitude in purple and green. |
Date | |
Source | Own work |
Author | Geek3 |
Other versions |
|
This plot was created with Matplotlib.
Source Code edit
The image is created by the following python source-code. Requirements:
- python
- Matplotlib plotting library
Python Matplotlib source code |
---|
#!/usr/bin/env python
# -*- coding: utf8 -*-
'''
Copyright (C) 2015 Geek3, Wikimedia Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'''
from math import *
import scipy
import matplotlib.pyplot as plt
from matplotlib import animation
from PIL import Image
# settings
fname = 'gaussianbeam_travelling_PRGn'
width, height = 240, 140
nframes = 16
fps=20
lambda_px = 16.
w0 = 16.
def E(r, z, w0):
z0 = pi * w0**2 / lambda_px
w = w0 * sqrt(1. + (z / z0)**2)
k = 2. * pi / lambda_px
R = z * (1. + (z0 / z)**2)
gouy = atan(z / z0)
E = w0 / w
E *= e ** (-(r/w)**2)
E *= e ** (-1j * k * r**2 / (2 * R))
E *= e ** (1j * (gouy - k * z))
return E
def draw(nframe):
# draw an image
image = scipy.zeros((height, width))
phase = nframe * 2 * pi / nframes
for y in range(height):
for x in range(width):
z = (x + 0.5) - width / 2.0
r = (y + 0.5) - height / 2.0
EE = E(r, z, w0)
image[y, x] = (EE * e**(1j*phase)).real
return image
def animate(nframe):
# prepare a clean and image-filling canvas for each frame
plt.clf()
fig.gca().set_position((0, 0, 1, 1))
plt.xlim(-0.5, width + 0.5)
plt.ylim(-0.5, height + 0.5)
plt.axis('off')
print 'frame', nframe
image = draw(nframe)
imgplot = plt.imshow(image, cmap='PRGn')
imgplot.set_clim(-1.0, 1.0)
imgplot.set_interpolation('nearest')
fig = plt.figure(figsize=(width/100., height/100.))
anim = animation.FuncAnimation(fig, animate, frames=nframes, repeat=False)
anim.save(fname + '.gif', writer='imagemagick', fps=fps)
|
Licensing edit
I, the copyright holder of this work, hereby publish it under the following licenses:
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
You may select the license of your choice.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 19:17, 12 July 2015 | 240 × 140 (335 KB) | Geek3 (talk | contribs) | animation of a travelling gaussian beam |
You cannot overwrite this file.
File usage on Commons
The following 2 pages use this file: