Code Monkey home page Code Monkey logo

k_index_calculator's Introduction

K-Index Calculator

==================

A module for calculation of the geomagnetic K-Index from horizontal geomagnetic components.

This module uses the Finnish Meteorological Institute (FMI) method, details of which can be found here:

In a nutshell, this module takes horizontal geomagnetic components like this: Horiz

... and calculates the K-Index: KFin

Quick Code Example

Assuming you have 4 days of geomagnetic data in the following format:

Times = array of datetime objects in second bins.

Bx, By, Bz = arrays of geomagnetic data in second bins.

First, convert the Times array into second floats:

>>> Times_float = Time2Float(Times)

Now convert all of the data to minute bins:

>>> minute_time, minute_bx, minute_by, minute_bz = MinuteBin(Times_float, Bx, By, Bz)

To get the K-Index for these 4 days:

>>> k_index, k_time, order = KIndexSuperCalc(minute_time, minute_bx, minute_by, n)

where n is the maximum threshold for a K9 event (dependent on latitude).

NOTE: The first few values in the array k_index are likely to be inaccurate. This is because of the way the K-Index is calculated. It is safest to dismiss the first 8 calculated K-Index values.

To plot the K-Index:

>>> KIndexPlotter(k_index[8:], k_time[8:], m)

where m is the figure number.

Installation

To install, type

pip install k_index_calculator

Author

Written by Sean Blake in Trinity College Dublin, 2014-2016

Email: [email protected]

GITHUB: https://github.com/TerminusEst

Uses the MIT license.

FMI Method

Assuming you have 4 days of geomagnetic data in the following format:

minute_time = array of datetime objects in minute bins.

minute_bx, minute_by, minute_bz = arrays of geomagnetic data in minute bins.

Step 1

For each 3-hour block in the horizontal geomagnetic components, the max variation is found. This is then compared to the following table to get an initial K-index:

K-Index Value nt Variation Range
0 (0-5)*(n/500)
2 (10-20)*(n/500)
3 (20-40)*(n/500)
4 (40-70)*(n/500)
5 (70-120)*(n/500)
6 (120-200)*(n/500)
7 (200-330)*(n/500)
8 (330-500)*(n/500)
9 (500+)*(n/500)

where n is the maximum threshold for a K9 event (this is dependent on geomagnetic latitude). This is calculated using the KIndex function.

Step 2

An estimation for the solar quiet or solar regular curve is calculated. This is calculated using the FMISmooth function, which is dependent on the preliminary K-Index.

Step 3 This solar quiet estimation is smoothed (SrSmooth), and subtracted from both horizontal components (Subtracted). SrCurve "Bx Component and Sr Curve"

Step 4 Steps 1-2 are repeated twice more with the reduced data to get a second and then final K-Index.

All of these steps can be combined in one call of KIndexSuperCalc. ##Functions List

Main Functions

KIndexSuperCalc

  • Calculates the K-index using the FMI method.

KIndexPlotter

  • Plots K-Index values in a nice Bar Plot

Secondary Functions

Time2Float

  • Converts datetime object or array of datetime objects to floats.

Float2Time

  • Converts float or array of floats to datetime objects.

MinuteBin

  • Bin second data into minutes.

KIndex

  • Calculate K-Index according to the FMI Method.

FMISmooth

  • Calculates the Solar Regular (Sr) curve according to the FMI Method.

SrSmooth

  • Smooths the solar regular curves.

Subtracted

  • Subtracts the smoothed solar regular curves from the minute binned data.

KIndexBarColor -Colours K-index bar plot so it looks nice.

k_index_calculator's People

Stargazers

Alice Martinez avatar

Watchers

James Cloos avatar

Forkers

tcdsolar dal3006

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.