- combine features from different sources/instruments (magnetic field, state data, etc.)
- generate new features
interpolate2
interpolate2 (df1:polars.dataframe.frame.DataFrame, df2, **kwargs)
interpolate
interpolate (df:polars.dataframe.frame.DataFrame, on='time')
interpolate_arr_dtype
interpolate_arr_dtype (df:polars.dataframe.frame.DataFrame, on)
Code
def test_interpolate():
c = pl.Series(
"c", [[4, 3], [1, 1], [None, None], [2, 2]], dtype=pl.Array(pl.Int64, 2)
)
c_interp = [[4, 3], [1, 1], [1.5, 1.5], [2, 2]]
on = "b"
df = pl.DataFrame({"a": [1, None, None, 3], "b": [1, 2, 4, 6], "c": c})
df.with_columns(a_interpolated=pl.col("a").interpolate_by(on))
assert df.pipe(interpolate_arr_dtype, on)["c"].to_list() == c_interp
assert df.pipe(interpolate, on)["c"].to_list() == c_interp
combine_features
combine_features (events:polars.dataframe.frame.DataFrame,
states_data:polars.dataframe.frame.DataFrame,
method:str='interpolate', left_on='t.d_time',
right_on='time', subset=False)
Additional features after combining
With combined dataset, we calculate additional features for each candidate.
Length
the length along the n direction of LMN coordinate system.
\[L_{n} = v_{n} T_{duration}\]
However this may not be accurate due to the MVA method.
\[L_{mn} = v_{mn} T_{duration}\]
If we have the normal vector of the current sheet, we can calculate the length along the normal direction.
\[L_{normal} = L_{k} = v_{normal} T_{duration}\]
Additionally, we can calculate the length projected into RTN coordinate system.
\[L_{R} = L_{k} \cos \theta\]
\[ j*0 = (\frac{d B}{d t})*{max} \frac{1}{v\_{mn}}\]
All features
calc_combined_features
calc_combined_features (df:polars.dataframe.frame.DataFrame,
b_norm_col='b_mag')
Calculate the combined features of the discontinuity
df |
DataFrame |
|
Input dataframe with discontinuity data |
b_norm_col |
str |
b_mag |
Column name for mean magnetic field magnitude |
update_events_with_plasma_data
update_events_with_plasma_data (events:polars.dataframe.frame.DataFrame,
plasma_data:polars.lazyframe.frame.LazyFr
ame|None, **kwargs)
update_events_with_temp_data
update_events_with_temp_data (events:polars.dataframe.frame.DataFrame,
ion_temp_data:polars.lazyframe.frame.LazyFr
ame|None, e_temp_data:polars.lazyframe.fram
e.LazyFrame|None)
update_events
update_events (events, plasma_data, plasma_meta, ion_temp_data,
e_temp_data, **kwargs)
calc_plasma_parameter_change
calc_plasma_parameter_change (df:polars.dataframe.frame.DataFrame, plasma
_meta:space_analysis.meta.PlasmaDataset=Pla
smaDataset(timerange=None, variables=None,
name=None, dataset=None, parameters=None,
ts=None, temperature_col=None,
para_col=None, perp_cols=None,
velocity_cols=None, speed_col=None,
density_col=None))