Muutke küpsiste eelistusi

E-raamat: Student's Guide to Python for Physical Modeling: Second Edition

  • Formaat: 240 pages
  • Ilmumisaeg: 10-Sep-2024
  • Kirjastus: Princeton University Press
  • Keel: eng
  • ISBN-13: 9780691270890
  • Formaat - EPUB+DRM
  • Hind: 24,31 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: 240 pages
  • Ilmumisaeg: 10-Sep-2024
  • Kirjastus: Princeton University Press
  • Keel: eng
  • ISBN-13: 9780691270890

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

A fully updated tutorial on the basics of the Python programming language for science students

Python is a computer programming language that has gained popularity throughout the sciences. This fully updated second edition of A Student's Guide to Python for Physical Modeling aims to help you, the student, teach yourself enough of the Python programming language to get started with physical modeling. You will learn how to install an open-source Python programming environment and use it to accomplish many common scientific computing tasks: importing, exporting, and visualizing data; numerical analysis; and simulation. No prior programming experience is assumed.

This guide introduces a wide range of useful tools, including:

  • Basic Python programming and scripting
  • Numerical arrays
  • Two- and three-dimensional graphics
  • Animation
  • Monte Carlo simulations
  • Numerical methods, including solving ordinary differential equations
  • Image processing


Numerous code samples and exercises—with solutions—illustrate new ideas as they are introduced. This guide also includes supplemental online resources: code samples, data sets, tutorials, and more. This edition includes new material on symbolic calculations with SymPy, an introduction to Python libraries for data science and machine learning (pandas and sklearn), and a primer on Python classes and object-oriented programming. A new appendix also introduces command line tools and version control with Git.

