24.NumpyPlotting.pdf - 24 Data Visualization Topics How to define a useful class for for manipulating sunrise\/sunset data How to graphically display

24.NumpyPlotting.pdf - 24 Data Visualization Topics How to...

This preview shows page 1 - 13 out of 53 pages.

24. Data Visualization Topics How to define a useful class for for manipulating sunrise/sunset data. How to graphically display facts about that data using numpy and pyplot.
Image of page 1
The Problem For various cities around the world, we would like to examine the “Sun Up” time throughout the year. How does it vary from day to day? What are the monthly averages? Sun Up Time = Sunset Time Sunrise Time
Image of page 2
Average Sun-Up (Hours): City Latitude June September December March --------------------------------------------------------------- London 51.50 16.55 12.64 7.93 11.89 Ithaca 42.43 15.24 12.47 9.13 11.95 NewYork 40.73 15.04 12.45 9.31 11.96 Cairo 30.05 14.05 12.34 10.25 11.99 Miami 25.78 13.72 12.29 10.56 12.02 Lagos 6.58 12.50 12.15 11.75 12.08 Johannesburg -26.20 10.52 11.94 13.75 12.23 Sydney -33.88 9.94 11.87 14.36 12.30 How Does Sun-Up Depend on Latitude and Month?
Image of page 3
Visualization!
Image of page 4
How Does Sun-Up Time Vary Day-to-Day?
Image of page 5
How Does Sun-Up Time Vary Month-To-Month?
Image of page 6
Recall the Motivating Problem For various cities around the world, we would like to examine the “Sun Up” time throughout the year. How does it vary from day to day? What are the monthly averages? Let’s define a class that makes this easy.
Image of page 7
Our Plan 1. We define a class Daylight that facilitates data acquisition. 2. We introduce numpy arrays and show how to use the pylab for plottiing
Image of page 8
The Class Daylight 5 Attributes Name : name of the city [str] Lat: latitude in degrees [float] Long: longitude in degrees [float] RiseTime: rise time in hours [length-365 numpy array] SetTime: set time in hours [length-365 numpy array]
Image of page 9
What the Constructor Does It will have one argument: the name of a city as a string. It will then read the .dat file associated with that city and proceed to set up the 5 attributes.
Image of page 10
A Folder Called RiseSetData Has .dat Files for Each these Cities Anaheim Anchorage Arlington Athens Atlanta Baltimore Bangkok Beijing Berlin Bogata Boston BuenosAires Cairo Chicago Cincinnati Cleveland Denver Detroit Honolulu Houston Ithaca Johannesburg KansasCity Lagos London LosAngeles MexicoCity Miami Milwaukee Minneapolis Moscow NewDelhi NewYork Oakland Paris Philadelphia Phoenix Pittsburgh RiodeJaneiro Rome SanFrancisco Seattle Seoul Sydney Tampa Teheran Tokyo Toronto Washington Wellington For us, .dat files are the same as .txt files Downloaded from :
Image of page 11
What do the lines in Ithaca.dat look like?
Image of page 12
Image of page 13

You've reached the end of your free preview.

Want to read all 53 pages?

  • Fall '19
  • Array, NumPy arrays, R S R S

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture