Question 1.1.1: In the cell below, produce a scatter plot that plots the latitude and longitude ofevery city in the cities table so that the result places northern cities at the top and western...

1 answer below »

Question 1.1.1: In the cell below, produce a scatter plot that plots the latitude and longitude ofevery city in the cities table so that the result places northern cities at the top and western citiesat the left.


Question 1.1.3: Assign num_unique_cities to the number of unique cities that appear in thecities table.


Question 1.1.4: Define the coordinates_to_region function below. It should take in two arguments,a city’s latitude (lat) and longitude (lon) coordinates, and output a string representingthe region it is located in.


Question 1.1.5: Add a new column in cities labeled Region that contains the region in whichthe city is located. For full credit, you must use the coordinates_to_region function you definedrather than reimplementing its logic.








project2 April 8, 2022 [1]: # Initialize Otter import otter grader = otter.Notebook("project2.ipynb") 1 Project 2: Climate Change—Temperatures and Precipitation In this project, you will investigate data on climate change, or the long-term shifts in temperatures and weather patterns! 1.0.1 Logistics Deadline. This project is due at 11:59pm PT on Friday, 4/15. You can receive 5 bonus points for submitting the project by 11:59pm PT on Thursday, 4/14. Projects will be accepted up to 2 days (48 hours) late. Projects submitted fewer than 24 hours after the deadline will receive 2/3 credit, and projects submitted between 24 and 48 hours after the deadline will receive 1/3 credit. We will not accept any projects that are submitted 48 hours or more after the deadline. There will be no lenience with late submissions. That includes if you miss the deadline due to internet or submission issues. Please submit early if you anticipate this being a problem. It’s much better to be early than late, so start working now. Checkpoint. For full credit, you must complete a checkpoint. For the checkpoint, you must complete the questions up until the end of Part 1, pass all public autograder tests for those sections, and submit to the Gradescope Project 2 Checkpoint assignment by 11:59pm PT on Friday, 4/8. This checkpoint is worth 5% of your entire project grade. There is no partial credit for the checkpoint, and we do not accept late checkpoint submissions. After you’ve submitted the checkpoint, you may still change your answers before the project deadline—only your final submission, to the Project 2 assignment, will be graded for correctness. You will have some lab time to work on these questions, but we recommend that you start the project before lab and leave time to finish the checkpoint afterward. Partners. You may work with one other partner; your partner must be from your assigned lab section. Only one person is required to submit to the checkpoint and project assign- ments. On Gradescope, the person who submits must also designate their partner so that both of you receive credit. Once you submit, click into your submission, and there will be an option to Add Group Member in the top right corner. You may also reference this walkthrough video on how to add partners on Gradescope. Make sure to re-add your partner every time you make a new submission, as Gradescope does not save partner information. 1 https://drive.google.com/file/d/1POtij6KECSBjCUeOC_F0Lt3ZmKN7LKIq/view?usp=sharing https://drive.google.com/file/d/1POtij6KECSBjCUeOC_F0Lt3ZmKN7LKIq/view?usp=sharing Rules. Don’t share your code with anybody but your partner. You are welcome to discuss questions with other students, but don’t share the answers. The experience of solving the problems in this project will prepare you for exams (and life). If someone asks you for the answer, resist! Instead, you can demonstrate how you would solve a similar problem. Support. You are not alone! Come to office hours, post on Ed, and talk to your classmates. If you want to ask about the details of your solution to a problem, make a private Ed post and the staff will respond. If you’re ever feeling overwhelmed or don’t know how to make progress, email your TA or tutor for help. You can find contact information for the staff on the course website. Tests. The tests that are given are not comprehensive and passing the tests for a question does not mean that you answered the question correctly. Tests usually only check that your table has the correct column labels. However, more tests will be applied to verify the correctness of your submission in order to assign your final score, so be careful and check your work! You might want to create your own checks along the way to see if your answers make sense. Additionally, before you submit, make sure that none of your cells take a very long time to run (several minutes). Free Response Questions: Make sure that you put the answers to the written questions in the indicated cell we provide. Every free response question should include an explanation that adequately answers the question. Your written work will be uploaded to Gradescope automatically after the project deadline; there is no action required on your part for this. Advice. Develop your answers incrementally. To perform a complicated task, break it up into steps, perform each step on a different line, give a new name to each result, and check that each intermediate result is what you expect. You can add any additional names or functions you want to the provided cells. Make sure that you are using distinct and meaningful variable names throughout the notebook. Along that line, DO NOT reuse the variable names that we use when we grade your answers. You never have to use just one line in this project or any others. Use intermediate variables and multiple lines as much as you would like! All of the concepts necessary for this project are found in the textbook. If you are stuck on a particular problem, reading through the relevant textbook section often will help clarify the concept. To get started, load datascience, numpy, matplotlib, and d8error. Make sure to also run the first cell of this notebook to load otter. [2]: # Run this cell to set up the notebook, but please don't change it. from datascience import * import numpy as np %matplotlib inline import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') np.set_printoptions(legacy='1.13') import warnings warnings.simplefilter('ignore') 2 http://data8.org/sp22/staff.html import d8error 1.1 Part 1: Temperatures In the following analysis, we will investigate one of the 21st century’s most prominent issues: climate change. While the details of climate science are beyond the scope of this course, we can start to learn about climate change just by analyzing public records of different cities’ temperature and precipitation over time. We will analyze a collection of historical daily temperature and precipitation measurements from weather stations in 210 U.S. cities. The dataset was compiled by Yuchuan Lai and David Dzombak [1]; a description of the data from the original authors and the data itself is available here. [1] Lai, Yuchuan; Dzombak, David (2019): Compiled historical daily temperature and precipitation data for selected 210 U.S. cities. Carnegie Mellon University. Dataset. 1.1.1 Part 1, Section 1: Cities Run the following cell to load information about the cities and preview the first few rows. [3]: cities = Table.read_table('city_info.csv', index_col=0) cities.show(3) The cities table has one row per weather station and the following columns: 1. "Name": The name of the US city 2. "ID": The unique identifier for the US city 3. "Lat": The latitude of the US city (measured in degrees of latitude) 4. "Lon": The longitude of the US city (measured in degrees of longitude) 5. "Stn.Name": The name of the weather station in which the data was collected 6. "Stn.stDate": A string representing the date of the first recording at that particular station 7. "Stn.edDate": A string representing the date of the last recording at that particular station The data lists the weather stations at which temperature and precipitation data were collected. Note that although some cities have multiple weather stations, only one is collecting data for that city at any given point in time. Thus, we are able to just focus on the cities themselves. Question 1.1.1: In the cell below, produce a scatter plot that plots the latitude and longitude of every city in the cities table so that the result places northern cities at the top and western cities at the left. Note: It’s okay to plot the same point multiple times! [4]: ... 3 https://kilthub.cmu.edu/articles/dataset/Compiled_daily_temperature_and_precipitation_data_for_the_U_S_cities/7890488 These cities are all within the continental U.S., and so the general shape of the U.S. should be visible in your plot. The shape will appear distorted compared to most maps for two reasons: the scatter plot is square even though the U.S. is wider than it is tall, and this scatter plot is an equirectangular projection of the spherical Earth. A geographical map of the same data uses the common Pseudo-Mercator projection. [6]: # Just run this cell Marker.map_table(cities.select('Lat', 'Lon', 'Name').relabeled('Name',␣ ↪'labels')) [6]: Question 1.1.2 Does it appear that these city locations are sampled uniformly at random from all the locations in the U.S.? Why or why not? No, the cities don’t appear to be sampled uniformly at random from all locations in the US because the city locations are concentrated towards the north side of the US. There are comparatively less cities located in the southern part of the US. Question 1.1.3: Assign num_unique_cities to the number of unique cities that appear in the 4 https://en.wikipedia.org/wiki/Equirectangular_projection https://en.wikipedia.org/wiki/Web_Mercator_projection cities table. [8]: num_unique_cites = ... # Do not change this line print(f"There are {num_unique_cites} unique cities that appear within our␣ ↪dataset.") There are 461 unique cities that appear within our dataset. [9]: grader.check("q1_1_3") [9]: q1_1_3 results: All test cases passed! In order to investigate further, it will be helpful to determine what region of the United States each city was located in: Northeast, Northwest, Southeast, or Southwest. For our purposes, we will be using the following geographical boundaries: 1. A station is located in the "Northeast" region if its latitude is above or equal to 40 degrees and its longtitude is greater than or equal to -100 degrees. 2. A station is located in the "Northwest" region if its latitude is above or equal to 40 degrees and its longtitude is less than -100 degrees. 3. A station is located in the "Southeast" region if its latitude is below 40 degrees and its longtitude is greater than or equal to -100 degrees. 4. A station is located in the "Southwest" region if its latitude is below 40 degrees and its longtitude is less than -100 degrees. Question 1.1.4: Define the coordinates_to_region function below. It should take in two ar- guments, a city’s latitude (lat) and longitude (lon) coordinates, and output a string representing the region it is located in. [ ]: def coordinates_to_region(...): ... [ ]: grader.check("q1_1_4") Question 1.1.5: Add a new column in cities labeled Region that contains the region in which the city is located. For full credit, you must use the coordinates_to_region function you defined rather than reimplementing its logic. [ ]: regions_array = ... cities = ... cities.show(5) [ ]: grader.check("q1_1_5") To confirm that you’ve defined your coordinates_to_region function correctly and successfully added the Region column to the cities table, run the following cell. Each region should have a different color in the result. 5 [ ]: # Just run this cell cities.scatter("Lon", "Lat", group="Region") Challenge Question 1.1.6 (OPTIONAL,
Answered 5 days AfterApr 08, 2022

Answer To: Question 1.1.1: In the cell below, produce a scatter plot that plots the latitude and longitude...

Sathishkumar answered on Apr 14 2022
100 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here