Beginning Python Visualization_ Creating Visual Transformation Scripts (2nd ed.) [Vaingast 2014-08-19].pdf
(
7208 KB
)
Pobierz
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xix
About the Technical Reviewer �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxi
Acknowledgments �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxiii
Introduction �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxv
■
Chapter 1: Navigating the World of Data Visualization�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½1
■
Chapter 2: The Environment �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½31
■
Chapter 3: Python for Programmers �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½55
■
Chapter 4: Data Organization �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½109
■
Chapter 5: Processing Text Files �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½141
■
Chapter 6: Graphs and Plots �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½189
■
Chapter 7: Math Games �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½233
■
Chapter 8: Science and Visualization �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½269
■
Chapter 9: Image Processing �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½307
■
Chapter 10: Advanced File Processing �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½343
■
Appendix: Additional Source Listing �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½371
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½379
v
Introduction
I have always been drawn to math and computers, ever since I was a kid playing computer games on my Sinclair ZX81.
When I attended university, I had a special interest in numerical analysis, a field that I feel combines math and
computers ideally. During my career, I learned of MATLAB, widely popular for digital signal processing, numerical
analysis, and feedback and control. MATLAB’s strong suits include a high-level programming language, excellent
graphing capabilities, and numerous packages from almost every imaginable engineering field. But I found that
MATLAB wasn’t enough. I worked with very large files and needed the ability to manipulate both text and data.
So I combined Perl, AWK, and Bash scripts to write programs that automate data analysis and visualization. And along
the way, I’ve developed practices and ideas involving the organization of data, such as ways to ensure file names are
unique and self-explanatory.
With the increasing popularity of the Internet, I learned about GNU/Linux and the open source movement.
I’ve made an effort to use open source software whenever possible, and so I’ve learned of GNU-Octave and gnuplot,
which together provide excellent scientific computing functionality. That fit well on my Linux machine: Bash scripts,
Perl and AWK, GNU-Octave, and gnuplot.
Knowing I was interested in programming languages and open source software, a friend suggested I give Python
a try. My first impression was that it was just another programming language: I could do almost anything I needed
with Perl and Bash, resorting to C/C++ if things got hairy. And I’d still need GNU-Octave and gnuplot, so what was
the advantage? Eventually, I did learn Python and discovered that it is far better than my previous collection of tools.
Python provides something that is extremely appealing: it’s a one-stop shop—you can do it all in Python.
I’ve shared my enthusiasm with friends and colleagues. Many who expressed interest with the ideas of data
processing and visualization would ask, “Can you recommend a book that teaches the ideas you’re preaching?”
And I would tell them, “Of course, numerous books cover this subject! But they didn’t want numerous books, just one,
with information distilled to focus on data analysis and visualization. I realized there wasn’t such a title, and this was
how the idea for this book originated.
What’s New in the Second Edition
Aside from using the most up-to-date version of Python that supports all the visualization packages (version 3.3 at the
time of the writing the second edition), I’ve also introduced the following additional content:
•
•
•
•
•
•
•
•
3-D plots and graphs
Non-rectangular contour plots
Matplotlib’s basemap
toolkit
Reading and writing MATLAB binary files
Reading and writing data to
NumPy
arrays
Reading and writing images to
NumPy
arrays
Making movies
IPython, IPython Notebook, and Spyder development environments
xxv
■
IntroduCtIon
Who This Book Is For
Although this book is about software, the target audience is not necessarily programmers or computer scientists.
I’ve assumed the reader’s main line of work is research or R&D, in his or her field of interest, be it astrophysics, signal
and image processing, or biology. The audience includes the following:
•
Graduate and PhD students in exact and natural sciences (physics, biology, and chemistry)
working on their thesis, dealing with large experimental data sets. The book also appeals to
students working on purely theoretical projects, as they require simulations and means to
analyze the results.
R&D engineers in the fields of electrical engineering (EE), mechanical engineering, and
chemical engineering: engineers working with large sets of data from multiple sources.
In EE more specifically, signal processing engineers, communication engineers, and systems
engineers will find the book appealing.
Programmers and computer enthusiasts, unfamiliar with Python and the GNU/Linux world,
but who are willing to dive into a new world of tools.
Hobbyist astronomers and other hobbyists who deal with data and are interested in using
Python to support their hobby.
•
•
•
The book can be appealing to these groups for different reasons. For scientists and engineers, the book provides
the means to be more productive in their work, without investing a considerable amount of time learning new
tools and programs that constantly change. For programmers and computer enthusiasts, the book can serve as an
appetizer, opening up their world to Python. And because of the unique approach presented here, they might share
the enthusiasm the author has for this wonderful software world. Perhaps it will even entice them to be part of the
large and growing open source community, sharing their own code.
It is assumed that the reader does have minimal proficiency with a computer, namely that he or she must
know how to manipulate files, install applications, view and edit files, and use applications to generate reports and
presentations. A background in numerical analysis, signal processing, and image processing, as well as programming,
is also helpful, but not required.
This book is not intended to serve as an encyclopedia of programming in Python and the covered packages.
Rather, it is meant to serve as an introduction to data analysis and visualization in Python, and it covers most of the
topics associated with that field.
How This Book Is Structured
The book is designed so that you can easily skip back and forth as you engage various topics.
Chapter 1 is a case study that introduces the topics discussed throughout the book: data analysis, data
management, and, of course, data visualization. The case study involves reading GPS data, analyzing it, and plotting it
along with relevant annotations (direction of travel, speed, etc.). A fully functional Python script will be built from the
ground up, complemented with lots of explanations. The fruit of our work will be an eye-catching GPS route.
If you’re new to data analysis and visualization, consider reading Chapter 2 first. The chapter describes how to
set up a development environment to perform the tasks associated with data analysis and visualization in Python,
including the selection of an OS, installing Python, and installing third-party packages.
If you’re new to Python, your next stop should be Chapter 3. In this chapter, I swiftly discuss the Python
programming language. I won’t be overly rehashing basic programming paradigms; instead I’ll provide a quick
overview of the building blocks for the Python programming.
Regardless of your Python programming experience, I highly encourage you to read Chapter 4 before
proceeding to the next chapters. Organization is the key to successful data analysis and visualization. This chapter
covers organizing data files, pros and cons of different file formats, file naming conventions, finding data files, and
automating file creation. The ideas in Chapter 4 are used throughout the book.
xxvi
Plik z chomika:
musli_com
Inne pliki z tego folderu:
A Learner's Guide to Programming Using the Python Language (2009).pdf
(17233 KB)
Beginning Python (2005).pdf
(17909 KB)
apprenez_a_programmer_en_python.pdf
(13106 KB)
A Primer on Scientific Programming with Python (4th ed.) [Langtangen 2014-08-02].pdf
(7148 KB)
A Primer on Scientific Programming with Python (3rd ed.) [Langtangen 2012-07-04].pdf
(5392 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin