Beginning Python Visualization - Crafting Visual Transformation Scripts


E-Book Content

Beginning Python Visualization Crafting Visual Transformation Scripts Shai Vaingast Beginning Python Visualization: Crafting Visual Transformation Scripts Copyright © 2009 by Shai Vaingast All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1843-2 ISBN-13 (electronic): 978-1-4302-1844-9 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editors: Frank Pohlmann, Michelle Lowman Technical Reviewer: C. Titus Brown Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Kylie Johnston Copy Editor: Ami Knox Associate Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor: Dina Quan Proofreader: Liz Welch Indexer: Julie Grady Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail kn`ano)ju0,-).,,1),2).-),-/1,0*_or#%%6 ***lnejpnks While the script might be shorter, there’s no performance gain. It is therefore suggested that you cascade functions only if it adds clarity; there’s a good chance you’ll be editing this code later on, and it’s important to be able to understand what’s going on. In fact, not cascading functions might be useful at times because you might need access to intermediate variables (such as b and _n in our case). The _or*na]`an object converts each row we read into a row of fields, in the form of a list. That row is then appended to a list of rows, `]p]. This is also the value returned by the function. NNote By now you’ve seen the dot symbol (*) used several times, and it might be a bit confusing, so an explanation is in order. The dot symbol is used to access function members of modules as well as function members of objects (classes). You’ve seen it in member functions of modules, such as _or*na]`an$%, but also for objects, such as b*na]`$%. In the latter, it means that the file object has a member function na]`$% and that function is called to operate on variable b. To access these functions, we use the dot operator. We’ll touch on this again in Chapter 3. Lastly, we use the ellipsis symbol (***) to denote line continuation when interactively entering commands in Python. Analyzing GPS Data Let’s take a closer look at the GPS data. s %ACHROWSEEMSTOSTARTWITHATEXTHEADERSTAMP BEGINNINGWITHTHECHARACTERS CL. s 4HEREARESEVERALHEADERSTAMPS FOREXAMPLE CLCO= and CLNI?. s &OLLOWINGTHEHEADERAREADDITIONALVALUES MOSTOFWHICHARENUMERIC C HA P TER 1 N N A V I G A T I N G T H E W O R LD O F D A T A V I S U A LI Z A T I O N Not being GPS savvy, I looked up the GPS format on the Internet. It turns out the format is known as NMEA 0183. NMEA stands for the National Marine Electronics Association; see dppl6++sss*jia]*knc for more information. The NMEA 0183 data format is described at dppl6++sss*cloejbkni]pekj*knc+`]ha+jia]*dpi. There are a lot of header stamps in the format, and some might hold useful information for our task. As mentioned earlier, several CL header stamps appear in our data files,
You might also like

A Concise Introduction To Data Compression
Authors: David Salomon    93    0


Mri: Basic Principles And Applications
Authors: Mark A. Brown , Richard C. Semelka    114    0


Lectures On Image Processing
Authors: Morse B.S.    115    0


3d Structure From Images — Smile 2000: Second European Workshop On 3d Structure From Multiple Images Of Large-scale Environments Dublin, Irleand, July 1–2, 2000 Revised Papers
Authors: Paul Debevec (auth.) , Marc Pollefeys , Luc Van Gool , Andrew Zisserman , Andrew Fitzgibbon (eds.)    107    0



Introduction To Programming With Fortran 77, 90, 95, 2003
Authors: Chivers , Sleightholme.    126    0


Linear Programming: Introduction
Authors: Dantzig G. , Thapa M.    159    0


Combinatorial Optimization. Theory And Algorithms
Authors: Bernhard Korte , Jens Vygen    170    0


A Handbook Of Statistical Analyses Using R
Authors: Brian S. Everitt , Torsten Hothorn    92    0