Problem Statement
Problem outline
Write a program the analyzes the NASA Meteorite Landings dataset available at https://data.nasa.gov/widgets/gh4g-9sfh. The program runs from the Terminal/CLI. The program will have two primary capabilities. The first is to display all meteorites discovered in a given year. The second is to display the meteorite geographically closest to a provided latitude and longitude.
The program must run from the CLI as python meteoric.py <command> <argument>. See the input format and sample inputs for examples of running the program.
Input format
The program must understand the following commands:
year <integer>: Print out the meteorite name, latitude, and longitude for all meteorites discovered in the<integer>year. It is possible that no meteorites were discovered in a given year. Example usage:python meteoric.py year 1999geopoint <latitude,longitude>: Print out the meteorite name, latitude, and longitude for the meteorite with the closest great-circle distance to the coordinates. Latitude is a float in the range [-90.0, 90.0]. Longitude is a float in the range [-180.0, 180.0]. Example usage:python meteoric.py geopoint 34.2257,-77.9447
The data in meteorite_landings.csv looks like this:
name,id,year,reclat,reclong
Aachen,1,1880,50.775,6.08333
Aarhus,2,1951,56.18333,10.23333
Abee,6,1952,54.21667,-113
Acapulco,10,1976,16.88333,-99.9
...
| Field | Description |
|---|---|
name | A name for the specific meteorite. |
id | A unique integer identifier for the meteorite. |
year | The year the meteorite was found or observed. Years are positive 4-digit integers. |
reclat | The latitude at which the meteorite was found. Latitudes are floats in the range [-90.0,90.0]. |
reclong | The longitude at which the meteorite was found. Longitudes are floats in the range [-180.0,180.0]. |
Important: a load_data() function is provided in meteoric.py that loads the data from meteorite_landings.csv into a list of lists. You do not need to validate the data in the CSV file, however, some fields may be blank if the information is missing.
Output format
- Print meteorite data to the console in a human-friendly format.
- When searching for all meteorites that were discovered in a given year the program will either: (a) display a list of meteorites discovered, or (b) display a message stating no meteorites were found for the given year.
- When searching for the closest meteorite landing from a specific location, the program will display the name (or names if two or more meteorites have an equal distance from the specified location) of the meteorite closest to the location given by the user.
- If the user fails to provide a valid command or valid arguments, the console displays an error message indicating what the user did incorrectly.
Exceptional conditions
Do not assume the <command> or <argument> are present or valid. The program must print an error message, not an exception or stack trace, if given bad arguments.
- user can put in an invalid command keyword
- user does not give an argument
- user gives an invalid data type with the year keyword
- user enters a year with no meteorite
- user inputs latitude and longitude incorrectly
- user enters multiple arguments
- user gives an out of range latitude or longitude
Sample input
python meteoric.py test: invalid commandpython meteoric.py year: missing argumentpython meteoric.py geopoint: missing argumentpython meteoric.py year s: invalid argumentpython meteoric.py geopoint abcdef: invalid argumentpython meteoric.py year 1999 2001 asd: invalid argumentspython meteoric.py geopoint 120.884,300.475: invalid latitude and longitudepython meteoric.py geopoint 32.558,78.854: valid search by geopointpython meteoric.py year 1818: valid search by yearpython meteoric.py year 55: valid search by year, no meteorites match that year
Sample output
You may change these to be more precised if you like, but not less precise.
Invalid command and argument. Correct format is python meteoric.py <command> <argument>.Invalid command and argument. Correct format is python meteoric.py <command> <argument>.Invalid command and argument. Correct format is python meteoric.py <command> <argument>.Invalid argument. year argument must be an integer.Invalid argument. geopoint argument must be latitude,longitude.Invalid command and argument. Correct format is python meteoric.py <command> <argument>.Invalid argument. geopoint latitude or longitude out of range.Meteorite(s) discovered closest to 32.4, 103.92: Guangyuan, latitude: 32.4, longitude: 105.9Meteorite(s) discovered in 1818: Seres, latitude: 41.05, longitude: 23.56667 Slobodka, latitude: 55, longitude: 35 Zaborzika, latitude: 50.28333, longitude: 27.68333 Cambria, latitude: 43.2, longitude: -78.8 Cape York, latitude: 76.13333, longitude: -64.93333No meteorites found for the year 55.