Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 67841097 authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Nicer omni key names. original_colnames kwarg added if you have code that depended on the old names

parent f564dbee
......@@ -28,46 +28,47 @@ from . import paramin
from . import io
from . import web
# This is straight from the format guide on spdf
OMNI_COLS = ('ID for IMF spacecraft',
'ID for SW Plasma spacecraft',
'# of points in IMF averages',
'# of points in Plasma averages',
'Percent interp',
'Timeshift, sec',
'RMS, Timeshift',
'RMS, Phase front normal',
'Time btwn observations, sec',
'Field magnitude average, nT',
'Bx, nT (GSE, GSM)',
'By, nT (GSE)',
'Bz, nT (GSE)',
'By, nT (GSM)',
'Bz, nT (GSM)',
'RMS SD B scalar, nT',
'RMS SD field vector, nT',
'Flow speed, km/s',
'Vx Velocity, km/s, GSE',
'Vy Velocity, km/s, GSE',
'Vz Velocity, km/s, GSE',
'Proton Density, n/cc',
'Temperature, K',
'Flow pressure, nPa',
'Electric field, mV/m',
'Plasma beta',
'Alfven mach number',
'X(s/c), GSE, Re',
'Y(s/c), GSE, Re',
'Z(s/c), GSE, Re',
'BSN location, Xgse, Re',
'BSN location, Ygse, Re',
'BSN location, Zgse, Re',
'AE-index, nT',
'AL-index, nT',
'AU-index, nT',
'SYM/D index, nT',
'SYM/H index, nT',
'ASY/D index, nT',
'ASY/H index, nT',
'PC(N) index',
'Magnetosonic mach number')
# This is straight from the format guide on spdf with nicer names as second col
OMNI_COLS = (('ID for IMF spacecraft', 'id_imf'),
('ID for SW Plasma spacecraft', 'id_sw'),
('# of points in IMF averages', 'num_avg_imf'),
('# of points in Plasma averages', 'num_avg_sw'),
('Percent interp', 'interp'),
('Timeshift, sec', 'timeshift'),
('RMS, Timeshift', 'rms_timeshift'),
('RMS, Phase front normal', 'rms_phase'),
('Time btwn observations, sec', 'dt'),
('Field magnitude average, nT', 'b'),
('Bx, nT (GSE, GSM)', 'bx'),
('By, nT (GSE)', 'by_gse'),
('Bz, nT (GSE)', 'bz_gse'),
('By, nT (GSM)', 'by'),
('Bz, nT (GSM)', 'bz'),
('RMS SD B scalar, nT', 'rms_sd_b'),
('RMS SD field vector, nT', 'rms_sd_field'),
('Flow speed, km/s', 'v'),
('Vx Velocity, km/s, GSE', 'vx_gse'),
('Vy Velocity, km/s, GSE', 'vy_gse'),
('Vz Velocity, km/s, GSE', 'vz_gse'),
('Proton Density, n/cc', 'density'),
('Temperature, K', 'temperature'),
('Flow pressure, nPa', 'pressure'),
('Electric field, mV/m', 'e'),
('Plasma beta', 'beta'),
('Alfven mach number', 'alfven_mach'),
('X(s/c), GSE, Re', 'x_gse'),
('Y(s/c), GSE, Re', 'y_gse'),
('Z(s/c), GSE, Re', 'z_gse'),
('BSN location, Xgse, Re', 'bsn_x_gse'),
('BSN location, Ygse, Re', 'bsn_y_gse'),
('BSN location, Zgse, Re', 'bsn_z_gse'),
('AE-index, nT', 'ae'),
('AL-index, nT', 'al'),
('AU-index, nT', 'au'),
('SYM/D index, nT', 'sym_d'),
('SYM/H index, nT', 'sym_h'),
('ASY/D index, nT', 'asy_d'),
('ASY/H index, nT', 'asy_h'),
('PC(N) index', 'pc_n'),
('Magnetosonic mach number', 'mach'),
)
......@@ -26,6 +26,11 @@ def get_omni_data(time_from, time_to, **kwargs):
data that you want to receive.
time_to (datetime.datetime): The end time of the solar wind data
you want to receive.
**kwargs:
original_colnames (bool): Use the original column names from the
spdf specification. The alternative is
nicer and shorter names. Defaults to
False.
Returns:
dict: This will be a list of *all* columns
......@@ -52,13 +57,17 @@ def get_omni_data(time_from, time_to, **kwargs):
if kwargs.get('high_res', True):
omni_url += 'high_res_omni/monthly_1min/'
col_names = OMNI_COLS # column names from spdf
# Initialize return dict
return_data = {}
return_data['times'] = []
for name in col_names:
return_data[name] = []
col_names = []
for name in OMNI_COLS:
if kwargs.get('original_colnames', False):
col_names += [name[0]]
return_data[name[0]] = []
else:
col_names += [name[1]]
return_data[name[1]] = []
# Iterate monthly to save RAM
for date in rrule.rrule(rrule.MONTHLY,
......@@ -83,13 +92,13 @@ def get_omni_data(time_from, time_to, **kwargs):
+ cols[3], # minute
'%Y %j %H %M')
if time >= time_from and time <= time_to:
return_data['times'].append(time)
return_data['times'] += [time]
# Assign the data from after the time columns (0:3)
for num, value in enumerate(cols[4:len(col_names)+4]):
if _check_bad_omni_num(value):
return_data[col_names[num]].append(None)
return_data[col_names[num]] += [None]
else:
return_data[col_names[num]].append(float(value))
return_data[col_names[num]] += [float(value)]
return return_data # dictionary with omni values where index is the row
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment