Code
using DrWatson
@quickactivate
include(srcdir("main.jl"))
import Beforerr: easy_save
using AlgebraOfGraphics: linear
using Dates
┌ Info: Electron temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:61
┌ Info: Ion temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:53
┌ Info: Electron temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:61
┌ Info: Ion temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:53
┌ Info: Electron temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:61
┌ Info: Ion temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:53
┌ Info: Electron temperature columns not found
└ @ Main /Users/zijin/projects/psp_conjunction/src/io.jl:61
# select the time range of interest "2021-04-29T00:45" to "2021-04-29T01:15"
function subset_timerange(df, start_time)
return subset(df, :time => t -> t .> DateTime(start_time))
end
function subset_timerange(df, start_time, end_time)
return subset(
subset_timerange(df, start_time),
:time => t -> t .< DateTime(end_time)
)
end
subset_timerange (generic function with 2 methods)
function plot_dist_comp(
df1, df2;
figure_kwargs=(size=(800, 600),)
)
df = reduce(vcat, [df1, df2], cols=:intersect)
data_layer = data(df) * mapping(color=ds_mapping, marker=ds_mapping)
maps = [l_log_map j_log_map
l_norm_log_map j_norm_log_map]
plot_dist(data_layer; maps, axis=(), visual=mapping(), figure_kwargs=figure_kwargs)
end
function plot_dist_comp(df1, df2, tr1, tr2)
df1 = subset_timerange(df1, tr1...)
df2 = subset_timerange(df2, tr2...)
@info "Number of data points in df1: $(nrow(df1))"
@info "Number of data points in df2: $(nrow(df2))"
plot_dist_comp(df1, df2)
end
plot_dist_comp (generic function with 2 methods)
2021-04-28T23:45:00
f1 = plot_dist_comp(psp_df, solo_df,
["2021-04-29T00:15", "2021-04-29T02:15"],
["2021-05-04T17:45:00", "2021-05-04T19:45:00"]
)
f2 = plot_dist_comp(psp_df, solo_df,
["2021-04-28T00:15", "2021-04-29T02:15"],
["2021-05-03T17:45:00", "2021-05-04T19:45:00"]
)
f3 = plot_dist_comp(psp_df, solo_df,
["2021-04-28T00:15", "2021-04-29T02:15"],
["2021-05-04T17:45:00", "2021-05-05T19:45:00"]
)
display(f1)
display(f2)
display(f3);
┌ Info: Number of data points in df1: 29
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:18
┌ Info: Number of data points in df2: 8
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:19
┌ Info: Number of data points in df1: 131
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:18
┌ Info: Number of data points in df2: 80
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:19
┌ Info: Number of data points in df1: 131
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:18
┌ Info: Number of data points in df2: 133
└ @ Main /Users/zijin/projects/psp_conjunction/notebooks/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_X50sZmlsZQ==.jl:19
begin
# base data layer
data_layer = data(df) * mapping(color=ds_mapping, marker=ds_mapping)
# data layer with different alpha
data_layer_a = (
(data(thm_df) + data(wind_df)) * visual(alpha=0.3) + data(psp_df) * visual(alpha=1)
) * mapping(
color=ds_mapping, marker=ds_mapping
)
# data layer with 1au missions
data_layer_b = (
(data(wind_df) + data(thm_df))
) * mapping(
color=:dataset, marker=:dataset
)
end;
# plot the density distribution of the thickness and current density
begin
fname = "properties_distribution"
maps = [l_log_map j_log_map
l_norm_log_map j_norm_log_map]
figure_kwargs = (size=(800, 600),)
plot_dist(data_layer; maps, axis=(), visual=mapping(), figure_kwargs=figure_kwargs)
easy_save(fname)
end
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc8/properties_distribution.svg
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:45
function plot_l_j_local_comp(df)
fig = Figure(size=(1000, 800))
data_layer = data(df) * mapping(col=:dataset)
facet = (; linkxaxes=:none, linkyaxes=:none)
# Thickness Panels
begin
plt = data_layer * mapping(di_log_map, l_log_map)
axis = (;)
draw!(fig[1, 1:3], plt, axis=axis, facet=facet)
end
# Current Density Panels
begin
plt = data_layer * mapping(jA_log_map, j_log_map)
axis = (;)
draw!(fig[2, 1:3], plt, axis=axis, facet=facet)
end
fig
end
df |> plot_l_j_local_comp
begin
fname = "thickness_current"
plt = data_layer_a * visual(Scatter)
fig = Figure(size=(1000, 500))
axis = log_axis
ga = fig[1, 1]
gb = fig[1, 2]
grid1 = plt * mapping(l_map, j_map) |> draw!(ga; axis=axis)
grid2 = plt * mapping(l_norm_map, j_norm_map) |> draw!(gb; axis=axis)
pretty_legend!(fig, grid1)
add_labels!([ga, gb])
easy_save(fname)
end
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/thickness_current.pdf
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
ggscatterhist
can not handle log scale well
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/dn-dB.pdf
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
Comparison of change in Alfven speed and plasma speed
The distinguishing feature of rotational discontinuities is the plasma velocity jump across them: the plasma flow velocity \(v_l\) (the solar wind velocity projected onto l) changes due to changes in \(B_l\), \(Δv_l=±Δv_A\) with \(v_A= B_l / \sqrt{4 n m}\) (Landau & Lifshitz 1960; Hudson 1970).
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/dvl.svg
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:45
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/vl_ratio.pdf
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/vl_ratio.png
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
Shen et al. (2024)
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/anisotropy_comparison_2d.pdf
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/anisotropy_comparison_2d.png
└ @ Beforerr /Users/zijin/.julia/dev/Beforerr/src/utils/makie.jl:48
Row | time | tstart | tstop | t.d_end | t.d_start | t.d_time | index_diff | len | std | std_prev | std_next | index_std | index_fluctuation | B.after | B.before | b_mag | b_n | bn_over_b | d_star | db_mag | db_over_b | db_over_b_max | fit.stat.chisqr | fit.stat.rsquared | fit.vars.amplitude | fit.vars.c | fit.vars.sigma | rotation_angle | dB_x | dB_y | dB_z | dB_lmn_x | dB_lmn_y | dB_lmn_z | k_x | k_y | k_z | Vl_x | Vl_y | Vl_z | Vn_x | Vn_y | Vn_z | duration | plasma_density | v_R | v_T | v_N | n.before | v_R_before | v_T_before | v_N_before | n.after | v_R_after | v_T_after | v_N_after | v_l | v_n | v_k | L_k | j0_k | ion_inertial_length | Alfven_speed | j_Alfven | L_k_norm | j0_k_norm | v.ion.before.l | v.ion.after.l | B.vec.before.l | B.vec.before.m | B.vec.before.n | B.vec.after.l | B.vec.after.m | B.vec.after.n | v.Alfven.before | v.Alfven.after | v.Alfven.before.l | v.Alfven.after.l | n.change | v.ion.change.l | B.change | v.Alfven.change | v.Alfven.change.l | ion_temp_para | ion_temp_perp | Λ_ion | dataset | B.mean | n.mean | Λ_t | Λ_ion_r |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DateTime | DateTime | DateTime | DateTime | DateTime | DateTime | Float64 | UInt32 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float32 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float32 | Float64 | Float64 | Float64 | Float32 | Float64 | Float64 | Float64 | Float32 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float32 | Float64 | Float64 | Float64 | Float64 | Float32 | Float32 | Float64 | String | Float64 | Float32 | Float64 | Float64 | |
1 | 2021-01-17T13:23:04 | 2021-01-17T13:22:56 | 2021-01-17T13:23:12 | 2021-01-17T13:23:11.442 | 2021-01-17T13:22:59.208 | 2021-01-17T13:23:05.131 | 0.648186 | 73 | 26.5526 | 10.7862 | 9.1192 | 2.46173 | 1.16665 | 101.789 | 44.0335 | 75.0677 | 2.27744 | 0.0303385 | 35.13 | 57.7554 | 0.769377 | 0.769377 | 2166.56 | 0.936807 | 50.5067 | 3.45086 | 0.359427 | 38.8267 | 55.2233 | -46.3511 | 10.8783 | -64.0992 | -34.7455 | -0.648997 | 0.0884341 | -0.12652 | -0.988014 | 0.357252 | -0.921461 | 0.152579 | -0.0675537 | 0.13744 | 0.988204 | 0.718854 | 2732.35 | 381.362 | -138.215 | 3.01064 | 2762.37 | 379.928 | -140.686 | 3.44903 | 2693.38 | 377.506 | -133.004 | 0.147888 | 264.061 | 41.7835 | 48.2377 | 34.6759 | 579.538 | 4.35666 | 31.3158 | 13709.1 | 7.95929 | 0.0422739 | 265.893 | 257.445 | 0.353517 | 44.0201 | 1.0304 | 64.4527 | 78.7656 | 1.6794 | 18.2693 | 42.7691 | 0.146672 | 27.0814 | -68.9861 | 8.44747 | 57.7554 | 24.4998 | 26.9347 | 64.687 | 57.5403 | 0.73955 | Parker Solar Probe | 72.9112 | 2727.87 | 0.901638 | 0.179771 |
2 | 2021-01-17T14:00:48 | 2021-01-17T14:00:40 | 2021-01-17T14:00:56 | 2021-01-17T14:00:53.754 | 2021-01-17T14:00:47.855 | 2021-01-17T14:00:47.086 | 0.361529 | 73 | 31.854 | 15.1253 | 6.79863 | 2.106 | 1.44077 | 136.929 | 218.531 | 155.794 | -5.14073 | -0.0329971 | 12.1512 | -81.6016 | 0.52378 | 0.52378 | 3746.21 | 0.592843 | 115.799 | -239.374 | 2.38247 | 7.16678 | 80.6002 | -3.1367 | 24.9029 | -84.416 | -0.564816 | -0.0287437 | -0.166979 | 0.75391 | 0.635404 | 0.953005 | -0.0410342 | 0.300163 | -0.128284 | 0.842916 | 0.522529 | 4.76494 | 3863.79 | 394.834 | -209.22 | 91.757 | 3787.03 | 386.74 | -202.149 | 83.7244 | 3771.57 | 370.53 | -189.192 | 63.788 | 412.406 | 179.06 | 165.359 | 787.925 | 58.4764 | 3.66366 | 54.6539 | 33833.3 | 215.065 | 0.00172837 | 401.991 | 380.027 | -213.71 | -45.1632 | -6.63765 | -129.294 | -44.5984 | -6.60891 | 77.4356 | 48.6197 | -75.7273 | -45.9086 | -15.4636 | 21.9645 | -81.6016 | -28.8159 | 29.8187 | 62.6138 | 39.6508 | 0.565511 | Parker Solar Probe | 177.73 | 3779.3 | 0.45742 | 0.236305 |
3 | 2021-01-17T14:04:16 | 2021-01-17T14:04:08 | 2021-01-17T14:04:24 | 2021-01-17T14:04:21.940 | 2021-01-17T14:04:13.421 | 2021-01-17T14:04:17.681 | 0.929971 | 73 | 41.46 | 17.2032 | 14.9907 | 2.41002 | 1.25386 | 117.341 | 19.9397 | 95.0441 | -10.1505 | -0.106798 | -27.2953 | 97.4013 | 1.0248 | 1.0248 | 37673.6 | 0.0644105 | -132.883 | 0.828218 | 1.21708 | 140.995 | 130.362 | 28.4358 | 0.136201 | 132.883 | 10.212 | 6.38537 | 0.164659 | -0.75789 | 0.631261 | -0.968391 | -0.233127 | -0.0887121 | -0.249287 | 0.916793 | 0.312005 | 2.43417 | 3671.34 | 347.46 | -127.721 | -19.1184 | 3696.02 | 346.453 | -129.023 | -16.8507 | 3632.13 | 345.098 | -126.874 | -11.6083 | -305.006 | 209.676 | 141.942 | 345.511 | 153.027 | 3.75845 | 34.2051 | 20119.9 | 91.929 | 0.00760574 | -303.929 | -303.582 | 17.4386 | -4.63218 | -8.4872 | -115.444 | -14.8442 | -14.8726 | 7.15205 | 42.4568 | 6.25492 | -41.7705 | -63.8911 | 0.346474 | 97.4013 | 35.3048 | 48.0254 | 52.4148 | 47.751 | 0.731686 | Parker Solar Probe | 68.6404 | 3664.07 | 0.999948 | 0.268276 |
4 | 2021-01-17T14:02:56 | 2021-01-17T14:02:48 | 2021-01-17T14:03:04 | 2021-01-17T14:03:02.860 | 2021-01-17T14:02:49.097 | 2021-01-17T14:02:58.196 | 1.05036 | 74 | 55.3271 | 9.25356 | 17.6372 | 3.13695 | 3.12493 | 52.3503 | 174.84 | 129.15 | -5.41188 | -0.0419039 | 21.6793 | -122.489 | 0.948429 | 0.948429 | 2701.74 | 0.983496 | 150.598 | -163.784 | 1.73666 | 51.8655 | 131.82 | 38.9729 | 55.7669 | -148.222 | -3.76153 | -4.6396 | -0.101562 | 0.912044 | -0.397316 | 0.894607 | 0.285819 | 0.34349 | 0.167674 | -0.927232 | 0.334853 | 3.47331 | 3460.77 | 327.214 | -132.42 | -14.7218 | 3415.25 | 321.447 | -133.69 | -18.1395 | 3575.76 | 352.967 | -131.117 | -14.4198 | 249.823 | 172.719 | 148.156 | 514.592 | 116.444 | 3.87111 | 47.8724 | 26544.1 | 132.931 | 0.00438681 | 243.127 | 273.338 | -168.928 | 44.0778 | -9.45836 | -20.7057 | 47.8393 | -4.81877 | 65.2389 | 19.0903 | -63.033 | -7.55065 | 160.513 | 30.2113 | -122.489 | -46.1486 | 55.4823 | 63.3292 | 46.3322 | 0.9178 | Parker Solar Probe | 113.595 | 3495.51 | 0.703496 | 0.304626 |
┌ Info: Saved /Users/zijin/projects/psp_conjunction/notebooks/figures/anisotropy.spi_n_spi.png
└ @ beforerr /Users/zijin/.julia/dev/beforerr.jl/src/utils/makie.jl:34
┌ Info: Saved /Users/zijin/projects/psp_conjunction/figures/enc7/anisotropy_theory.png
└ @ beforerr /Users/zijin/.julia/dev/beforerr.jl/src/utils/makie.jl:34
function plot_anistropy_comparison()
fname = "anisotropy_comparison"
fig = Figure(size=(1000, 800))
plt_Λ = data(
stack(earth_df, [:Λ, :Λ_t, :Λ_ion, :Λ_e], [:time, :dataset])
) * mapping(:value => L"\Lambda", color=:variable, marker=:variable, col=:dataset)
grid1 = plt_Λ * density() |> draw!$fig[1, 1:2]
grid2 = plt_Λ * histogram() |> draw!$fig[2, 1:2]
# easy_save("$(fname)_$psp_p_instr")
# legend!(fig[1, 1:2], grid, titleposition=:left, orientation=:horizontal)
pretty_legend!(fig, grid1)
fig
end
function plot_anistropy_comparison_i_e()
fname = "anisotropy_comparison_i_e"
mapping_layer = mapping(
Λ_e_map, Λ_ion_map,
)
# draw a dashed line with slope 1
df2 = (Λ_e=[0, 0.3], Λ_ion=[0, 0.3])
plt = (data(earth_df) * mapping(row=:dataset) + data(df2) * visual(Lines)) * mapping_layer
fig = draw(plt, facet=(; linkxaxes=:minimal, linkyaxes=:minimal))
fig
end
plot_anistropy_comparison_i_e (generic function with 1 method)