Python Scripting for Computational Science

by
Format: Hardcover
Pub. Date: 2004-10-01
Publisher(s): Springer Verlag
  • Free Shipping Icon

    This Item Qualifies for Free Shipping!*

    *Excludes marketplace orders.

List Price: $73.45

Rent Textbook

Select for Price
There was a problem. Please try again later.

Rent Digital

Rent Digital Options
Online:30 Days access
Downloadable:30 Days
$32.04
Online:60 Days access
Downloadable:60 Days
$42.72
Online:90 Days access
Downloadable:90 Days
$53.40
Online:120 Days access
Downloadable:120 Days
$64.08
Online:180 Days access
Downloadable:180 Days
$69.42
Online:1825 Days access
Downloadable:Lifetime Access
$106.80
$69.42

New Textbook

We're Sorry
Sold Out

Used Textbook

We're Sorry
Sold Out

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

The goal of this book is to teach computational scientists and engineers how to develop tailored, flexible, and efficient working environments built from small programs (scripts) written in the easy-to-learn, very high-level language Python. The focus is on examples and applications of relevance to computational science: gluing existing applications and tools, e.g. for automating simulation, data analysis, and visualization; steering simulations and computational experiments; equipping programs with graphical user interfaces; making computational Web services; creating interactive interfaces with a Maple/Matlab-like syntax to numerical applications in C/C++ or Fortran; and building flexible object-oriented programming interfaces to existing C/C++ or Fortran libraries. In short, scripting with Python makes you much more productive, increases the reliability of your scientific work and lets you have more fun - under Unix, Windows and MacIntosh.

Table of Contents