Let's Go xiii
1 Getting Started with Python 1(18)
1.1 Algorithms and algorithmic thinking
1(3)
1.1.1 Algorithmic thinking
1(1)
1.1.2 States
2(1)
1.1.3 What does a = a + 1 mean?
3(1)
1.1.4 Symbolic versus numerical
3(1)
1.2 Launch Python
4(7)
1.2.1 IPython console
6(4)
1.2.2 Error messages
10(1)
1.2.3 Sources of help
10(1)
1.2.4 Good practice: Keep a log
11(1)
1.3 Python modules
11(3)
1.3.1 import
12(1)
1.3.2 from ... import
12(1)
1.3.3 NumPy and PyPlot
13(1)
1.4 Python expressions
14(5)
1.4.1 Numbers
14(1)
1.4.2 Arithmetic operations and predefined functions
14(1)
1.4.3 Good practice: Variable names
15(1)
1.4.4 More about functions
16(3)
2 Organizing Data 19(16)
2.1 Objects and their methods
19(2)
2.2 Lists, tuples, and arrays
21(8)
2.2.1 Creating a list or tuple
21(1)
2.2.2 NumPy arrays
21(2)
2.2.3 Filling an array with values
23(1)
2.2.4 Concatenation of arrays
24(1)
2.2.5 Accessing array elements
25(1)
2.2.6 Arrays and assignments
26(1)
2.2.7 Slicing
27(1)
2.2.8 Flattening an array
28(1)
2.2.9 Reshaping an array
28(1)
2.2.10 TT2 Lists and arrays as indices
29(1)
2.3 Strings
29(6)
2.3.1 Raw strings
31(1)
2.3.2 Formatting strings with the format ( ) method
31(1)
2.3.3 T2 Formatting strings with %
32(3)
3 Structure and Control 35(18)
3.1 Loops
35(3)
3.1.1 for loops
35(2)
3.1.2 while loops
37(1)
3.1.3 Very long loops
37(1)
3.1.4 Infinite loops
37(1)
3.2 Array operations
38(4)
3.2.1 Vectorizing math
38(2)
3.2.2 Matrix math
40(1)
3.2.3 Reducing an array
41(1)
3.3 Scripts
42(7)
3.3.1 The Editor
42(1)
3.3.2 T2 Other editors
42(1)
3.3.3 First steps to debugging
43(2)
3.3.4 Good practice: Commenting
45(2)
3.3.5 Good practice: Using named parameters
47(1)
3.3.6 Good practice: Units
48(1)
3.4 Contingent behavior: Branching
49(4)
3.4.1 The if statement
50(1)
3.4.2 Testing equality of floats
51(1)
3.5 Nesting
52(1)
4 Data In, Results Out 53(18)
4.1 Importing data
53(4)
4.1.1 Obtaining data
54(1)
4.1.2 Bringing data into Python
54(3)
4.2 Exporting data
57(3)
4.2.1 Scripts
57(1)
4.2.2 Data files
58(2)
4.3 Visualizing data
60(11)
4.3.1 The plot command and its relatives
60(3)
4.3.2 Log axes
63(1)
4.3.3 Manipulate and embellish
63(2)
4.3.4 Replacing curves
65(1)
4.3.5 T2 More about figures and their axes
65(1)
4.3.6 T2 Error bars
66(1)
4.3.7 3D graphs
66(1)
4.3.8 Multiple plots
67(1)
4.3.9 Subplots
68(1)
4.3.10 Saving figures
69(1)
4.3.11 T2 Using figures in other applications
70(1)
5 First Computer Lab 71(4)
5.1 HIV example
71(2)
5.1.1 Explore the model
71(1)
5.1.2 Fit experimental data
72(1)
5.2 Bacterial example
73(2)
5.2.1 Explore the model
73(1)
5.2.2 Fit experimental data
73(2)
6 Random Number Generation and Numerical Methods 75(28)
6.1 Writing your own functions
75(6)
6.1.1 Defining functions in Python
76(2)
6.1.2 Updating functions
78(1)
6.1.3 Arguments, keywords, and defaults
78(1)
6.1.4 Return values
79(1)
6.1.5 Functional programming
80(1)
6.2 Random numbers and simulation
81(2)
6.2.1 Simulating coin flips
82(1)
6.2.2 Generating trajectories
82(1)
6.3 Histograms and bar graphs
83(3)
6.3.1 Creating histograms
83(2)
6.3.2 Finer control
85(1)
6.4 Contour plots, surface plots, and heat maps
86(3)
6.4.1 Generating a grid of points
86(1)
6.4.2 Contour plots
86(1)
6.4.3 Surface plots
87(1)
6.4.4 Heat maps
88(1)
6.5 Numerical solution of nonlinear equations
89(2)
6.5.1 General real functions
89(1)
6.5.2 Complex roots of polynomials
90(1)
6.6 Solving systems of linear equations
91(1)
6.7 Numerical integration
92(3)
6.7.1 Integrating a predefined function
92(1)
6.7.2 Integrating your own function
93(1)
6.7.3 Oscillatory integrands
94(1)
6.7.4 T2 Parameter dependence
94(1)
6.8 Numerical solution of differential equations
95(5)
6.8.1 Reformulating the problem
95(1)
6.8.2 Solving an ODE
96(1)
6.8.3 T2 Parameter dependence
97(1)
6.8.4 Other ODE solvers
98(2)
6.9 Vector fields and streamlines
100(3)
6.9.1 Vector fields
100(1)
6.9.2 Streamlines
101(2)
7 Second Computer Lab 103(6)
7.1 Generating and plotting trajectories
103(1)
7.2 Plotting the displacement distribution
104(1)
7.3 Rare events
105(4)
7.3.1 The Poisson distribution
105(1)
7.3.2 Waiting times
106(3)
8 Images and Animation 109(10)
8.1 Image processing
109(2)
8.1.1 Images as NumPy arrays
109(1)
8.1.2 Saving and displaying images
110(1)
8.1.3 Manipulating images
110(1)
8.2 Displaying data as an image
111(2)
8.3 Animation
113(6)
8.3.1 Creating animations
113(1)
8.3.2 Saving animations
114(3)
HTML movies
115(2)
T2 Using an encoder
117(1)
8.3.3 Conclusion
117(2)
9 Third Computer Lab 119(6)
9.1 Convolution
119(3)
9.1.1 Python tools for image processing
120(1)
9.1.2 Averaging
121(1)
9.1.3 Smoothing with a Gaussian
121(1)
9.2 Denoising an image
122(1)
9.3 Emphasizing features
122(1)
9.4 T2 Image files and arrays
123(2)
10 Advanced Techniques 125(32)
10.1 Dictionaries and generators
125(8)
10.1.1 Dictionaries
126(2)
10.1.2 Special function arguments
128(1)
10.1.3 List comprehensions and generators
129(4)
10.2 Tools for data science
133(5)
10.2.1 Series and data frames with pandas
133(2)
10.2.2 Machine learning with scikit-learn
135(3)
10.2.3 Next steps
138(1)
10.3 Symbolic computing
138(10)
10.3.1 Wolfram Alpha
139(2)
10.3.2 The SymPy library
141(3)
10.3.3 Other alternatives
144(1)
10.3.4 First passage revisited
144(4)
10.4 Writing your own classes
148(11)
10.4.1 A random walk class
148(7)
10.4.2 When to use classes
155(2)
Get Going 157(2)
A Installing Python 159(7)
A.1 Install Python and Spyder
159(3)
A.1.1 Graphical installation
160(1)
A.1.2 Command line installation
161(1)
A.2 Setting up Spyder
162(2)
A.2.1 Working directory
162(1)
A.2.2 Interactive graphics
163(1)
A.2.3 Script template
163(1)
A.2.4 Restart
164(1)
A.3 Keeping up to date
164(1)
A.4 Installing FFmpeg
164(1)
A.5 Installing ImageMagick
164(2)
B Command Line Tools 166(17)
B.1 The command line
166(5)
B.1.1 Navigating your file system
167(2)
B.1.2 Creating, renaming, moving, and removing files
169(1)
B.1.3 Creating and removing directories
169(1)
B.1.4 Python and Conda
170(1)
B.2 Text editors
171(1)
B.3 Version control
172(10)
B.3.1 How Git works
172(2)
B.3.2 Installing and using Git
174(3)
B.3.3 Tracking changes and synchronizing repositories
177(2)
B.3.4 Summary of useful workflows
179(2)
B.3.5 Troubleshooting
181(1)
B.4 Conclusion
182(1)
C Jupyter Notebooks 183(7)
C.1 Getting started
183(3)
C.1.1 Launch Jupyter Notebooks
183(1)
C.1.2 Open a notebook
184(1)
C.1.3 Multiple notebooks
184(1)
C.1.4 Quitting Jupyter
185(1)
C.1.5 n Setting the default directory
185(1)
C.2 Cells
186(2)
C.2.1 Code cells
186(1)
C.2.2 Graphics
187(1)
C.2.3 Markdown cells
187(1)
C.2.4 Edit mode and command mode
187(1)
C.3 Sharing
188(1)
C.4 More details
188(1)
C.5 Pros and cons
188(2)
D Errors and Error Messages 190(4)
D.1 Python errors in general
190(1)
D.2 Some common errors
191(3)
E Python 2 versus Python 3 194(3)
E.1 Division
194(1)
E.2 Print command
195(1)
E.3 User input
195(1)
E.4 More assistance
196(1)
F Under the Hood 197(8)
F.1 Assignment statements
197(2)
F.2 Memory management
199(1)
F.3 Functions
199(1)
F.4 Scope
200(3)
F.4.1 Name collisions
202(1)
F.4.2 Variables passed as arguments
203(1)
F.5 Summary
203(2)
G Answers to "Your Turn" Questions 205(8)
Acknowledgments 213(2)
Recommended Reading 215(2)
Index 217
Jesse M. Kinder is associate professor of physics at the Oregon Institute of Technology. Philip Nelson is professor of physics at the University of Pennsylvania. His books include From Photon to Neuron (Princeton), Physical Models of Living Systems, and Biological Physics.