当前位置:天才代写 > 计算机视觉 > Processing代写 > Meteorite Data Processing代写 assignment代写 data structures代写

Meteorite Data Processing代写 assignment代写 data structures代写

2020-10-25 11:36 星期日 所属: Processing代写 浏览:930

Week 7 PA: Meteorite Data Processing

Meteorite Data Processing代写 For this assignment, you will be working with data from NASA’s Open Data Portal about all known

Submit Assignment Meteorite Data Processing代写

Due  Wednesday by 11:59pm Points  10 Submitting  a file upload File Types  py

For this assignment, you will be working with data from NASA’s Open Data Portal about all known meteoritelandings. (Source: Meteorite Landings | NASA Open Data Portal (https://data.nasa.gov/Space Science/MeteoriteLandings/gh4g9sfh) ).

The csv (comma-separated values) file of data you’ll be using is Meteorite_Landings.csv . It contains data of all known meteorite landings. I’ve slimmed down the data sothere are only a few pieces of data for each meteorite: its name, its mass (rounded to the nearest gram), and its location in (latitude, longitude).Meteorite Data Processing代写

The focus of the programming assignment is to practice reading from and writing to files, processing data,and working with data structures (lists and dictionaries). You will use Python to help process information in alarge pool of data, and use string methods to process data stored from files.

You have two weeks to complete this assignment. Please do not wait to start the assignment – you have more time to complete this assignment because it will take more time than most programming assignments.

Example Meteorite Data Processing代写

Below is an example of what the shell should look like when you run your program. Note that the text in black is what the user typed in on their keyboard.

Welcome to the Meteorite Landings Database!

Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit.

What would you like to do? 1

Please enter the name of the meteorite you’d like to look up: Aachen

The meteorite named Aachen weighed 21 grams and was found at latitude 50.775 and longitude 6.08333

Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit.Meteorite Data Processing代写

What would you like to do? 1

Please enter the name of the meteorite you’d like to look up: Northwest 470

ERROR: no meteorite data found

Please enter the name of the meteorite you’d like to look up: Northwest Africa 470

The meteorite named Northwest Africa 470 weighed 63 grams and was found at latitude 31.98333 and longitude -4.186

67Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit. Meteorite Data Processing代写

What would you like to do? 1

Please enter the name of the meteorite you’d like to look up: Osterplana

The meteorite named Osterplana weighed -1 grams and was found at latitude 58.58333 and longitude 13.43333

Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit. Meteorite Data Processing代写

What would you like to do? 2

Please enter a mass: 15000000

File 15000000.csv has been created.

Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit.

What would you like to do? 2

Please enter a mass: 25000000

File 25000000.csv has been created.

Enter 1 to look up information on a meteorite by name.

Enter 2 to create a new csv file that contains all meteorites greater than a specified mass.

Enter 0 to exit.Meteorite Data Processing代写

What would you like to do? 0

The 15000000.csv file created in this sample run should look like this:

Armanty

Bacubirito

Campo del Cielo

Canyon Diablo

Cape York

Chupaderos

Gibeon

Hoba

Mbosi

Mundrabilla

Sikhote-Alin

Willamette

And the 25000000.csv file should look like this:

Armanty Meteorite Data Processing代写

Campo del Cielo

Canyon Diablo

Cape York

Gibeon

Hoba

I recommend you run your code with other various inputs to check to make sure your code is working correctly. Confirm that your program gives expected results.

Data and Information

All data needed for the assignment is in the Meteorite_Landings.csv file. Please download this file and save itinto the same folder where you will save your .py file containing your Python code. You do not need to turn inthe .csv file. When I test your code, I will have the same exact csv file on my computer. Please make sureyour code works with a file named exactly Meteorite_Landings.csv. If your code tries to open a file named Meteorite_Landings(2).csv, for example, it will fail the test cases.

The file has over thirty thousand lines, so it will take a while to open. (You should open the file forviewing by using a simple text editor like Notepad instead of a spreadsheet program like Excel.) Meteorite Data Processing代写

Meteorite Data Processing代写
Meteorite Data Processing代写

That said, it looks like the following:

name,mass (g),GeoLocation

Aachen,21,”(50.775000, 6.083330)”

Aarhus,720,”(56.183330, 10.233330)”

Abee,107000,”(54.216670, -113.000000)”

Acapulco,1914,”(16.883330, -99.900000)”

Achiras,780,”(-33.166670, -64.950000)”

Adhi Kot,4239,”(32.100000, 71.800000)”

Adzhi-Bogdo (stone),910,”(44.833330, 95.166670)”

Agen,30000,”(44.216670, 0.616670)”

Aguada,1620,”(-31.600000, -65.233330)”Meteorite Data Processing代写

Aguila Blanca,1440,”(-30.866670, -64.550000)”

Aioun el Atrouss,1000,”(16.398060, -9.570280)”

Aïr,24000,”(19.083330, 8.383330)”

Aire-sur-la-Lys,,”(50.666670, 2.333330)”

Akaba,779,”(29.516670, 35.050000)

Note that the first line contains header information. Each line after that represents one Meteorite, andcontains its name, mass (rounded to the nearest gram), and location in (latitude, longitude). Note that thesevalues are separated by commas. The location will require some extra handling, as it is surrounded byquotes and itself has a comma in it that separates the latitude and longitude.

You will use a single dictionary to store this data in your code.

You will not receive full credit on this project if you do not use a dictionary for this purpose. Each key-value pair should represent a singlemeteorite. The key should be the name of the meteorite as a string. The value should be a list. Thefirst element in the list should be the mass in grams as an integer. The second element in the listshould be the latitude as a floating point value. The third element in the list should be the longitude as a floating point value. Do not store the headers in the dictionary – just the data.

Some masses are unknown, and will show up as an empty string. Before storing the mass into thedictionary, you must determine if this is the case. Check and see if the section of the line containing the massis an empty string. If it is, store the mass as -1 grams. This way, if one were to process the data stored inyour dictionary, they would know right away if the mass was not recorded.Meteorite Data Processing代写

Do the same for the latitude and longitude: if there is no data for the location, store the latitude andlongitude both as -1. (I realize this is not a perfect solution, but for the purposes of this assignment this is okay).

Requirements

Save your file as LastnamePA07.py where Lastname is your last name.

Your user interface should include the following:

  • Output- display a welcome message and instructions for various options Tell the user to Enter 1 to look up information on a meteorite by name

Tell the user to Enter 2 to create a new csv file that contains all meteorites greater than a specified mass

Tell the user to Enter 0 to exit the program Meteorite Data Processing代写

  • Input- the program should ask for:

What the user wants to do (a number between 0 and 2)

  • Output- the program’s output will depend on what the user tells the program to do. Please see details for each function below.

Your program should have (at least) three functions:

  • Amain function that controls the flow of the program. It should: Create the dictionary that stores the meteorite data
    • Firstcreate an empty dictionary
    • Then,go though each line of the file (don’t forget the first line has header information)
      • Stripeach line to remove any extra whitespace
      • Spliteach line to create a list of relevant dat
      • Manipulatesaid data using string operations such as slicingMeteorite Data Processing代写
      • Savethe data into the dictionary
        • Thekey should be the name of the meteorite as a string
        • Thevalue should be a lis The first element in the list should be the mass in grams as aninteger. The second element in the list should be the latitude as a floating point value. Thethird element in the list should be the longitude as a floating point value.
Display a welcome message

Continue to ask the user to input a number (0-2) until the user enters the number 0

  • Ifthe user inputs 1, call the get_meteorite_info function with appropriate arguments
  • Ifthe user inputs 2, call the create_mass_file function with appropriate arguments Make sure you call main at the end of your code so the program runs!
  • Aget_meteorite_info function with one parameter variable: met_dictionary which is a dictionary that contains all meteorite data

This function should prompt the user to enter a name of a meteorite.

It should then check and see if this meteorite exists in the data. If it does not, print an error message and call the get_meteorite_info function again.Meteorite Data Processing代写

If the name does exist in the data, the function should display message with details (including thename, mass, latitude and longitude) about the meteorite with the specified name. It should retrieve these details from the met_dictionary.

(See the example runs above for examples.)

  • Acreate_mass_file function with one parameter variable: met_dictionary which is a dictionary that contains all meteorite data

This function should prompt the user to enter a mass as an integer

Then, create a list containing all of the names of meteorites with a mass strictly greater than the mass entered by the user

Sort this list in alphabetical order

Create a new csv file (the name should be the mass the user inputted and the file’s extension should be .csv) that contains this list of meteorites, one on each line, in alphabetical order. (Note: it is okay if the last line in this new csv file is a blank line.)

Other requirements:
  • Youare not allowed to use the Python csv module (e. do not use the line import csv in your code)
  • Includeheader comments at the top of the file that has at least your name, email, and a brief description of the program. The description should be 1 or 2 lines long describing the purpose of the program.
  • Includecomments to label and describe each function.Meteorite Data Processing代写
  • Usecomments elsewhere that you think would help guide the reader. You don’t want to overdo it though. Not every line of code needs a commen Think in terms of blocks, or if a calculation is not clear.

Assume the reader has not read the homework assignment. Assume the reader knows Python.

  • Includeblank lines to separate the main sections of the code. This makes your code look more organized and easier to read.
  • Usedescriptive variable names.
  • Yourfunction names and variable parameters must be exactly as described above.

Code Organization Meteorite Data Processing代写

  • mainfunction definition
    • Includesone function call to both get_meteorite_info and create_mass_file
    • Seeabove for more information and details as to when these function calls should be made.
  • get_meteorite_infofunction definition

Displays information about a single meteorite. See above for more information.

  • create_mass_filefunction definition

Creates a new csv file containing the names of all meteorites greater than a specified mass. See above for more information.Meteorite Data Processing代写

  • Callto main function

Hints

I recommend doing this in stages. Processing the data and placing it correctly into the dictionary will likely take the majority of your time. I’d personally try to get this part done within the first week, then work on the rest of the assignment during the second week.

Processing the Data Meteorite Data Processing代写

First build your dictionary of data. To do this, process each line of the csv file, one at a time. Note that youwill need to not process the first line, since that just has header information.

Try to process just one line first and place the associated data into the dictionary. Once you have one lineworking, then edit your code to loop through all the lines and add the data from each line into the dictionary. There are MANY lines so if you try to run the loop while debugging, it will take you a long time. By starting with just one line of data, it will be much easier to debug.

As mentioned above, there will be some lines that are missing data. This is common when you work with”real world” data, and it is up to the programmer to design algorithms so that their code can handle allpossible edge cases.Meteorite Data Processing代写

 Here are few examples of lines that you may receive from the csv file:

  1. 1.Aachen,21,”(50.775000,6.083330)”\n
  2. 2.Aire-sur-la-Lys,,”(50.666670,2.333330)\n
  3. BullsRun,2250,\n
  4. AsarcoMexicana,,\n

Line 1 above is a “normal” line that has all the data. Line 2 is a line that is missing the mass data. Line 3 ismissing the latitude and longitude data. Line 4 is missing the mass, latitude, and longitude data. Your codeneeds to handle all 4 categories of lines shown above. I recommend first figuring out the algorithm for doingthis. On paper, outline how you can determine which of the 4 above categories each line fits into. Then, foreach category, determine what you need to do when you store the data for the line into the dictionary. When writing your code, you’ll likely use conditional statements.

You will likely run into errors such as “cannot convert string to int” or “cannot convert string to float.” If thishappens, print the part of your code that you are trying to convert to another type, and check to see what itlooks like. You will use various string operations (such as slicing) to manipulate the string to contain just thedata itself (and no extra characters) so it can be converted to another type.Meteorite Data Processing代写

Warning: don’t try to print the entire dictionary. Your computer will likely freeze. You can instead test it by printing out various key-value pairs in your dictionary by looking them up with their key.

Don’t forget to close your file! If you run your code and forgot to close your file, you might need to re- download the csv file again.

The Rest of the Program

Then work on the user interface. Initially, have it print out different messages if the user enters 1, or 2. (Themessages don’t matter – they are just used for testing and can be replaced later). Test it with various inputs (0-2). Check to make sure that it continues to ask for inputs until the user inputs 0. Not sure how to get thewhile loop to run until the user enters 0 to exit? Refer to the HowTo: Use Boolean Values as Flags

page on Canvas.

The get_meteorite_info function is the easier one of the two, so you can decide if you want to work on that one or the other one: create_mass_file first.

General Hints

Run your code every time you write a few lines to check for errors, rather than typing out the entire file at once then running it. This will make it easier to debug. If you get error messages, find the line number in the message. In a file in IDLE, the line number that the cursor is currently on is displayed on the bottom right of the window (look for Ln).Meteorite Data Processing代写

Reminders

Canvas will only let you submit a .py file, so make sure you use IDLE to write your code (and not something like Microsoft Word). When you first open IDLE, it shows the shell. Code you type in the shell will not be saved. Instead, when in IDLE click File then New File, and write your code here. You can then save it (click File then Save).

Project Rubric

Please refer to the assignment rubric to see how you will be graded. Let me know before the deadline if you have any questions.Meteorite Data Processing代写

You are not allowed to use the built-in Python csv module (i.e. do not use the line import csv in your code), as this assignment assesses your ability (not the Python csv module’s ability) to process and manipulate data. If you do, your score will be reduced by 50%.

 

Meteorite Data Processing代写
Meteorite Data Processing代写

更多其他:C++代写 java代写 r代写 代码代写 金融代写  python代写 web代写 物理代写 数学代写 考试助攻 C语言代写 finance代写 code代写 作业帮助 lab代写 计算机代写

合作平台:天才代写 幽灵代写 写手招聘 Essay代写

 

天才代写-代写联系方式