GEOG 4463 & 5463 - Earth Analytics Bootcamp: Homework 4

In This Lesson

Homework 4

For this assignment, you will create a Jupyter Notebook with your answers to the questions below, and submit this Jupyter Notebook to a Github repository for Homework 4 following the instructions below Part II: Submit Your Jupyter Notebook to GitHub.

You need to complete this assignment (Homework 4) by Tuesday, August 21st at 8:00 AM (U.S. Mountain Daylight Time). See this link to convert the due date/time to your local time.

This assignment will primarily test your skills to notify others of pull requests on Github.com from Day 9 and to write functions from Day 10. Your skills will loops from Day 7 and conditional statements from Day 8 will also be reviewed.

You will be asked to work with familiar data: temperature and precipitation for various months and years of data for Boulder, Colorado, provided by the U.S. National Oceanic and Atmospheric Administration (NOAA).

What You Need

Be sure that you have completed all of the lessons from Days 7 to 10 for the Earth Analytics Bootcamp. Completing the challenges at the end of the lessons will also help you with this assignment. Review the lessons as needed to answer the questions.

You will need to fork and clone a Github repository for Homework 4 from https://github.com/earthlab-education/ea-bootcamp-hw-4-yourusername. You will receive an invitation to the Github repository for Homework 4 via CANVAS.

Note: the repository will be empty, as you will add a new Jupyter Notebook containing your answers to the questions below.

Part I: Create and Modify a Jupyter Notebook

Begin by creating a new Jupyter Notebook in your forked repository from https://github.com/yourusername/ea-bootcamp-hw-4-yourusername.

Note that Git will recognize this new Jupyter Notebook as a new file that can be added, committed, and pushed back to your forked repository on Github.com.

Be Sure to Add Documentation to Your Notebook (4 pts)

Start with Markdown cell containing a Markdown title for this assignment, plus an author name and date in list form. Bold the words for author and date, but do not bold your name and today’s date.

Add a Markdown cell before each code cell you create to describe the purpose of your code (e.g. what are you accomplishing by executing this code?). Think carefully about how many cells you should have to best organize your data (hint: review lessons for examples of how code can be grouped into cells).

Within code cells, be sure to also add Python comments to document each code block and use the PEP 8 guidelines to assign appropriate variable names that are short and concise but also clearly indicate the kind of data contained in the variable.

Be Sure to Document Functions and Assign Clear Function Names (8 pts)

In this assignment, you will be asked to write several functions.

Be sure to add documentation within your functions using Python comments to tell the user what the function is doing and and what inputs it can take.

Question 4: Write Function to Convert Units (6 pts)

Imagine you work for NOAA, which you know publishes their precipitation data in inches, rather than millimeters. You have received new data in millimeters, so you need to convert these values to match your other NOAA datasets.

Write a function to convert the units of a numpy array from millimeters to inches (one inch = 25.4 millimeters). (Note you will execute it in the next question.)

Be sure to add documentation within your functions using Python comments to tell the user what the function is doing and and what inputs it can take.

Question 5: Apply Function and Save Output to New Numpy Array (4 pts)

Run your function on the numpy array created from monthly_precip_mm_1998-to-2017.csv to convert the units from millimeters to inches.

Question 6: Write Function to Convert Units (8 pts)

Imagine you work for NOAA, which you know publishes their temperature data in Fahrenheit, rather than Celsius. You have received new data in Celsius, so you need to convert these values to match your other NOAA datasets.

Write a function to convert the units of a numpy array from Celsius to Fahrenheit (Fahrenheit = (Celsius * 1.8) + 32). (Note you will execute it in the next question.)

Be sure to add documentation within your functions using Python comments to tell the user what the function is doing and and what inputs it can take.

Question 7: Apply Function and Save Output to New Numpy Array (4 pts)

Run your function on the numpy array created from monthly_temp_cel_1998-to-2017.csv to convert the units from Celsius to Fahrenheit.

Question 15: Write Conditional Statement to Check Dimensions (4 pts)

Write a conditional statement to check that the dimensions are the same between the numpy array created for temperature in Question 12 and your numpy array containing the month names created in Question 14.

Using your conditional statement, print a message stating whether or not the dimensions are the same, so that you can plot these numpy arrays together.

Hint:

Compare the shape of the arrays, rather than the single value for the dimension.

Recall the operator to check equality between two values.

These arrays have the same shape and can be plotted together.

Question 16: Plot Your Numpy Arrays (4 pts)

Create a plot of your choosing to display your data from the numpy array created for temperature in Question 12 and your numpy array containing the month names created in Question 14.

Be sure to add a title and label the axes with the appropriate units.

For the title, think carefully about what this data is actually showing. Review your code that created this temperature array, so that you can title the plot appropriately.

Question 17: Practice Pseudo Coding (10 pts)

Without using too much jargon, make a list of all of the steps that you had to complete prior to creating the plot for Question 16. (FYI - this is pseudo-coding! Identifying the steps needed in order to write and automate your code.)

Begin your list with the conversion of the temperature data from Celsius to Fahrenheit and end it with checking that the dimensions between the numpy arrays were the same, so you could plot.

How could use functions to more easily accomplish the goal of creating the final plot? (Note: describe in words. You are not being asked to create a function to do this.)

Identifying what you do not already know is also very important in pseudo-coding a workflow.

With this in mind, do you think it would be possible to create one function that accomplishes all of the steps listed in subquestion 1?

What would you need to know how to do, in order to write one function that completed all of the steps?

Tag the Instructor in Your Pull Request (2 pts)

In your pull request message to submit this homework, include @jlpalomino in your message for the Pull Request to notify the instructor of your submission.

Remember that you can edit a message for the pull request, if you forget to include it the first time. The message will be updated when you save the changes.