Generate VOEvent XMLs
Project description
HEK-VOEvent-Tools
Python module that generates VOEvent XML from user-supplied data.
Requirements
- Python 3.0.0+
- Pandas 2.3.0+
- Numpy 2.3.0+
Installation and Setup
(Recommended): Set up a python virtual environment
python -m venv .venv
source .venv/bin/activate
Run the following commands to install the related dependencies, and then the package itself.
pip install pandas
pip install numpy
pip install hek-voevent-tools
If you downloaded the package from source, you can install the package locally with the following command
pip install -e .
Modify the config.ini file to configure the XML output directory at lib/(Python version)/site-packages/hek_voevent_tools/. You can also change the voevent spec file location, which by default is https://www.lmsal.com/hek/software/herconfig/VOEvent_Spec.txt
Supported Event Types and Attributes
The full list of event types and coresponding attributes can be found here: https://www.lmsal.com/hek/VOEvent_Spec.html
Current HEK entries does NOT support the latest VOEvent 2.0 schema.
How to use
First, import VOEvent-tools
from hek_voevent_tools import parse_features_file, create_event, export_event, load_config
Load from config.ini
config = load_config()
VOEVENT_SPEC = config['DEFAULT'].get('specs_location')
OUTPUT_PATH = config['DEFAULT'].get('output_path')
Convert the VOEvent_Spec file into a Pandas dataframe
csv_dataframe = parse_features_file(VOEVENT_SPEC)
Create the VOEvent object, in which you also provide the event type as a two letter abbreviation as listed in the specs file.
voevent = create_event(csv_dataframe, EVENT_TYPE='FL')
Assigned required and optional parameters
voevent.required['OBS_Observatory'] = 'SDO'
voevent.required['OBS_Instrument'] = 'AIA'
...
voevent.optional['FL_PeakFlux'] = "674.229"
Add citations
voevent.citation = {
'action': 'supersedes',
'description': 'Closing of open event'
}
Add a reference
voevent.reference.append({
'name': 'Publication',
'link': 'http://www.harvard.edu/',
'type': 'html'
})
Display all information from a VOEvent object, including what is required or optional.
voevent.help()
Export the VOEvent object as an XML file. By default, the file location is defined at output_path in config.ini.
export_event(csv_dataframe, voevent, OUTPUT_PATH+'example.xml')
Please refer to demo_FL.py example below for a full script on using voevent-tools-pkg.
Running the unit tests from source
(Recommended): Install and run pytests
pip install pytest
pytest -v
You can also run the unit tests with Python's built-in unittest.
python -m unittest discover -s tests
Example code
# =====================================================
# demo_FL.py
# --------------
# Create example for FL
# =====================================================
import os
from datetime import datetime
from hek_voevent_tools import parse_features_file, create_event, export_event, load_config
# Pull from configuration file
config = load_config()
VOEVENT_SPEC = config['DEFAULT'].get('specs_location')
OUTPUT_PATH = config['DEFAULT'].get('output_path')
# User defined inputs
EVENT_TYPE = 'FL'
OUTPUT_FILENAME = 'FL_test.xml'
# Import the VOEvent Schema from .csv to object
print(f'Reading in .csv from [{VOEVENT_SPEC}]...')
csv_data = parse_features_file(VOEVENT_SPEC)
# Add attributes to the event and make it match below
print(f'Creating XML data structure for event type [{EVENT_TYPE}]...')
voevent = create_event(csv_data, EVENT_TYPE)
voevent.required['KB_ArchivURL'] = 'ivo://helio-informatics.org/FL_FlareDetective-TriggerModule_20250703_143416_2025-07-03T08:50:05.835_1' + "_test1"
voevent.required['KB_ArchivID'] = 'ivo://helio-informatics.org/FL_FlareDetective-TriggerModule_20250703_143416_2025-07-03T08:50:05.835_1' + "_test1"
voevent.required['KB_Archivist'] = 'Paolo C. Grigis - pgrigis@cfa.harvard.edu'
voevent.required['KB_ArchivDate'] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")
voevent.required['OBS_Observatory'] = 'SDO'
voevent.required['OBS_Instrument'] = 'AIA'
voevent.required['OBS_ChannelID'] = '193'
voevent.required['OBS_MeanWavel'] = '193.000'
voevent.required['OBS_WavelUnit'] = 'angstrom'
voevent.required['FRM_Name'] = 'Flare Detective - Trigger Module'
voevent.required['FRM_Identifier'] = 'Feature Finding Team'
voevent.required['FRM_Institute'] = 'SAO'
voevent.required['FRM_HumanFlag'] = 'F'
voevent.required['FRM_ParamSet'] = 'DerivativeThreshold= 3.00000e+00 EndFraction= 2.50000e-01'
voevent.required['FRM_DateRun'] = '2025-07-03T07:34:13.000'
voevent.required['FRM_Contact'] = 'Paolo C. Grigis - pgrigis@cfa.harvard.edu'
voevent.required['FRM_URL'] = 'http://www.cfa.harvard.edu'
voevent.optional['FRM_VersionNumber'] = "0.510000"
voevent.required['Event_StartTime'] = '2025-07-03T08:49:05.835'
voevent.required['Event_PeakTime'] = '2025-07-03T08:50:17.846'
voevent.required['Event_EndTime'] = '2025-07-03T08:51:53.835'
voevent.required['Event_CoordSys'] = 'UTC-HPC-TOPO'
voevent.required['Event_CoordUnit'] = 'arcseconds'
voevent.required['Event_Coord1'] = '-576.000'
voevent.required['Event_Coord2'] = '-345.600'
voevent.required['Event_C1Error'] = '2.00000'
voevent.required['Event_C2Error'] = '2.00000'
voevent.required['BoundBox_C1LL'] = '-440' #Coordinates of lower-left
voevent.required['BoundBox_C2LL'] = '263.2' #Corner of bounding box
voevent.required['BoundBox_C1UR'] = '-363.2' #Coordinates of upper-right
voevent.required['BoundBox_C2UR'] = '340' #Corner of bounding box
voevent.optional['FL_PeakFlux'] = "674.229"
voevent.optional['FL_PeakFluxUnit'] = "DN/sec/pixel"
voevent.optional['Event_TestFlag'] = 'True'
voevent.citation = {
'action': 'supersedes',
'description': 'Closing of open event'
}
voevent.reference.append({
'name': 'Publication',
'link': 'http://www.harvard.edu/',
'type': 'html'
})
# Export the structure to an XML file
voevent.help()
os.makedirs(OUTPUT_PATH, exist_ok=True)
export_event(csv_data, voevent, OUTPUT_PATH+OUTPUT_FILENAME)
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
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 hek_voevent_tools-1.0.1.tar.gz.
File metadata
- Download URL: hek_voevent_tools-1.0.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73bb79946a5193c98091fb3288b5af7826b916086553a989e337a5e547130cd7
|
|
| MD5 |
3f71ad621ae485cfda528e5bc9d27993
|
|
| BLAKE2b-256 |
962f137f81b8b6c99896d1367fac89fff1d2502a1681b983a4b76cbc0ea688f1
|
File details
Details for the file hek_voevent_tools-1.0.1-py3-none-any.whl.
File metadata
- Download URL: hek_voevent_tools-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4eb505004af1e272eb8d9ceacf59d25aabc813c1b96c64b560cd83ab0deb5367
|
|
| MD5 |
1d93e53d7c638cee138f2a178e7cfb61
|
|
| BLAKE2b-256 |
229643a018dbcf232669c431f2808f9ffe2cb3ddb10de69ce23477f56f311d71
|