Ahamidullin / PROJECT

this project is a data analysis application in c++
2 stars 0 forks source link

documentation (4) #8

Open DevAnDess opened 2 months ago

yanantro commented 2 months ago

DRAFT:

Overview This program demonstrates how to classify NASA exoplanets based on their characteristics using the NASA Exoplanet API. The program fetches data from the API and performs clustering using the K-Means algorithm to group exoplanets into different categories.

Requirements C++ compiler cURL library for making API requests JSON library for parsing API response

Installation Install cURL library: sudo apt-get install libcurl4-openssl-dev Install JSON library (e.g., nlohmann/json):

git clone https://github.com/nlohmann/json.git
cd json
mkdir build
cd build
cmake ..
make
sudo make install

Compile the program: g++ exoplanet_classification.cpp -o exoplanet_classification -lcurl

Usage

#include <iostream>
#include <curl/curl.h>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

// Function to make API request
size_t write_callback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl;
    CURLcode res;
    std::string response_str;

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://exoplanetarchive.ipac.caltech.edu/cgi-bin/nstedAPI/nph-nstedAPI?table=exoplanets&format=json");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_str);
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }

    json response_json = json::parse(response_str);

    // Perform clustering algorithm (K-Means) on exoplanet data
    // ...

    return 0;
}

Example json

{
    "exoplanets": [
        {
            "pl_name": "Kepler-22 b",
            "pl_hostname": "Kepler-22",
            "pl_discmethod": "Transit",
            "pl_pnum": 1,
            "pl_orbper": 289.86259,
            "pl_orbsmax": 0.84937517,
            "pl_orbeccen": 0.17,
            "pl_orbincl": 89.95,
            "pl_bmassj": 0.1924
        },
        {
            "pl_name": "Proxima Centauri b",
            "pl_hostname": "Proxima Centauri",
            "pl_discmethod": "Radial Velocity",
            "pl_pnum": 1,
            "pl_orbper": 11.186,
            "pl_orbsmax": 0.0485,
            "pl_orbeccen": 0.35,
            "pl_orbincl": 56.9,
            "pl_bmassj": 0.004
        }
    ]
}

Reference NASA Exoplanet Archive API

yanantro commented 2 months ago

Документация проекта, посмотрите пж что добавить что исправить + нужны NEO objects @DevAnDess

doc4.docx

yanantro commented 2 months ago

update

doc4.docx

yanantro commented 2 months ago

update 2

doc4.docx