From f9693bfaf25688c7d8ba5133db94dda647511397 Mon Sep 17 00:00:00 2001 From: Markku Alho Date: Thu, 26 Sep 2024 10:53:23 +0300 Subject: [PATCH 1/3] First try --- pyVlsv/reduction.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index 7d7757ef..a2e03bb3 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -76,6 +76,9 @@ def sumv( variable ): # Third dimension: components return np.sum(np.array(variable),axis=0) +def Alias( variable ): + return variable[0] + def condition_matrix_array( condition, matrices ): # This routine is still very slow due to for-loops ''' Repeats condition n times and forms an array of it @@ -1213,6 +1216,27 @@ def makelambda(index): v5reducers["vg_jacobian_bper"] = DataReducerVariable(["vg_dperbxvoldx","vg_dperbxvoldy","vg_dperbxvoldz","vg_dperbyvoldx","vg_dperbyvoldy","vg_dperbyvoldz","vg_dperbzvoldx","vg_dperbzvoldy","vg_dperbzvoldz"], TensorFromScalars, "T/m", 9, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") v5reducers["vg_j"] = DataReducerVariable(["vg_jacobian_bper"], J, "A/m^2", 3, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +# Not the most elegant alias setup - could refine to fetch upstream metadata +v5reducers["vg_derivatives/vg_dbxvoldx"] = DataReducerVariable(["vg_dbxvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbyvoldx"] = DataReducerVariable(["vg_dbyvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbzvoldx"] = DataReducerVariable(["vg_dbzvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbxvoldy"] = DataReducerVariable(["vg_dbxvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbyvoldy"] = DataReducerVariable(["vg_dbyvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbzvoldy"] = DataReducerVariable(["vg_dbzvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbxvoldz"] = DataReducerVariable(["vg_dbxvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbyvoldz"] = DataReducerVariable(["vg_dbyvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dbzvoldz"] = DataReducerVariable(["vg_dbzvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") + +v5reducers["vg_derivatives/vg_dperbxvoldx"] = DataReducerVariable(["vg_dperbxvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbyvoldx"] = DataReducerVariable(["vg_dperbyvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbzvoldx"] = DataReducerVariable(["vg_dperbzvoldx"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbxvoldy"] = DataReducerVariable(["vg_dperbxvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbyvoldy"] = DataReducerVariable(["vg_dperbyvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbzvoldy"] = DataReducerVariable(["vg_dperbzvoldy"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbxvoldz"] = DataReducerVariable(["vg_dperbxvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbyvoldz"] = DataReducerVariable(["vg_dperbyvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_derivatives/vg_dperbzvoldz"] = DataReducerVariable(["vg_dperbzvoldz"], Alias, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") + #multipopv5reducers multipopv5reducers = {} multipopv5reducers["pop/vg_rhom"] = DataReducerVariable(["pop/vg_rho"], rhom, "kg/m3", 1, latex=r"$\rho_{m,\mathrm{REPLACEPOP}}$",latexunits=r"$\mathrm{kg}\,\mathrm{m}^{-3}$") From 73ea6fb67f686333e86e9ad2afe73ba9581db9e7 Mon Sep 17 00:00:00 2001 From: Markku Alho Date: Thu, 26 Sep 2024 10:54:51 +0300 Subject: [PATCH 2/3] Added comment --- pyVlsv/reduction.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index a2e03bb3..eb38ab5a 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -76,6 +76,7 @@ def sumv( variable ): # Third dimension: components return np.sum(np.array(variable),axis=0) +# This just returns the upstream variable for passing forwards under a new datareducer name def Alias( variable ): return variable[0] From 28564dadc15c343abcf3169111f7b597f99c1359 Mon Sep 17 00:00:00 2001 From: Markku Alho Date: Thu, 26 Sep 2024 11:04:03 +0300 Subject: [PATCH 3/3] Make the top-level reducers point to new format data first (even if the lines start to get a bit long) --- pyVlsv/reduction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index eb38ab5a..08c72f2f 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -1213,8 +1213,8 @@ def makelambda(index): v5reducers["vg_dxs"] = DataReducerVariable(["CellID"], vg_dx, "m", 3, latex=r"$\Delta{}\vec{r}$", latexunits=r"$\mathrm{m}$", useReader=True) v5reducers["vg_reflevel"] = DataReducerVariable(["CellID"], vg_reflevel, "", 1, latex=r"reflevel", latexunits=r"", useReader=True) -v5reducers["vg_jacobian_b"] = DataReducerVariable(["vg_dbxvoldx","vg_dbxvoldy","vg_dbxvoldz","vg_dbyvoldx","vg_dbyvoldy","vg_dbyvoldz","vg_dbzvoldx","vg_dbzvoldy","vg_dbzvoldz"], TensorFromScalars, "T/m", 9, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") -v5reducers["vg_jacobian_bper"] = DataReducerVariable(["vg_dperbxvoldx","vg_dperbxvoldy","vg_dperbxvoldz","vg_dperbyvoldx","vg_dperbyvoldy","vg_dperbyvoldz","vg_dperbzvoldx","vg_dperbzvoldy","vg_dperbzvoldz"], TensorFromScalars, "T/m", 9, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_jacobian_b"] = DataReducerVariable(["vg_derivatives/vg_dbxvoldx","vg_derivatives/vg_dbxvoldy","vg_derivatives/vg_dbxvoldz","vg_derivatives/vg_dbyvoldx","vg_derivatives/vg_dbyvoldy","vg_derivatives/vg_dbyvoldz","vg_derivatives/vg_dbzvoldx","vg_derivatives/vg_dbzvoldy","vg_derivatives/vg_dbzvoldz"], TensorFromScalars, "T/m", 9, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") +v5reducers["vg_jacobian_bper"] = DataReducerVariable(["vg_derivatives/vg_dperbxvoldx","vg_derivatives/vg_dperbxvoldy","vg_derivatives/vg_dperbxvoldz","vg_derivatives/vg_dperbyvoldx","vg_derivatives/vg_dperbyvoldy","vg_derivatives/vg_dperbyvoldz","vg_derivatives/vg_dperbzvoldx","vg_derivatives/vg_dperbzvoldy","vg_derivatives/vg_dperbzvoldz"], TensorFromScalars, "T/m", 9, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") v5reducers["vg_j"] = DataReducerVariable(["vg_jacobian_bper"], J, "A/m^2", 3, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$") # Not the most elegant alias setup - could refine to fetch upstream metadata