Code
%load_ext autoreload
%autoreload 2
0 : psp_fld_l2_mag_RTN_4_Sa_per_Cyc
1 : psp_swp_spi_sf00_L3_DENS
2 : psp_swp_spi_sf00_L3_VEL_RTN_SUN
3 : psp_swp_spi_sf00_L3_VEL_RTN
4 : psp_swp_spi_af00_L3_DENS
5 : psp_swp_spi_af00_L3_VEL_RTN_SUN
6 : psp_swp_spi_af00_L3_VEL_RTN
7 : Tp_spani_b
8 : Tp_spanib_b
24-Aug-24 12:49:58: DeprecationWarning: backend2gui is deprecated since IPython 8.24, backends are managed in matplotlib and can be externally registered.
2024-08-24 12:52:24.698 | INFO | space_analysis.ds.tplot.formulary:ts_Alfven_speed:22 - Time of B and density are not the same, interpolating density to B
2024-08-24 12:52:25.270 | INFO | space_analysis.ds.tplot.formulary:ts_Alfven_speed:22 - Time of B and density are not the same, interpolating density to B
We can see it is necessary to interpolate the magnetic field data to plasma data’s time resolution to properly calculate the Alfvenicity.
import polars as pl
def find_events(df: pl.DataFrame):
return (
df.with_columns(
Λ_t=1 - (pl.col("v.ion.change.l") / pl.col("v.Alfven.change.l")) ** 2
)
.with_columns(rate=(pl.col("Λ_ion") / pl.col("Λ_t") - 1).abs())
.sort("rate")
)
events = find_events(p_conf.events.pipe(keep_good_fit).pipe(unique_events))
tstart | tstop | Λ_t | Λ_ion | rate |
2021-01-17 13:22:56 | 2021-01-17 13:23:12 | 0.90 | 0.74 | 0.18 |
2021-01-17 14:02:48 | 2021-01-17 14:03:04 | 0.70 | 0.92 | 0.30 |
2021-01-17 13:54:16 | 2021-01-17 13:54:32 | 0.79 | 0.51 | 0.35 |
2021-01-18 19:17:44 | 2021-01-18 19:18:00 | 0.34 | 0.18 | 0.47 |
2021-01-18 19:19:44 | 2021-01-18 19:20:00 | 0.36 | 0.18 | 0.48 |
01-Jul-24 14:18:40: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
01-Jul-24 14:18:40: psp_fld_l2_mag_RTN_4_Sa_per_Cyc_temp is currently not in pytplot.
2024-07-01 14:18:40.976 | INFO | space_analysis.ds.tplot.formulary:ts_Alfven_speed:22 - Time of B and density are not the same, interpolating density to B
01-Jul-24 14:18:42: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
01-Jul-24 14:18:42: psp_fld_l2_mag_RTN_4_Sa_per_Cyc_temp is currently not in pytplot.
2024-07-01 14:18:42.515 | INFO | space_analysis.ds.tplot.formulary:ts_Alfven_speed:22 - Time of B and density are not the same, interpolating density to B
None
None