Introduction
1(26)
Scripting versus Traditional Programming
1(21)
Why Scripting is Useful in Computational Science
2(2)
Classification of Programming Languages
4(1)
Productive Pairs of Programming Languages
5(1)
Gluing Existing Applications
6(1)
Scripting Yields Shorter Code
7(1)
Efficiency
8(1)
Type-Specification (Declaration) of Variables
9(2)
Flexible Function Interfaces
11(1)
Interactive Computing
12(1)
Creating Code at Run Time
13(1)
Nested Heterogeneous Data Structures
14(2)
GUI Programming
16(1)
Mixed Language Programming
17(2)
When to Choose a Dynamically Typed Language
19(1)
Why Python?
20(1)
Script or Program?
21(1)
Preparations for Working with This Book
22(5)
Getting Started with Python Scripting
27(38)
A Scientific Hello World Script
27(5)
Executing Python Scripts
28(1)
Dissection of the Scientific Hello World Script
29(3)
Reading and Writing Data Files
32(8)
Problem Specification
32(1)
The Complete Code
33(1)
Dissection
33(3)
Working with Files in Memory
36(1)
Efficiency Measurements
37(1)
Exercises
38(2)
Automating Simulation and Visualization
40(12)
The Simulation Code
41(2)
Using Gnuplot to Visualize Curves
43(1)
Functionality of the Script
44(1)
The Complete Code
45(2)
Dissection
47(3)
Exercises
50(2)
Conducting Numerical Experiments
52(8)
Wrapping a Loop Around Another Script
53(1)
Generating an HTML Report
54(2)
Making Animations
56(1)
Varying Any Parameter
57(3)
Exercises
60(1)
File Format Conversion
60(5)
The First Version of the Script
61(1)
The Second Version of the Script
62(3)
Basic Python
65(56)
Introductory Topics
65(9)
Recommended Python Documentation
66(1)
Testing Statements in the Interactive Shell
67(1)
Control Statements
68(1)
Running an Application
69(2)
File Reading and Writing
71(1)
Output Formatting
72(2)
Variables of Different Types
74(26)
Boolean Types
74(1)
The None Variable
75(1)
Numbers and Numerical Expressions
76(2)
Lists and Tuples
78(6)
Dictionaries
84(3)
Splitting and Joining Text
87(1)
String Operations
88(1)
Text Processing
89(2)
The Basics of a Python Class
91(2)
Determining a Variable's Type
93(2)
Exercises
95(5)
Functions
100(8)
Keyword Arguments
101(1)
Doc Strings
102(1)
Variable Number of Arguments
102(2)
Call by Reference
104(1)
Treatment of Input and Output Arguments
105(1)
Function Objects
106(2)
Working with Files and Directories
108(13)
Listing Files in a Directory
108(1)
Testing File Types
108(1)
Removing Files and Directories
109(2)
Copying and Renaming Files
111(1)
Splitting Pathnames
111(1)
Creating and Moving to Directories
112(1)
Traversing Directory Trees
113(2)
Exercises
115(6)
Numerical Computing in Python
121(48)
A Quick NumPy Primer
123(8)
Creating Arrays
123(1)
Array Indexing
124(2)
Array Computations
126(1)
Type Testing
127(2)
Hidden Temporary Arrays
129(1)
Exercises
130(1)
Vectorized Algorithms
131(5)
From Scalar to Array Function Arguments
131(1)
Slicing
132(1)
Remark on Efficiency
133(2)
Exercises
135(1)
More Advanced Array Computing
136(20)
Random Numbers
137(1)
Linear Algebra
138(1)
The Gnuplot Module
139(3)
Example: Curve Fitting
142(1)
Arrays on Structured Grids
143(3)
File I/O with NumPy Arrays
146(1)
Reading and Writing Tables with NumPy Arrays
147(3)
Functionality in the Numpytools Module
150(2)
Exercises
152(4)
Other Tools for Numerical Computations
156(13)
The ScientificPython Package
156(5)
The SciPy Package
161(4)
The Python-Matlab Interface
165(1)
Some Useful Python Modules
166(3)
Combining Python with Fortran, C, and C++
169(36)
About Mixed Language Programming
169(5)
Applications of Mixed Language Programming
170(1)
Calling C from Python
170(2)
Automatic Generation of Wrapper Code
172(2)
Scientific Hello World Examples
174(18)
Combining Python and Fortran
175(5)
Combining Python and C
180(6)
Combining Python and C++ Functions
186(2)
Combining Python and C++ Classes
188(4)
Exercises
192(1)
A Simple Computational Steering Example
192(9)
Modified Time Loop for Repeated Simulations
193(1)
Creating a Python Interface
194(2)
The Steering Python Script
196(3)
Equipping the Steering Script with a GUI
199(2)
Scripting Interfaces to Large Libraries
201(4)
Introduction to GUI Programming
205(70)
Scientific Hello World GUI
205(24)
Introductory Topics
205(3)
The First Python/Tkinter Encounter
208(3)
Binding Events
211(1)
Changing the Layout
212(4)
The Final Scientific Hello World GUI
216(2)
An Alternative to Tkinter Variables
218(1)
About the Pack Command
219(2)
An Introduction to the Grid Geometry Manager
221(2)
Implementing a GUI as a Class
223(2)
A Simple Graphical Function Evaluator
225(2)
Exercises
227(2)
Adding GUIs to Scripts
229(6)
A Simulation and Visualization Script with a GUI
229(3)
Improving the Layout
232(2)
Exercises
234(1)
A List of Common Widget Operations
235(40)
Frame
238(1)
Label
239(1)
Button
240(1)
Text Entry
241(1)
Balloon Help
242(1)
Option Menu
243(1)
Slider
243(1)
Check Button
244(1)
Making a Simple Megawidget
244(1)
Menu Bar
245(3)
List Data
248(1)
Listbox
248(3)
Radio Button
251(2)
Combo Box
253(1)
Message Box
253(2)
User-Defined Dialogs
255(1)
Color-Picker Dialogs
256(3)
File Selection Dialogs
259(1)
Toplevel
260(1)
Some Other Types of Widgets
261(1)
Adapting Widgets to the User's Resize Actions
262(2)
Customizing Fonts and Colors
264(2)
Widget Overview
266(2)
Exercises
268(7)
Web Interfaces and CGI Programming
275(24)
Introductory CGI Scripts
276(10)
Web Forms and CGI Scripts
277(2)
Generating Forms in CGI Scripts
279(2)
Debugging CGI Scripts
281(2)
A General Shell Script Wrapper for CGI Scripts
283(2)
Security Issues
285(1)
Adding Web Interfaces to Scripts
286(13)
A Class for Form Parameters
286(3)
Calling Other Programs
289(1)
Running Simulations
290(1)
Getting a CGI Script to Work
291(3)
Using Web Applications from Scripts
294(2)
Exercises
296(3)
Advanced Python
299(132)
Miscellaneous Topics
299(6)
Parsing Command-Line Arguments
299(3)
Platform-Dependent Operations
302(1)
Run-Time Generation of Code
303(1)
Exercises
304(1)
Regular Expressions and Text Processing
305(38)
Motivation
306(3)
Special Characters
309(2)
Regular Expressions for Real Numbers
311(3)
Using Groups to Extract Parts of a Text
314(1)
Extracting Interval Limits
314(5)
Extracting Multiple Matches
319(4)
Splitting Text
323(1)
Pattern-Matching Modifiers
324(3)
Substitution and Backreferences
327(1)
Example: Swapping Arguments in Function Calls
327(4)
A General Substitution Script
331(1)
Debugging Regular Expressions
332(1)
Exercises
333(10)
Tools for Handling Data in Files
343(10)
Writing and Reading Python Data Structures
343(2)
Pickling Objects
345(2)
Shelving Objects
347(1)
Writing and Reading Zip Archive Files
348(1)
Downloading Internet Files
349(1)
Binary Input/Output
350(2)
Exercises
352(1)
A Database for NumPy Arrays
353(6)
The Structure of the Database
353(3)
Pickling
356(1)
Formatted ASCII Storage
357(1)
Shelving
358(1)
Comparing the Various Techniques
359(1)
Scripts Involving Local and Remote Hosts
359(6)
Secure Shell Commands
360(1)
Distributed Simulation and Visualization
361(2)
Client/Server Programming
363(1)
Threads
364(1)
Classes
365(35)
Class Programming
366(3)
Checking the Class Type
369(1)
Private Data
370(1)
Static Data
370(1)
Special Attributes
371(1)
Special Methods
372(1)
Multiple Inheritance
373(1)
Using a Class as a C-like Structure
374(1)
Attribute Access via String Names
374(1)
Example: Turning String Formulas into Functions
375(2)
Example: Class for Structured Grids
377(2)
New-Style Classes
379(1)
Implementing Get/Set Functions via Properties
380(1)
Subclassing Built-in Types
381(2)
Copy and Assignment
383(4)
Building Class Interfaces at Run Time
387(3)
Building Flexible Class Interfaces
390(6)
Exercises
396(4)
Scope of Variables
400(5)
Global, Local, and Class Variables
400(1)
Nested Functions
401(1)
Dictionaries of Variables in Namespaces
402(3)
Exceptions
405(3)
Handling Exceptions
406(1)
Raising Exceptions
407(1)
Iterators
408(14)
Constructing an Iterator
408(2)
A Pointwise Grid Iterator
410(3)
A Vectorized Grid Iterator
413(2)
Generators
415(2)
Some Aspects of Generic Programming
417(4)
Exercises
421(1)
Investigating Efficiency
422(9)
CPU-Time Measurements
422(3)
Profiling Python Scripts
425(1)
Optimization of Python Code
426(5)
Fortran Programming with NumPy Arrays
431(32)
Problem Definition
431(3)
Filling an Array in Fortran
434(3)
The Fortran Subroutine
434(1)
Building and Inspecting the Extension Module
435(2)
Array Storage Issues
437(14)
Generating an Erroneous Interface
437(2)
Array Storage in C and Fortran
439(1)
Input and Output Arrays as Function Arguments
440(6)
F2PY Interface Files
446(4)
Hiding Work Arrays
450(1)
Increasing Callback Efficiency
451(7)
Callbacks to Vectorized Python Functions
451(3)
Avoiding Callbacks to Python
454(1)
Compiled Inline Callback Functions
455(3)
Summary
458(1)
Exercises
459(4)
C and C++ Programming with NumPy Arrays
463(40)
C Programming with NumPy Arrays
464(16)
The Basics of the NumPy C API
464(2)
The Handwritten Extension Code
466(1)
Sending Arguments from Python to C
467(1)
Consistency Checks
468(1)
Computing Array Values
468(3)
Returning an Output Array
471(1)
Convenient Macros
472(1)
Module Initialization
473(1)
Extension Module Template
474(2)
Compiling, Linking, and Debugging the Module
476(1)
Writing a Wrapper for a C Function
477(3)
C++ Programming with NumPy Arrays
480(13)
Wrapping a NumPy Array in a C++ Object
480(2)
Using SCXX
482(3)
NumPy-C++ Class Conversion
485(8)
Comparison of the Implementations
493(5)
Efficiency
493(3)
Error Handling
496(1)
Summary
497(1)
Exercises
498(5)
More Advanced GUI Programming
503(76)
Adding Plot Areas in GUIs
503(14)
The BLT Graph Widget
504(6)
Animation of Functions in BLT Graph Widgets
510(2)
Other Tools for Making GUIs with Plots
512(3)
Exercises
515(2)
Event Bindings
517(9)
Binding Events to Functions with Arguments
517(3)
A Text Widget with Tailored Keyboard Bindings
520(3)
A Fancy List Widget
523(3)
Animated Graphics with Canvas Widgets
526(16)
The First Canvas Encounter
527(1)
Coordinate Systems
528(4)
The Mathematical Model Class
532(1)
The Planet Class
533(2)
Drawing and Moving Planets
535(1)
Dragging Planets to New Positions
536(4)
Using Pmw's Scrolled Canvas Widget
540(2)
Simulation and Visualization Scripts
542(37)
Restructuring the Script
543(2)
Representing a Parameter by a Class
545(14)
Improved Command-Line Script
559(1)
Improved GUI Script
560(1)
Improved CGI Script
561(1)
Parameters with Physical Dimensions
562(2)
Adding a Curve Plot Area
564(2)
Automatic Generation of Scripts
566(1)
Applications of the Tools
567(5)
Allowing Physical Units in Input Files
572(4)
Converting Input Files to GUIs
576(3)
Tools and Examples
579(70)
Running Series of Computer Experiments
579(13)
Multiple Values of Input Parameters
580(3)
Implementation Details
583(5)
Further Applications
588(4)
Tools for Representing Functions
592(20)
Functions Defined by String Formulas
592(2)
A Unified Interface to Functions
594(6)
Interactive Drawing of Functions
600(5)
A Notebook for Selecting Functions
605(7)
Solving Partial Differential Equations
612(37)
Numerical Methods for ID Wave Equations
613(3)
Implementations of ID Wave Equations
616(6)
Classes for Solving ID Wave Equations
622(7)
A Problem Solving Environment
629(6)
Numerical Methods for 2D Wave Equations
635(3)
Implementations of 2D Wave Equations
638(8)
Exercises
646(3)
A Setting up the Required Software Environment
649(16)
Installation on Unix Systems
649(11)
A Suggested Directory Structure
650(1)
Setting Some Environment Variables
650(1)
Installing Tcl/Tk and Additional Modules
651(1)
Installing Python
652(2)
Installing Python Modules
654(4)
Installing Gnuplot
658(1)
Installing SWIG
658(1)
Summary of Environment Variables
659(1)
Testing the Installation of Scripting Utilities
659(1)
Installation on Windows Systems
660(5)
B Elements of Software Engineering
665(50)
Building and Using Modules
665(8)
Single-File Modules
665(4)
Multi-File Modules
669(1)
Debugging and Troubleshooting
670(3)
Tools for Documenting Python Software
673(5)
Doc Strings
673(1)
Tools for Automatic Documentation
674(4)
Coding Standards
678(9)
Style Guide
678(4)
Pythonic Programming
682(5)
Verification of Scripts
687(18)
Automating Regression Tests
687(5)
Implementing a Tool for Regression Tests
692(3)
Writing a Test Script
695(1)
Verifying Output from Numerical Computations
696(4)
Automatic Doc String Testing
700(2)
Unit Testing
702(3)
Version Control Management
705(5)
Getting Started with CVS
705(4)
Building Scripts to Simplify the Use of CVS
709(1)
Exercises
710(5)
Bibliography 715(2)
Index 717

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.