forked from IMAP-Science-Operations-Center/imap_processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswapi_utils.py
More file actions
57 lines (42 loc) · 1.08 KB
/
swapi_utils.py
File metadata and controls
57 lines (42 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Various classes and functions used throughout SWAPI processing.
This module contains utility classes and functions that are used by various
other SWAPI processing modules.
"""
from enum import IntEnum
from pathlib import Path
import numpy as np
import pandas as pd
class SWAPIAPID(IntEnum):
"""Create ENUM for apid."""
SWP_HK = 1184
SWP_SCI = 1188
SWP_AUT = 1192
class SWAPIMODE(IntEnum):
"""Create ENUM for MODE."""
LVENG = 0
LVSCI = 1
HVENG = 2
HVSCI = 3
def read_swapi_lut_table(file_path: Path) -> pd.DataFrame:
"""
Read the LUT table from a CSV file.
Parameters
----------
file_path : pathlib.Path
The path to the LUT table CSV file.
Returns
-------
pandas.DataFrame
The LUT table as a DataFrame.
"""
df = pd.read_csv(file_path)
# Clean and convert 'Energy' column from comma-separated strings to integers
df["Energy"] = (
df["Energy"]
.astype(str)
.str.replace(",", "", regex=False)
.replace("Solve", -1)
.astype(np.float64)
)
return df