The Connor's Lightning Parser Lib (LPL) is an extremely powerful analysis utility with a simplistic front-end in mind.
Project description
Connor's Lightning Parser Lib (LPL)
The Connor's Lightning Parser Lib (LPL) is an extremely powerful analysis utility with a simplistic front-end in mind.
The analyzer is capable of processing millions of LYLOUT datapoints in mere minutes by using a SQL database back-end for initial filtering, and then uses optimized work-arounds for computationally expensive methods that omit square-root and trig functions for distances between points. Not to mention it's back-end parses most data with indexes (list[int], list[list[int]], etc.) instead of the entire data itself. Additionally, it uses multi-processing when necessary to accelerate processes.
[!NOTE] The stitchings are done on a temporal and delta-magnitude basis. This basically means that scipy's cKDTree, despite being powerful and timely, does not include temporal thresholds and therefore would not accurately stitch lightning points that respect the lightning strike. Therefore, this code will go from 4 minutes with 3 million points to 2 hours for 10 million points. I will likely switch to C or C++ down the line to improve processing time. But for now, this is the most optimized Python library I can make for temporal distance lightning stitching.
All of these methods allow extremely fast computation times, given the immense scale and size of the data itself.
This library extracts LYLOUT data, store it into a lightning database, and processes millions of datapoints in the database to a reasonably fast and optimized speed. This project is meant to be a framework for applications to implement and parse data more appropriately.
Assuming the following specs (tested on a laptop with Ubuntu 22.04):
- 64 GB DDR4 RAM
- RTX 2060 Mobile (6GB)
- Intel i7-10750H (6 Cores -> 12 Threads)
- Python 3.12.3 (Regular version/Not conda)
Three million datapoints should take roughly 4 minutes to process (excluding generating plots). Running the same exact parameters again would take 18-20 seconds due to caching.
Start
Getting Started
-
Git clone the project
git clone https://github.com/CorniiDog/lightning_research_database.git -
Open the project in VSCode
-
Create a virtual environment (
cmd+shift+pfor MACOS orctrl+shift+pfor Windows) -> "Python:Select Interpreter" -> ".venv" and then select a specified version. -
Either check the box for "requirements.txt" before continuing, or after re-opening the terminal to do
pip install -r requirements.txt
To Run the project
- Drag and drop your LYLOUT text files into "lylout_files" directory.
- Modify the filters in "main.py":
start_time = datetime.datetime(2020, 4, 29, 0, 0, tzinfo=datetime.timezone.utc).timestamp() # Timestamp converts to unix (float)
end_time = datetime.datetime(2020, 4, 29, 23, 59, tzinfo=datetime.timezone.utc).timestamp() # Timestamp converts to unix (float)
# Build filter list for time_unix boundaries.
# Look at "List of headers" above for additional
# Filterings
filters = [
("time_unix", ">=", start_time), # In unix
("time_unix", "<=", end_time), # In unix
("reduced_chi2", "<", 5.0,), # The chi^2 (reliability index) value to accept the data
("num_stations", ">=", 5), # Number of stations that have visibly seen the strike
("alt", "<=", 24000), # alt is in meters. Therefore 20 km = 20000m
("alt", ">", 0), # Above ground
("power_db", ">", -4), # In dBW
("power_db", "<", 50), # In dBW
]
- Modify parameters
# Additional parameters that determines "What points make up a single lightning strike"
# They are explicitly defined
params = {
# Creating an initial lightning strike
"max_lightning_dist": 30000, # Max distance between two points to determine it being involved in the same strike
"max_lightning_speed": 1.4e8, # Max speed between two points in m/s (essentially dx/dt)
"min_lightning_speed": 0, # Min speed between two points in m/s (essentially dx/dt)
"min_lightning_points": 100, # The minimum number of points to pass the system as a "lightning strike"
"max_lightning_time_threshold": 0.3, # Max number of seconds between points
"max_lightning_duration": 30, # Max seconds that define an entire lightning strike. This is essentially a "time window" for all of the points to fill the region that determines a "lightning strike"
# Combining intercepting lightning strike data filtering
"combine_strikes_with_intercepting_times": True, # Set to true to ensure that strikes with intercepting times get combined.
"intercepting_times_extension_buffer": 0.6, # Number of seconds of additional overlap to allow an additional strike to be involved
"intercepting_times_extension_max_distance": 100000, # The max distance between the start point of one lightning strike and at least one from the entirety of another lightning strike's points
}
- Run with
python run main.pyand observe the images in their respective directories
[!NOTE] Some individuals may upload a compressed LYLOUT file without adding a suggestive extension filename. Make sure that all LYLOUT files are able to be readable as a text file. If they are not, they are likely compressed, with or without the extension name. It is suggested to try to add the ".gz" extension at the end manually by renaming the file, and attempt to unzip it. If that is not successful, try adding ".zip" and attempt to unzip.
[!NOTE] When data is added to "lylout_files", everything gets hashed and recorded into "lylout_db.db". This ".db" file is a SQL database that stores all historical lightning strikes. If the database is becoming too large, you can simply delete the "lylout_db.db" file.
Useful Functions
-
Run in background:
python main.py > output.log 2>&1 & disown -
List all files in directory './' and sizes:
du -h --max-depth=1 ./ | sort -hr -
./.venv/bin/python main.py -
./.venv/bin/python main.py > output.log 2>&1 & disown -
./.venv/bin/pip install -r requirements.txt -
./.venv/bin/pip show setuptools -
./.venv/bin/python3 -m build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lightning_parser_lib-0.0.1.tar.gz.
File metadata
- Download URL: lightning_parser_lib-0.0.1.tar.gz
- Upload date:
- Size: 32.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f15af91ab68d41ba2d0bae316798fbb7ff34eef2a46b6deda22b57f804b0192
|
|
| MD5 |
2c2aadb1481f43419cab33ba3533b5c0
|
|
| BLAKE2b-256 |
4aabef51f2abdec5d2fdfdd7b9b0c2d80aeca11ad2832b05314ac95510152246
|
File details
Details for the file lightning_parser_lib-0.0.1-py3-none-any.whl.
File metadata
- Download URL: lightning_parser_lib-0.0.1-py3-none-any.whl
- Upload date:
- Size: 34.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bab95aa881bf0a4e49bc7ac1f80f03a50560513389c08ea29bdf807d4e12bc2
|
|
| MD5 |
8f89ec49d14cf945df177e4ad598ddb8
|
|
| BLAKE2b-256 |
13428298d0e04f93699756e1e9af815d0dfdc61f1aebe25ad7d4376733e69a6b
|