This project demonstrates the use of JavaScript and Node.js to analyze and transform data about Near Earth Objects (NEOs) provided by NASA. The dataset, in JSON format, contains 202 objects representing various properties of NEOs, including observed magnitude, orbital properties, and classification as asteroids or comets. The program performs the following tasks in five steps:
- Loading JSON Data
- Basic Functions
- Data Analysis
- Changing JSON Format
- Unit Testing
This README outlines the structure, functionality, and development process of the project.
main.js: The main JavaScript file containing the program code.main.test.js: Unit tests implemented using Jest.NEO Analysis Report.pdf: Report detailing the implementation and analysis process.NEOWISE_Dataset.json: The original dataset provided for analysis.NEOWISE_classes.json: The rearranged JSON file sorted by NEO class type.
- JavaScript: Core programming language for data analysis and manipulation.
- Node.js: Environment for file handling and JSON processing.
- Jest: Testing framework for unit tests.
To get started with the project, follow these steps:
Ensure you have Node.js installed on your system. Download Node.js here
- Clone this repository to your local machine:
git clone <repository-url>
cd <repository-folder>
- Initialize the project with npm:
npm init
- When prompted:
- Press Enter to accept defaults for most options.
- Set the entry point to
main.js(or the defaultindex.js). - Set test command to jest.
- Install Jest for testing
npm install --save-dev jest
- Run the main script:
node main.js
- Run the Jest tests:
npm test
- The JSON file is read and parsed into a JavaScript object using Node.js.
- Encapsulates the data-loading logic within a reusable function for modularity.
Four key functions were developed:
findNeoByIndex: Retrieves a NEO by its index in the dataset.filterByOrbitClass: Filters NEOs by their orbit class.filterByPha: Filters NEOs that are classified as Potentially Hazardous Asteroids (PHA).findNeoByDesignation: Searches for a NEO by its unique designation.
- Created functions to analyze and compare NEO properties:
filterByPhaAndOrbitClass: Filters NEOs by both PHA status and orbit class.calculateStats: Computes maximum, minimum, and average values for orbital properties.
- Used
console.tablefor formatted output to visualize comparisons. - Reverse-engineered definitions of NEO classifications (e.g., PHA criteria, asteroid/comet classes) using dataset analysis.
Example Results for functions using console.table:
findNeoByDesignation("419880 (2011 AH37)"):
%22).png)
filterByPhaAndOrbitClass(true, "Aten"):
.png)
filterByPhaAndOrbitClass(false, "Aten"):
.png)
calculateStats(phaPropertyValues):
.png)
calculateStats(jupiterPropertyValues):
.png)
- Rearranged the dataset into arrays sorted by NEO class type.
- Saved the new structure into a JSON file (NEOWISE_classes.json) for improved accessibility and usability.
Utilized the Jest framework to test program functions:
- Checked valid and invalid inputs for
findNeoByIndexandfindNeoByDesignation. - Verified the functions
extractClassPropertyValuesandcalculateStats.
-
Potentially Hazardous Asteroids (PHA):
- Defined by observed magnitude ≤ 22.0 and MOID ≤ 0.05 AU.
- PHAs exhibit smaller orbital properties compared to non-PHAs.
-
Asteroid Classes:
- Apollo: Earth-crossing asteroids (most likely to be PHAs).
- Amor: Orbits farther from Earth (least likely to be PHAs).
- Aten: Smallest orbits and MOIDs.
-
Comet Classes:
- Identified unique orbital characteristics (e.g., Halley-type comets have the longest orbital inclinations).
This project demonstrates the practical application of JavaScript programming fundamentals, emphasizing the analysis, transformation, and testing of data. By systematically addressing each task, the project illustrates how simple functions and logical operations can handle complex datasets, offering insights into NEO classifications and characteristics.
.png)

