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.
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
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?
How Does Sun-Up Time Vary Day-to-Day?
How Does Sun-Up Time Vary Month-To-Month?
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.
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
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]
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.
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 :
What do the lines in Ithaca.dat look like?
You've reached the end of your free preview.
Want to read all 53 pages?
- Fall '19
- Array, NumPy arrays, R S R S