Coder Social home page Coder Social logo

go-ualf's Introduction

UALF Parser for Go

Overview

UALF Parser is a Go library designed to parse lightning data formatted in the Universal ASCII Lightning Format (UALF). It provides an efficient and user-friendly way to convert UALF strings into structured Lightning structs in Go, making it easier for developers to integrate lightning data into their applications.

Installation

To install the UALF Parser, use the go get command:

go get github.com/einarhh/go-ualf

Usage

To use the UALF parser, import it into your Go project and call the ParseUALF method with a UALF-formatted string.

Example:

package main

import (
    "fmt"
    "github.com/einarhh/go-ualf"
)

func main() {
    ualfData := "2024 01 20 17 07 34 877390848 63.8099 2.6209 30 0 11 17 118.80 0.50 0.40 7.44 11.8 7.5 3.0 0 1 0 1"
    lightningData, err := ualf.ParseUALF(ualfData)
    if err != nil {
        fmt.Println("Error parsing UALF data:", err)
        return
    }

    fmt.Printf("Parsed Lightning Data: %+v\n", lightningData)
}

The Lightning Struct

The Lightning struct is the core data structure used by UALF Parser. It includes fields corresponding to the UALF specification.

The Version field, while not specified in the UALF standard, is included in the data obtained from frost.met.no. In this parser, we treat Version as an optional field. It is omitted if the string's first field represents the year.

type Lightning struct {
	Version          int       `json:"version"`
	Timestamp        time.Time `json:"timestamp"`
	Lat              float64   `json:"lat"`
	Lon              float64   `json:"lon"`
	PeakCurrent      int       `json:"peakcurrent"`
	Multiplicity     int       `json:"multiplicity"`
	Sensors          int       `json:"sensors"`
	DegreesOfFreedom int       `json:"degreesOfFreedom"`
	Angle            float32   `json:"angle"`
	SemiMajorAxis    float32   `json:"semiMajorAxis"`
	SemiMinorAxis    float32   `json:"semiMinorAxis"`
	ChiSquare        float32   `json:"chiSquare"`
	RiseTime         float32   `json:"riseTime"`
	PeakToZeroTime   float32   `json:"peakToZeroTime"`
	MaxRateOfRise    float32   `json:"maxRateOfRise"`
	CloudIndicator   bool      `json:"cloudIndicator"`
	AngleIndicator   bool      `json:"angleIndicator"`
	SignalIndicator  bool      `json:"signalIndicator"`
	TimingIndicator  bool      `json:"timingIndicator"`
}

Acknowledgments

  • SMHI Open Data API Docs - Lightning Archive
  • The Norwegian Meteorological institute

go-ualf's People

Contributors

einarhh avatar

Watchers

 avatar

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.