In this assignment, you will practice using logic and loops using a dataset of objects from the Messier Catalog. The dataset includes basic information about each object, like it’s type, magnitude, distance, constellation, and the best viewing season. Your tasks will involve reading the data, analyzing it, and using numpy
, logic, and loops to answer questions about it!
Opening the Dataset¶
The data is stored in a .npy
file, which you can load with np.load()
. We will provide this .npy
file via slack, and you can use the following line of code to open up the file in your code and store it’s contents in a variable called data
.
data = np.load('/Users/yasmeenasali/Downloads/messier_data.npy')
Each row in the dataset corresponds to a single Messier object, with the following fields:
- Messier: Name of the Messier object as a string (e.g.,
'M107'
,'M108'
) - RA and DEC: the Right Ascension and Declination of the object (coordinates in the sky).
- Type: Type of object (e.g.,
'Gc'
for Globular Cluster,'Sp'
for Spiral,'Ba'
for Barred Spiral) - Mag: Magnitude (brightness) of the object. Magnitudes are a unit-less system, and lower numbers mean brighter objects!
- Distance: Distance from Earth in units of light-years
- Constellation: The constellation in which the object resides
- Season: The best viewing season (spring, summer, autumn, winter)
Since we have not practiced with large 2D datasets a lot, here are some tips and reminders.
- You can access each row of the dataset using indexing. For instance,
data[0]
will return the first row of the array (aka all of the above column values for a single Messier object). - You can access each column of the dataset using
data['Messier']
for example, where now rather than indexing by an integer we are indexing by a column key (a column name). This will return a numpy array of all the Messier numbers for all of the objects.
Submission Requirements:¶
- Submit your code as a
.py
file. - Include comments in your code explaining what each part does!!