Combine magnetic field data and plasma data

02-Jun-24 09:00:27: UserWarning: Traceback (most recent call last):
  File "/Users/zijin/projects/ids_finder/.pixi/envs/default/lib/python3.11/site-packages/pdpipe/__init__.py", line 85, in <module>
    from . import skintegrate
  File "/Users/zijin/projects/ids_finder/.pixi/envs/default/lib/python3.11/site-packages/pdpipe/skintegrate.py", line 20, in <module>
    from sklearn.base import BaseEstimator
ModuleNotFoundError: No module named 'sklearn'


02-Jun-24 09:00:27: UserWarning: pdpipe: Scikit-learn or skutil import failed. Scikit-learn-dependent pipeline stages will not be loaded.

02-Jun-24 09:00:27: UserWarning: Traceback (most recent call last):
  File "/Users/zijin/projects/ids_finder/.pixi/envs/default/lib/python3.11/site-packages/pdpipe/__init__.py", line 105, in <module>
    from . import nltk_stages
  File "/Users/zijin/projects/ids_finder/.pixi/envs/default/lib/python3.11/site-packages/pdpipe/nltk_stages.py", line 19, in <module>
    import nltk
ModuleNotFoundError: No module named 'nltk'


02-Jun-24 09:00:27: UserWarning: pdpipe: nltk import failed. nltk-dependent  pipeline stages will not be loaded.

source

format_time

 format_time (df:polars.dataframe.frame.DataFrame, time_unit='ns')

source

interpolate2

 interpolate2 (df1:polars.dataframe.frame.DataFrame, df2, **kwargs)

source

interpolate

 interpolate (df:polars.dataframe.frame.DataFrame, on='time',
              method='index', limit=1, limit_direction='both')

source

combine_features

 combine_features (events:polars.dataframe.frame.DataFrame,
                   states_data:polars.dataframe.frame.DataFrame, plasma_me
                   ta:space_analysis.ds.meta.PlasmaMeta=PlasmaMeta(dataset
                   =None, parameters=None, density_col=None,
                   velocity_cols=None, speed_col=None,
                   temperature_col=None), method:str='interpolate')

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}}\]


source

vector_project_pl

 vector_project_pl (df:polars.dataframe.frame.DataFrame, v1_cols, v2_cols,
                    name=None)

source

vector_project

 vector_project (v1:xarray.core.dataarray.DataArray,
                 v2:xarray.core.dataarray.DataArray, dim='v_dim')
Code
# test
import numpy as np

da_a = xr.DataArray(np.arange(3 * 2).reshape(3, 2), dims=["v_dim", "time"])
print(da_a)
vector_project(da_a, da_a, dim="v_dim")
<xarray.DataArray (v_dim: 3, time: 2)> Size: 48B
array([[0, 1],
       [2, 3],
       [4, 5]])
Dimensions without coordinates: v_dim, time
<xarray.DataArray (time: 2)> Size: 16B
array([4.47213595, 5.91607978])
Dimensions without coordinates: time

source

calc_rotation_angle_pl

 calc_rotation_angle_pl (df:polars.dataframe.frame.DataFrame, v1_cols,
                         v2_cols, name)

Inertial length


source

compute_inertial_length

 compute_inertial_length (df:polars.dataframe.frame.DataFrame,
                          density_col='plasma_density')

Alfven current


source

compute_Alfven_current

 compute_Alfven_current (df:polars.dataframe.frame.DataFrame,
                         density_col='plasma_density')

All features


source

calc_plasma_parameter_change

 calc_plasma_parameter_change (df:polars.dataframe.frame.DataFrame,
                               plasma_meta:space_analysis.ds.meta.PlasmaMe
                               ta=PlasmaMeta(dataset=None,
                               parameters=None, density_col=None,
                               velocity_cols=None, speed_col=None,
                               temperature_col=None))

source

calc_combined_features

 calc_combined_features (df:polars.dataframe.frame.DataFrame,
                         b_cols:list[str]=None, detail:bool=True,
                         normal_cols:list[str]=['k_x', 'k_y', 'k_z'],
                         Vl_cols=['Vl_x', 'Vl_y', 'Vl_z'],
                         Vn_cols=['Vn_x', 'Vn_y', 'Vn_z'],
                         thickness_cols=['L_k'], current_cols=['j0_k'], pl
                         asma_meta:space_analysis.ds.meta.PlasmaMeta=None,
                         **kwargs)

*Calculate the combined features of the discontinuity

Args: df (pl.DataFrame): description normal_cols (list[str], optional): normal vector of the discontinuity plane. Defaults to [ “k_x”, “k_y”, “k_z”, ]. detail (bool, optional): description. Defaults to True. Vl_cols (list, optional): maxium variance direction vector of the magnetic field. Defaults to [ “Vl_x”, “Vl_y”, “Vl_z”, ]. Vn_cols (list, optional): minimum variance direction vector of the magnetic field. Defaults to [ “Vn_x”, “Vn_y”, “Vn_z”, ]. current_cols (list, optional): description. Defaults to [“j0_mn”, “j0_k”].*

Type Default Details
df DataFrame
b_cols list None [“B_background_x”, “B_background_y”, “B_background_z”]
detail bool True
normal_cols list [‘k_x’, ‘k_y’, ‘k_z’]
Vl_cols list [‘Vl_x’, ‘Vl_y’, ‘Vl_z’]
Vn_cols list [‘Vn_x’, ‘Vn_y’, ‘Vn_z’]
thickness_cols list [‘L_k’]
current_cols list [‘j0_k’]
plasma_meta PlasmaMeta None
kwargs