0% found this document useful (0 votes)
14 views21 pages

Final Project I (Final) (1)

Uploaded by

epsibhas61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

Final Project I (Final) (1)

Uploaded by

epsibhas61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

1.

Introduction:
Meteor showers are celestial events that occur when Earth passes through
the debris left by comets or asteroids. These events can be spectacular and are
often a highlight for amateur astronomers and stargazers. However, the ability
to predict the visibility of these meteor showers depends on various factors,
including the paths of comets, atmospheric conditions, and light pollution. The
Meteor Shower Prediction Projection aims to develop a predictive system that
utilizes historical data to forecast the visibility of meteor showers from specific
locations on Earth.
In this project, we will use many tool and technique, data science and
machine learning as given below:
 Use Python, Pandas, and Visual Studio Code to understand meteor
showers.
 Use machine learning to cleanse and impute missing data from datasets.
 Discover how to identify bimodal data across human and make
prediction of meteors.
 Explore the Code Tour extension in Visual Studio Code for code
writing guidance.

This module focuses on a real-world event, meteor showers. It guides


you to use data science to predict the best day to see a meteor shower in
your general location.

2. OBJECTIVES:

The primary objectives of the Meteor Shower Prediction Project are as


follows:
1. Enhance Public Awareness: Educate the public about meteor showers and
provide timely information for viewing opportunities.
2. Utilize Historical Data: Analyse historical data on meteor showers to create
predictive models.
3. Visualize Data and Predictions: Present data visually to enhance
understanding and engagement with meteor showers.

1|data science
3. PREVIOUS WORK:

The study of meteor showers has a rich history, with various


organizations and researchers compiling data on meteor events. Previous work
includes:
1. Comet Thatcher:
Comet Thatcher was first discovered in 1861. It takes this comet 415.5
years to go around the sun. The Lyrids meteor shower which can be seen in
April is created from the debris of this comet.
2. Comet Halley
Comet Halley was first discovered in 1531. It takes this comet 76 years
to go around the sun. The Eta Aquarids meteor shower which can be seen in
May is created from the debris of this comet. The meteor shower from
Orionids which can be sighted in October is also from the debris of this comet.
3. Comet Swift-Tuttle
Comet Swift-Tuttle was first discovered in 1862. It takes this comet 133
years to go around the sun. The Perseids meteor shower which can be seen in
August is created from the debris of this comet. The Perseids meteor shower
appears to come from the direction of the constellation Perseus.
4. Comet Tempel-Tuttle
Comet Tempel-Tuttle was discovered separately in 1865 and in 1866. It
takes this comet 33 years to go around the sun. The Leonids meteor shower
which can be seen in November is created from the debris of this comet.
Sometimes, the Leonids meteor shower can also become a meteor storm.
Phases of the moon
When the moon goes around the Earth, different amounts of the light of
the sun are reflected from the Moon to Earth. This change in the number of
light cases the size of the moon to change every day during the month. The
phases of the Moon have been named depending on the amount of light
reflecting from the moon.
The different phases of the Moon are as follows:
• New Moon
• Waxing crescent
• First-quarter
• Waxing gibbous
• Full Moon
• Waning gibbous
• Third-quarter
2|data science
4. CURRENT WORK:
Current efforts in the Meteor Shower Prediction Project are focused on:
 Data Collection and Integration: Compiling historical data from
multiple sources.
 Data Processing and Preparation: Cleaning and preparing the data.
 Write Predictor function and Testing: Implementing and validating
various machine learning algorithms to predict meteor shower
visibility.
5. METHODOLOGY:

5.1 Set Up Your Development Environment:


To create the model, you need some kind of Python notebook development
environment.
 Make sure you're signed in to GitHub.
 Go to Codespaces.
 In the Explore quick start templates section, locate the Jupyter
Notebook template and select Use this template.

5.2 Collect Data Related To Meteor Showers:


Get data ready to create your prediction model.
Before we gather data, it's important to identify the kind of data that we want
to find. We know a few things:
 Meteoroids that melt off of comets typically cause meteor showers.
 Comets have an orbit around the sun that's observable and predictable.
 A bright Moon makes a meteor shower harder to see.
 The orbit and spin of Earth affects where a meteor shower can be seen
from Earth.

3|data science
5.3 Import data:
Code:
import numpy as np

import pandas as pd

Output:

5.4 Explore data:


For each variable you created, print the head and the info for those
DataFrames. Head allows you to see the first five lines in the .csv files.

Code:
meteor_showers.head()

Output:

4|data science
Code:
meteor_showers.info()

Output:

Code:
moon_phases.head()

Output:

5|data science
Code:
moon_phases.info()

Output:

Code:
constellations.head()

Output:

6|data science
Code:
constellations.info()

Output:

Code:
cities.head()

Output:

7|data science
Code:
cities.info()

Output:

5.5 Convert to numbers:

