From: <jd...@us...> - 2007-10-26 17:43:54
|
Revision: 4013 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4013&view=rev Author: jdh2358 Date: 2007-10-26 10:43:50 -0700 (Fri, 26 Oct 2007) Log Message: ----------- added some figs for convolution example Added Paths: ----------- trunk/py4science/workbook/fig/convolve_deltas.eps trunk/py4science/workbook/fig/convolve_deltas.png trunk/py4science/workbook/scripts/ trunk/py4science/workbook/scripts/convolve_deltas.py trunk/py4science/workbook/scripts/convolve_explain.py Added: trunk/py4science/workbook/fig/convolve_deltas.eps =================================================================== --- trunk/py4science/workbook/fig/convolve_deltas.eps (rev 0) +++ trunk/py4science/workbook/fig/convolve_deltas.eps 2007-10-26 17:43:50 UTC (rev 4013) @@ -0,0 +1,780 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: convolve_deltas.eps +%%Creator: matplotlib version 0.90.1, http://matplotlib.sourceforge.net/ +%%CreationDate: Fri Oct 26 12:42:28 2007 +%%Orientation: portrait +%%BoundingBox: 18 180 594 612 +%%EndComments +%%BeginProlog +/mpldict 7 dict def +mpldict begin +/m { moveto } bind def +/l { lineto } bind def +/r { rlineto } bind def +/box { +m +1 index 0 r +0 exch r +neg 0 r +closepath +} bind def +/clipbox { +box +clip +newpath +} bind def +/ellipse { +newpath +matrix currentmatrix 7 1 roll +translate +scale +0 0 1 5 3 roll arc +setmatrix +closepath +} bind def +%!PS-Adobe-3.0 Resource-Font +%%Title: Bitstream Vera Sans +%%Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. +%%Creator: Converted from TrueType by PPR +25 dict begin +/_d{bind def}bind def +/_m{moveto}_d +/_l{lineto}_d +/_cl{closepath eofill}_d +/_c{curveto}_d +/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d +/_e{exec}_d +/FontName /BitstreamVeraSans-Roman def +/PaintType 0 def +/FontMatrix[.001 0 0 .001 0 0]def +/FontBBox[-182 -235 1287 928]def +/FontType 3 def +/Encoding StandardEncoding def +/FontInfo 10 dict dup begin +/FamilyName (Bitstream Vera Sans) def +/FullName (Bitstream Vera Sans) def +/Notice (Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.) def +/Weight (Roman) def +/Version (Release 1.10) def +/ItalicAngle 0.0 def +/isFixedPitch false def +/UnderlinePosition -213 def +/UnderlineThickness 143 def +end readonly def +/CharStrings 7 dict dup begin +/period{318 0 107 0 210 124 _sc +107 124 _m +210 124 _l +210 0 _l +107 0 _l +107 124 _l +_cl}_d +/zero{636 0 66 -13 570 742 _sc +318 664 _m +267 664 229 639 203 589 _c +177 539 165 464 165 364 _c +165 264 177 189 203 139 _c +229 89 267 64 318 64 _c +369 64 407 89 433 139 _c +458 189 471 264 471 364 _c +471 464 458 539 433 589 _c +407 639 369 664 318 664 _c +318 742 _m +399 742 461 709 505 645 _c +548 580 570 486 570 364 _c +570 241 548 147 505 83 _c +461 19 399 -13 318 -13 _c +236 -13 173 19 130 83 _c +87 147 66 241 66 364 _c +66 486 87 580 130 645 _c +173 709 236 742 318 742 _c +_cl}_d +/one{636 0 110 0 544 729 _sc +124 83 _m +285 83 _l +285 639 _l +110 604 _l +110 694 _l +284 729 _l +383 729 _l +383 83 _l +544 83 _l +544 0 _l +124 0 _l +124 83 _l +_cl}_d +/two{{636 0 73 0 536 742 _sc +192 83 _m +536 83 _l +536 0 _l +73 0 _l +73 83 _l +110 121 161 173 226 239 _c +290 304 331 346 348 365 _c +380 400 402 430 414 455 _c +426 479 433 504 433 528 _c +433 566 419 598 392 622 _c +365 646 330 659 286 659 _c +255 659 222 653 188 643 _c +154 632 117 616 78 594 _c +78 694 _l +118 710 155 722 189 730 _c +223 738 255 742 284 742 _c +359 742 419 723 464 685 _c +509 647 532 597 532 534 _c +532 504 526 475 515 449 _c +504 422 484 390 454 354 _c +446 344 420 317 376 272 _c +332 227 271 164 192 83 _c +_cl}_e}_d +/three{{636 0 76 -13 556 742 _sc +406 393 _m +453 383 490 362 516 330 _c +542 298 556 258 556 212 _c +556 140 531 84 482 45 _c +432 6 362 -13 271 -13 _c +240 -13 208 -10 176 -4 _c +144 1 110 10 76 22 _c +76 117 _l +103 101 133 89 166 81 _c +198 73 232 69 268 69 _c +330 69 377 81 409 105 _c +441 129 458 165 458 212 _c +458 254 443 288 413 312 _c +383 336 341 349 287 349 _c +202 349 _l +202 430 _l +291 430 _l +339 430 376 439 402 459 _c +428 478 441 506 441 543 _c +441 580 427 609 401 629 _c +374 649 336 659 287 659 _c +260 659 231 656 200 650 _c +169 644 135 635 98 623 _c +98 711 _l +135 721 170 729 203 734 _c +235 739 266 742 296 742 _c +}_e{370 742 429 725 473 691 _c +517 657 539 611 539 553 _c +539 513 527 479 504 451 _c +481 423 448 403 406 393 _c +_cl}_e}_d +/four{636 0 49 0 580 729 _sc +378 643 _m +129 254 _l +378 254 _l +378 643 _l +352 729 _m +476 729 _l +476 254 _l +580 254 _l +580 172 _l +476 172 _l +476 0 _l +378 0 _l +378 172 _l +49 172 _l +49 267 _l +352 729 _l +_cl}_d +/five{{636 0 77 -13 549 729 _sc +108 729 _m +495 729 _l +495 646 _l +198 646 _l +198 467 _l +212 472 227 476 241 478 _c +255 480 270 482 284 482 _c +365 482 429 459 477 415 _c +525 370 549 310 549 234 _c +549 155 524 94 475 51 _c +426 8 357 -13 269 -13 _c +238 -13 207 -10 175 -6 _c +143 -1 111 6 77 17 _c +77 116 _l +106 100 136 88 168 80 _c +199 72 232 69 267 69 _c +323 69 368 83 401 113 _c +433 143 450 183 450 234 _c +450 284 433 324 401 354 _c +368 384 323 399 267 399 _c +241 399 214 396 188 390 _c +162 384 135 375 108 363 _c +108 729 _l +_cl}_e}_d +end readonly def + +/BuildGlyph + {exch begin + CharStrings exch + 2 copy known not{pop /.notdef}if + true 3 1 roll get exec + end}_d + +/BuildChar { + 1 index /Encoding get exch get + 1 index /BuildGlyph get exec +}_d + +FontName currentdict end definefont pop +%%EOF +end +%%EndProlog +mpldict begin +18 180 translate +576 432 0 0 clipbox +gsave +1.000 setgray +1.000 setlinewidth +0 setlinejoin +2 setlinecap +[] 0 setdash +0 0 m +0 432 l +576 432 l +576 0 l +closepath +gsave +fill +grestore +stroke +grestore +gsave +0.000 setgray +72 43.2 m +72 388.8 l +518.4 388.8 l +518.4 43.2 l +closepath +gsave +1.000 setgray +fill +grestore +stroke +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +69.21 43.2 m +69.21 388.8 l +74.79 388.8 l +74.79 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +91.53 43.2 m +91.53 362.457 l +97.11 362.457 l +97.11 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +113.85 43.2 m +113.85 307.904 l +119.43 307.904 l +119.43 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +136.17 43.2 m +136.17 239.267 l +141.75 239.267 l +141.75 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +158.49 43.2 m +158.49 172.281 l +164.07 172.281 l +164.07 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +180.81 43.2 m +180.81 120.84 l +186.39 120.84 l +186.39 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +203.13 43.2 m +203.13 94.252 l +208.71 94.252 l +208.71 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +225.45 43.2 m +225.45 95.729 l +231.03 95.729 l +231.03 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +247.77 43.2 m +247.77 122.291 l +253.35 122.291 l +253.35 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +270.09 43.2 m +270.09 165.978 l +275.67 165.978 l +275.67 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +292.41 43.2 m +292.41 216 l +297.99 216 l +297.99 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +314.73 43.2 m +314.73 261.261 l +320.31 261.261 l +320.31 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +337.05 43.2 m +337.05 292.723 l +342.63 292.723 l +342.63 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +359.37 43.2 m +359.37 305.099 l +364.95 305.099 l +364.95 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +381.69 43.2 m +381.69 297.61 l +387.27 297.61 l +387.27 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +404.01 43.2 m +404.01 273.718 l +409.59 273.718 l +409.59 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +426.33 43.2 m +426.33 239.993 l +431.91 239.993 l +431.91 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +448.65 43.2 m +448.65 204.446 l +454.23 204.446 l +454.23 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +470.97 43.2 m +470.97 174.705 l +476.55 174.705 l +476.55 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +gsave +gsave +446.4 345.6 72 43.2 clipbox +493.29 43.2 m +493.29 156.455 l +498.87 156.455 l +498.87 43.2 l +closepath +gsave +0.000 0.000 1.000 setrgbcolor +fill +grestore +stroke +grestore +grestore +0.000 0.000 1.000 setrgbcolor +2.000 setlinewidth +gsave +446.4 345.6 72 43.2 clipbox +72 388.8 m +94.32 362.457 l +116.64 307.904 l +138.96 239.267 l +161.28 172.281 l +183.6 120.84 l +205.92 94.252 l +228.24 95.7291 l +250.56 122.291 l +272.88 165.978 l +295.2 216 l +317.52 261.261 l +339.84 292.723 l +362.16 305.099 l +384.48 297.61 l +406.8 273.718 l +429.12 239.993 l +451.44 204.446 l +473.76 174.705 l +496.08 156.455 l +stroke +grestore +0.000 setgray +gsave +446.4 345.6 72 43.2 clipbox +72 43.2 m +518.4 43.2 l +stroke +grestore +/BitstreamVeraSans-Roman findfont +12.000 scalefont +setfont +63.25 30.122 m +0 0.172 rmoveto +(0.0) show +0.500 setlinewidth +0 setlinecap +/o { gsave +newpath +translate +-0.5 0 m +-0.5 4 l +closepath +stroke +grestore } bind def +161.28 43.2 o +/o { gsave +newpath +translate +-0.5 -4 m +-0.5 0 l +closepath +stroke +grestore } bind def +161.28 388.8 o +152.686 30.122 m +0 0.172 rmoveto +(0.1) show +/o { gsave +newpath +translate +-0.5 0 m +-0.5 4 l +closepath +stroke +grestore } bind def +250.56 43.2 o +/o { gsave +newpath +translate +-0.5 -4 m +-0.5 0 l +closepath +stroke +grestore } bind def +250.56 388.8 o +242.013 30.122 m +0 0.172 rmoveto +(0.2) show +/o { gsave +newpath +translate +-0.5 0 m +-0.5 4 l +closepath +stroke +grestore } bind def +339.84 43.2 o +/o { gsave +newpath +translate +-0.5 -4 m +-0.5 0 l +closepath +stroke +grestore } bind def +339.84 388.8 o +331.176 30.122 m +0 0.172 rmoveto +(0.3) show +/o { gsave +newpath +translate +-0.5 0 m +-0.5 4 l +closepath +stroke +grestore } bind def +429.12 43.2 o +/o { gsave +newpath +translate +-0.5 -4 m +-0.5 0 l +closepath +stroke +grestore } bind def +429.12 388.8 o +420.307 30.122 m +0 0.172 rmoveto +(0.4) show +/o { gsave +newpath +translate +-0.5 0 m +-0.5 4 l +closepath +stroke +grestore } bind def +518.4 43.2 o +/o { gsave +newpath +translate +-0.5 -4 m +-0.5 0 l +closepath +stroke +grestore } bind def +518.4 388.8 o +509.775 30.122 m +0 0.172 rmoveto +(0.5) show +50.5 38.661 m +0 0.172 rmoveto +(0.0) show +/o { gsave +newpath +translate +0 0.5 m +4 0.5 l +closepath +stroke +grestore } bind def +72 129.6 o +/o { gsave +newpath +translate +-4 0.5 m +0 0.5 l +closepath +stroke +grestore } bind def +518.4 129.6 o +50.75 125.061 m +0 0.172 rmoveto +(0.5) show +/o { gsave +newpath +translate +0 0.5 m +4 0.5 l +closepath +stroke +grestore } bind def +72 216 o +/o { gsave +newpath +translate +-4 0.5 m +0 0.5 l +closepath +stroke +grestore } bind def +518.4 216 o +51.016 211.461 m +0 0.172 rmoveto +(1.0) show +/o { gsave +newpath +translate +0 0.5 m +4 0.5 l +closepath +stroke +grestore } bind def +72 302.4 o +/o { gsave +newpath +translate +-4 0.5 m +0 0.5 l +closepath +stroke +grestore } bind def +518.4 302.4 o +51.266 297.939 m +0 0.172 rmoveto +(1.5) show +50.578 384.261 m +0 0.172 rmoveto +(2.0) show +1.000 setlinewidth +2 setlinecap +72 43.2 m +518.4 43.2 l +518.4 388.8 l +72 388.8 l +72 43.2 l +stroke + +end +showpage Added: trunk/py4science/workbook/fig/convolve_deltas.png =================================================================== (Binary files differ) Property changes on: trunk/py4science/workbook/fig/convolve_deltas.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/py4science/workbook/scripts/convolve_deltas.py =================================================================== --- trunk/py4science/workbook/scripts/convolve_deltas.py (rev 0) +++ trunk/py4science/workbook/scripts/convolve_deltas.py 2007-10-26 17:43:50 UTC (rev 4013) @@ -0,0 +1,18 @@ +import numpy as npy +from pylab import figure, show + +dt = 0.025 +t = npy.arange(0.0, 0.5, dt) +Nt = len(t) + + +s = npy.exp(-2*t)*npy.cos(2*3*npy.pi*t)+1.0 +fig = figure() +ax = fig.add_subplot(111) +ax.plot(t, s, color='blue', lw=2) +ax.bar(t-dt/8., s, facecolor='blue', width=dt/4.) +ax.axhline(0, color='black', lw=2) +ax.set_xlim(xmin=0) +fig.savefig('convolve_deltas.png', dpi=150) +fig.savefig('convolve_deltas.eps') +show() Added: trunk/py4science/workbook/scripts/convolve_explain.py =================================================================== --- trunk/py4science/workbook/scripts/convolve_explain.py (rev 0) +++ trunk/py4science/workbook/scripts/convolve_explain.py 2007-10-26 17:43:50 UTC (rev 4013) @@ -0,0 +1,48 @@ +import numpy as npy +from pylab import figure, show + +dt = 0.01 +t = npy.arange(0.0, 10.0, dt) +Nt = len(t) + +def impulse_response(t): + 'double exponential response function' + return (npy.exp(-t) - npy.exp(-5*t)) + +i1 = npy.zeros(len(t)) +i2 = npy.zeros(len(t)) +i3 = npy.zeros(len(t)) +r = impulse_response(t) + +ind1, ind2, ind3 = 100, 300, 900 +i1[ind1] = 1 +i2[ind2] = 1.7 +i3[ind3] = 0.6 + +y1 = npy.convolve(i1, r, mode='full')[:Nt] +y2 = npy.convolve(i2, r, mode='full')[:Nt] +y3 = npy.convolve(i3, r, mode='full')[:Nt] + +fig = figure() +ax1 = ax = fig.add_subplot(311) +ax.plot(t, r, 'k', lw=2) +ax.set_ylabel('impulse response') + +ax = fig.add_subplot(312, sharex=ax1) +ax.bar(t[ind1], i1[ind1], facecolor='blue', lw=2, edgecolor='blue', width=3*dt) +ax.bar(t[ind2], i2[ind2], facecolor='green', lw=2, edgecolor='green', width=3*dt) +ax.bar(t[ind3], i3[ind3], facecolor='red', lw=2, edgecolor='red', width=3*dt) +ax.plot(t, y1, color='blue', lw=1, label='input 1') +ax.plot(t, y2, color='green', lw=1, label='input 2') +ax.plot(t, y3, color='red', lw=1, label='input d') +ax.set_ylabel('3 inputs') + + +ax = fig.add_subplot(313, sharex=ax1) +ax.plot(t, y1+y2+y3, color='black', lw=2, label='sum') +ax.set_ylabel('output') +#ax.legend(loc='best') + +fig.savefig('../fig/convolve_inputs.png', dpi=150) +fig.savefig('../fig/convolve_inputs.eps') +show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |