Created
April 3, 2014 09:43
-
-
Save msund/9951563 to your computer and use it in GitHub Desktop.
Computational Methods NB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "SciPy" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import scipy as sp\nfrom numpy.fft import *", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 55 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "from matplotlylib import fig_to_plotly\nusername = 'IPython.Demo'\napi_key = '1fw3zw2o13'", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 56 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "L = 20\nn = 128\nx = linspace(-L/2., L/2., n, endpoint=False)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 57 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "fig1 = plt.figure()\nu = exp(-x**2)\nplot(x,u)\nfig_to_plotly(fig1, username, api_key, notebook = True)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<iframe height=\"500\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/2469/600/450\" width=\"650\"></iframe>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 61, | |
"text": "<IPython.core.display.HTML at 0x1013a9ad0>" | |
} | |
], | |
"prompt_number": 61 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "fig2 = plt.figure()\nut = fft(u)\nplot(ut)\nfig_to_plotly(fig2, username, api_key, notebook = True)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<iframe height=\"500\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/2470/600/450\" width=\"650\"></iframe>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 62, | |
"text": "<IPython.core.display.HTML at 0x10ddf55d0>" | |
} | |
], | |
"prompt_number": 62 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "fig3 = plt.figure()\nplot(abs(fftshift(ut)))\nfig_to_plotly(fig3, username, api_key, notebook = True)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<iframe height=\"500\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/2471/600/450\" width=\"650\"></iframe>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 63, | |
"text": "<IPython.core.display.HTML at 0x10de26dd0>" | |
} | |
], | |
"prompt_number": 63 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "k = (2*pi/L)*r_[linspace(0, n/2-1, n/2), linspace(-n/2,-1,n/2)]", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 64 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "fig4 = plt.figure()\nplot(fftshift(k), abs(fftshift(ut)))\nfig_to_plotly(fig4, username, api_key, notebook = True)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<iframe height=\"500\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/2473/600/450\" width=\"650\"></iframe>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 66, | |
"text": "<IPython.core.display.HTML at 0x10dda70d0>" | |
} | |
], | |
"prompt_number": 66 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment