# Assignment 3: Sunny Days

Due: Thursday, 30 September 2021 at 11:59 p.m.

We love sunny summer days, but the equinox is already behind us, and we know the hours of daylight are beginning to dwindle. In this assignment, we'll use our experience working with tables (in class and in lab) to process a table of solar (and lunar) temporal information and visualize how the amount of daylight varies over time.

Some kindly astronomers have shared a data set with us. They've posted it as a Google sheet.

Task: Copy the unique ID -- the long string of letters, numbers, and hyphens -- in the spreadsheet URL and use it to load the first sheet into a Pyret table, as you've done in lab.

Note: We won't use all of the columns in this spreadsheet. That's perfectly normal when when working with real data.

Hint: Be sure you have the necessary include expressions!

To compute the amount of daylight, we'll need to know the elapsed time between sunrise and sunset. It's complex to do this with times expressed as hours and minutes, e.g., 6:30, so we'll first write a function to convert a time to minutes.

Task: Design a function time-str-to-minutes that takes a time as a string (like those in the table) and converts it to the number of minutes since midnight.

Note: You will need to use the function string-to-number. Despite its name, the output is not a number! It's some number if the string can be converted and none if it can't. You only need to worry about the some case. To get the number out, use .value:

››› string-to-number("06")
some(6)
››› string-to-number("06").value
6


Hint: You may find it easier to do this if you first normalize the data so all times are in the same format. Currently some have two digits for the hours and some have one.

Hint: Since the times are strings, you may want to review the documentation listing the functions Pyret provides for working with strings. Some of these produce a List, which is a data type we haven't worked with yet -- but the problem can be solved without using any of those functions.

Now that we know how many minutes a particular time is since midnight, we can compute the difference between two times, such as our sunrise and sunset times.

Task: Design a function hours-of-sunlight that takes a row of the table and returns the number of hours of sunlight there are on that day.

Task: Build a new table with a column computed by your hours-of-sunlight function.

While we can look at the numbers we added to the table, it's nice to get an overview from a plot.

Task: Display a bar chart of the hours of sunlight.

Unfortunately, none of the columns in the table give a particularly friendly label for the bars in the plot. Let's fix that!

Task: Add a column to the table giving a name for each row. This could be the full date or an abbreviated month name. Update your plot to use this column for its labels.

As with Assignment 2, you are expected to follow good Pyret style, including writing docstrings and examples for each function. Review the Testing and Style Guidelines and ask questions if anything's unclear!

• Download your file (File -> Download) and ensure it's named asmt3-code.arr.