From 77429cce7db63627c741aca827079df50b2efe83 Mon Sep 17 00:00:00 2001 From: JonasSuni Date: Fri, 13 Sep 2024 11:33:33 +0300 Subject: [PATCH 1/2] Add magnetic pressure data reducer --- pyVlsv/reduction.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index f7f5ad0d..a995604e 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -609,7 +609,11 @@ def gyrotropy(variables): Q = 1 - 4 * I2 / ( (I1 - Ppar)*(I1 + 3* Ppar) ) return Q - +def magnetic_pressure( variables ): + ''' Data reducer for finding the magnetic pressure + ''' + Magneticfield = variables[1] + return np.sum(np.asarray(Magneticfield)**2,axis=-1) / 2.0 / mu_0 def beta( variables ): ''' Data reducer for finding the plasma beta @@ -923,6 +927,8 @@ def makelambda(index): datareducers["pdyn"] = DataReducerVariable(["v", "rhom"], Pdyn, "Pa", 1, latex=r"$P_\mathrm{dyn}$",latexunits=r"$\mathrm{Pa}$") datareducers["pdynx"] = DataReducerVariable(["v", "rhom"], Pdynx, "Pa", 1, latex=r"$P_\mathrm{dyn,x}$",latexunits=r"$\mathrm{Pa}$") +datareducers["pmag"] = DataReducerVariable(["b"], magnetic_pressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") + datareducers["poynting"] = DataReducerVariable(["e", "b"], Poynting, "W/m2", 3, latex=r"$S$", latexunits=r"\mathrm{W}\,\mathrm{m}^{-2}$") datareducers["hallterm"] = DataReducerVariable(["e", "v", "b"], Hallterm, "V/m", 3, latex=r"$E_\mathrm{Hall}$", latexunits=r"\mathrm{V}\,\mathrm{m}^{-1}$") datareducers["firstadiabatic"] = DataReducerVariable(["tperpendicular","b"], firstadiabatic, "K/T", 1, latex=r"$T_\perp B^{-1}$",latexunits=r"$\mathrm{K}\,\mathrm{T}^{-1}$") @@ -1136,6 +1142,8 @@ def makelambda(index): v5reducers["vg_pdyn"] = DataReducerVariable(["vg_v", "vg_rhom"], Pdyn, "Pa", 1, latex=r"$P_\mathrm{dyn}$",latexunits=r"$\mathrm{Pa}$") v5reducers["vg_pdynx"] = DataReducerVariable(["vg_v", "vg_rhom"], Pdynx, "Pa", 1, latex=r"$P_\mathrm{dyn,x}$",latexunits=r"$\mathrm{Pa}$") +v5reducers["vg_pmag"] = DataReducerVariable(["vg_b_vol"], magnetic_pressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") + v5reducers["vg_di"] = DataReducerVariable(["proton/vg_rho"], ion_inertial, "m", 1, latex=r"$d_\mathrm{i}$",latexunits=r"$\mathrm{m}$") v5reducers["vg_pressure"] = DataReducerVariable(["vg_ptensor_diagonal"], Pressure, "Pa", 1, latex=r"$P$", latexunits=r"$\mathrm{Pa}$") From 3e3e08180da05621dc4c64b7096a8b59e55a19fe Mon Sep 17 00:00:00 2001 From: JonasSuni Date: Fri, 13 Sep 2024 20:22:15 +0300 Subject: [PATCH 2/2] Change reducer name to p_magnetic and bug fix --- pyVlsv/reduction.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index a995604e..59bd56f4 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -609,10 +609,10 @@ def gyrotropy(variables): Q = 1 - 4 * I2 / ( (I1 - Ppar)*(I1 + 3* Ppar) ) return Q -def magnetic_pressure( variables ): +def MagneticPressure( variables ): ''' Data reducer for finding the magnetic pressure ''' - Magneticfield = variables[1] + Magneticfield = variables[0] return np.sum(np.asarray(Magneticfield)**2,axis=-1) / 2.0 / mu_0 def beta( variables ): @@ -927,7 +927,7 @@ def makelambda(index): datareducers["pdyn"] = DataReducerVariable(["v", "rhom"], Pdyn, "Pa", 1, latex=r"$P_\mathrm{dyn}$",latexunits=r"$\mathrm{Pa}$") datareducers["pdynx"] = DataReducerVariable(["v", "rhom"], Pdynx, "Pa", 1, latex=r"$P_\mathrm{dyn,x}$",latexunits=r"$\mathrm{Pa}$") -datareducers["pmag"] = DataReducerVariable(["b"], magnetic_pressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") +datareducers["p_magnetic"] = DataReducerVariable(["b"], MagneticPressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") datareducers["poynting"] = DataReducerVariable(["e", "b"], Poynting, "W/m2", 3, latex=r"$S$", latexunits=r"\mathrm{W}\,\mathrm{m}^{-2}$") datareducers["hallterm"] = DataReducerVariable(["e", "v", "b"], Hallterm, "V/m", 3, latex=r"$E_\mathrm{Hall}$", latexunits=r"\mathrm{V}\,\mathrm{m}^{-1}$") @@ -1142,7 +1142,7 @@ def makelambda(index): v5reducers["vg_pdyn"] = DataReducerVariable(["vg_v", "vg_rhom"], Pdyn, "Pa", 1, latex=r"$P_\mathrm{dyn}$",latexunits=r"$\mathrm{Pa}$") v5reducers["vg_pdynx"] = DataReducerVariable(["vg_v", "vg_rhom"], Pdynx, "Pa", 1, latex=r"$P_\mathrm{dyn,x}$",latexunits=r"$\mathrm{Pa}$") -v5reducers["vg_pmag"] = DataReducerVariable(["vg_b_vol"], magnetic_pressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") +v5reducers["vg_p_magnetic"] = DataReducerVariable(["vg_b_vol"], MagneticPressure, "Pa", 1, latex=r"$P_\mathrm{mag}$",latexunits=r"$\mathrm{Pa}$") v5reducers["vg_di"] = DataReducerVariable(["proton/vg_rho"], ion_inertial, "m", 1, latex=r"$d_\mathrm{i}$",latexunits=r"$\mathrm{m}$")