We can see from the calls to head () that a lot of information is written in
words (strings) instead of numbers (integers). Some data makes sense as
strings, like city names or meteor shower names. But other data makes more
sense as integers, like months or Moon phases.

You can quickly convert the month columns to numbers:

o Create a map of months to numbers. We can see from the output of


head() that the months are all lowercase.
o Map the map of months to the columns that have months in them.
o Save the result to the DataFrame.

8|data science
Code:
months = {'january':1, 'february':2, 'march':3, 'april':4,
'may':5,'june':6, 'july':7, 'august':8, 'september':9,
'october':10, 'november':11, 'december':12}

meteor_showers.bestmonth =
meteor_showers.bestmonth.map(months)
meteor_showers.startmonth =
meteor_showers.startmonth.map(months)
meteor_showers.endmonth =
meteor_showers.endmonth.map(months)
moon_phases.month = moon_phases.month.map(months)
constellations.bestmonth =
constellations.bestmonth.map(months)

Verify your changes by adding calls to head() and info() to each of the
three DataFrames that you modified. For example:
Code:
meteor_showers.head()

Output:

Code:
meteor_showers.info()

Output:

9|data science
Before continue, convert months and days in
the meteor_showers DataFrame to a type called date time, which tracks dates.

Create two new columns: start date and end date. These columns will
contain a month and day in 2020:

Code:

meteor_showers['startdate'] =
pd.to_datetime(2020*10000+meteor_showers.startmonth*100+meteo
r_showers.startday,format='%Y%m%d')

meteor_showers['enddate'] =
pd.to_datetime(2020*10000+meteor_showers.endmonth*100+meteor_
showers.endday,format='%Y%m%d')

