Skip to main content

A Python library for predicting electron density using XGBoost

Project description

MISA_XGModel

A Python library for predicting electron density using XGBoost.


Overview

This library provides tools to predict electron density (Ne) using a machine-learning model based on XGBoost. It supports querying predictions for specific latitude, longitude, day of year (DOY), altitude, and solar local time (SLT), while leveraging pre-computed geophysical indices.


Features

  • Predict electron density (Ne) for specific geospatial and temporal conditions.
  • Clamp input values to the bounds of the training dataset for robustness.
  • Supports querying geophysical indices from provided datasets.
  • Modular design for integrating geophysical models in Python applications.

Installation

You can install this package via pip:

pip install MISA_XGModel

Usage

Quickstart

Here’s how you can use the library to predict electron density:

from MISA_XGModel import predict_ne, query_model

# Predict Ne with dataset lookup for geophysical indices
predicted_ne = predict_ne(
    lat=42.0, lon=-71.0, doy=99, alt=150.0, slt=12.0, year=2024
)
print(f"Predicted Ne: {predicted_ne:.2e}")

# Predict Ne with precomputed geophysical indices
predicted_ne = query_model(
    lat=42.0, lon=-71.0, doy=99, alt=150.0, slt=12.0,
    hp30=2, ap30=7, f107=209, kp=2.3, fism2=0.0007678
)
print(f"Predicted Ne: {predicted_ne:.2e}")

Inputs and Parameters

Clamping Input Values

Input parameters (lat, lon, doy, alt, slt) are clamped to the boundaries of the training data. These boundaries are defined as follows:

Parameter Min Value Max Value
lat 37.5 49.9
lon -85.7 -76.1
alt 94.6 km 500 km
slt 0.0 hrs 24 hrs

predict_ne Function

Parameter Type Description
lat float Latitude of the input location (degrees). Clamped to [37.5, 49.9].
lon float Longitude of the input location (degrees). Clamped to [-85.7, -76.1].
doy int Day of year (1-365).
alt float Altitude in kilometers. Clamped to [94.6, 500].
slt float Solar local time (0-24 hours). Clamped to [0.0, 24].
year int Year to lookup geophysical indices in the dataset.
master_geo_ds xarray.Dataset Dataset containing geophysical indices (default: master_geo_ds).
model XGBRegressor Pre-trained XGBoost model for predictions (default: optimized_xgb).
scaler StandardScaler Scaler used for feature normalization (default: scaler_large).

This function also retrieves geophysical indices (hp30, ap30, f107, kp, fism2) from the provided dataset for the specified year and day of year (doy).


query_model Function

Parameter Type Description
lat float Latitude of the input location (degrees). Clamped to [37.5, 49.9].
lon float Longitude of the input location (degrees). Clamped to [-85.7, -76.1].
doy int Day of year (1-365).
alt float Altitude in kilometers. Clamped to [94.6, 500].
slt float Solar local time (0-24 hours). Clamped to [0.0, 24].
hp30 float Precomputed geophysical index.
ap30 float Precomputed geophysical index.
f107 float Precomputed geophysical index.
kp float Precomputed geophysical index.
fism2 float Precomputed geophysical index.
model XGBRegressor Pre-trained XGBoost model for predictions (default: optimized_xgb).
scaler StandardScaler Scaler used for feature normalization (default: scaler_large).

predict_ne requires geophysical indices as input, allowing for greater control over predictions in scenarios where geophysical data is already available.


Requirements

  • Python 3.7+
  • Dependencies:
    • xgboost
    • scikit-learn
    • numpy
    • pandas
    • xarray
    • joblib
    • netcdf4

License

This project is licensed under the MIT License - see the LICENSE file for details.


Author


Acknowledgments

  • Thank you to Sevag Derghazarian for his continuous support and consultation on this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

misa_xgmodel-0.1.5.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

MISA_XGModel-0.1.5-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file misa_xgmodel-0.1.5.tar.gz.

File metadata

  • Download URL: misa_xgmodel-0.1.5.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for misa_xgmodel-0.1.5.tar.gz
Algorithm Hash digest
SHA256 997b3fdea023332f8e44fde40785f631a35ff0cc06544e99df1aa3788cac7e80
MD5 8631c141062666d5a9cf39283408c1d9
BLAKE2b-256 c20550c9b18542b239c3eaa30e76c8d1d02f6dc41ce79a05ce4fbd3cfad00090

See more details on using hashes here.

File details

Details for the file MISA_XGModel-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: MISA_XGModel-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for MISA_XGModel-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 77df9ddc7634c165805f205d83f5454cc1b2804b20bf8f1121b1b25cf607357c
MD5 e0711b8f5cf851a16f77eb7f0c36f321
BLAKE2b-256 cddc13beb4e992e89d2994c38d16c7e3bfc346163685d3234a0220348a4ebd79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page