Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducer aliases #284

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
First try
  • Loading branch information
alhom committed Sep 26, 2024
commit f9693bfaf25688c7d8ba5133db94dda647511397
24 changes: 24 additions & 0 deletions pyVlsv/reduction.py
Original file line number Diff line number Diff line change
@@ -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}$")