moon_phases['date'] =
pd.to_datetime(2020*10000+moon_phases.month*100+moon_phases.d
ay,format='%Y%m%d')
hemispheres = {'northern':0, 'southern':1, 'northern,
southern':3}
meteor_showers.hemisphere =
meteor_showers.hemisphere.map(hemispheres)
constellations.hemisphere =
constellations.hemisphere.map(hemispheres)
Moon_phase.head()

Output:

10 | d a t a s c i e n c e
Code:
check = moon_phases.groupby('moonphase')['moonphase'].count()
check

Output:

Finally, convert Moon phases to numbers that represent the percentage of the
Moon that's visible. This time, add a new column to represent the data:

 Create the map of phases to numbers.


 Add a new column called percentage and set it to the moonphase column
that's mapped to the numbers.
 Show the first five rows.

Code:
phases = {'new moon':0,'third quarter':0.5, 'first
quarter':0.5,'full moon':1.0}

moon_phases['percentage'] =
moon_phases.moonphase.map(phases)
moon_phases.head()

Output:

11 | d a t a s c i e n c e
5.6 Remove unnecessary data:

Some of the data from these .csv files isn't useful. You can delete the
following data:

Code:
meteor_showers = meteor_showers.drop(['startmonth', 'startday',
'endmonth', 'endday', 'hemisphere'], axis=1)

moon_phases =
moon_phases.drop(['month','day','moonphase','specialevent'],
axis=1)

constellations = constellations.drop(['besttime'], axis=1)


moon_phase.info()

Output:

12 | d a t a s c i e n c e
5.7 Missing data:

One of the .csv files is interesting. The output


of moon_phases.info() shows the following information:
Code & Output:

Code:
lastPhase = 0

for index, row in moon_phases.iterrows():


if pd.isnull(row['percentage']):
moon_phases.at[index,'percentage'] = lastPhase
else:
lastPhase = row['percentage']

moon_phases.info()

Output:

Now data is cleansed and ready to be analyzed!

13 | d a t a s c i e n c e
5.9 Write the prediction function:
This module introduces a simplified way to examine data. Without using a lot
of predictions, our method is a lot like a complex lookup table. You can later
expand on the model with data like weather to make it more like a classical
machine learning model.
The four data sets are:

Code & Output:

Code & Output:

14 | d a t a s c i e n c e
Code & Output:

Code & Output:

The function that we write needs to:


 Determine the latitude of a city.
 Use that latitude to figure out which constellations are visible to that
city.
 Use the constellations to determine which meteor showers are visible to
that city.
 Use the meteor showers to determine the dates that they're visible.
 Use the dates to find the optimal date that has the least amount of light
from the Moon.
 Use these steps to build your function.
15 | d a t a s c i e n c e
5.10 Determine The Latitude:
Create a function called predict_best_meteor_shower_viewing that takes in
a city as a parameter:

Code:
def predict_best_meteor_shower_viewing(city):

def predict_best_meteor_shower_viewing(city):

latitude = cities.loc[cities['city'] == city,


'latitude'].iloc[0]

print(cities['city'] == 'Abu Dhabi')


print(cities.loc[cities['city'] == 'Abu Dhabi'])

print(cities.loc[cities['city'] == 'Abu Dhabi', 'latitude'])

print(cities.loc[cities['city'] == 'Abu Dhabi',


'latitude'].iloc[0])

predict_best_meteor_shower_viewing(city):
latitude = cities.loc[cities['city'] == city,
'latitude'].iloc[0]

return latitude

Write a predictor function:


def predict_best_meteor_shower_viewing(city):

latitude = cities.loc[cities['city'] == city, 'latitude'].iloc[0]

constellation_list =
constellations.loc[(constellations['latitudestart'] >=
latitude) & (constellations['latitudeend'] <= latitude),
'constellation'].tolist()

return constellation_list

print(predict_best_meteor_shower_viewing('Abu Dhabi'))

Output:
Unfortunately, San Diego isn't available for a
prediction at this time.

16 | d a t a s c i e n c e
5.11 Find the optimal date based on Moon phases:
Finally, we can find the minimum value of the Moon phase (the least
amount of light shining from the Moon). For this predictive function,
we just grab the first date
Code:
best_moon_date=moon_phases_list.loc[moon_phases_list['percenta
ge'].idxmin()]['date']
meteor_shower_string += meteor_shower + " is best seen if you look
towards the " + constellation + " constellation on " +
best_moon_date.to_pydatetime().strftime("%B %d, %Y") + ".\n"

One tricky part in this code is where we convert the date to a pydatetime and
then convert it to a string by using strftime. If we try to omit this part, we'll get
an error.

5.12 Final Code:


Here's the final code for this predictive function:
Code:
def predict_best_meteor_shower_viewing(city):

meteor_shower_string = ""

if city not in cities.values:

meteor_shower_string = "Unfortunately, " + city + " isn't available for a


prediction at this time."

return meteor_shower_string

latitude = cities.loc[cities['city'] == city, 'latitude'].iloc[0]

constellation_list = constellations.loc[(constellations['latitudestart'] >=


latitude) & (constellations['latitudeend'] <= latitude),
'constellation'].tolist()

if not constellation_list:

meteor_shower_string = "Unfortunately, there are no meteor showers


viewable from "+ city + "."

return meteor_shower_string

meteor_shower_string = "In " + city + " you can see the following meteor
showers:\n"

for constellation in constellation_list:

17 | d a t a s c i e n c e
meteor_shower = meteor_showers.loc[meteor_showers['radiant'] ==
constellation, 'name'].iloc[0]

meteor_shower_startdate = meteor_showers.loc[meteor_showers['radiant']
== constellation, 'startdate'].iloc[0]

meteor_shower_enddate = meteor_showers.loc[meteor_showers['radiant']
== constellation, 'enddate'].iloc[0]

moon_phases_list = moon_phases.loc[(moon_phases['date'] >=


meteor_shower_startdate) & (moon_phases['date'] <=
meteor_shower_enddate)]

best_moon_date =
moon_phases_list.loc[moon_phases_list['percentage'].idxmin()]['date']

meteor_shower_string += meteor_shower + " is best seen if you look


towards the " + constellation + " constellation on " +
best_moon_date.to_pydatetime().strftime("%B %d, %Y") + ".\n"
return meteor_shower_string

print(predict_best_meteor_shower_viewing('new delhi'))
Output:

Code:
moon_phase.describe()

18 | d a t a s c i e n c e
Output:

CONCLUSION:

The Meteor Shower Prediction Project aims to bridge the gap between
complex astronomical data and everyday stargazers. By leveraging historical
data, machine learning, and user engagement, this project seeks to enhance the
experience of observing meteor showers and foster a greater appreciation for
celestial events. The ongoing work is poised to make significant contributions
to the field of astronomy, making it more accessible to the general public.

19 | d a t a s c i e n c e
DESCRIPTION:

Meteor Shower Prediction Project

Meteor showers are celestial events that occur when Earth passes through
debris trails left by comets or asteroids. These stunning displays are a favorite
among astronomers and stargazers. However, predicting their visibility
depends on several factors, such as the paths of comets, atmospheric
conditions, and local light pollution.

The Meteor Shower Prediction Project aims to create a system that uses
historical data and advanced techniques to forecast meteor shower visibility
from specific locations. This project integrates data science and machine
learning tools to enhance prediction accuracy. Key objectives include:

 Utilizing Python, Pandas, and Visual Studio Code to analyze meteor


shower data.
 Employing machine learning to clean datasets and address missing data
effectively.
 Identifying bimodal patterns in meteor data to improve prediction
accuracy.
 Exploring the Code Tour extension in Visual Studio Code for step-by-
step coding guidance.

This initiative combines data analysis, computational tools, and astronomy to


make meteor shower predictions more reliable and accessible.

20 | d a t a s c i e n c e
BIBLIOGRAPHY:

I. CBSE handbook for students.


II. GitHub on this link -
https://github.com/sguthals/learnwithdrg/tree/main/OverTheMoon/mete
or-showers
III. Various research papers on machine learning applications in astronomy.
IV. Online platforms and tools related to astronomy education and
engagement.

21 | d a t a s c i e n c e

You might also like