1 / 36

Title

Windows Python Tutorial. Title. Center for Coastal and Ocean Mapping NOAA/UNH Joint Hydrographic Center. Kurt Schwehr Jan 2007. Day 2 More python. Loops and tests Plotting And more…. Class website: http://vislab-ccom.unh.edu/~schwehr/Classes. What does perl look like?.

Download Presentation

Title

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Python Tutorial Title Center for Coastal and Ocean Mapping NOAA/UNH Joint Hydrographic Center Kurt Schwehr Jan 2007

  2. Day 2More python • Loops and tests • Plotting • And more…

  3. Class website:http://vislab-ccom.unh.edu/~schwehr/Classes

  4. What does perl look like?

  5. First some review of Day 1 • We covered a lot of ground yesterday • Please ask if you have any questions

  6. Lists are created with [ ]

  7. Use tab to find out what ‘methods’ are available

  8. Getting help on functions

  9. Asking a function or module for help

  10. Start ipython

  11. If tests and indentation matters

  12. for loops

  13. Matplot lib

  14. 1st plot

  15. 2nd plot

  16. Discreet samples form a sine wave

  17. Reading files – Step 1 • First create a file to read • Save it as data01.txt on the desktop

  18. Get to the Desktop in IPython

  19. Now read the file • Finish the for loop by going by unindenting • Each line is getting to new line characters • Use a comma to prevent the double end line

  20. Make a data file with some numbers • Save as data02.txt

  21. Read as textHow do we skip lines that start with ‘#’? • Use if and continue

  22. Now we need to get these values to be numbers • The variable line still has the last line read • How can we get the float values of “3 2.2”

  23. Now put it all together in a script • Use SciTE to create the file • SciTE does not know this is python until you save the file

  24. Run the script

  25. Make that a function so you can reuse it! • Use SciTE to create ‘ex04.py’

  26. Those ‘-’ in the left column collapse code

  27. Import ex04

  28. Use ex04.read_y to get some data

  29. Plot it!

  30. Save the plot

  31. Write some data to disk • Use file to open a file, but tell it ‘w’ to open for writing • write does not append a newline and only takes strings • Close the file to make sure the data is written into the file

  32. View the data in SciTE

  33. Time is important for data logging

  34. Adding documentation to modules and functions

  35. The ex05 module now has a help

More Related