Skip to content

Commit

Permalink
Merge pull request #184 from alhom/vlsvPostprocessor2
Browse files Browse the repository at this point in the history
vlsvReader improvements
  • Loading branch information
markusbattarbee authored May 5, 2023
2 parents 3631e84 + ad672da commit 7338cb0
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 98 deletions.
4 changes: 3 additions & 1 deletion pyVlsv/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class DataReducerVariable:
latex = ""
latexunits = ""
useVspace = False
useReader = False
vector_size=1
def __init__(self, variables, operation, units, vector_size, latex="", latexunits="",useVspace=False):
def __init__(self, variables, operation, units, vector_size, latex="", latexunits="",useVspace=False,useReader=False):
''' Constructor for the class
:param variables List of variables for doing calculations with
:param operation The operation (function) that operates on the variables
Expand All @@ -53,4 +54,5 @@ def plus( array ):
self.latex = latex
self.latexunits = latexunits
self.useVspace = useVspace
self.useReader = useReader

23 changes: 23 additions & 0 deletions pyVlsv/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,20 @@ def firstadiabatic( variables ):
B = np.ma.masked_less_equal(np.ma.masked_invalid(B),0)
return np.ma.divide(Tperp,B)

def vg_coordinates_cellcenter( variables, reader):
cellids = variables[0]
return reader.get_cell_coordinates(cellids)

def vg_coordinates_lowcorner( variables, reader):
cellids = variables[0]
dxs = variables[1]
return reader.get_cell_coordinates(cellids)-dxs/2

def vg_dx(variables, reader):
cellids = variables[0]
return reader.get_cell_dx(cellids)


#list of operators. The user can apply these to any variable,
#including more general datareducers. Can only be used to reduce one
#variable at a time
Expand Down Expand Up @@ -1004,6 +1018,15 @@ def makelambda(index):
v5reducers["vg_restart_rhom"] = DataReducerVariable(["moments"], restart_rhom, "kg/m3", 1, latex=r"$\rho_m$",latexunits=r"$\mathrm{kg}\,\mathrm{m}^{-3}$")
v5reducers["vg_restart_rhoq"] = DataReducerVariable(["moments"], restart_rhoq, "C/m3", 1, latex=r"$\rho_q$",latexunits=r"$\mathrm{C}\,\mathrm{m}^{-3}$")

v5reducers["vg_coordinates"] = DataReducerVariable(["CellID"], vg_coordinates_cellcenter, "m", 3, latex=r"$\vec{r}_\mathrm{cc}$", latexunits=r"$\mathrm{m}$", useReader=True)
v5reducers["vg_coordinates_cell_center"] = DataReducerVariable(["CellID"], vg_coordinates_cellcenter, "m", 3, latex=r"$\vec{r}_\mathrm{cc}$", latexunits=r"$\mathrm{m}$", useReader=True)
v5reducers["vg_coordinates_cell_lowcorner"] = DataReducerVariable(["CellID","vg_dxs"], vg_coordinates_lowcorner, "m", 3, latex=r"$\vec{r}_\mathrm{cc}$", latexunits=r"$\mathrm{m}$", useReader=True)


v5reducers["vg_dx"] = DataReducerVariable(["CellID"], vg_dx, "m", 3, latex=r"$\Delta{}\vec{r}$", latexunits=r"$\mathrm{m}$", useReader=True)
v5reducers["vg_dxs"] = DataReducerVariable(["CellID"], vg_dx, "m", 3, latex=r"$\Delta{}\vec{r}$", latexunits=r"$\mathrm{m}$", useReader=True)



#multipopv5reducers
multipopv5reducers = {}
Expand Down
Loading

0 comments on commit 7338cb0

Please sign in to comment.