![]() Python Imaging Library (PIL) example Edge detection using numerical differentiationĮdge detection using numerical differentiation (cont.) import Image as im a = im. 2 5 ∗ ( b−a ) x1 = a x2 = x1 + q u a r t e r x3 = x2 + q u a r t e r x4 = x3 + q u a r t e r x5 = b f 1 = f ( x1 ) f 2 = f ( x2 ) f 3 = f ( x3 ) f 4 = f ( x4 ) f 5 = f ( x5 ) s = ( b−a ) ∗ ( f 1 +4.∗ f 3 + f 5 ) / 6. 5 ∗ ( a+b ) p a r t i t i o n ( f, a, midpoint, ma圎rror ) p a r t i t i o n ( f, midpoint, b, ma圎rror ) else : p r i n t ’ i n t e r v a l = ’, a, b, ’ −−> ’, i n t e g r a l, e r r o r x = a integralArray = integral errorArray = error k += 1 return def basicSimpson ( f, a, b ) : q u a r t e r = 0. e−5) (SHARCNET/UOIT)Īdaptive Simpson integration (cont.) Driver script that calls partition (next page) and plots the function and the grid points used in integration def simpsonAdaptive ( f, a, b, ma圎rror ) : global k, x, integralArray, errorArray k = 0 x = zeros (1000) integralArray = zeros (1000) errorArray = zeros (1000) p a r t i t i o n ( f, a, b, ma圎rror ) x = b p r i n t ’ number o f i n t e r v a l s = ’, k p r i n t ’ t o t a l i n t e g r a l = ’, sum ( i n t e g r a l A r r a y ) p r i n t ’ t o t a l e r r o r ma圎rror : midpoint = 0. ![]() Matplotlib example Adaptive Simpson integrationįrom pylab import ∗ from a d a p t i v e import basicSimpson, p a r t i t i o n, simpsonAdaptive def f ( x ) : return sin (1./ x ) simpsonAdaptive ( f, 0. examples of closed proprietary tools: IDL, Matlab (SHARCNET/UOIT). ![]() there is nothing you cannot do with open-source tools.once you start accumulating scripts, you lock yourself into using these toolsįorever, and consequently paying $$ on a regular basis.cannot get help from open-source community, user base usually smaller.limitations on where you can run them, which machines/platforms, etc.highly recommend: Python’s Matplotlib library, other Python librariesĢD/3D visualization: displaying multidimensional datasets, typically data on 2D/3D structured grids or on unstructured meshes (that have some topology in 2D/3D) Whatever you do, try to avoid proprietary tools, unless those tools provide a clear advantage (most likely not).something as simple as gnuplot or pgplot.2D/3D visualization 1D plotting: plotting functions of one variable, 1D tabulated data Gravitational fields, 2D/3D fluids, ≤6D radiation field, magnetic fields, particle dataġD plotting vs. Scientific data formats and visualization of large datasets Compute Ontario Summer School, May 2013Īlex Razoumov SHARCNET/UOITĬopy of these slides in data and sample C++, Fortran, Python codes in (two directories inside: code/ and data/) (SHARCNET/UOIT)ĢD/3D flows, density, temperature, tracers
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |